784 lines
1.9 MiB
784 lines
1.9 MiB
var hP=Object.defineProperty;var mP=(t,s,n)=>s in t?hP(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Kx=(t,s,n)=>mP(t,typeof s!="symbol"?s+"":s,n);function fP(t,s){for(var n=0;n<s.length;n++){const r=s[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in t)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(t,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();var Vo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Yx={exports:{}},Xd={},Zx={exports:{}},en={};/**
|
||
* @license React
|
||
* react.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var pw;function pP(){if(pw)return en;pw=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.iterator;function x(T){return T===null||typeof T!="object"?null:(T=h&&T[h]||T["@@iterator"],typeof T=="function"?T:null)}var u={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,v={};function w(T,F,I){this.props=T,this.context=F,this.refs=v,this.updater=I||u}w.prototype.isReactComponent={},w.prototype.setState=function(T,F){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,F,"setState")},w.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function j(){}j.prototype=w.prototype;function b(T,F,I){this.props=T,this.context=F,this.refs=v,this.updater=I||u}var C=b.prototype=new j;C.constructor=b,N(C,w.prototype),C.isPureReactComponent=!0;var S=Array.isArray,D=Object.prototype.hasOwnProperty,_={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function E(T,F,I){var K,G={},V=null,Y=null;if(F!=null)for(K in F.ref!==void 0&&(Y=F.ref),F.key!==void 0&&(V=""+F.key),F)D.call(F,K)&&!A.hasOwnProperty(K)&&(G[K]=F[K]);var re=arguments.length-2;if(re===1)G.children=I;else if(1<re){for(var ae=Array(re),ue=0;ue<re;ue++)ae[ue]=arguments[ue+2];G.children=ae}if(T&&T.defaultProps)for(K in re=T.defaultProps,re)G[K]===void 0&&(G[K]=re[K]);return{$$typeof:t,type:T,key:V,ref:Y,props:G,_owner:_.current}}function q(T,F){return{$$typeof:t,type:T.type,key:F,ref:T.ref,props:T.props,_owner:T._owner}}function O(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function R(T){var F={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(I){return F[I]})}var P=/\/+/g;function L(T,F){return typeof T=="object"&&T!==null&&T.key!=null?R(""+T.key):F.toString(36)}function $(T,F,I,K,G){var V=typeof T;(V==="undefined"||V==="boolean")&&(T=null);var Y=!1;if(T===null)Y=!0;else switch(V){case"string":case"number":Y=!0;break;case"object":switch(T.$$typeof){case t:case s:Y=!0}}if(Y)return Y=T,G=G(Y),T=K===""?"."+L(Y,0):K,S(G)?(I="",T!=null&&(I=T.replace(P,"$&/")+"/"),$(G,F,I,"",function(ue){return ue})):G!=null&&(O(G)&&(G=q(G,I+(!G.key||Y&&Y.key===G.key?"":(""+G.key).replace(P,"$&/")+"/")+T)),F.push(G)),1;if(Y=0,K=K===""?".":K+":",S(T))for(var re=0;re<T.length;re++){V=T[re];var ae=K+L(V,re);Y+=$(V,F,I,ae,G)}else if(ae=x(T),typeof ae=="function")for(T=ae.call(T),re=0;!(V=T.next()).done;)V=V.value,ae=K+L(V,re++),Y+=$(V,F,I,ae,G);else if(V==="object")throw F=String(T),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return Y}function Z(T,F,I){if(T==null)return T;var K=[],G=0;return $(T,K,"","",function(V){return F.call(I,V,G++)}),K}function Q(T){if(T._status===-1){var F=T._result;F=F(),F.then(function(I){(T._status===0||T._status===-1)&&(T._status=1,T._result=I)},function(I){(T._status===0||T._status===-1)&&(T._status=2,T._result=I)}),T._status===-1&&(T._status=0,T._result=F)}if(T._status===1)return T._result.default;throw T._result}var W={current:null},U={transition:null},M={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:U,ReactCurrentOwner:_};function z(){throw Error("act(...) is not supported in production builds of React.")}return en.Children={map:Z,forEach:function(T,F,I){Z(T,function(){F.apply(this,arguments)},I)},count:function(T){var F=0;return Z(T,function(){F++}),F},toArray:function(T){return Z(T,function(F){return F})||[]},only:function(T){if(!O(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},en.Component=w,en.Fragment=n,en.Profiler=a,en.PureComponent=b,en.StrictMode=r,en.Suspense=m,en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M,en.act=z,en.cloneElement=function(T,F,I){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var K=N({},T.props),G=T.key,V=T.ref,Y=T._owner;if(F!=null){if(F.ref!==void 0&&(V=F.ref,Y=_.current),F.key!==void 0&&(G=""+F.key),T.type&&T.type.defaultProps)var re=T.type.defaultProps;for(ae in F)D.call(F,ae)&&!A.hasOwnProperty(ae)&&(K[ae]=F[ae]===void 0&&re!==void 0?re[ae]:F[ae])}var ae=arguments.length-2;if(ae===1)K.children=I;else if(1<ae){re=Array(ae);for(var ue=0;ue<ae;ue++)re[ue]=arguments[ue+2];K.children=re}return{$$typeof:t,type:T.type,key:G,ref:V,props:K,_owner:Y}},en.createContext=function(T){return T={$$typeof:o,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:i,_context:T},T.Consumer=T},en.createElement=E,en.createFactory=function(T){var F=E.bind(null,T);return F.type=T,F},en.createRef=function(){return{current:null}},en.forwardRef=function(T){return{$$typeof:d,render:T}},en.isValidElement=O,en.lazy=function(T){return{$$typeof:p,_payload:{_status:-1,_result:T},_init:Q}},en.memo=function(T,F){return{$$typeof:f,type:T,compare:F===void 0?null:F}},en.startTransition=function(T){var F=U.transition;U.transition={};try{T()}finally{U.transition=F}},en.unstable_act=z,en.useCallback=function(T,F){return W.current.useCallback(T,F)},en.useContext=function(T){return W.current.useContext(T)},en.useDebugValue=function(){},en.useDeferredValue=function(T){return W.current.useDeferredValue(T)},en.useEffect=function(T,F){return W.current.useEffect(T,F)},en.useId=function(){return W.current.useId()},en.useImperativeHandle=function(T,F,I){return W.current.useImperativeHandle(T,F,I)},en.useInsertionEffect=function(T,F){return W.current.useInsertionEffect(T,F)},en.useLayoutEffect=function(T,F){return W.current.useLayoutEffect(T,F)},en.useMemo=function(T,F){return W.current.useMemo(T,F)},en.useReducer=function(T,F,I){return W.current.useReducer(T,F,I)},en.useRef=function(T){return W.current.useRef(T)},en.useState=function(T){return W.current.useState(T)},en.useSyncExternalStore=function(T,F,I){return W.current.useSyncExternalStore(T,F,I)},en.useTransition=function(){return W.current.useTransition()},en.version="18.3.1",en}var xw;function fd(){return xw||(xw=1,Zx.exports=pP()),Zx.exports}/**
|
||
* @license React
|
||
* react-jsx-runtime.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var gw;function xP(){if(gw)return Xd;gw=1;var t=fd(),s=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(d,m,f){var p,h={},x=null,u=null;f!==void 0&&(x=""+f),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(u=m.ref);for(p in m)r.call(m,p)&&!i.hasOwnProperty(p)&&(h[p]=m[p]);if(d&&d.defaultProps)for(p in m=d.defaultProps,m)h[p]===void 0&&(h[p]=m[p]);return{$$typeof:s,type:d,key:x,ref:u,props:h,_owner:a.current}}return Xd.Fragment=n,Xd.jsx=o,Xd.jsxs=o,Xd}var vw;function gP(){return vw||(vw=1,Yx.exports=xP()),Yx.exports}var e=gP(),g=fd();const Ct=Nf(g),wf=fP({__proto__:null,default:Ct},[g]);var rm={},Qx={exports:{}},ta={},Xx={exports:{}},Jx={};/**
|
||
* @license React
|
||
* scheduler.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var yw;function vP(){return yw||(yw=1,(function(t){function s(U,M){var z=U.length;U.push(M);e:for(;0<z;){var T=z-1>>>1,F=U[T];if(0<a(F,M))U[T]=M,U[z]=F,z=T;else break e}}function n(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var M=U[0],z=U.pop();if(z!==M){U[0]=z;e:for(var T=0,F=U.length,I=F>>>1;T<I;){var K=2*(T+1)-1,G=U[K],V=K+1,Y=U[V];if(0>a(G,z))V<F&&0>a(Y,G)?(U[T]=Y,U[V]=z,T=V):(U[T]=G,U[K]=z,T=K);else if(V<F&&0>a(Y,z))U[T]=Y,U[V]=z,T=V;else break e}}return M}function a(U,M){var z=U.sortIndex-M.sortIndex;return z!==0?z:U.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,d=o.now();t.unstable_now=function(){return o.now()-d}}var m=[],f=[],p=1,h=null,x=3,u=!1,N=!1,v=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(U){for(var M=n(f);M!==null;){if(M.callback===null)r(f);else if(M.startTime<=U)r(f),M.sortIndex=M.expirationTime,s(m,M);else break;M=n(f)}}function S(U){if(v=!1,C(U),!N)if(n(m)!==null)N=!0,Q(D);else{var M=n(f);M!==null&&W(S,M.startTime-U)}}function D(U,M){N=!1,v&&(v=!1,j(E),E=-1),u=!0;var z=x;try{for(C(M),h=n(m);h!==null&&(!(h.expirationTime>M)||U&&!R());){var T=h.callback;if(typeof T=="function"){h.callback=null,x=h.priorityLevel;var F=T(h.expirationTime<=M);M=t.unstable_now(),typeof F=="function"?h.callback=F:h===n(m)&&r(m),C(M)}else r(m);h=n(m)}if(h!==null)var I=!0;else{var K=n(f);K!==null&&W(S,K.startTime-M),I=!1}return I}finally{h=null,x=z,u=!1}}var _=!1,A=null,E=-1,q=5,O=-1;function R(){return!(t.unstable_now()-O<q)}function P(){if(A!==null){var U=t.unstable_now();O=U;var M=!0;try{M=A(!0,U)}finally{M?L():(_=!1,A=null)}}else _=!1}var L;if(typeof b=="function")L=function(){b(P)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,Z=$.port2;$.port1.onmessage=P,L=function(){Z.postMessage(null)}}else L=function(){w(P,0)};function Q(U){A=U,_||(_=!0,L())}function W(U,M){E=w(function(){U(t.unstable_now())},M)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(U){U.callback=null},t.unstable_continueExecution=function(){N||u||(N=!0,Q(D))},t.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<U?Math.floor(1e3/U):5},t.unstable_getCurrentPriorityLevel=function(){return x},t.unstable_getFirstCallbackNode=function(){return n(m)},t.unstable_next=function(U){switch(x){case 1:case 2:case 3:var M=3;break;default:M=x}var z=x;x=M;try{return U()}finally{x=z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(U,M){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var z=x;x=U;try{return M()}finally{x=z}},t.unstable_scheduleCallback=function(U,M,z){var T=t.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?T+z:T):z=T,U){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=z+F,U={id:p++,callback:M,priorityLevel:U,startTime:z,expirationTime:F,sortIndex:-1},z>T?(U.sortIndex=z,s(f,U),n(m)===null&&U===n(f)&&(v?(j(E),E=-1):v=!0,W(S,z-T))):(U.sortIndex=F,s(m,U),N||u||(N=!0,Q(D))),U},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(U){var M=x;return function(){var z=x;x=M;try{return U.apply(this,arguments)}finally{x=z}}}})(Jx)),Jx}var bw;function yP(){return bw||(bw=1,Xx.exports=vP()),Xx.exports}/**
|
||
* @license React
|
||
* react-dom.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var jw;function bP(){if(jw)return ta;jw=1;var t=fd(),s=yP();function n(l){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+l,y=1;y<arguments.length;y++)c+="&args[]="+encodeURIComponent(arguments[y]);return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function i(l,c){o(l,c),o(l+"Capture",c)}function o(l,c){for(a[l]=c,l=0;l<c.length;l++)r.add(c[l])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,f=/^[: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]*$/,p={},h={};function x(l){return m.call(h,l)?!0:m.call(p,l)?!1:f.test(l)?h[l]=!0:(p[l]=!0,!1)}function u(l,c,y,k){if(y!==null&&y.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return k?!1:y!==null?!y.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function N(l,c,y,k){if(c===null||typeof c>"u"||u(l,c,y,k))return!0;if(k)return!1;if(y!==null)switch(y.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function v(l,c,y,k,B,H,ne){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=k,this.attributeNamespace=B,this.mustUseProperty=y,this.propertyName=l,this.type=c,this.sanitizeURL=H,this.removeEmptyString=ne}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){w[l]=new v(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var c=l[0];w[c]=new v(c,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){w[l]=new v(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){w[l]=new v(l,2,!1,l,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(l){w[l]=new v(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){w[l]=new v(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){w[l]=new v(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){w[l]=new v(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){w[l]=new v(l,5,!1,l.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function b(l){return l[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(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var c=l.replace(j,b);w[c]=new v(c,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){w[l]=new v(l,1,!1,l.toLowerCase(),null,!1,!1)}),w.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){w[l]=new v(l,1,!1,l.toLowerCase(),null,!0,!0)});function C(l,c,y,k){var B=w.hasOwnProperty(c)?w[c]:null;(B!==null?B.type!==0:k||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(N(c,y,B,k)&&(y=null),k||B===null?x(c)&&(y===null?l.removeAttribute(c):l.setAttribute(c,""+y)):B.mustUseProperty?l[B.propertyName]=y===null?B.type===3?!1:"":y:(c=B.attributeName,k=B.attributeNamespace,y===null?l.removeAttribute(c):(B=B.type,y=B===3||B===4&&y===!0?"":""+y,k?l.setAttributeNS(k,c,y):l.setAttribute(c,y))))}var S=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),_=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),R=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),U=Symbol.iterator;function M(l){return l===null||typeof l!="object"?null:(l=U&&l[U]||l["@@iterator"],typeof l=="function"?l:null)}var z=Object.assign,T;function F(l){if(T===void 0)try{throw Error()}catch(y){var c=y.stack.trim().match(/\n( *(at )?)/);T=c&&c[1]||""}return`
|
||
`+T+l}var I=!1;function K(l,c){if(!l||I)return"";I=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(Qe){var k=Qe}Reflect.construct(l,[],c)}else{try{c.call()}catch(Qe){k=Qe}l.call(c.prototype)}else{try{throw Error()}catch(Qe){k=Qe}l()}}catch(Qe){if(Qe&&k&&typeof Qe.stack=="string"){for(var B=Qe.stack.split(`
|
||
`),H=k.stack.split(`
|
||
`),ne=B.length-1,ve=H.length-1;1<=ne&&0<=ve&&B[ne]!==H[ve];)ve--;for(;1<=ne&&0<=ve;ne--,ve--)if(B[ne]!==H[ve]){if(ne!==1||ve!==1)do if(ne--,ve--,0>ve||B[ne]!==H[ve]){var De=`
|
||
`+B[ne].replace(" at new "," at ");return l.displayName&&De.includes("<anonymous>")&&(De=De.replace("<anonymous>",l.displayName)),De}while(1<=ne&&0<=ve);break}}}finally{I=!1,Error.prepareStackTrace=y}return(l=l?l.displayName||l.name:"")?F(l):""}function G(l){switch(l.tag){case 5:return F(l.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return l=K(l.type,!1),l;case 11:return l=K(l.type.render,!1),l;case 1:return l=K(l.type,!0),l;default:return""}}function V(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case A:return"Fragment";case _:return"Portal";case q:return"Profiler";case E:return"StrictMode";case L:return"Suspense";case $:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case R:return(l.displayName||"Context")+".Consumer";case O:return(l._context.displayName||"Context")+".Provider";case P:var c=l.render;return l=l.displayName,l||(l=c.displayName||c.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case Z:return c=l.displayName||null,c!==null?c:V(l.type)||"Memo";case Q:c=l._payload,l=l._init;try{return V(l(c))}catch{}}return null}function Y(l){var c=l.type;switch(l.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=c.render,l=l.displayName||l.name||"",c.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V(c);case 8:return c===E?"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 c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function re(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ae(l){var c=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ue(l){var c=ae(l)?"checked":"value",y=Object.getOwnPropertyDescriptor(l.constructor.prototype,c),k=""+l[c];if(!l.hasOwnProperty(c)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var B=y.get,H=y.set;return Object.defineProperty(l,c,{configurable:!0,get:function(){return B.call(this)},set:function(ne){k=""+ne,H.call(this,ne)}}),Object.defineProperty(l,c,{enumerable:y.enumerable}),{getValue:function(){return k},setValue:function(ne){k=""+ne},stopTracking:function(){l._valueTracker=null,delete l[c]}}}}function ye(l){l._valueTracker||(l._valueTracker=ue(l))}function ce(l){if(!l)return!1;var c=l._valueTracker;if(!c)return!0;var y=c.getValue(),k="";return l&&(k=ae(l)?l.checked?"true":"false":l.value),l=k,l!==y?(c.setValue(l),!0):!1}function je(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function Me(l,c){var y=c.checked;return z({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??l._wrapperState.initialChecked})}function ut(l,c){var y=c.defaultValue==null?"":c.defaultValue,k=c.checked!=null?c.checked:c.defaultChecked;y=re(c.value!=null?c.value:y),l._wrapperState={initialChecked:k,initialValue:y,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function jt(l,c){c=c.checked,c!=null&&C(l,"checked",c,!1)}function ft(l,c){jt(l,c);var y=re(c.value),k=c.type;if(y!=null)k==="number"?(y===0&&l.value===""||l.value!=y)&&(l.value=""+y):l.value!==""+y&&(l.value=""+y);else if(k==="submit"||k==="reset"){l.removeAttribute("value");return}c.hasOwnProperty("value")?Ce(l,c.type,y):c.hasOwnProperty("defaultValue")&&Ce(l,c.type,re(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(l.defaultChecked=!!c.defaultChecked)}function X(l,c,y){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var k=c.type;if(!(k!=="submit"&&k!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+l._wrapperState.initialValue,y||c===l.value||(l.value=c),l.defaultValue=c}y=l.name,y!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,y!==""&&(l.name=y)}function Ce(l,c,y){(c!=="number"||je(l.ownerDocument)!==l)&&(y==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+y&&(l.defaultValue=""+y))}var xe=Array.isArray;function We(l,c,y,k){if(l=l.options,c){c={};for(var B=0;B<y.length;B++)c["$"+y[B]]=!0;for(y=0;y<l.length;y++)B=c.hasOwnProperty("$"+l[y].value),l[y].selected!==B&&(l[y].selected=B),B&&k&&(l[y].defaultSelected=!0)}else{for(y=""+re(y),c=null,B=0;B<l.length;B++){if(l[B].value===y){l[B].selected=!0,k&&(l[B].defaultSelected=!0);return}c!==null||l[B].disabled||(c=l[B])}c!==null&&(c.selected=!0)}}function Be(l,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return z({},c,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function rt(l,c){var y=c.value;if(y==null){if(y=c.children,c=c.defaultValue,y!=null){if(c!=null)throw Error(n(92));if(xe(y)){if(1<y.length)throw Error(n(93));y=y[0]}c=y}c==null&&(c=""),y=c}l._wrapperState={initialValue:re(y)}}function ht(l,c){var y=re(c.value),k=re(c.defaultValue);y!=null&&(y=""+y,y!==l.value&&(l.value=y),c.defaultValue==null&&l.defaultValue!==y&&(l.defaultValue=y)),k!=null&&(l.defaultValue=""+k)}function ge(l){var c=l.textContent;c===l._wrapperState.initialValue&&c!==""&&c!==null&&(l.value=c)}function Je(l){switch(l){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function mt(l,c){return l==null||l==="http://www.w3.org/1999/xhtml"?Je(c):l==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var de,at=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,y,k,B){MSApp.execUnsafeLocalFunction(function(){return l(c,y,k,B)})}:l})(function(l,c){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=c;else{for(de=de||document.createElement("div"),de.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=de.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;c.firstChild;)l.appendChild(c.firstChild)}});function ot(l,c){if(c){var y=l.firstChild;if(y&&y===l.lastChild&&y.nodeType===3){y.nodeValue=c;return}}l.textContent=c}var ke={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},Zt=["Webkit","ms","Moz","O"];Object.keys(ke).forEach(function(l){Zt.forEach(function(c){c=c+l.charAt(0).toUpperCase()+l.substring(1),ke[c]=ke[l]})});function Bt(l,c,y){return c==null||typeof c=="boolean"||c===""?"":y||typeof c!="number"||c===0||ke.hasOwnProperty(l)&&ke[l]?(""+c).trim():c+"px"}function _s(l,c){l=l.style;for(var y in c)if(c.hasOwnProperty(y)){var k=y.indexOf("--")===0,B=Bt(y,c[y],k);y==="float"&&(y="cssFloat"),k?l.setProperty(y,B):l[y]=B}}var Us=z({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 fs(l,c){if(c){if(Us[l]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function Vs(l,c){if(l.indexOf("-")===-1)return typeof c.is=="string";switch(l){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 Qs=null;function Xs(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var ie=null,nt=null,fe=null;function Ae(l){if(l=Md(l)){if(typeof ie!="function")throw Error(n(280));var c=l.stateNode;c&&(c=yh(c),ie(l.stateNode,l.type,c))}}function Fe(l){nt?fe?fe.push(l):fe=[l]:nt=l}function Ke(){if(nt){var l=nt,c=fe;if(fe=nt=null,Ae(l),c)for(l=0;l<c.length;l++)Ae(c[l])}}function Le(l,c){return l(c)}function Ue(){}var et=!1;function dt(l,c,y){if(et)return l(c,y);et=!0;try{return Le(l,c,y)}finally{et=!1,(nt!==null||fe!==null)&&(Ue(),Ke())}}function ss(l,c){var y=l.stateNode;if(y===null)return null;var k=yh(y);if(k===null)return null;y=k[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(l=l.type,k=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!k;break e;default:l=!1}if(l)return null;if(y&&typeof y!="function")throw Error(n(231,c,typeof y));return y}var Wt=!1;if(d)try{var kt={};Object.defineProperty(kt,"passive",{get:function(){Wt=!0}}),window.addEventListener("test",kt,kt),window.removeEventListener("test",kt,kt)}catch{Wt=!1}function wt(l,c,y,k,B,H,ne,ve,De){var Qe=Array.prototype.slice.call(arguments,3);try{c.apply(y,Qe)}catch(Dt){this.onError(Dt)}}var Os=!1,as=null,Se=!1,be=null,pt={onError:function(l){Os=!0,as=l}};function Ve(l,c,y,k,B,H,ne,ve,De){Os=!1,as=null,wt.apply(pt,arguments)}function bt(l,c,y,k,B,H,ne,ve,De){if(Ve.apply(this,arguments),Os){if(Os){var Qe=as;Os=!1,as=null}else throw Error(n(198));Se||(Se=!0,be=Qe)}}function gt(l){var c=l,y=l;if(l.alternate)for(;c.return;)c=c.return;else{l=c;do c=l,(c.flags&4098)!==0&&(y=c.return),l=c.return;while(l)}return c.tag===3?y:null}function rs(l){if(l.tag===13){var c=l.memoizedState;if(c===null&&(l=l.alternate,l!==null&&(c=l.memoizedState)),c!==null)return c.dehydrated}return null}function is(l){if(gt(l)!==l)throw Error(n(188))}function Ts(l){var c=l.alternate;if(!c){if(c=gt(l),c===null)throw Error(n(188));return c!==l?null:l}for(var y=l,k=c;;){var B=y.return;if(B===null)break;var H=B.alternate;if(H===null){if(k=B.return,k!==null){y=k;continue}break}if(B.child===H.child){for(H=B.child;H;){if(H===y)return is(B),l;if(H===k)return is(B),c;H=H.sibling}throw Error(n(188))}if(y.return!==k.return)y=B,k=H;else{for(var ne=!1,ve=B.child;ve;){if(ve===y){ne=!0,y=B,k=H;break}if(ve===k){ne=!0,k=B,y=H;break}ve=ve.sibling}if(!ne){for(ve=H.child;ve;){if(ve===y){ne=!0,y=H,k=B;break}if(ve===k){ne=!0,k=H,y=B;break}ve=ve.sibling}if(!ne)throw Error(n(189))}}if(y.alternate!==k)throw Error(n(190))}if(y.tag!==3)throw Error(n(188));return y.stateNode.current===y?l:c}function Ws(l){return l=Ts(l),l!==null?nn(l):null}function nn(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var c=nn(l);if(c!==null)return c;l=l.sibling}return null}var Ee=s.unstable_scheduleCallback,$t=s.unstable_cancelCallback,Xt=s.unstable_shouldYield,Cs=s.unstable_requestPaint,Mt=s.unstable_now,ze=s.unstable_getCurrentPriorityLevel,xt=s.unstable_ImmediatePriority,yt=s.unstable_UserBlockingPriority,Ot=s.unstable_NormalPriority,Pt=s.unstable_LowPriority,Jt=s.unstable_IdlePriority,bs=null,ns=null;function Ds(l){if(ns&&typeof ns.onCommitFiberRoot=="function")try{ns.onCommitFiberRoot(bs,l,void 0,(l.current.flags&128)===128)}catch{}}var ts=Math.clz32?Math.clz32:vn,js=Math.log,tn=Math.LN2;function vn(l){return l>>>=0,l===0?32:31-(js(l)/tn|0)|0}var jn=64,xn=4194304;function gn(l){switch(l&-l){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 l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Ye(l,c){var y=l.pendingLanes;if(y===0)return 0;var k=0,B=l.suspendedLanes,H=l.pingedLanes,ne=y&268435455;if(ne!==0){var ve=ne&~B;ve!==0?k=gn(ve):(H&=ne,H!==0&&(k=gn(H)))}else ne=y&~B,ne!==0?k=gn(ne):H!==0&&(k=gn(H));if(k===0)return 0;if(c!==0&&c!==k&&(c&B)===0&&(B=k&-k,H=c&-c,B>=H||B===16&&(H&4194240)!==0))return c;if((k&4)!==0&&(k|=y&16),c=l.entangledLanes,c!==0)for(l=l.entanglements,c&=k;0<c;)y=31-ts(c),B=1<<y,k|=l[y],c&=~B;return k}function qt(l,c){switch(l){case 1:case 2:case 4:return c+250;case 8:case 16:case 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 c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ze(l,c){for(var y=l.suspendedLanes,k=l.pingedLanes,B=l.expirationTimes,H=l.pendingLanes;0<H;){var ne=31-ts(H),ve=1<<ne,De=B[ne];De===-1?((ve&y)===0||(ve&k)!==0)&&(B[ne]=qt(ve,c)):De<=c&&(l.expiredLanes|=ve),H&=~ve}}function Gt(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function St(){var l=jn;return jn<<=1,(jn&4194240)===0&&(jn=64),l}function qn(l){for(var c=[],y=0;31>y;y++)c.push(l);return c}function Er(l,c,y){l.pendingLanes|=c,c!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,c=31-ts(c),l[c]=y}function Fr(l,c){var y=l.pendingLanes&~c;l.pendingLanes=c,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=c,l.mutableReadLanes&=c,l.entangledLanes&=c,c=l.entanglements;var k=l.eventTimes;for(l=l.expirationTimes;0<y;){var B=31-ts(y),H=1<<B;c[B]=0,k[B]=-1,l[B]=-1,y&=~H}}function wn(l,c){var y=l.entangledLanes|=c;for(l=l.entanglements;y;){var k=31-ts(y),B=1<<k;B&c|l[k]&c&&(l[k]|=c),y&=~B}}var Js=0;function Sa(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var It,As,_r,ca,Ca,Yr=!1,Nr=[],kn=null,Sn=null,sr=null,wr=new Map,Sr=new Map,yn=[],Dn="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Aa(l,c){switch(l){case"focusin":case"focusout":kn=null;break;case"dragenter":case"dragleave":Sn=null;break;case"mouseover":case"mouseout":sr=null;break;case"pointerover":case"pointerout":wr.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Sr.delete(c.pointerId)}}function ka(l,c,y,k,B,H){return l===null||l.nativeEvent!==H?(l={blockedOn:c,domEventName:y,eventSystemFlags:k,nativeEvent:H,targetContainers:[B]},c!==null&&(c=Md(c),c!==null&&As(c)),l):(l.eventSystemFlags|=k,c=l.targetContainers,B!==null&&c.indexOf(B)===-1&&c.push(B),l)}function qi(l,c,y,k,B){switch(c){case"focusin":return kn=ka(kn,l,c,y,k,B),!0;case"dragenter":return Sn=ka(Sn,l,c,y,k,B),!0;case"mouseover":return sr=ka(sr,l,c,y,k,B),!0;case"pointerover":var H=B.pointerId;return wr.set(H,ka(wr.get(H)||null,l,c,y,k,B)),!0;case"gotpointercapture":return H=B.pointerId,Sr.set(H,ka(Sr.get(H)||null,l,c,y,k,B)),!0}return!1}function xi(l){var c=Ao(l.target);if(c!==null){var y=gt(c);if(y!==null){if(c=y.tag,c===13){if(c=rs(y),c!==null){l.blockedOn=c,Ca(l.priority,function(){_r(y)});return}}else if(c===3&&y.stateNode.current.memoizedState.isDehydrated){l.blockedOn=y.tag===3?y.stateNode.containerInfo:null;return}}}l.blockedOn=null}function gi(l){if(l.blockedOn!==null)return!1;for(var c=l.targetContainers;0<c.length;){var y=yi(l.domEventName,l.eventSystemFlags,c[0],l.nativeEvent);if(y===null){y=l.nativeEvent;var k=new y.constructor(y.type,y);Qs=k,y.target.dispatchEvent(k),Qs=null}else return c=Md(y),c!==null&&As(c),l.blockedOn=y,!1;c.shift()}return!0}function bl(l,c,y){gi(l)&&y.delete(c)}function jl(){Yr=!1,kn!==null&&gi(kn)&&(kn=null),Sn!==null&&gi(Sn)&&(Sn=null),sr!==null&&gi(sr)&&(sr=null),wr.forEach(bl),Sr.forEach(bl)}function da(l,c){l.blockedOn===c&&(l.blockedOn=null,Yr||(Yr=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,jl)))}function Da(l){function c(B){return da(B,l)}if(0<Nr.length){da(Nr[0],l);for(var y=1;y<Nr.length;y++){var k=Nr[y];k.blockedOn===l&&(k.blockedOn=null)}}for(kn!==null&&da(kn,l),Sn!==null&&da(Sn,l),sr!==null&&da(sr,l),wr.forEach(c),Sr.forEach(c),y=0;y<yn.length;y++)k=yn[y],k.blockedOn===l&&(k.blockedOn=null);for(;0<yn.length&&(y=yn[0],y.blockedOn===null);)xi(y),y.blockedOn===null&&yn.shift()}var ua=S.ReactCurrentBatchConfig,Va=!0;function fc(l,c,y,k){var B=Js,H=ua.transition;ua.transition=null;try{Js=1,vi(l,c,y,k)}finally{Js=B,ua.transition=H}}function Rd(l,c,y,k){var B=Js,H=ua.transition;ua.transition=null;try{Js=4,vi(l,c,y,k)}finally{Js=B,ua.transition=H}}function vi(l,c,y,k){if(Va){var B=yi(l,c,y,k);if(B===null)Fp(l,c,k,nr,y),Aa(l,k);else if(qi(B,l,c,y,k))k.stopPropagation();else if(Aa(l,k),c&4&&-1<Dn.indexOf(l)){for(;B!==null;){var H=Md(B);if(H!==null&&It(H),H=yi(l,c,y,k),H===null&&Fp(l,c,k,nr,y),H===B)break;B=H}B!==null&&k.stopPropagation()}else Fp(l,c,k,null,y)}}var nr=null;function yi(l,c,y,k){if(nr=null,l=Xs(k),l=Ao(l),l!==null)if(c=gt(l),c===null)l=null;else if(y=c.tag,y===13){if(l=rs(c),l!==null)return l;l=null}else if(y===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;l=null}else c!==l&&(l=null);return nr=l,null}function zi(l){switch(l){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ze()){case xt:return 1;case yt:return 4;case Ot:case Pt:return 16;case Jt:return 536870912;default:return 16}default:return 16}}var Br=null,yo=null,Ui=null;function bo(){if(Ui)return Ui;var l,c=yo,y=c.length,k,B="value"in Br?Br.value:Br.textContent,H=B.length;for(l=0;l<y&&c[l]===B[l];l++);var ne=y-l;for(k=1;k<=ne&&c[y-k]===B[H-k];k++);return Ui=B.slice(l,1<k?1-k:void 0)}function bi(l){var c=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&c===13&&(l=13)):l=c,l===10&&(l=13),32<=l||l===13?l:0}function Nl(){return!0}function wl(){return!1}function rn(l){function c(y,k,B,H,ne){this._reactName=y,this._targetInst=B,this.type=k,this.nativeEvent=H,this.target=ne,this.currentTarget=null;for(var ve in l)l.hasOwnProperty(ve)&&(y=l[ve],this[ve]=y?y(H):H[ve]);return this.isDefaultPrevented=(H.defaultPrevented!=null?H.defaultPrevented:H.returnValue===!1)?Nl:wl,this.isPropagationStopped=wl,this}return z(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var y=this.nativeEvent;y&&(y.preventDefault?y.preventDefault():typeof y.returnValue!="unknown"&&(y.returnValue=!1),this.isDefaultPrevented=Nl)},stopPropagation:function(){var y=this.nativeEvent;y&&(y.stopPropagation?y.stopPropagation():typeof y.cancelBubble!="unknown"&&(y.cancelBubble=!0),this.isPropagationStopped=Nl)},persist:function(){},isPersistent:Nl}),c}var ee={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},se=rn(ee),he=z({},ee,{view:0,detail:0}),pe=rn(he),Ne,$e,qe,ct=z({},he,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:dr,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==qe&&(qe&&l.type==="mousemove"?(Ne=l.screenX-qe.screenX,$e=l.screenY-qe.screenY):$e=Ne=0,qe=l),Ne)},movementY:function(l){return"movementY"in l?l.movementY:$e}}),ds=rn(ct),Kt=z({},ct,{dataTransfer:0}),Ft=rn(Kt),Rs=z({},he,{relatedTarget:0}),cn=rn(Rs),Kn=z({},ee,{animationName:0,elapsedTime:0,pseudoElement:0}),zt=rn(Kn),Es=z({},ee,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),os=rn(Es),On=z({},ee,{data:0}),Cr=rn(On),zn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cr={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},$r={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ha(l){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(l):(l=$r[l])?!!c[l]:!1}function dr(){return Ha}var jo=z({},he,{key:function(l){if(l.key){var c=zn[l.key]||l.key;if(c!=="Unidentified")return c}return l.type==="keypress"?(l=bi(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?cr[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:dr,charCode:function(l){return l.type==="keypress"?bi(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?bi(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Sl=rn(jo),pc=z({},ct,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),No=rn(pc),Cl=z({},he,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:dr}),Vi=rn(Cl),Wa=z({},ee,{propertyName:0,elapsedTime:0,pseudoElement:0}),xc=rn(Wa),rr=z({},ct,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),gc=rn(rr),Ra=[9,13,27,32],Al=d&&"CompositionEvent"in window,Hi=null;d&&"documentMode"in document&&(Hi=document.documentMode);var Ea=d&&"TextEvent"in window&&!Hi,Ga=d&&(!Al||Hi&&8<Hi&&11>=Hi),kl=" ",Wi=!1;function wo(l,c){switch(l){case"keyup":return Ra.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oh(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Dl=!1;function Ap(l,c){switch(l){case"compositionend":return oh(c);case"keypress":return c.which!==32?null:(Wi=!0,kl);case"textInput":return l=c.data,l===kl&&Wi?null:l;default:return null}}function kp(l,c){if(Dl)return l==="compositionend"||!Al&&wo(l,c)?(l=bo(),Ui=yo=Br=null,Dl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Ga&&c.locale!=="ko"?null:c.data;default:return null}}var Dp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ch(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c==="input"?!!Dp[l.type]:c==="textarea"}function dh(l,c,y,k){Fe(k),c=xh(c,"onChange"),0<c.length&&(y=new se("onChange","change",null,y,k),l.push({event:y,listeners:c}))}var So=null,Co=null;function Rp(l){_j(l,0)}function vc(l){var c=Sc(l);if(ce(c))return l}function Ep(l,c){if(l==="change")return c}var uh=!1;if(d){var Ed;if(d){var yc="oninput"in document;if(!yc){var ur=document.createElement("div");ur.setAttribute("oninput","return;"),yc=typeof ur.oninput=="function"}Ed=yc}else Ed=!1;uh=Ed&&(!document.documentMode||9<document.documentMode)}function Rl(){So&&(So.detachEvent("onpropertychange",hh),Co=So=null)}function hh(l){if(l.propertyName==="value"&&vc(Co)){var c=[];dh(c,Co,l,Xs(l)),dt(Rp,c)}}function fT(l,c,y){l==="focusin"?(Rl(),So=c,Co=y,So.attachEvent("onpropertychange",hh)):l==="focusout"&&Rl()}function pT(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return vc(Co)}function xT(l,c){if(l==="click")return vc(c)}function gT(l,c){if(l==="input"||l==="change")return vc(c)}function vT(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var Ka=typeof Object.is=="function"?Object.is:vT;function _d(l,c){if(Ka(l,c))return!0;if(typeof l!="object"||l===null||typeof c!="object"||c===null)return!1;var y=Object.keys(l),k=Object.keys(c);if(y.length!==k.length)return!1;for(k=0;k<y.length;k++){var B=y[k];if(!m.call(c,B)||!Ka(l[B],c[B]))return!1}return!0}function vj(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function yj(l,c){var y=vj(l);l=0;for(var k;y;){if(y.nodeType===3){if(k=l+y.textContent.length,l<=c&&k>=c)return{node:y,offset:c-l};l=k}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=vj(y)}}function bj(l,c){return l&&c?l===c?!0:l&&l.nodeType===3?!1:c&&c.nodeType===3?bj(l,c.parentNode):"contains"in l?l.contains(c):l.compareDocumentPosition?!!(l.compareDocumentPosition(c)&16):!1:!1}function jj(){for(var l=window,c=je();c instanceof l.HTMLIFrameElement;){try{var y=typeof c.contentWindow.location.href=="string"}catch{y=!1}if(y)l=c.contentWindow;else break;c=je(l.document)}return c}function _p(l){var c=l&&l.nodeName&&l.nodeName.toLowerCase();return c&&(c==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||c==="textarea"||l.contentEditable==="true")}function yT(l){var c=jj(),y=l.focusedElem,k=l.selectionRange;if(c!==y&&y&&y.ownerDocument&&bj(y.ownerDocument.documentElement,y)){if(k!==null&&_p(y)){if(c=k.start,l=k.end,l===void 0&&(l=c),"selectionStart"in y)y.selectionStart=c,y.selectionEnd=Math.min(l,y.value.length);else if(l=(c=y.ownerDocument||document)&&c.defaultView||window,l.getSelection){l=l.getSelection();var B=y.textContent.length,H=Math.min(k.start,B);k=k.end===void 0?H:Math.min(k.end,B),!l.extend&&H>k&&(B=k,k=H,H=B),B=yj(y,H);var ne=yj(y,k);B&&ne&&(l.rangeCount!==1||l.anchorNode!==B.node||l.anchorOffset!==B.offset||l.focusNode!==ne.node||l.focusOffset!==ne.offset)&&(c=c.createRange(),c.setStart(B.node,B.offset),l.removeAllRanges(),H>k?(l.addRange(c),l.extend(ne.node,ne.offset)):(c.setEnd(ne.node,ne.offset),l.addRange(c)))}}for(c=[],l=y;l=l.parentNode;)l.nodeType===1&&c.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<c.length;y++)l=c[y],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var bT=d&&"documentMode"in document&&11>=document.documentMode,bc=null,Tp=null,Td=null,Pp=!1;function Nj(l,c,y){var k=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;Pp||bc==null||bc!==je(k)||(k=bc,"selectionStart"in k&&_p(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),Td&&_d(Td,k)||(Td=k,k=xh(Tp,"onSelect"),0<k.length&&(c=new se("onSelect","select",null,c,y),l.push({event:c,listeners:k}),c.target=bc)))}function mh(l,c){var y={};return y[l.toLowerCase()]=c.toLowerCase(),y["Webkit"+l]="webkit"+c,y["Moz"+l]="moz"+c,y}var jc={animationend:mh("Animation","AnimationEnd"),animationiteration:mh("Animation","AnimationIteration"),animationstart:mh("Animation","AnimationStart"),transitionend:mh("Transition","TransitionEnd")},Op={},wj={};d&&(wj=document.createElement("div").style,"AnimationEvent"in window||(delete jc.animationend.animation,delete jc.animationiteration.animation,delete jc.animationstart.animation),"TransitionEvent"in window||delete jc.transitionend.transition);function fh(l){if(Op[l])return Op[l];if(!jc[l])return l;var c=jc[l],y;for(y in c)if(c.hasOwnProperty(y)&&y in wj)return Op[l]=c[y];return l}var Sj=fh("animationend"),Cj=fh("animationiteration"),Aj=fh("animationstart"),kj=fh("transitionend"),Dj=new Map,Rj="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function El(l,c){Dj.set(l,c),i(c,[l])}for(var Lp=0;Lp<Rj.length;Lp++){var Ip=Rj[Lp],jT=Ip.toLowerCase(),NT=Ip[0].toUpperCase()+Ip.slice(1);El(jT,"on"+NT)}El(Sj,"onAnimationEnd"),El(Cj,"onAnimationIteration"),El(Aj,"onAnimationStart"),El("dblclick","onDoubleClick"),El("focusin","onFocus"),El("focusout","onBlur"),El(kj,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pd="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),wT=new Set("cancel close invalid load scroll toggle".split(" ").concat(Pd));function Ej(l,c,y){var k=l.type||"unknown-event";l.currentTarget=y,bt(k,c,void 0,l),l.currentTarget=null}function _j(l,c){c=(c&4)!==0;for(var y=0;y<l.length;y++){var k=l[y],B=k.event;k=k.listeners;e:{var H=void 0;if(c)for(var ne=k.length-1;0<=ne;ne--){var ve=k[ne],De=ve.instance,Qe=ve.currentTarget;if(ve=ve.listener,De!==H&&B.isPropagationStopped())break e;Ej(B,ve,Qe),H=De}else for(ne=0;ne<k.length;ne++){if(ve=k[ne],De=ve.instance,Qe=ve.currentTarget,ve=ve.listener,De!==H&&B.isPropagationStopped())break e;Ej(B,ve,Qe),H=De}}}if(Se)throw l=be,Se=!1,be=null,l}function Rn(l,c){var y=c[Vp];y===void 0&&(y=c[Vp]=new Set);var k=l+"__bubble";y.has(k)||(Tj(c,l,2,!1),y.add(k))}function Mp(l,c,y){var k=0;c&&(k|=4),Tj(y,l,k,c)}var ph="_reactListening"+Math.random().toString(36).slice(2);function Od(l){if(!l[ph]){l[ph]=!0,r.forEach(function(y){y!=="selectionchange"&&(wT.has(y)||Mp(y,!1,l),Mp(y,!0,l))});var c=l.nodeType===9?l:l.ownerDocument;c===null||c[ph]||(c[ph]=!0,Mp("selectionchange",!1,c))}}function Tj(l,c,y,k){switch(zi(c)){case 1:var B=fc;break;case 4:B=Rd;break;default:B=vi}y=B.bind(null,c,y,l),B=void 0,!Wt||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(B=!0),k?B!==void 0?l.addEventListener(c,y,{capture:!0,passive:B}):l.addEventListener(c,y,!0):B!==void 0?l.addEventListener(c,y,{passive:B}):l.addEventListener(c,y,!1)}function Fp(l,c,y,k,B){var H=k;if((c&1)===0&&(c&2)===0&&k!==null)e:for(;;){if(k===null)return;var ne=k.tag;if(ne===3||ne===4){var ve=k.stateNode.containerInfo;if(ve===B||ve.nodeType===8&&ve.parentNode===B)break;if(ne===4)for(ne=k.return;ne!==null;){var De=ne.tag;if((De===3||De===4)&&(De=ne.stateNode.containerInfo,De===B||De.nodeType===8&&De.parentNode===B))return;ne=ne.return}for(;ve!==null;){if(ne=Ao(ve),ne===null)return;if(De=ne.tag,De===5||De===6){k=H=ne;continue e}ve=ve.parentNode}}k=k.return}dt(function(){var Qe=H,Dt=Xs(y),Lt=[];e:{var At=Dj.get(l);if(At!==void 0){var ls=se,xs=l;switch(l){case"keypress":if(bi(y)===0)break e;case"keydown":case"keyup":ls=Sl;break;case"focusin":xs="focus",ls=cn;break;case"focusout":xs="blur",ls=cn;break;case"beforeblur":case"afterblur":ls=cn;break;case"click":if(y.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ls=ds;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ls=Ft;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ls=Vi;break;case Sj:case Cj:case Aj:ls=zt;break;case kj:ls=xc;break;case"scroll":ls=pe;break;case"wheel":ls=gc;break;case"copy":case"cut":case"paste":ls=os;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ls=No}var vs=(c&4)!==0,Gn=!vs&&l==="scroll",He=vs?At!==null?At+"Capture":null:At;vs=[];for(var Te=Qe,Ge;Te!==null;){Ge=Te;var Ut=Ge.stateNode;if(Ge.tag===5&&Ut!==null&&(Ge=Ut,He!==null&&(Ut=ss(Te,He),Ut!=null&&vs.push(Ld(Te,Ut,Ge)))),Gn)break;Te=Te.return}0<vs.length&&(At=new ls(At,xs,null,y,Dt),Lt.push({event:At,listeners:vs}))}}if((c&7)===0){e:{if(At=l==="mouseover"||l==="pointerover",ls=l==="mouseout"||l==="pointerout",At&&y!==Qs&&(xs=y.relatedTarget||y.fromElement)&&(Ao(xs)||xs[Gi]))break e;if((ls||At)&&(At=Dt.window===Dt?Dt:(At=Dt.ownerDocument)?At.defaultView||At.parentWindow:window,ls?(xs=y.relatedTarget||y.toElement,ls=Qe,xs=xs?Ao(xs):null,xs!==null&&(Gn=gt(xs),xs!==Gn||xs.tag!==5&&xs.tag!==6)&&(xs=null)):(ls=null,xs=Qe),ls!==xs)){if(vs=ds,Ut="onMouseLeave",He="onMouseEnter",Te="mouse",(l==="pointerout"||l==="pointerover")&&(vs=No,Ut="onPointerLeave",He="onPointerEnter",Te="pointer"),Gn=ls==null?At:Sc(ls),Ge=xs==null?At:Sc(xs),At=new vs(Ut,Te+"leave",ls,y,Dt),At.target=Gn,At.relatedTarget=Ge,Ut=null,Ao(Dt)===Qe&&(vs=new vs(He,Te+"enter",xs,y,Dt),vs.target=Ge,vs.relatedTarget=Gn,Ut=vs),Gn=Ut,ls&&xs)t:{for(vs=ls,He=xs,Te=0,Ge=vs;Ge;Ge=Nc(Ge))Te++;for(Ge=0,Ut=He;Ut;Ut=Nc(Ut))Ge++;for(;0<Te-Ge;)vs=Nc(vs),Te--;for(;0<Ge-Te;)He=Nc(He),Ge--;for(;Te--;){if(vs===He||He!==null&&vs===He.alternate)break t;vs=Nc(vs),He=Nc(He)}vs=null}else vs=null;ls!==null&&Pj(Lt,At,ls,vs,!1),xs!==null&&Gn!==null&&Pj(Lt,Gn,xs,vs,!0)}}e:{if(At=Qe?Sc(Qe):window,ls=At.nodeName&&At.nodeName.toLowerCase(),ls==="select"||ls==="input"&&At.type==="file")var Ns=Ep;else if(ch(At))if(uh)Ns=gT;else{Ns=pT;var Ls=fT}else(ls=At.nodeName)&&ls.toLowerCase()==="input"&&(At.type==="checkbox"||At.type==="radio")&&(Ns=xT);if(Ns&&(Ns=Ns(l,Qe))){dh(Lt,Ns,y,Dt);break e}Ls&&Ls(l,At,Qe),l==="focusout"&&(Ls=At._wrapperState)&&Ls.controlled&&At.type==="number"&&Ce(At,"number",At.value)}switch(Ls=Qe?Sc(Qe):window,l){case"focusin":(ch(Ls)||Ls.contentEditable==="true")&&(bc=Ls,Tp=Qe,Td=null);break;case"focusout":Td=Tp=bc=null;break;case"mousedown":Pp=!0;break;case"contextmenu":case"mouseup":case"dragend":Pp=!1,Nj(Lt,y,Dt);break;case"selectionchange":if(bT)break;case"keydown":case"keyup":Nj(Lt,y,Dt)}var Is;if(Al)e:{switch(l){case"compositionstart":var Hs="onCompositionStart";break e;case"compositionend":Hs="onCompositionEnd";break e;case"compositionupdate":Hs="onCompositionUpdate";break e}Hs=void 0}else Dl?wo(l,y)&&(Hs="onCompositionEnd"):l==="keydown"&&y.keyCode===229&&(Hs="onCompositionStart");Hs&&(Ga&&y.locale!=="ko"&&(Dl||Hs!=="onCompositionStart"?Hs==="onCompositionEnd"&&Dl&&(Is=bo()):(Br=Dt,yo="value"in Br?Br.value:Br.textContent,Dl=!0)),Ls=xh(Qe,Hs),0<Ls.length&&(Hs=new Cr(Hs,l,null,y,Dt),Lt.push({event:Hs,listeners:Ls}),Is?Hs.data=Is:(Is=oh(y),Is!==null&&(Hs.data=Is)))),(Is=Ea?Ap(l,y):kp(l,y))&&(Qe=xh(Qe,"onBeforeInput"),0<Qe.length&&(Dt=new Cr("onBeforeInput","beforeinput",null,y,Dt),Lt.push({event:Dt,listeners:Qe}),Dt.data=Is))}_j(Lt,c)})}function Ld(l,c,y){return{instance:l,listener:c,currentTarget:y}}function xh(l,c){for(var y=c+"Capture",k=[];l!==null;){var B=l,H=B.stateNode;B.tag===5&&H!==null&&(B=H,H=ss(l,y),H!=null&&k.unshift(Ld(l,H,B)),H=ss(l,c),H!=null&&k.push(Ld(l,H,B))),l=l.return}return k}function Nc(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function Pj(l,c,y,k,B){for(var H=c._reactName,ne=[];y!==null&&y!==k;){var ve=y,De=ve.alternate,Qe=ve.stateNode;if(De!==null&&De===k)break;ve.tag===5&&Qe!==null&&(ve=Qe,B?(De=ss(y,H),De!=null&&ne.unshift(Ld(y,De,ve))):B||(De=ss(y,H),De!=null&&ne.push(Ld(y,De,ve)))),y=y.return}ne.length!==0&&l.push({event:c,listeners:ne})}var ST=/\r\n?/g,CT=/\u0000|\uFFFD/g;function Oj(l){return(typeof l=="string"?l:""+l).replace(ST,`
|
||
`).replace(CT,"")}function gh(l,c,y){if(c=Oj(c),Oj(l)!==c&&y)throw Error(n(425))}function vh(){}var Bp=null,$p=null;function qp(l,c){return l==="textarea"||l==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var zp=typeof setTimeout=="function"?setTimeout:void 0,AT=typeof clearTimeout=="function"?clearTimeout:void 0,Lj=typeof Promise=="function"?Promise:void 0,kT=typeof queueMicrotask=="function"?queueMicrotask:typeof Lj<"u"?function(l){return Lj.resolve(null).then(l).catch(DT)}:zp;function DT(l){setTimeout(function(){throw l})}function Up(l,c){var y=c,k=0;do{var B=y.nextSibling;if(l.removeChild(y),B&&B.nodeType===8)if(y=B.data,y==="/$"){if(k===0){l.removeChild(B),Da(c);return}k--}else y!=="$"&&y!=="$?"&&y!=="$!"||k++;y=B}while(y);Da(c)}function _l(l){for(;l!=null;l=l.nextSibling){var c=l.nodeType;if(c===1||c===3)break;if(c===8){if(c=l.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return l}function Ij(l){l=l.previousSibling;for(var c=0;l;){if(l.nodeType===8){var y=l.data;if(y==="$"||y==="$!"||y==="$?"){if(c===0)return l;c--}else y==="/$"&&c++}l=l.previousSibling}return null}var wc=Math.random().toString(36).slice(2),ji="__reactFiber$"+wc,Id="__reactProps$"+wc,Gi="__reactContainer$"+wc,Vp="__reactEvents$"+wc,RT="__reactListeners$"+wc,ET="__reactHandles$"+wc;function Ao(l){var c=l[ji];if(c)return c;for(var y=l.parentNode;y;){if(c=y[Gi]||y[ji]){if(y=c.alternate,c.child!==null||y!==null&&y.child!==null)for(l=Ij(l);l!==null;){if(y=l[ji])return y;l=Ij(l)}return c}l=y,y=l.parentNode}return null}function Md(l){return l=l[ji]||l[Gi],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function Sc(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function yh(l){return l[Id]||null}var Hp=[],Cc=-1;function Tl(l){return{current:l}}function En(l){0>Cc||(l.current=Hp[Cc],Hp[Cc]=null,Cc--)}function Cn(l,c){Cc++,Hp[Cc]=l.current,l.current=c}var Pl={},Tr=Tl(Pl),Zr=Tl(!1),ko=Pl;function Ac(l,c){var y=l.type.contextTypes;if(!y)return Pl;var k=l.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===c)return k.__reactInternalMemoizedMaskedChildContext;var B={},H;for(H in y)B[H]=c[H];return k&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=c,l.__reactInternalMemoizedMaskedChildContext=B),B}function Qr(l){return l=l.childContextTypes,l!=null}function bh(){En(Zr),En(Tr)}function Mj(l,c,y){if(Tr.current!==Pl)throw Error(n(168));Cn(Tr,c),Cn(Zr,y)}function Fj(l,c,y){var k=l.stateNode;if(c=c.childContextTypes,typeof k.getChildContext!="function")return y;k=k.getChildContext();for(var B in k)if(!(B in c))throw Error(n(108,Y(l)||"Unknown",B));return z({},y,k)}function jh(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Pl,ko=Tr.current,Cn(Tr,l),Cn(Zr,Zr.current),!0}function Bj(l,c,y){var k=l.stateNode;if(!k)throw Error(n(169));y?(l=Fj(l,c,ko),k.__reactInternalMemoizedMergedChildContext=l,En(Zr),En(Tr),Cn(Tr,l)):En(Zr),Cn(Zr,y)}var Ki=null,Nh=!1,Wp=!1;function $j(l){Ki===null?Ki=[l]:Ki.push(l)}function _T(l){Nh=!0,$j(l)}function Ol(){if(!Wp&&Ki!==null){Wp=!0;var l=0,c=Js;try{var y=Ki;for(Js=1;l<y.length;l++){var k=y[l];do k=k(!0);while(k!==null)}Ki=null,Nh=!1}catch(B){throw Ki!==null&&(Ki=Ki.slice(l+1)),Ee(xt,Ol),B}finally{Js=c,Wp=!1}}return null}var kc=[],Dc=0,wh=null,Sh=0,_a=[],Ta=0,Do=null,Yi=1,Zi="";function Ro(l,c){kc[Dc++]=Sh,kc[Dc++]=wh,wh=l,Sh=c}function qj(l,c,y){_a[Ta++]=Yi,_a[Ta++]=Zi,_a[Ta++]=Do,Do=l;var k=Yi;l=Zi;var B=32-ts(k)-1;k&=~(1<<B),y+=1;var H=32-ts(c)+B;if(30<H){var ne=B-B%5;H=(k&(1<<ne)-1).toString(32),k>>=ne,B-=ne,Yi=1<<32-ts(c)+B|y<<B|k,Zi=H+l}else Yi=1<<H|y<<B|k,Zi=l}function Gp(l){l.return!==null&&(Ro(l,1),qj(l,1,0))}function Kp(l){for(;l===wh;)wh=kc[--Dc],kc[Dc]=null,Sh=kc[--Dc],kc[Dc]=null;for(;l===Do;)Do=_a[--Ta],_a[Ta]=null,Zi=_a[--Ta],_a[Ta]=null,Yi=_a[--Ta],_a[Ta]=null}var ha=null,ma=null,Ln=!1,Ya=null;function zj(l,c){var y=Ia(5,null,null,0);y.elementType="DELETED",y.stateNode=c,y.return=l,c=l.deletions,c===null?(l.deletions=[y],l.flags|=16):c.push(y)}function Uj(l,c){switch(l.tag){case 5:var y=l.type;return c=c.nodeType!==1||y.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(l.stateNode=c,ha=l,ma=_l(c.firstChild),!0):!1;case 6:return c=l.pendingProps===""||c.nodeType!==3?null:c,c!==null?(l.stateNode=c,ha=l,ma=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(y=Do!==null?{id:Yi,overflow:Zi}:null,l.memoizedState={dehydrated:c,treeContext:y,retryLane:1073741824},y=Ia(18,null,null,0),y.stateNode=c,y.return=l,l.child=y,ha=l,ma=null,!0):!1;default:return!1}}function Yp(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Zp(l){if(Ln){var c=ma;if(c){var y=c;if(!Uj(l,c)){if(Yp(l))throw Error(n(418));c=_l(y.nextSibling);var k=ha;c&&Uj(l,c)?zj(k,y):(l.flags=l.flags&-4097|2,Ln=!1,ha=l)}}else{if(Yp(l))throw Error(n(418));l.flags=l.flags&-4097|2,Ln=!1,ha=l}}}function Vj(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;ha=l}function Ch(l){if(l!==ha)return!1;if(!Ln)return Vj(l),Ln=!0,!1;var c;if((c=l.tag!==3)&&!(c=l.tag!==5)&&(c=l.type,c=c!=="head"&&c!=="body"&&!qp(l.type,l.memoizedProps)),c&&(c=ma)){if(Yp(l))throw Hj(),Error(n(418));for(;c;)zj(l,c),c=_l(c.nextSibling)}if(Vj(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,c=0;l;){if(l.nodeType===8){var y=l.data;if(y==="/$"){if(c===0){ma=_l(l.nextSibling);break e}c--}else y!=="$"&&y!=="$!"&&y!=="$?"||c++}l=l.nextSibling}ma=null}}else ma=ha?_l(l.stateNode.nextSibling):null;return!0}function Hj(){for(var l=ma;l;)l=_l(l.nextSibling)}function Rc(){ma=ha=null,Ln=!1}function Qp(l){Ya===null?Ya=[l]:Ya.push(l)}var TT=S.ReactCurrentBatchConfig;function Fd(l,c,y){if(l=y.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(y._owner){if(y=y._owner,y){if(y.tag!==1)throw Error(n(309));var k=y.stateNode}if(!k)throw Error(n(147,l));var B=k,H=""+l;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===H?c.ref:(c=function(ne){var ve=B.refs;ne===null?delete ve[H]:ve[H]=ne},c._stringRef=H,c)}if(typeof l!="string")throw Error(n(284));if(!y._owner)throw Error(n(290,l))}return l}function Ah(l,c){throw l=Object.prototype.toString.call(c),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":l))}function Wj(l){var c=l._init;return c(l._payload)}function Gj(l){function c(He,Te){if(l){var Ge=He.deletions;Ge===null?(He.deletions=[Te],He.flags|=16):Ge.push(Te)}}function y(He,Te){if(!l)return null;for(;Te!==null;)c(He,Te),Te=Te.sibling;return null}function k(He,Te){for(He=new Map;Te!==null;)Te.key!==null?He.set(Te.key,Te):He.set(Te.index,Te),Te=Te.sibling;return He}function B(He,Te){return He=zl(He,Te),He.index=0,He.sibling=null,He}function H(He,Te,Ge){return He.index=Ge,l?(Ge=He.alternate,Ge!==null?(Ge=Ge.index,Ge<Te?(He.flags|=2,Te):Ge):(He.flags|=2,Te)):(He.flags|=1048576,Te)}function ne(He){return l&&He.alternate===null&&(He.flags|=2),He}function ve(He,Te,Ge,Ut){return Te===null||Te.tag!==6?(Te=zx(Ge,He.mode,Ut),Te.return=He,Te):(Te=B(Te,Ge),Te.return=He,Te)}function De(He,Te,Ge,Ut){var Ns=Ge.type;return Ns===A?Dt(He,Te,Ge.props.children,Ut,Ge.key):Te!==null&&(Te.elementType===Ns||typeof Ns=="object"&&Ns!==null&&Ns.$$typeof===Q&&Wj(Ns)===Te.type)?(Ut=B(Te,Ge.props),Ut.ref=Fd(He,Te,Ge),Ut.return=He,Ut):(Ut=Zh(Ge.type,Ge.key,Ge.props,null,He.mode,Ut),Ut.ref=Fd(He,Te,Ge),Ut.return=He,Ut)}function Qe(He,Te,Ge,Ut){return Te===null||Te.tag!==4||Te.stateNode.containerInfo!==Ge.containerInfo||Te.stateNode.implementation!==Ge.implementation?(Te=Ux(Ge,He.mode,Ut),Te.return=He,Te):(Te=B(Te,Ge.children||[]),Te.return=He,Te)}function Dt(He,Te,Ge,Ut,Ns){return Te===null||Te.tag!==7?(Te=Mo(Ge,He.mode,Ut,Ns),Te.return=He,Te):(Te=B(Te,Ge),Te.return=He,Te)}function Lt(He,Te,Ge){if(typeof Te=="string"&&Te!==""||typeof Te=="number")return Te=zx(""+Te,He.mode,Ge),Te.return=He,Te;if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case D:return Ge=Zh(Te.type,Te.key,Te.props,null,He.mode,Ge),Ge.ref=Fd(He,null,Te),Ge.return=He,Ge;case _:return Te=Ux(Te,He.mode,Ge),Te.return=He,Te;case Q:var Ut=Te._init;return Lt(He,Ut(Te._payload),Ge)}if(xe(Te)||M(Te))return Te=Mo(Te,He.mode,Ge,null),Te.return=He,Te;Ah(He,Te)}return null}function At(He,Te,Ge,Ut){var Ns=Te!==null?Te.key:null;if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number")return Ns!==null?null:ve(He,Te,""+Ge,Ut);if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case D:return Ge.key===Ns?De(He,Te,Ge,Ut):null;case _:return Ge.key===Ns?Qe(He,Te,Ge,Ut):null;case Q:return Ns=Ge._init,At(He,Te,Ns(Ge._payload),Ut)}if(xe(Ge)||M(Ge))return Ns!==null?null:Dt(He,Te,Ge,Ut,null);Ah(He,Ge)}return null}function ls(He,Te,Ge,Ut,Ns){if(typeof Ut=="string"&&Ut!==""||typeof Ut=="number")return He=He.get(Ge)||null,ve(Te,He,""+Ut,Ns);if(typeof Ut=="object"&&Ut!==null){switch(Ut.$$typeof){case D:return He=He.get(Ut.key===null?Ge:Ut.key)||null,De(Te,He,Ut,Ns);case _:return He=He.get(Ut.key===null?Ge:Ut.key)||null,Qe(Te,He,Ut,Ns);case Q:var Ls=Ut._init;return ls(He,Te,Ge,Ls(Ut._payload),Ns)}if(xe(Ut)||M(Ut))return He=He.get(Ge)||null,Dt(Te,He,Ut,Ns,null);Ah(Te,Ut)}return null}function xs(He,Te,Ge,Ut){for(var Ns=null,Ls=null,Is=Te,Hs=Te=0,fr=null;Is!==null&&Hs<Ge.length;Hs++){Is.index>Hs?(fr=Is,Is=null):fr=Is.sibling;var fn=At(He,Is,Ge[Hs],Ut);if(fn===null){Is===null&&(Is=fr);break}l&&Is&&fn.alternate===null&&c(He,Is),Te=H(fn,Te,Hs),Ls===null?Ns=fn:Ls.sibling=fn,Ls=fn,Is=fr}if(Hs===Ge.length)return y(He,Is),Ln&&Ro(He,Hs),Ns;if(Is===null){for(;Hs<Ge.length;Hs++)Is=Lt(He,Ge[Hs],Ut),Is!==null&&(Te=H(Is,Te,Hs),Ls===null?Ns=Is:Ls.sibling=Is,Ls=Is);return Ln&&Ro(He,Hs),Ns}for(Is=k(He,Is);Hs<Ge.length;Hs++)fr=ls(Is,He,Hs,Ge[Hs],Ut),fr!==null&&(l&&fr.alternate!==null&&Is.delete(fr.key===null?Hs:fr.key),Te=H(fr,Te,Hs),Ls===null?Ns=fr:Ls.sibling=fr,Ls=fr);return l&&Is.forEach(function(Ul){return c(He,Ul)}),Ln&&Ro(He,Hs),Ns}function vs(He,Te,Ge,Ut){var Ns=M(Ge);if(typeof Ns!="function")throw Error(n(150));if(Ge=Ns.call(Ge),Ge==null)throw Error(n(151));for(var Ls=Ns=null,Is=Te,Hs=Te=0,fr=null,fn=Ge.next();Is!==null&&!fn.done;Hs++,fn=Ge.next()){Is.index>Hs?(fr=Is,Is=null):fr=Is.sibling;var Ul=At(He,Is,fn.value,Ut);if(Ul===null){Is===null&&(Is=fr);break}l&&Is&&Ul.alternate===null&&c(He,Is),Te=H(Ul,Te,Hs),Ls===null?Ns=Ul:Ls.sibling=Ul,Ls=Ul,Is=fr}if(fn.done)return y(He,Is),Ln&&Ro(He,Hs),Ns;if(Is===null){for(;!fn.done;Hs++,fn=Ge.next())fn=Lt(He,fn.value,Ut),fn!==null&&(Te=H(fn,Te,Hs),Ls===null?Ns=fn:Ls.sibling=fn,Ls=fn);return Ln&&Ro(He,Hs),Ns}for(Is=k(He,Is);!fn.done;Hs++,fn=Ge.next())fn=ls(Is,He,Hs,fn.value,Ut),fn!==null&&(l&&fn.alternate!==null&&Is.delete(fn.key===null?Hs:fn.key),Te=H(fn,Te,Hs),Ls===null?Ns=fn:Ls.sibling=fn,Ls=fn);return l&&Is.forEach(function(uP){return c(He,uP)}),Ln&&Ro(He,Hs),Ns}function Gn(He,Te,Ge,Ut){if(typeof Ge=="object"&&Ge!==null&&Ge.type===A&&Ge.key===null&&(Ge=Ge.props.children),typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case D:e:{for(var Ns=Ge.key,Ls=Te;Ls!==null;){if(Ls.key===Ns){if(Ns=Ge.type,Ns===A){if(Ls.tag===7){y(He,Ls.sibling),Te=B(Ls,Ge.props.children),Te.return=He,He=Te;break e}}else if(Ls.elementType===Ns||typeof Ns=="object"&&Ns!==null&&Ns.$$typeof===Q&&Wj(Ns)===Ls.type){y(He,Ls.sibling),Te=B(Ls,Ge.props),Te.ref=Fd(He,Ls,Ge),Te.return=He,He=Te;break e}y(He,Ls);break}else c(He,Ls);Ls=Ls.sibling}Ge.type===A?(Te=Mo(Ge.props.children,He.mode,Ut,Ge.key),Te.return=He,He=Te):(Ut=Zh(Ge.type,Ge.key,Ge.props,null,He.mode,Ut),Ut.ref=Fd(He,Te,Ge),Ut.return=He,He=Ut)}return ne(He);case _:e:{for(Ls=Ge.key;Te!==null;){if(Te.key===Ls)if(Te.tag===4&&Te.stateNode.containerInfo===Ge.containerInfo&&Te.stateNode.implementation===Ge.implementation){y(He,Te.sibling),Te=B(Te,Ge.children||[]),Te.return=He,He=Te;break e}else{y(He,Te);break}else c(He,Te);Te=Te.sibling}Te=Ux(Ge,He.mode,Ut),Te.return=He,He=Te}return ne(He);case Q:return Ls=Ge._init,Gn(He,Te,Ls(Ge._payload),Ut)}if(xe(Ge))return xs(He,Te,Ge,Ut);if(M(Ge))return vs(He,Te,Ge,Ut);Ah(He,Ge)}return typeof Ge=="string"&&Ge!==""||typeof Ge=="number"?(Ge=""+Ge,Te!==null&&Te.tag===6?(y(He,Te.sibling),Te=B(Te,Ge),Te.return=He,He=Te):(y(He,Te),Te=zx(Ge,He.mode,Ut),Te.return=He,He=Te),ne(He)):y(He,Te)}return Gn}var Ec=Gj(!0),Kj=Gj(!1),kh=Tl(null),Dh=null,_c=null,Xp=null;function Jp(){Xp=_c=Dh=null}function ex(l){var c=kh.current;En(kh),l._currentValue=c}function tx(l,c,y){for(;l!==null;){var k=l.alternate;if((l.childLanes&c)!==c?(l.childLanes|=c,k!==null&&(k.childLanes|=c)):k!==null&&(k.childLanes&c)!==c&&(k.childLanes|=c),l===y)break;l=l.return}}function Tc(l,c){Dh=l,Xp=_c=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&c)!==0&&(Xr=!0),l.firstContext=null)}function Pa(l){var c=l._currentValue;if(Xp!==l)if(l={context:l,memoizedValue:c,next:null},_c===null){if(Dh===null)throw Error(n(308));_c=l,Dh.dependencies={lanes:0,firstContext:l}}else _c=_c.next=l;return c}var Eo=null;function sx(l){Eo===null?Eo=[l]:Eo.push(l)}function Yj(l,c,y,k){var B=c.interleaved;return B===null?(y.next=y,sx(c)):(y.next=B.next,B.next=y),c.interleaved=y,Qi(l,k)}function Qi(l,c){l.lanes|=c;var y=l.alternate;for(y!==null&&(y.lanes|=c),y=l,l=l.return;l!==null;)l.childLanes|=c,y=l.alternate,y!==null&&(y.childLanes|=c),y=l,l=l.return;return y.tag===3?y.stateNode:null}var Ll=!1;function nx(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zj(l,c){l=l.updateQueue,c.updateQueue===l&&(c.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Xi(l,c){return{eventTime:l,lane:c,tag:0,payload:null,callback:null,next:null}}function Il(l,c,y){var k=l.updateQueue;if(k===null)return null;if(k=k.shared,(hn&2)!==0){var B=k.pending;return B===null?c.next=c:(c.next=B.next,B.next=c),k.pending=c,Qi(l,y)}return B=k.interleaved,B===null?(c.next=c,sx(k)):(c.next=B.next,B.next=c),k.interleaved=c,Qi(l,y)}function Rh(l,c,y){if(c=c.updateQueue,c!==null&&(c=c.shared,(y&4194240)!==0)){var k=c.lanes;k&=l.pendingLanes,y|=k,c.lanes=y,wn(l,y)}}function Qj(l,c){var y=l.updateQueue,k=l.alternate;if(k!==null&&(k=k.updateQueue,y===k)){var B=null,H=null;if(y=y.firstBaseUpdate,y!==null){do{var ne={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};H===null?B=H=ne:H=H.next=ne,y=y.next}while(y!==null);H===null?B=H=c:H=H.next=c}else B=H=c;y={baseState:k.baseState,firstBaseUpdate:B,lastBaseUpdate:H,shared:k.shared,effects:k.effects},l.updateQueue=y;return}l=y.lastBaseUpdate,l===null?y.firstBaseUpdate=c:l.next=c,y.lastBaseUpdate=c}function Eh(l,c,y,k){var B=l.updateQueue;Ll=!1;var H=B.firstBaseUpdate,ne=B.lastBaseUpdate,ve=B.shared.pending;if(ve!==null){B.shared.pending=null;var De=ve,Qe=De.next;De.next=null,ne===null?H=Qe:ne.next=Qe,ne=De;var Dt=l.alternate;Dt!==null&&(Dt=Dt.updateQueue,ve=Dt.lastBaseUpdate,ve!==ne&&(ve===null?Dt.firstBaseUpdate=Qe:ve.next=Qe,Dt.lastBaseUpdate=De))}if(H!==null){var Lt=B.baseState;ne=0,Dt=Qe=De=null,ve=H;do{var At=ve.lane,ls=ve.eventTime;if((k&At)===At){Dt!==null&&(Dt=Dt.next={eventTime:ls,lane:0,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null});e:{var xs=l,vs=ve;switch(At=c,ls=y,vs.tag){case 1:if(xs=vs.payload,typeof xs=="function"){Lt=xs.call(ls,Lt,At);break e}Lt=xs;break e;case 3:xs.flags=xs.flags&-65537|128;case 0:if(xs=vs.payload,At=typeof xs=="function"?xs.call(ls,Lt,At):xs,At==null)break e;Lt=z({},Lt,At);break e;case 2:Ll=!0}}ve.callback!==null&&ve.lane!==0&&(l.flags|=64,At=B.effects,At===null?B.effects=[ve]:At.push(ve))}else ls={eventTime:ls,lane:At,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null},Dt===null?(Qe=Dt=ls,De=Lt):Dt=Dt.next=ls,ne|=At;if(ve=ve.next,ve===null){if(ve=B.shared.pending,ve===null)break;At=ve,ve=At.next,At.next=null,B.lastBaseUpdate=At,B.shared.pending=null}}while(!0);if(Dt===null&&(De=Lt),B.baseState=De,B.firstBaseUpdate=Qe,B.lastBaseUpdate=Dt,c=B.shared.interleaved,c!==null){B=c;do ne|=B.lane,B=B.next;while(B!==c)}else H===null&&(B.shared.lanes=0);Po|=ne,l.lanes=ne,l.memoizedState=Lt}}function Xj(l,c,y){if(l=c.effects,c.effects=null,l!==null)for(c=0;c<l.length;c++){var k=l[c],B=k.callback;if(B!==null){if(k.callback=null,k=y,typeof B!="function")throw Error(n(191,B));B.call(k)}}}var Bd={},Ni=Tl(Bd),$d=Tl(Bd),qd=Tl(Bd);function _o(l){if(l===Bd)throw Error(n(174));return l}function rx(l,c){switch(Cn(qd,c),Cn($d,l),Cn(Ni,Bd),l=c.nodeType,l){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:mt(null,"");break;default:l=l===8?c.parentNode:c,c=l.namespaceURI||null,l=l.tagName,c=mt(c,l)}En(Ni),Cn(Ni,c)}function Pc(){En(Ni),En($d),En(qd)}function Jj(l){_o(qd.current);var c=_o(Ni.current),y=mt(c,l.type);c!==y&&(Cn($d,l),Cn(Ni,y))}function ax(l){$d.current===l&&(En(Ni),En($d))}var Fn=Tl(0);function _h(l){for(var c=l;c!==null;){if(c.tag===13){var y=c.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||y.data==="$?"||y.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var ix=[];function lx(){for(var l=0;l<ix.length;l++)ix[l]._workInProgressVersionPrimary=null;ix.length=0}var Th=S.ReactCurrentDispatcher,ox=S.ReactCurrentBatchConfig,To=0,Bn=null,ar=null,hr=null,Ph=!1,zd=!1,Ud=0,PT=0;function Pr(){throw Error(n(321))}function cx(l,c){if(c===null)return!1;for(var y=0;y<c.length&&y<l.length;y++)if(!Ka(l[y],c[y]))return!1;return!0}function dx(l,c,y,k,B,H){if(To=H,Bn=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Th.current=l===null||l.memoizedState===null?MT:FT,l=y(k,B),zd){H=0;do{if(zd=!1,Ud=0,25<=H)throw Error(n(301));H+=1,hr=ar=null,c.updateQueue=null,Th.current=BT,l=y(k,B)}while(zd)}if(Th.current=Ih,c=ar!==null&&ar.next!==null,To=0,hr=ar=Bn=null,Ph=!1,c)throw Error(n(300));return l}function ux(){var l=Ud!==0;return Ud=0,l}function wi(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return hr===null?Bn.memoizedState=hr=l:hr=hr.next=l,hr}function Oa(){if(ar===null){var l=Bn.alternate;l=l!==null?l.memoizedState:null}else l=ar.next;var c=hr===null?Bn.memoizedState:hr.next;if(c!==null)hr=c,ar=l;else{if(l===null)throw Error(n(310));ar=l,l={memoizedState:ar.memoizedState,baseState:ar.baseState,baseQueue:ar.baseQueue,queue:ar.queue,next:null},hr===null?Bn.memoizedState=hr=l:hr=hr.next=l}return hr}function Vd(l,c){return typeof c=="function"?c(l):c}function hx(l){var c=Oa(),y=c.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=l;var k=ar,B=k.baseQueue,H=y.pending;if(H!==null){if(B!==null){var ne=B.next;B.next=H.next,H.next=ne}k.baseQueue=B=H,y.pending=null}if(B!==null){H=B.next,k=k.baseState;var ve=ne=null,De=null,Qe=H;do{var Dt=Qe.lane;if((To&Dt)===Dt)De!==null&&(De=De.next={lane:0,action:Qe.action,hasEagerState:Qe.hasEagerState,eagerState:Qe.eagerState,next:null}),k=Qe.hasEagerState?Qe.eagerState:l(k,Qe.action);else{var Lt={lane:Dt,action:Qe.action,hasEagerState:Qe.hasEagerState,eagerState:Qe.eagerState,next:null};De===null?(ve=De=Lt,ne=k):De=De.next=Lt,Bn.lanes|=Dt,Po|=Dt}Qe=Qe.next}while(Qe!==null&&Qe!==H);De===null?ne=k:De.next=ve,Ka(k,c.memoizedState)||(Xr=!0),c.memoizedState=k,c.baseState=ne,c.baseQueue=De,y.lastRenderedState=k}if(l=y.interleaved,l!==null){B=l;do H=B.lane,Bn.lanes|=H,Po|=H,B=B.next;while(B!==l)}else B===null&&(y.lanes=0);return[c.memoizedState,y.dispatch]}function mx(l){var c=Oa(),y=c.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=l;var k=y.dispatch,B=y.pending,H=c.memoizedState;if(B!==null){y.pending=null;var ne=B=B.next;do H=l(H,ne.action),ne=ne.next;while(ne!==B);Ka(H,c.memoizedState)||(Xr=!0),c.memoizedState=H,c.baseQueue===null&&(c.baseState=H),y.lastRenderedState=H}return[H,k]}function eN(){}function tN(l,c){var y=Bn,k=Oa(),B=c(),H=!Ka(k.memoizedState,B);if(H&&(k.memoizedState=B,Xr=!0),k=k.queue,fx(rN.bind(null,y,k,l),[l]),k.getSnapshot!==c||H||hr!==null&&hr.memoizedState.tag&1){if(y.flags|=2048,Hd(9,nN.bind(null,y,k,B,c),void 0,null),mr===null)throw Error(n(349));(To&30)!==0||sN(y,c,B)}return B}function sN(l,c,y){l.flags|=16384,l={getSnapshot:c,value:y},c=Bn.updateQueue,c===null?(c={lastEffect:null,stores:null},Bn.updateQueue=c,c.stores=[l]):(y=c.stores,y===null?c.stores=[l]:y.push(l))}function nN(l,c,y,k){c.value=y,c.getSnapshot=k,aN(c)&&iN(l)}function rN(l,c,y){return y(function(){aN(c)&&iN(l)})}function aN(l){var c=l.getSnapshot;l=l.value;try{var y=c();return!Ka(l,y)}catch{return!0}}function iN(l){var c=Qi(l,1);c!==null&&Ja(c,l,1,-1)}function lN(l){var c=wi();return typeof l=="function"&&(l=l()),c.memoizedState=c.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vd,lastRenderedState:l},c.queue=l,l=l.dispatch=IT.bind(null,Bn,l),[c.memoizedState,l]}function Hd(l,c,y,k){return l={tag:l,create:c,destroy:y,deps:k,next:null},c=Bn.updateQueue,c===null?(c={lastEffect:null,stores:null},Bn.updateQueue=c,c.lastEffect=l.next=l):(y=c.lastEffect,y===null?c.lastEffect=l.next=l:(k=y.next,y.next=l,l.next=k,c.lastEffect=l)),l}function oN(){return Oa().memoizedState}function Oh(l,c,y,k){var B=wi();Bn.flags|=l,B.memoizedState=Hd(1|c,y,void 0,k===void 0?null:k)}function Lh(l,c,y,k){var B=Oa();k=k===void 0?null:k;var H=void 0;if(ar!==null){var ne=ar.memoizedState;if(H=ne.destroy,k!==null&&cx(k,ne.deps)){B.memoizedState=Hd(c,y,H,k);return}}Bn.flags|=l,B.memoizedState=Hd(1|c,y,H,k)}function cN(l,c){return Oh(8390656,8,l,c)}function fx(l,c){return Lh(2048,8,l,c)}function dN(l,c){return Lh(4,2,l,c)}function uN(l,c){return Lh(4,4,l,c)}function hN(l,c){if(typeof c=="function")return l=l(),c(l),function(){c(null)};if(c!=null)return l=l(),c.current=l,function(){c.current=null}}function mN(l,c,y){return y=y!=null?y.concat([l]):null,Lh(4,4,hN.bind(null,c,l),y)}function px(){}function fN(l,c){var y=Oa();c=c===void 0?null:c;var k=y.memoizedState;return k!==null&&c!==null&&cx(c,k[1])?k[0]:(y.memoizedState=[l,c],l)}function pN(l,c){var y=Oa();c=c===void 0?null:c;var k=y.memoizedState;return k!==null&&c!==null&&cx(c,k[1])?k[0]:(l=l(),y.memoizedState=[l,c],l)}function xN(l,c,y){return(To&21)===0?(l.baseState&&(l.baseState=!1,Xr=!0),l.memoizedState=y):(Ka(y,c)||(y=St(),Bn.lanes|=y,Po|=y,l.baseState=!0),c)}function OT(l,c){var y=Js;Js=y!==0&&4>y?y:4,l(!0);var k=ox.transition;ox.transition={};try{l(!1),c()}finally{Js=y,ox.transition=k}}function gN(){return Oa().memoizedState}function LT(l,c,y){var k=$l(l);if(y={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null},vN(l))yN(c,y);else if(y=Yj(l,c,y,k),y!==null){var B=zr();Ja(y,l,k,B),bN(y,c,k)}}function IT(l,c,y){var k=$l(l),B={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null};if(vN(l))yN(c,B);else{var H=l.alternate;if(l.lanes===0&&(H===null||H.lanes===0)&&(H=c.lastRenderedReducer,H!==null))try{var ne=c.lastRenderedState,ve=H(ne,y);if(B.hasEagerState=!0,B.eagerState=ve,Ka(ve,ne)){var De=c.interleaved;De===null?(B.next=B,sx(c)):(B.next=De.next,De.next=B),c.interleaved=B;return}}catch{}finally{}y=Yj(l,c,B,k),y!==null&&(B=zr(),Ja(y,l,k,B),bN(y,c,k))}}function vN(l){var c=l.alternate;return l===Bn||c!==null&&c===Bn}function yN(l,c){zd=Ph=!0;var y=l.pending;y===null?c.next=c:(c.next=y.next,y.next=c),l.pending=c}function bN(l,c,y){if((y&4194240)!==0){var k=c.lanes;k&=l.pendingLanes,y|=k,c.lanes=y,wn(l,y)}}var Ih={readContext:Pa,useCallback:Pr,useContext:Pr,useEffect:Pr,useImperativeHandle:Pr,useInsertionEffect:Pr,useLayoutEffect:Pr,useMemo:Pr,useReducer:Pr,useRef:Pr,useState:Pr,useDebugValue:Pr,useDeferredValue:Pr,useTransition:Pr,useMutableSource:Pr,useSyncExternalStore:Pr,useId:Pr,unstable_isNewReconciler:!1},MT={readContext:Pa,useCallback:function(l,c){return wi().memoizedState=[l,c===void 0?null:c],l},useContext:Pa,useEffect:cN,useImperativeHandle:function(l,c,y){return y=y!=null?y.concat([l]):null,Oh(4194308,4,hN.bind(null,c,l),y)},useLayoutEffect:function(l,c){return Oh(4194308,4,l,c)},useInsertionEffect:function(l,c){return Oh(4,2,l,c)},useMemo:function(l,c){var y=wi();return c=c===void 0?null:c,l=l(),y.memoizedState=[l,c],l},useReducer:function(l,c,y){var k=wi();return c=y!==void 0?y(c):c,k.memoizedState=k.baseState=c,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:c},k.queue=l,l=l.dispatch=LT.bind(null,Bn,l),[k.memoizedState,l]},useRef:function(l){var c=wi();return l={current:l},c.memoizedState=l},useState:lN,useDebugValue:px,useDeferredValue:function(l){return wi().memoizedState=l},useTransition:function(){var l=lN(!1),c=l[0];return l=OT.bind(null,l[1]),wi().memoizedState=l,[c,l]},useMutableSource:function(){},useSyncExternalStore:function(l,c,y){var k=Bn,B=wi();if(Ln){if(y===void 0)throw Error(n(407));y=y()}else{if(y=c(),mr===null)throw Error(n(349));(To&30)!==0||sN(k,c,y)}B.memoizedState=y;var H={value:y,getSnapshot:c};return B.queue=H,cN(rN.bind(null,k,H,l),[l]),k.flags|=2048,Hd(9,nN.bind(null,k,H,y,c),void 0,null),y},useId:function(){var l=wi(),c=mr.identifierPrefix;if(Ln){var y=Zi,k=Yi;y=(k&~(1<<32-ts(k)-1)).toString(32)+y,c=":"+c+"R"+y,y=Ud++,0<y&&(c+="H"+y.toString(32)),c+=":"}else y=PT++,c=":"+c+"r"+y.toString(32)+":";return l.memoizedState=c},unstable_isNewReconciler:!1},FT={readContext:Pa,useCallback:fN,useContext:Pa,useEffect:fx,useImperativeHandle:mN,useInsertionEffect:dN,useLayoutEffect:uN,useMemo:pN,useReducer:hx,useRef:oN,useState:function(){return hx(Vd)},useDebugValue:px,useDeferredValue:function(l){var c=Oa();return xN(c,ar.memoizedState,l)},useTransition:function(){var l=hx(Vd)[0],c=Oa().memoizedState;return[l,c]},useMutableSource:eN,useSyncExternalStore:tN,useId:gN,unstable_isNewReconciler:!1},BT={readContext:Pa,useCallback:fN,useContext:Pa,useEffect:fx,useImperativeHandle:mN,useInsertionEffect:dN,useLayoutEffect:uN,useMemo:pN,useReducer:mx,useRef:oN,useState:function(){return mx(Vd)},useDebugValue:px,useDeferredValue:function(l){var c=Oa();return ar===null?c.memoizedState=l:xN(c,ar.memoizedState,l)},useTransition:function(){var l=mx(Vd)[0],c=Oa().memoizedState;return[l,c]},useMutableSource:eN,useSyncExternalStore:tN,useId:gN,unstable_isNewReconciler:!1};function Za(l,c){if(l&&l.defaultProps){c=z({},c),l=l.defaultProps;for(var y in l)c[y]===void 0&&(c[y]=l[y]);return c}return c}function xx(l,c,y,k){c=l.memoizedState,y=y(k,c),y=y==null?c:z({},c,y),l.memoizedState=y,l.lanes===0&&(l.updateQueue.baseState=y)}var Mh={isMounted:function(l){return(l=l._reactInternals)?gt(l)===l:!1},enqueueSetState:function(l,c,y){l=l._reactInternals;var k=zr(),B=$l(l),H=Xi(k,B);H.payload=c,y!=null&&(H.callback=y),c=Il(l,H,B),c!==null&&(Ja(c,l,B,k),Rh(c,l,B))},enqueueReplaceState:function(l,c,y){l=l._reactInternals;var k=zr(),B=$l(l),H=Xi(k,B);H.tag=1,H.payload=c,y!=null&&(H.callback=y),c=Il(l,H,B),c!==null&&(Ja(c,l,B,k),Rh(c,l,B))},enqueueForceUpdate:function(l,c){l=l._reactInternals;var y=zr(),k=$l(l),B=Xi(y,k);B.tag=2,c!=null&&(B.callback=c),c=Il(l,B,k),c!==null&&(Ja(c,l,k,y),Rh(c,l,k))}};function jN(l,c,y,k,B,H,ne){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(k,H,ne):c.prototype&&c.prototype.isPureReactComponent?!_d(y,k)||!_d(B,H):!0}function NN(l,c,y){var k=!1,B=Pl,H=c.contextType;return typeof H=="object"&&H!==null?H=Pa(H):(B=Qr(c)?ko:Tr.current,k=c.contextTypes,H=(k=k!=null)?Ac(l,B):Pl),c=new c(y,H),l.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Mh,l.stateNode=c,c._reactInternals=l,k&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=B,l.__reactInternalMemoizedMaskedChildContext=H),c}function wN(l,c,y,k){l=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(y,k),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(y,k),c.state!==l&&Mh.enqueueReplaceState(c,c.state,null)}function gx(l,c,y,k){var B=l.stateNode;B.props=y,B.state=l.memoizedState,B.refs={},nx(l);var H=c.contextType;typeof H=="object"&&H!==null?B.context=Pa(H):(H=Qr(c)?ko:Tr.current,B.context=Ac(l,H)),B.state=l.memoizedState,H=c.getDerivedStateFromProps,typeof H=="function"&&(xx(l,c,H,y),B.state=l.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof B.getSnapshotBeforeUpdate=="function"||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(c=B.state,typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount(),c!==B.state&&Mh.enqueueReplaceState(B,B.state,null),Eh(l,y,B,k),B.state=l.memoizedState),typeof B.componentDidMount=="function"&&(l.flags|=4194308)}function Oc(l,c){try{var y="",k=c;do y+=G(k),k=k.return;while(k);var B=y}catch(H){B=`
|
||
Error generating stack: `+H.message+`
|
||
`+H.stack}return{value:l,source:c,stack:B,digest:null}}function vx(l,c,y){return{value:l,source:null,stack:y??null,digest:c??null}}function yx(l,c){try{console.error(c.value)}catch(y){setTimeout(function(){throw y})}}var $T=typeof WeakMap=="function"?WeakMap:Map;function SN(l,c,y){y=Xi(-1,y),y.tag=3,y.payload={element:null};var k=c.value;return y.callback=function(){Vh||(Vh=!0,Ox=k),yx(l,c)},y}function CN(l,c,y){y=Xi(-1,y),y.tag=3;var k=l.type.getDerivedStateFromError;if(typeof k=="function"){var B=c.value;y.payload=function(){return k(B)},y.callback=function(){yx(l,c)}}var H=l.stateNode;return H!==null&&typeof H.componentDidCatch=="function"&&(y.callback=function(){yx(l,c),typeof k!="function"&&(Fl===null?Fl=new Set([this]):Fl.add(this));var ne=c.stack;this.componentDidCatch(c.value,{componentStack:ne!==null?ne:""})}),y}function AN(l,c,y){var k=l.pingCache;if(k===null){k=l.pingCache=new $T;var B=new Set;k.set(c,B)}else B=k.get(c),B===void 0&&(B=new Set,k.set(c,B));B.has(y)||(B.add(y),l=eP.bind(null,l,c,y),c.then(l,l))}function kN(l){do{var c;if((c=l.tag===13)&&(c=l.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return l;l=l.return}while(l!==null);return null}function DN(l,c,y,k,B){return(l.mode&1)===0?(l===c?l.flags|=65536:(l.flags|=128,y.flags|=131072,y.flags&=-52805,y.tag===1&&(y.alternate===null?y.tag=17:(c=Xi(-1,1),c.tag=2,Il(y,c,1))),y.lanes|=1),l):(l.flags|=65536,l.lanes=B,l)}var qT=S.ReactCurrentOwner,Xr=!1;function qr(l,c,y,k){c.child=l===null?Kj(c,null,y,k):Ec(c,l.child,y,k)}function RN(l,c,y,k,B){y=y.render;var H=c.ref;return Tc(c,B),k=dx(l,c,y,k,H,B),y=ux(),l!==null&&!Xr?(c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~B,Ji(l,c,B)):(Ln&&y&&Gp(c),c.flags|=1,qr(l,c,k,B),c.child)}function EN(l,c,y,k,B){if(l===null){var H=y.type;return typeof H=="function"&&!qx(H)&&H.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(c.tag=15,c.type=H,_N(l,c,H,k,B)):(l=Zh(y.type,null,k,c,c.mode,B),l.ref=c.ref,l.return=c,c.child=l)}if(H=l.child,(l.lanes&B)===0){var ne=H.memoizedProps;if(y=y.compare,y=y!==null?y:_d,y(ne,k)&&l.ref===c.ref)return Ji(l,c,B)}return c.flags|=1,l=zl(H,k),l.ref=c.ref,l.return=c,c.child=l}function _N(l,c,y,k,B){if(l!==null){var H=l.memoizedProps;if(_d(H,k)&&l.ref===c.ref)if(Xr=!1,c.pendingProps=k=H,(l.lanes&B)!==0)(l.flags&131072)!==0&&(Xr=!0);else return c.lanes=l.lanes,Ji(l,c,B)}return bx(l,c,y,k,B)}function TN(l,c,y){var k=c.pendingProps,B=k.children,H=l!==null?l.memoizedState:null;if(k.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Cn(Ic,fa),fa|=y;else{if((y&1073741824)===0)return l=H!==null?H.baseLanes|y:y,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:l,cachePool:null,transitions:null},c.updateQueue=null,Cn(Ic,fa),fa|=l,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=H!==null?H.baseLanes:y,Cn(Ic,fa),fa|=k}else H!==null?(k=H.baseLanes|y,c.memoizedState=null):k=y,Cn(Ic,fa),fa|=k;return qr(l,c,B,y),c.child}function PN(l,c){var y=c.ref;(l===null&&y!==null||l!==null&&l.ref!==y)&&(c.flags|=512,c.flags|=2097152)}function bx(l,c,y,k,B){var H=Qr(y)?ko:Tr.current;return H=Ac(c,H),Tc(c,B),y=dx(l,c,y,k,H,B),k=ux(),l!==null&&!Xr?(c.updateQueue=l.updateQueue,c.flags&=-2053,l.lanes&=~B,Ji(l,c,B)):(Ln&&k&&Gp(c),c.flags|=1,qr(l,c,y,B),c.child)}function ON(l,c,y,k,B){if(Qr(y)){var H=!0;jh(c)}else H=!1;if(Tc(c,B),c.stateNode===null)Bh(l,c),NN(c,y,k),gx(c,y,k,B),k=!0;else if(l===null){var ne=c.stateNode,ve=c.memoizedProps;ne.props=ve;var De=ne.context,Qe=y.contextType;typeof Qe=="object"&&Qe!==null?Qe=Pa(Qe):(Qe=Qr(y)?ko:Tr.current,Qe=Ac(c,Qe));var Dt=y.getDerivedStateFromProps,Lt=typeof Dt=="function"||typeof ne.getSnapshotBeforeUpdate=="function";Lt||typeof ne.UNSAFE_componentWillReceiveProps!="function"&&typeof ne.componentWillReceiveProps!="function"||(ve!==k||De!==Qe)&&wN(c,ne,k,Qe),Ll=!1;var At=c.memoizedState;ne.state=At,Eh(c,k,ne,B),De=c.memoizedState,ve!==k||At!==De||Zr.current||Ll?(typeof Dt=="function"&&(xx(c,y,Dt,k),De=c.memoizedState),(ve=Ll||jN(c,y,ve,k,At,De,Qe))?(Lt||typeof ne.UNSAFE_componentWillMount!="function"&&typeof ne.componentWillMount!="function"||(typeof ne.componentWillMount=="function"&&ne.componentWillMount(),typeof ne.UNSAFE_componentWillMount=="function"&&ne.UNSAFE_componentWillMount()),typeof ne.componentDidMount=="function"&&(c.flags|=4194308)):(typeof ne.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=k,c.memoizedState=De),ne.props=k,ne.state=De,ne.context=Qe,k=ve):(typeof ne.componentDidMount=="function"&&(c.flags|=4194308),k=!1)}else{ne=c.stateNode,Zj(l,c),ve=c.memoizedProps,Qe=c.type===c.elementType?ve:Za(c.type,ve),ne.props=Qe,Lt=c.pendingProps,At=ne.context,De=y.contextType,typeof De=="object"&&De!==null?De=Pa(De):(De=Qr(y)?ko:Tr.current,De=Ac(c,De));var ls=y.getDerivedStateFromProps;(Dt=typeof ls=="function"||typeof ne.getSnapshotBeforeUpdate=="function")||typeof ne.UNSAFE_componentWillReceiveProps!="function"&&typeof ne.componentWillReceiveProps!="function"||(ve!==Lt||At!==De)&&wN(c,ne,k,De),Ll=!1,At=c.memoizedState,ne.state=At,Eh(c,k,ne,B);var xs=c.memoizedState;ve!==Lt||At!==xs||Zr.current||Ll?(typeof ls=="function"&&(xx(c,y,ls,k),xs=c.memoizedState),(Qe=Ll||jN(c,y,Qe,k,At,xs,De)||!1)?(Dt||typeof ne.UNSAFE_componentWillUpdate!="function"&&typeof ne.componentWillUpdate!="function"||(typeof ne.componentWillUpdate=="function"&&ne.componentWillUpdate(k,xs,De),typeof ne.UNSAFE_componentWillUpdate=="function"&&ne.UNSAFE_componentWillUpdate(k,xs,De)),typeof ne.componentDidUpdate=="function"&&(c.flags|=4),typeof ne.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof ne.componentDidUpdate!="function"||ve===l.memoizedProps&&At===l.memoizedState||(c.flags|=4),typeof ne.getSnapshotBeforeUpdate!="function"||ve===l.memoizedProps&&At===l.memoizedState||(c.flags|=1024),c.memoizedProps=k,c.memoizedState=xs),ne.props=k,ne.state=xs,ne.context=De,k=Qe):(typeof ne.componentDidUpdate!="function"||ve===l.memoizedProps&&At===l.memoizedState||(c.flags|=4),typeof ne.getSnapshotBeforeUpdate!="function"||ve===l.memoizedProps&&At===l.memoizedState||(c.flags|=1024),k=!1)}return jx(l,c,y,k,H,B)}function jx(l,c,y,k,B,H){PN(l,c);var ne=(c.flags&128)!==0;if(!k&&!ne)return B&&Bj(c,y,!1),Ji(l,c,H);k=c.stateNode,qT.current=c;var ve=ne&&typeof y.getDerivedStateFromError!="function"?null:k.render();return c.flags|=1,l!==null&&ne?(c.child=Ec(c,l.child,null,H),c.child=Ec(c,null,ve,H)):qr(l,c,ve,H),c.memoizedState=k.state,B&&Bj(c,y,!0),c.child}function LN(l){var c=l.stateNode;c.pendingContext?Mj(l,c.pendingContext,c.pendingContext!==c.context):c.context&&Mj(l,c.context,!1),rx(l,c.containerInfo)}function IN(l,c,y,k,B){return Rc(),Qp(B),c.flags|=256,qr(l,c,y,k),c.child}var Nx={dehydrated:null,treeContext:null,retryLane:0};function wx(l){return{baseLanes:l,cachePool:null,transitions:null}}function MN(l,c,y){var k=c.pendingProps,B=Fn.current,H=!1,ne=(c.flags&128)!==0,ve;if((ve=ne)||(ve=l!==null&&l.memoizedState===null?!1:(B&2)!==0),ve?(H=!0,c.flags&=-129):(l===null||l.memoizedState!==null)&&(B|=1),Cn(Fn,B&1),l===null)return Zp(c),l=c.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((c.mode&1)===0?c.lanes=1:l.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(ne=k.children,l=k.fallback,H?(k=c.mode,H=c.child,ne={mode:"hidden",children:ne},(k&1)===0&&H!==null?(H.childLanes=0,H.pendingProps=ne):H=Qh(ne,k,0,null),l=Mo(l,k,y,null),H.return=c,l.return=c,H.sibling=l,c.child=H,c.child.memoizedState=wx(y),c.memoizedState=Nx,l):Sx(c,ne));if(B=l.memoizedState,B!==null&&(ve=B.dehydrated,ve!==null))return zT(l,c,ne,k,ve,B,y);if(H){H=k.fallback,ne=c.mode,B=l.child,ve=B.sibling;var De={mode:"hidden",children:k.children};return(ne&1)===0&&c.child!==B?(k=c.child,k.childLanes=0,k.pendingProps=De,c.deletions=null):(k=zl(B,De),k.subtreeFlags=B.subtreeFlags&14680064),ve!==null?H=zl(ve,H):(H=Mo(H,ne,y,null),H.flags|=2),H.return=c,k.return=c,k.sibling=H,c.child=k,k=H,H=c.child,ne=l.child.memoizedState,ne=ne===null?wx(y):{baseLanes:ne.baseLanes|y,cachePool:null,transitions:ne.transitions},H.memoizedState=ne,H.childLanes=l.childLanes&~y,c.memoizedState=Nx,k}return H=l.child,l=H.sibling,k=zl(H,{mode:"visible",children:k.children}),(c.mode&1)===0&&(k.lanes=y),k.return=c,k.sibling=null,l!==null&&(y=c.deletions,y===null?(c.deletions=[l],c.flags|=16):y.push(l)),c.child=k,c.memoizedState=null,k}function Sx(l,c){return c=Qh({mode:"visible",children:c},l.mode,0,null),c.return=l,l.child=c}function Fh(l,c,y,k){return k!==null&&Qp(k),Ec(c,l.child,null,y),l=Sx(c,c.pendingProps.children),l.flags|=2,c.memoizedState=null,l}function zT(l,c,y,k,B,H,ne){if(y)return c.flags&256?(c.flags&=-257,k=vx(Error(n(422))),Fh(l,c,ne,k)):c.memoizedState!==null?(c.child=l.child,c.flags|=128,null):(H=k.fallback,B=c.mode,k=Qh({mode:"visible",children:k.children},B,0,null),H=Mo(H,B,ne,null),H.flags|=2,k.return=c,H.return=c,k.sibling=H,c.child=k,(c.mode&1)!==0&&Ec(c,l.child,null,ne),c.child.memoizedState=wx(ne),c.memoizedState=Nx,H);if((c.mode&1)===0)return Fh(l,c,ne,null);if(B.data==="$!"){if(k=B.nextSibling&&B.nextSibling.dataset,k)var ve=k.dgst;return k=ve,H=Error(n(419)),k=vx(H,k,void 0),Fh(l,c,ne,k)}if(ve=(ne&l.childLanes)!==0,Xr||ve){if(k=mr,k!==null){switch(ne&-ne){case 4:B=2;break;case 16:B=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:B=32;break;case 536870912:B=268435456;break;default:B=0}B=(B&(k.suspendedLanes|ne))!==0?0:B,B!==0&&B!==H.retryLane&&(H.retryLane=B,Qi(l,B),Ja(k,l,B,-1))}return $x(),k=vx(Error(n(421))),Fh(l,c,ne,k)}return B.data==="$?"?(c.flags|=128,c.child=l.child,c=tP.bind(null,l),B._reactRetry=c,null):(l=H.treeContext,ma=_l(B.nextSibling),ha=c,Ln=!0,Ya=null,l!==null&&(_a[Ta++]=Yi,_a[Ta++]=Zi,_a[Ta++]=Do,Yi=l.id,Zi=l.overflow,Do=c),c=Sx(c,k.children),c.flags|=4096,c)}function FN(l,c,y){l.lanes|=c;var k=l.alternate;k!==null&&(k.lanes|=c),tx(l.return,c,y)}function Cx(l,c,y,k,B){var H=l.memoizedState;H===null?l.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:k,tail:y,tailMode:B}:(H.isBackwards=c,H.rendering=null,H.renderingStartTime=0,H.last=k,H.tail=y,H.tailMode=B)}function BN(l,c,y){var k=c.pendingProps,B=k.revealOrder,H=k.tail;if(qr(l,c,k.children,y),k=Fn.current,(k&2)!==0)k=k&1|2,c.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=c.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&FN(l,y,c);else if(l.tag===19)FN(l,y,c);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===c)break e;for(;l.sibling===null;){if(l.return===null||l.return===c)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}k&=1}if(Cn(Fn,k),(c.mode&1)===0)c.memoizedState=null;else switch(B){case"forwards":for(y=c.child,B=null;y!==null;)l=y.alternate,l!==null&&_h(l)===null&&(B=y),y=y.sibling;y=B,y===null?(B=c.child,c.child=null):(B=y.sibling,y.sibling=null),Cx(c,!1,B,y,H);break;case"backwards":for(y=null,B=c.child,c.child=null;B!==null;){if(l=B.alternate,l!==null&&_h(l)===null){c.child=B;break}l=B.sibling,B.sibling=y,y=B,B=l}Cx(c,!0,y,null,H);break;case"together":Cx(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Bh(l,c){(c.mode&1)===0&&l!==null&&(l.alternate=null,c.alternate=null,c.flags|=2)}function Ji(l,c,y){if(l!==null&&(c.dependencies=l.dependencies),Po|=c.lanes,(y&c.childLanes)===0)return null;if(l!==null&&c.child!==l.child)throw Error(n(153));if(c.child!==null){for(l=c.child,y=zl(l,l.pendingProps),c.child=y,y.return=c;l.sibling!==null;)l=l.sibling,y=y.sibling=zl(l,l.pendingProps),y.return=c;y.sibling=null}return c.child}function UT(l,c,y){switch(c.tag){case 3:LN(c),Rc();break;case 5:Jj(c);break;case 1:Qr(c.type)&&jh(c);break;case 4:rx(c,c.stateNode.containerInfo);break;case 10:var k=c.type._context,B=c.memoizedProps.value;Cn(kh,k._currentValue),k._currentValue=B;break;case 13:if(k=c.memoizedState,k!==null)return k.dehydrated!==null?(Cn(Fn,Fn.current&1),c.flags|=128,null):(y&c.child.childLanes)!==0?MN(l,c,y):(Cn(Fn,Fn.current&1),l=Ji(l,c,y),l!==null?l.sibling:null);Cn(Fn,Fn.current&1);break;case 19:if(k=(y&c.childLanes)!==0,(l.flags&128)!==0){if(k)return BN(l,c,y);c.flags|=128}if(B=c.memoizedState,B!==null&&(B.rendering=null,B.tail=null,B.lastEffect=null),Cn(Fn,Fn.current),k)break;return null;case 22:case 23:return c.lanes=0,TN(l,c,y)}return Ji(l,c,y)}var $N,Ax,qN,zN;$N=function(l,c){for(var y=c.child;y!==null;){if(y.tag===5||y.tag===6)l.appendChild(y.stateNode);else if(y.tag!==4&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===c)break;for(;y.sibling===null;){if(y.return===null||y.return===c)return;y=y.return}y.sibling.return=y.return,y=y.sibling}},Ax=function(){},qN=function(l,c,y,k){var B=l.memoizedProps;if(B!==k){l=c.stateNode,_o(Ni.current);var H=null;switch(y){case"input":B=Me(l,B),k=Me(l,k),H=[];break;case"select":B=z({},B,{value:void 0}),k=z({},k,{value:void 0}),H=[];break;case"textarea":B=Be(l,B),k=Be(l,k),H=[];break;default:typeof B.onClick!="function"&&typeof k.onClick=="function"&&(l.onclick=vh)}fs(y,k);var ne;y=null;for(Qe in B)if(!k.hasOwnProperty(Qe)&&B.hasOwnProperty(Qe)&&B[Qe]!=null)if(Qe==="style"){var ve=B[Qe];for(ne in ve)ve.hasOwnProperty(ne)&&(y||(y={}),y[ne]="")}else Qe!=="dangerouslySetInnerHTML"&&Qe!=="children"&&Qe!=="suppressContentEditableWarning"&&Qe!=="suppressHydrationWarning"&&Qe!=="autoFocus"&&(a.hasOwnProperty(Qe)?H||(H=[]):(H=H||[]).push(Qe,null));for(Qe in k){var De=k[Qe];if(ve=B!=null?B[Qe]:void 0,k.hasOwnProperty(Qe)&&De!==ve&&(De!=null||ve!=null))if(Qe==="style")if(ve){for(ne in ve)!ve.hasOwnProperty(ne)||De&&De.hasOwnProperty(ne)||(y||(y={}),y[ne]="");for(ne in De)De.hasOwnProperty(ne)&&ve[ne]!==De[ne]&&(y||(y={}),y[ne]=De[ne])}else y||(H||(H=[]),H.push(Qe,y)),y=De;else Qe==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,ve=ve?ve.__html:void 0,De!=null&&ve!==De&&(H=H||[]).push(Qe,De)):Qe==="children"?typeof De!="string"&&typeof De!="number"||(H=H||[]).push(Qe,""+De):Qe!=="suppressContentEditableWarning"&&Qe!=="suppressHydrationWarning"&&(a.hasOwnProperty(Qe)?(De!=null&&Qe==="onScroll"&&Rn("scroll",l),H||ve===De||(H=[])):(H=H||[]).push(Qe,De))}y&&(H=H||[]).push("style",y);var Qe=H;(c.updateQueue=Qe)&&(c.flags|=4)}},zN=function(l,c,y,k){y!==k&&(c.flags|=4)};function Wd(l,c){if(!Ln)switch(l.tailMode){case"hidden":c=l.tail;for(var y=null;c!==null;)c.alternate!==null&&(y=c),c=c.sibling;y===null?l.tail=null:y.sibling=null;break;case"collapsed":y=l.tail;for(var k=null;y!==null;)y.alternate!==null&&(k=y),y=y.sibling;k===null?c||l.tail===null?l.tail=null:l.tail.sibling=null:k.sibling=null}}function Or(l){var c=l.alternate!==null&&l.alternate.child===l.child,y=0,k=0;if(c)for(var B=l.child;B!==null;)y|=B.lanes|B.childLanes,k|=B.subtreeFlags&14680064,k|=B.flags&14680064,B.return=l,B=B.sibling;else for(B=l.child;B!==null;)y|=B.lanes|B.childLanes,k|=B.subtreeFlags,k|=B.flags,B.return=l,B=B.sibling;return l.subtreeFlags|=k,l.childLanes=y,c}function VT(l,c,y){var k=c.pendingProps;switch(Kp(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Or(c),null;case 1:return Qr(c.type)&&bh(),Or(c),null;case 3:return k=c.stateNode,Pc(),En(Zr),En(Tr),lx(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(l===null||l.child===null)&&(Ch(c)?c.flags|=4:l===null||l.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,Ya!==null&&(Mx(Ya),Ya=null))),Ax(l,c),Or(c),null;case 5:ax(c);var B=_o(qd.current);if(y=c.type,l!==null&&c.stateNode!=null)qN(l,c,y,k,B),l.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!k){if(c.stateNode===null)throw Error(n(166));return Or(c),null}if(l=_o(Ni.current),Ch(c)){k=c.stateNode,y=c.type;var H=c.memoizedProps;switch(k[ji]=c,k[Id]=H,l=(c.mode&1)!==0,y){case"dialog":Rn("cancel",k),Rn("close",k);break;case"iframe":case"object":case"embed":Rn("load",k);break;case"video":case"audio":for(B=0;B<Pd.length;B++)Rn(Pd[B],k);break;case"source":Rn("error",k);break;case"img":case"image":case"link":Rn("error",k),Rn("load",k);break;case"details":Rn("toggle",k);break;case"input":ut(k,H),Rn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!H.multiple},Rn("invalid",k);break;case"textarea":rt(k,H),Rn("invalid",k)}fs(y,H),B=null;for(var ne in H)if(H.hasOwnProperty(ne)){var ve=H[ne];ne==="children"?typeof ve=="string"?k.textContent!==ve&&(H.suppressHydrationWarning!==!0&&gh(k.textContent,ve,l),B=["children",ve]):typeof ve=="number"&&k.textContent!==""+ve&&(H.suppressHydrationWarning!==!0&&gh(k.textContent,ve,l),B=["children",""+ve]):a.hasOwnProperty(ne)&&ve!=null&&ne==="onScroll"&&Rn("scroll",k)}switch(y){case"input":ye(k),X(k,H,!0);break;case"textarea":ye(k),ge(k);break;case"select":case"option":break;default:typeof H.onClick=="function"&&(k.onclick=vh)}k=B,c.updateQueue=k,k!==null&&(c.flags|=4)}else{ne=B.nodeType===9?B:B.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=Je(y)),l==="http://www.w3.org/1999/xhtml"?y==="script"?(l=ne.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof k.is=="string"?l=ne.createElement(y,{is:k.is}):(l=ne.createElement(y),y==="select"&&(ne=l,k.multiple?ne.multiple=!0:k.size&&(ne.size=k.size))):l=ne.createElementNS(l,y),l[ji]=c,l[Id]=k,$N(l,c,!1,!1),c.stateNode=l;e:{switch(ne=Vs(y,k),y){case"dialog":Rn("cancel",l),Rn("close",l),B=k;break;case"iframe":case"object":case"embed":Rn("load",l),B=k;break;case"video":case"audio":for(B=0;B<Pd.length;B++)Rn(Pd[B],l);B=k;break;case"source":Rn("error",l),B=k;break;case"img":case"image":case"link":Rn("error",l),Rn("load",l),B=k;break;case"details":Rn("toggle",l),B=k;break;case"input":ut(l,k),B=Me(l,k),Rn("invalid",l);break;case"option":B=k;break;case"select":l._wrapperState={wasMultiple:!!k.multiple},B=z({},k,{value:void 0}),Rn("invalid",l);break;case"textarea":rt(l,k),B=Be(l,k),Rn("invalid",l);break;default:B=k}fs(y,B),ve=B;for(H in ve)if(ve.hasOwnProperty(H)){var De=ve[H];H==="style"?_s(l,De):H==="dangerouslySetInnerHTML"?(De=De?De.__html:void 0,De!=null&&at(l,De)):H==="children"?typeof De=="string"?(y!=="textarea"||De!=="")&&ot(l,De):typeof De=="number"&&ot(l,""+De):H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&H!=="autoFocus"&&(a.hasOwnProperty(H)?De!=null&&H==="onScroll"&&Rn("scroll",l):De!=null&&C(l,H,De,ne))}switch(y){case"input":ye(l),X(l,k,!1);break;case"textarea":ye(l),ge(l);break;case"option":k.value!=null&&l.setAttribute("value",""+re(k.value));break;case"select":l.multiple=!!k.multiple,H=k.value,H!=null?We(l,!!k.multiple,H,!1):k.defaultValue!=null&&We(l,!!k.multiple,k.defaultValue,!0);break;default:typeof B.onClick=="function"&&(l.onclick=vh)}switch(y){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return Or(c),null;case 6:if(l&&c.stateNode!=null)zN(l,c,l.memoizedProps,k);else{if(typeof k!="string"&&c.stateNode===null)throw Error(n(166));if(y=_o(qd.current),_o(Ni.current),Ch(c)){if(k=c.stateNode,y=c.memoizedProps,k[ji]=c,(H=k.nodeValue!==y)&&(l=ha,l!==null))switch(l.tag){case 3:gh(k.nodeValue,y,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&gh(k.nodeValue,y,(l.mode&1)!==0)}H&&(c.flags|=4)}else k=(y.nodeType===9?y:y.ownerDocument).createTextNode(k),k[ji]=c,c.stateNode=k}return Or(c),null;case 13:if(En(Fn),k=c.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(Ln&&ma!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Hj(),Rc(),c.flags|=98560,H=!1;else if(H=Ch(c),k!==null&&k.dehydrated!==null){if(l===null){if(!H)throw Error(n(318));if(H=c.memoizedState,H=H!==null?H.dehydrated:null,!H)throw Error(n(317));H[ji]=c}else Rc(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Or(c),H=!1}else Ya!==null&&(Mx(Ya),Ya=null),H=!0;if(!H)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=y,c):(k=k!==null,k!==(l!==null&&l.memoizedState!==null)&&k&&(c.child.flags|=8192,(c.mode&1)!==0&&(l===null||(Fn.current&1)!==0?ir===0&&(ir=3):$x())),c.updateQueue!==null&&(c.flags|=4),Or(c),null);case 4:return Pc(),Ax(l,c),l===null&&Od(c.stateNode.containerInfo),Or(c),null;case 10:return ex(c.type._context),Or(c),null;case 17:return Qr(c.type)&&bh(),Or(c),null;case 19:if(En(Fn),H=c.memoizedState,H===null)return Or(c),null;if(k=(c.flags&128)!==0,ne=H.rendering,ne===null)if(k)Wd(H,!1);else{if(ir!==0||l!==null&&(l.flags&128)!==0)for(l=c.child;l!==null;){if(ne=_h(l),ne!==null){for(c.flags|=128,Wd(H,!1),k=ne.updateQueue,k!==null&&(c.updateQueue=k,c.flags|=4),c.subtreeFlags=0,k=y,y=c.child;y!==null;)H=y,l=k,H.flags&=14680066,ne=H.alternate,ne===null?(H.childLanes=0,H.lanes=l,H.child=null,H.subtreeFlags=0,H.memoizedProps=null,H.memoizedState=null,H.updateQueue=null,H.dependencies=null,H.stateNode=null):(H.childLanes=ne.childLanes,H.lanes=ne.lanes,H.child=ne.child,H.subtreeFlags=0,H.deletions=null,H.memoizedProps=ne.memoizedProps,H.memoizedState=ne.memoizedState,H.updateQueue=ne.updateQueue,H.type=ne.type,l=ne.dependencies,H.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),y=y.sibling;return Cn(Fn,Fn.current&1|2),c.child}l=l.sibling}H.tail!==null&&Mt()>Mc&&(c.flags|=128,k=!0,Wd(H,!1),c.lanes=4194304)}else{if(!k)if(l=_h(ne),l!==null){if(c.flags|=128,k=!0,y=l.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),Wd(H,!0),H.tail===null&&H.tailMode==="hidden"&&!ne.alternate&&!Ln)return Or(c),null}else 2*Mt()-H.renderingStartTime>Mc&&y!==1073741824&&(c.flags|=128,k=!0,Wd(H,!1),c.lanes=4194304);H.isBackwards?(ne.sibling=c.child,c.child=ne):(y=H.last,y!==null?y.sibling=ne:c.child=ne,H.last=ne)}return H.tail!==null?(c=H.tail,H.rendering=c,H.tail=c.sibling,H.renderingStartTime=Mt(),c.sibling=null,y=Fn.current,Cn(Fn,k?y&1|2:y&1),c):(Or(c),null);case 22:case 23:return Bx(),k=c.memoizedState!==null,l!==null&&l.memoizedState!==null!==k&&(c.flags|=8192),k&&(c.mode&1)!==0?(fa&1073741824)!==0&&(Or(c),c.subtreeFlags&6&&(c.flags|=8192)):Or(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function HT(l,c){switch(Kp(c),c.tag){case 1:return Qr(c.type)&&bh(),l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 3:return Pc(),En(Zr),En(Tr),lx(),l=c.flags,(l&65536)!==0&&(l&128)===0?(c.flags=l&-65537|128,c):null;case 5:return ax(c),null;case 13:if(En(Fn),l=c.memoizedState,l!==null&&l.dehydrated!==null){if(c.alternate===null)throw Error(n(340));Rc()}return l=c.flags,l&65536?(c.flags=l&-65537|128,c):null;case 19:return En(Fn),null;case 4:return Pc(),null;case 10:return ex(c.type._context),null;case 22:case 23:return Bx(),null;case 24:return null;default:return null}}var $h=!1,Lr=!1,WT=typeof WeakSet=="function"?WeakSet:Set,hs=null;function Lc(l,c){var y=l.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(k){Un(l,c,k)}else y.current=null}function kx(l,c,y){try{y()}catch(k){Un(l,c,k)}}var UN=!1;function GT(l,c){if(Bp=Va,l=jj(),_p(l)){if("selectionStart"in l)var y={start:l.selectionStart,end:l.selectionEnd};else e:{y=(y=l.ownerDocument)&&y.defaultView||window;var k=y.getSelection&&y.getSelection();if(k&&k.rangeCount!==0){y=k.anchorNode;var B=k.anchorOffset,H=k.focusNode;k=k.focusOffset;try{y.nodeType,H.nodeType}catch{y=null;break e}var ne=0,ve=-1,De=-1,Qe=0,Dt=0,Lt=l,At=null;t:for(;;){for(var ls;Lt!==y||B!==0&&Lt.nodeType!==3||(ve=ne+B),Lt!==H||k!==0&&Lt.nodeType!==3||(De=ne+k),Lt.nodeType===3&&(ne+=Lt.nodeValue.length),(ls=Lt.firstChild)!==null;)At=Lt,Lt=ls;for(;;){if(Lt===l)break t;if(At===y&&++Qe===B&&(ve=ne),At===H&&++Dt===k&&(De=ne),(ls=Lt.nextSibling)!==null)break;Lt=At,At=Lt.parentNode}Lt=ls}y=ve===-1||De===-1?null:{start:ve,end:De}}else y=null}y=y||{start:0,end:0}}else y=null;for($p={focusedElem:l,selectionRange:y},Va=!1,hs=c;hs!==null;)if(c=hs,l=c.child,(c.subtreeFlags&1028)!==0&&l!==null)l.return=c,hs=l;else for(;hs!==null;){c=hs;try{var xs=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(xs!==null){var vs=xs.memoizedProps,Gn=xs.memoizedState,He=c.stateNode,Te=He.getSnapshotBeforeUpdate(c.elementType===c.type?vs:Za(c.type,vs),Gn);He.__reactInternalSnapshotBeforeUpdate=Te}break;case 3:var Ge=c.stateNode.containerInfo;Ge.nodeType===1?Ge.textContent="":Ge.nodeType===9&&Ge.documentElement&&Ge.removeChild(Ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ut){Un(c,c.return,Ut)}if(l=c.sibling,l!==null){l.return=c.return,hs=l;break}hs=c.return}return xs=UN,UN=!1,xs}function Gd(l,c,y){var k=c.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var B=k=k.next;do{if((B.tag&l)===l){var H=B.destroy;B.destroy=void 0,H!==void 0&&kx(c,y,H)}B=B.next}while(B!==k)}}function qh(l,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var y=c=c.next;do{if((y.tag&l)===l){var k=y.create;y.destroy=k()}y=y.next}while(y!==c)}}function Dx(l){var c=l.ref;if(c!==null){var y=l.stateNode;switch(l.tag){case 5:l=y;break;default:l=y}typeof c=="function"?c(l):c.current=l}}function VN(l){var c=l.alternate;c!==null&&(l.alternate=null,VN(c)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(c=l.stateNode,c!==null&&(delete c[ji],delete c[Id],delete c[Vp],delete c[RT],delete c[ET])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function HN(l){return l.tag===5||l.tag===3||l.tag===4}function WN(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||HN(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Rx(l,c,y){var k=l.tag;if(k===5||k===6)l=l.stateNode,c?y.nodeType===8?y.parentNode.insertBefore(l,c):y.insertBefore(l,c):(y.nodeType===8?(c=y.parentNode,c.insertBefore(l,y)):(c=y,c.appendChild(l)),y=y._reactRootContainer,y!=null||c.onclick!==null||(c.onclick=vh));else if(k!==4&&(l=l.child,l!==null))for(Rx(l,c,y),l=l.sibling;l!==null;)Rx(l,c,y),l=l.sibling}function Ex(l,c,y){var k=l.tag;if(k===5||k===6)l=l.stateNode,c?y.insertBefore(l,c):y.appendChild(l);else if(k!==4&&(l=l.child,l!==null))for(Ex(l,c,y),l=l.sibling;l!==null;)Ex(l,c,y),l=l.sibling}var Ar=null,Qa=!1;function Ml(l,c,y){for(y=y.child;y!==null;)GN(l,c,y),y=y.sibling}function GN(l,c,y){if(ns&&typeof ns.onCommitFiberUnmount=="function")try{ns.onCommitFiberUnmount(bs,y)}catch{}switch(y.tag){case 5:Lr||Lc(y,c);case 6:var k=Ar,B=Qa;Ar=null,Ml(l,c,y),Ar=k,Qa=B,Ar!==null&&(Qa?(l=Ar,y=y.stateNode,l.nodeType===8?l.parentNode.removeChild(y):l.removeChild(y)):Ar.removeChild(y.stateNode));break;case 18:Ar!==null&&(Qa?(l=Ar,y=y.stateNode,l.nodeType===8?Up(l.parentNode,y):l.nodeType===1&&Up(l,y),Da(l)):Up(Ar,y.stateNode));break;case 4:k=Ar,B=Qa,Ar=y.stateNode.containerInfo,Qa=!0,Ml(l,c,y),Ar=k,Qa=B;break;case 0:case 11:case 14:case 15:if(!Lr&&(k=y.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){B=k=k.next;do{var H=B,ne=H.destroy;H=H.tag,ne!==void 0&&((H&2)!==0||(H&4)!==0)&&kx(y,c,ne),B=B.next}while(B!==k)}Ml(l,c,y);break;case 1:if(!Lr&&(Lc(y,c),k=y.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=y.memoizedProps,k.state=y.memoizedState,k.componentWillUnmount()}catch(ve){Un(y,c,ve)}Ml(l,c,y);break;case 21:Ml(l,c,y);break;case 22:y.mode&1?(Lr=(k=Lr)||y.memoizedState!==null,Ml(l,c,y),Lr=k):Ml(l,c,y);break;default:Ml(l,c,y)}}function KN(l){var c=l.updateQueue;if(c!==null){l.updateQueue=null;var y=l.stateNode;y===null&&(y=l.stateNode=new WT),c.forEach(function(k){var B=sP.bind(null,l,k);y.has(k)||(y.add(k),k.then(B,B))})}}function Xa(l,c){var y=c.deletions;if(y!==null)for(var k=0;k<y.length;k++){var B=y[k];try{var H=l,ne=c,ve=ne;e:for(;ve!==null;){switch(ve.tag){case 5:Ar=ve.stateNode,Qa=!1;break e;case 3:Ar=ve.stateNode.containerInfo,Qa=!0;break e;case 4:Ar=ve.stateNode.containerInfo,Qa=!0;break e}ve=ve.return}if(Ar===null)throw Error(n(160));GN(H,ne,B),Ar=null,Qa=!1;var De=B.alternate;De!==null&&(De.return=null),B.return=null}catch(Qe){Un(B,c,Qe)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)YN(c,l),c=c.sibling}function YN(l,c){var y=l.alternate,k=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Xa(c,l),Si(l),k&4){try{Gd(3,l,l.return),qh(3,l)}catch(vs){Un(l,l.return,vs)}try{Gd(5,l,l.return)}catch(vs){Un(l,l.return,vs)}}break;case 1:Xa(c,l),Si(l),k&512&&y!==null&&Lc(y,y.return);break;case 5:if(Xa(c,l),Si(l),k&512&&y!==null&&Lc(y,y.return),l.flags&32){var B=l.stateNode;try{ot(B,"")}catch(vs){Un(l,l.return,vs)}}if(k&4&&(B=l.stateNode,B!=null)){var H=l.memoizedProps,ne=y!==null?y.memoizedProps:H,ve=l.type,De=l.updateQueue;if(l.updateQueue=null,De!==null)try{ve==="input"&&H.type==="radio"&&H.name!=null&&jt(B,H),Vs(ve,ne);var Qe=Vs(ve,H);for(ne=0;ne<De.length;ne+=2){var Dt=De[ne],Lt=De[ne+1];Dt==="style"?_s(B,Lt):Dt==="dangerouslySetInnerHTML"?at(B,Lt):Dt==="children"?ot(B,Lt):C(B,Dt,Lt,Qe)}switch(ve){case"input":ft(B,H);break;case"textarea":ht(B,H);break;case"select":var At=B._wrapperState.wasMultiple;B._wrapperState.wasMultiple=!!H.multiple;var ls=H.value;ls!=null?We(B,!!H.multiple,ls,!1):At!==!!H.multiple&&(H.defaultValue!=null?We(B,!!H.multiple,H.defaultValue,!0):We(B,!!H.multiple,H.multiple?[]:"",!1))}B[Id]=H}catch(vs){Un(l,l.return,vs)}}break;case 6:if(Xa(c,l),Si(l),k&4){if(l.stateNode===null)throw Error(n(162));B=l.stateNode,H=l.memoizedProps;try{B.nodeValue=H}catch(vs){Un(l,l.return,vs)}}break;case 3:if(Xa(c,l),Si(l),k&4&&y!==null&&y.memoizedState.isDehydrated)try{Da(c.containerInfo)}catch(vs){Un(l,l.return,vs)}break;case 4:Xa(c,l),Si(l);break;case 13:Xa(c,l),Si(l),B=l.child,B.flags&8192&&(H=B.memoizedState!==null,B.stateNode.isHidden=H,!H||B.alternate!==null&&B.alternate.memoizedState!==null||(Px=Mt())),k&4&&KN(l);break;case 22:if(Dt=y!==null&&y.memoizedState!==null,l.mode&1?(Lr=(Qe=Lr)||Dt,Xa(c,l),Lr=Qe):Xa(c,l),Si(l),k&8192){if(Qe=l.memoizedState!==null,(l.stateNode.isHidden=Qe)&&!Dt&&(l.mode&1)!==0)for(hs=l,Dt=l.child;Dt!==null;){for(Lt=hs=Dt;hs!==null;){switch(At=hs,ls=At.child,At.tag){case 0:case 11:case 14:case 15:Gd(4,At,At.return);break;case 1:Lc(At,At.return);var xs=At.stateNode;if(typeof xs.componentWillUnmount=="function"){k=At,y=At.return;try{c=k,xs.props=c.memoizedProps,xs.state=c.memoizedState,xs.componentWillUnmount()}catch(vs){Un(k,y,vs)}}break;case 5:Lc(At,At.return);break;case 22:if(At.memoizedState!==null){XN(Lt);continue}}ls!==null?(ls.return=At,hs=ls):XN(Lt)}Dt=Dt.sibling}e:for(Dt=null,Lt=l;;){if(Lt.tag===5){if(Dt===null){Dt=Lt;try{B=Lt.stateNode,Qe?(H=B.style,typeof H.setProperty=="function"?H.setProperty("display","none","important"):H.display="none"):(ve=Lt.stateNode,De=Lt.memoizedProps.style,ne=De!=null&&De.hasOwnProperty("display")?De.display:null,ve.style.display=Bt("display",ne))}catch(vs){Un(l,l.return,vs)}}}else if(Lt.tag===6){if(Dt===null)try{Lt.stateNode.nodeValue=Qe?"":Lt.memoizedProps}catch(vs){Un(l,l.return,vs)}}else if((Lt.tag!==22&&Lt.tag!==23||Lt.memoizedState===null||Lt===l)&&Lt.child!==null){Lt.child.return=Lt,Lt=Lt.child;continue}if(Lt===l)break e;for(;Lt.sibling===null;){if(Lt.return===null||Lt.return===l)break e;Dt===Lt&&(Dt=null),Lt=Lt.return}Dt===Lt&&(Dt=null),Lt.sibling.return=Lt.return,Lt=Lt.sibling}}break;case 19:Xa(c,l),Si(l),k&4&&KN(l);break;case 21:break;default:Xa(c,l),Si(l)}}function Si(l){var c=l.flags;if(c&2){try{e:{for(var y=l.return;y!==null;){if(HN(y)){var k=y;break e}y=y.return}throw Error(n(160))}switch(k.tag){case 5:var B=k.stateNode;k.flags&32&&(ot(B,""),k.flags&=-33);var H=WN(l);Ex(l,H,B);break;case 3:case 4:var ne=k.stateNode.containerInfo,ve=WN(l);Rx(l,ve,ne);break;default:throw Error(n(161))}}catch(De){Un(l,l.return,De)}l.flags&=-3}c&4096&&(l.flags&=-4097)}function KT(l,c,y){hs=l,ZN(l)}function ZN(l,c,y){for(var k=(l.mode&1)!==0;hs!==null;){var B=hs,H=B.child;if(B.tag===22&&k){var ne=B.memoizedState!==null||$h;if(!ne){var ve=B.alternate,De=ve!==null&&ve.memoizedState!==null||Lr;ve=$h;var Qe=Lr;if($h=ne,(Lr=De)&&!Qe)for(hs=B;hs!==null;)ne=hs,De=ne.child,ne.tag===22&&ne.memoizedState!==null?JN(B):De!==null?(De.return=ne,hs=De):JN(B);for(;H!==null;)hs=H,ZN(H),H=H.sibling;hs=B,$h=ve,Lr=Qe}QN(l)}else(B.subtreeFlags&8772)!==0&&H!==null?(H.return=B,hs=H):QN(l)}}function QN(l){for(;hs!==null;){var c=hs;if((c.flags&8772)!==0){var y=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Lr||qh(5,c);break;case 1:var k=c.stateNode;if(c.flags&4&&!Lr)if(y===null)k.componentDidMount();else{var B=c.elementType===c.type?y.memoizedProps:Za(c.type,y.memoizedProps);k.componentDidUpdate(B,y.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var H=c.updateQueue;H!==null&&Xj(c,H,k);break;case 3:var ne=c.updateQueue;if(ne!==null){if(y=null,c.child!==null)switch(c.child.tag){case 5:y=c.child.stateNode;break;case 1:y=c.child.stateNode}Xj(c,ne,y)}break;case 5:var ve=c.stateNode;if(y===null&&c.flags&4){y=ve;var De=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":De.autoFocus&&y.focus();break;case"img":De.src&&(y.src=De.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var Qe=c.alternate;if(Qe!==null){var Dt=Qe.memoizedState;if(Dt!==null){var Lt=Dt.dehydrated;Lt!==null&&Da(Lt)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Lr||c.flags&512&&Dx(c)}catch(At){Un(c,c.return,At)}}if(c===l){hs=null;break}if(y=c.sibling,y!==null){y.return=c.return,hs=y;break}hs=c.return}}function XN(l){for(;hs!==null;){var c=hs;if(c===l){hs=null;break}var y=c.sibling;if(y!==null){y.return=c.return,hs=y;break}hs=c.return}}function JN(l){for(;hs!==null;){var c=hs;try{switch(c.tag){case 0:case 11:case 15:var y=c.return;try{qh(4,c)}catch(De){Un(c,y,De)}break;case 1:var k=c.stateNode;if(typeof k.componentDidMount=="function"){var B=c.return;try{k.componentDidMount()}catch(De){Un(c,B,De)}}var H=c.return;try{Dx(c)}catch(De){Un(c,H,De)}break;case 5:var ne=c.return;try{Dx(c)}catch(De){Un(c,ne,De)}}}catch(De){Un(c,c.return,De)}if(c===l){hs=null;break}var ve=c.sibling;if(ve!==null){ve.return=c.return,hs=ve;break}hs=c.return}}var YT=Math.ceil,zh=S.ReactCurrentDispatcher,_x=S.ReactCurrentOwner,La=S.ReactCurrentBatchConfig,hn=0,mr=null,Yn=null,kr=0,fa=0,Ic=Tl(0),ir=0,Kd=null,Po=0,Uh=0,Tx=0,Yd=null,Jr=null,Px=0,Mc=1/0,el=null,Vh=!1,Ox=null,Fl=null,Hh=!1,Bl=null,Wh=0,Zd=0,Lx=null,Gh=-1,Kh=0;function zr(){return(hn&6)!==0?Mt():Gh!==-1?Gh:Gh=Mt()}function $l(l){return(l.mode&1)===0?1:(hn&2)!==0&&kr!==0?kr&-kr:TT.transition!==null?(Kh===0&&(Kh=St()),Kh):(l=Js,l!==0||(l=window.event,l=l===void 0?16:zi(l.type)),l)}function Ja(l,c,y,k){if(50<Zd)throw Zd=0,Lx=null,Error(n(185));Er(l,y,k),((hn&2)===0||l!==mr)&&(l===mr&&((hn&2)===0&&(Uh|=y),ir===4&&ql(l,kr)),ea(l,k),y===1&&hn===0&&(c.mode&1)===0&&(Mc=Mt()+500,Nh&&Ol()))}function ea(l,c){var y=l.callbackNode;Ze(l,c);var k=Ye(l,l===mr?kr:0);if(k===0)y!==null&&$t(y),l.callbackNode=null,l.callbackPriority=0;else if(c=k&-k,l.callbackPriority!==c){if(y!=null&&$t(y),c===1)l.tag===0?_T(tw.bind(null,l)):$j(tw.bind(null,l)),kT(function(){(hn&6)===0&&Ol()}),y=null;else{switch(Sa(k)){case 1:y=xt;break;case 4:y=yt;break;case 16:y=Ot;break;case 536870912:y=Jt;break;default:y=Ot}y=cw(y,ew.bind(null,l))}l.callbackPriority=c,l.callbackNode=y}}function ew(l,c){if(Gh=-1,Kh=0,(hn&6)!==0)throw Error(n(327));var y=l.callbackNode;if(Fc()&&l.callbackNode!==y)return null;var k=Ye(l,l===mr?kr:0);if(k===0)return null;if((k&30)!==0||(k&l.expiredLanes)!==0||c)c=Yh(l,k);else{c=k;var B=hn;hn|=2;var H=nw();(mr!==l||kr!==c)&&(el=null,Mc=Mt()+500,Lo(l,c));do try{XT();break}catch(ve){sw(l,ve)}while(!0);Jp(),zh.current=H,hn=B,Yn!==null?c=0:(mr=null,kr=0,c=ir)}if(c!==0){if(c===2&&(B=Gt(l),B!==0&&(k=B,c=Ix(l,B))),c===1)throw y=Kd,Lo(l,0),ql(l,k),ea(l,Mt()),y;if(c===6)ql(l,k);else{if(B=l.current.alternate,(k&30)===0&&!ZT(B)&&(c=Yh(l,k),c===2&&(H=Gt(l),H!==0&&(k=H,c=Ix(l,H))),c===1))throw y=Kd,Lo(l,0),ql(l,k),ea(l,Mt()),y;switch(l.finishedWork=B,l.finishedLanes=k,c){case 0:case 1:throw Error(n(345));case 2:Io(l,Jr,el);break;case 3:if(ql(l,k),(k&130023424)===k&&(c=Px+500-Mt(),10<c)){if(Ye(l,0)!==0)break;if(B=l.suspendedLanes,(B&k)!==k){zr(),l.pingedLanes|=l.suspendedLanes&B;break}l.timeoutHandle=zp(Io.bind(null,l,Jr,el),c);break}Io(l,Jr,el);break;case 4:if(ql(l,k),(k&4194240)===k)break;for(c=l.eventTimes,B=-1;0<k;){var ne=31-ts(k);H=1<<ne,ne=c[ne],ne>B&&(B=ne),k&=~H}if(k=B,k=Mt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*YT(k/1960))-k,10<k){l.timeoutHandle=zp(Io.bind(null,l,Jr,el),k);break}Io(l,Jr,el);break;case 5:Io(l,Jr,el);break;default:throw Error(n(329))}}}return ea(l,Mt()),l.callbackNode===y?ew.bind(null,l):null}function Ix(l,c){var y=Yd;return l.current.memoizedState.isDehydrated&&(Lo(l,c).flags|=256),l=Yh(l,c),l!==2&&(c=Jr,Jr=y,c!==null&&Mx(c)),l}function Mx(l){Jr===null?Jr=l:Jr.push.apply(Jr,l)}function ZT(l){for(var c=l;;){if(c.flags&16384){var y=c.updateQueue;if(y!==null&&(y=y.stores,y!==null))for(var k=0;k<y.length;k++){var B=y[k],H=B.getSnapshot;B=B.value;try{if(!Ka(H(),B))return!1}catch{return!1}}}if(y=c.child,c.subtreeFlags&16384&&y!==null)y.return=c,c=y;else{if(c===l)break;for(;c.sibling===null;){if(c.return===null||c.return===l)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function ql(l,c){for(c&=~Tx,c&=~Uh,l.suspendedLanes|=c,l.pingedLanes&=~c,l=l.expirationTimes;0<c;){var y=31-ts(c),k=1<<y;l[y]=-1,c&=~k}}function tw(l){if((hn&6)!==0)throw Error(n(327));Fc();var c=Ye(l,0);if((c&1)===0)return ea(l,Mt()),null;var y=Yh(l,c);if(l.tag!==0&&y===2){var k=Gt(l);k!==0&&(c=k,y=Ix(l,k))}if(y===1)throw y=Kd,Lo(l,0),ql(l,c),ea(l,Mt()),y;if(y===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=c,Io(l,Jr,el),ea(l,Mt()),null}function Fx(l,c){var y=hn;hn|=1;try{return l(c)}finally{hn=y,hn===0&&(Mc=Mt()+500,Nh&&Ol())}}function Oo(l){Bl!==null&&Bl.tag===0&&(hn&6)===0&&Fc();var c=hn;hn|=1;var y=La.transition,k=Js;try{if(La.transition=null,Js=1,l)return l()}finally{Js=k,La.transition=y,hn=c,(hn&6)===0&&Ol()}}function Bx(){fa=Ic.current,En(Ic)}function Lo(l,c){l.finishedWork=null,l.finishedLanes=0;var y=l.timeoutHandle;if(y!==-1&&(l.timeoutHandle=-1,AT(y)),Yn!==null)for(y=Yn.return;y!==null;){var k=y;switch(Kp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&bh();break;case 3:Pc(),En(Zr),En(Tr),lx();break;case 5:ax(k);break;case 4:Pc();break;case 13:En(Fn);break;case 19:En(Fn);break;case 10:ex(k.type._context);break;case 22:case 23:Bx()}y=y.return}if(mr=l,Yn=l=zl(l.current,null),kr=fa=c,ir=0,Kd=null,Tx=Uh=Po=0,Jr=Yd=null,Eo!==null){for(c=0;c<Eo.length;c++)if(y=Eo[c],k=y.interleaved,k!==null){y.interleaved=null;var B=k.next,H=y.pending;if(H!==null){var ne=H.next;H.next=B,k.next=ne}y.pending=k}Eo=null}return l}function sw(l,c){do{var y=Yn;try{if(Jp(),Th.current=Ih,Ph){for(var k=Bn.memoizedState;k!==null;){var B=k.queue;B!==null&&(B.pending=null),k=k.next}Ph=!1}if(To=0,hr=ar=Bn=null,zd=!1,Ud=0,_x.current=null,y===null||y.return===null){ir=1,Kd=c,Yn=null;break}e:{var H=l,ne=y.return,ve=y,De=c;if(c=kr,ve.flags|=32768,De!==null&&typeof De=="object"&&typeof De.then=="function"){var Qe=De,Dt=ve,Lt=Dt.tag;if((Dt.mode&1)===0&&(Lt===0||Lt===11||Lt===15)){var At=Dt.alternate;At?(Dt.updateQueue=At.updateQueue,Dt.memoizedState=At.memoizedState,Dt.lanes=At.lanes):(Dt.updateQueue=null,Dt.memoizedState=null)}var ls=kN(ne);if(ls!==null){ls.flags&=-257,DN(ls,ne,ve,H,c),ls.mode&1&&AN(H,Qe,c),c=ls,De=Qe;var xs=c.updateQueue;if(xs===null){var vs=new Set;vs.add(De),c.updateQueue=vs}else xs.add(De);break e}else{if((c&1)===0){AN(H,Qe,c),$x();break e}De=Error(n(426))}}else if(Ln&&ve.mode&1){var Gn=kN(ne);if(Gn!==null){(Gn.flags&65536)===0&&(Gn.flags|=256),DN(Gn,ne,ve,H,c),Qp(Oc(De,ve));break e}}H=De=Oc(De,ve),ir!==4&&(ir=2),Yd===null?Yd=[H]:Yd.push(H),H=ne;do{switch(H.tag){case 3:H.flags|=65536,c&=-c,H.lanes|=c;var He=SN(H,De,c);Qj(H,He);break e;case 1:ve=De;var Te=H.type,Ge=H.stateNode;if((H.flags&128)===0&&(typeof Te.getDerivedStateFromError=="function"||Ge!==null&&typeof Ge.componentDidCatch=="function"&&(Fl===null||!Fl.has(Ge)))){H.flags|=65536,c&=-c,H.lanes|=c;var Ut=CN(H,ve,c);Qj(H,Ut);break e}}H=H.return}while(H!==null)}aw(y)}catch(Ns){c=Ns,Yn===y&&y!==null&&(Yn=y=y.return);continue}break}while(!0)}function nw(){var l=zh.current;return zh.current=Ih,l===null?Ih:l}function $x(){(ir===0||ir===3||ir===2)&&(ir=4),mr===null||(Po&268435455)===0&&(Uh&268435455)===0||ql(mr,kr)}function Yh(l,c){var y=hn;hn|=2;var k=nw();(mr!==l||kr!==c)&&(el=null,Lo(l,c));do try{QT();break}catch(B){sw(l,B)}while(!0);if(Jp(),hn=y,zh.current=k,Yn!==null)throw Error(n(261));return mr=null,kr=0,ir}function QT(){for(;Yn!==null;)rw(Yn)}function XT(){for(;Yn!==null&&!Xt();)rw(Yn)}function rw(l){var c=ow(l.alternate,l,fa);l.memoizedProps=l.pendingProps,c===null?aw(l):Yn=c,_x.current=null}function aw(l){var c=l;do{var y=c.alternate;if(l=c.return,(c.flags&32768)===0){if(y=VT(y,c,fa),y!==null){Yn=y;return}}else{if(y=HT(y,c),y!==null){y.flags&=32767,Yn=y;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{ir=6,Yn=null;return}}if(c=c.sibling,c!==null){Yn=c;return}Yn=c=l}while(c!==null);ir===0&&(ir=5)}function Io(l,c,y){var k=Js,B=La.transition;try{La.transition=null,Js=1,JT(l,c,y,k)}finally{La.transition=B,Js=k}return null}function JT(l,c,y,k){do Fc();while(Bl!==null);if((hn&6)!==0)throw Error(n(327));y=l.finishedWork;var B=l.finishedLanes;if(y===null)return null;if(l.finishedWork=null,l.finishedLanes=0,y===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var H=y.lanes|y.childLanes;if(Fr(l,H),l===mr&&(Yn=mr=null,kr=0),(y.subtreeFlags&2064)===0&&(y.flags&2064)===0||Hh||(Hh=!0,cw(Ot,function(){return Fc(),null})),H=(y.flags&15990)!==0,(y.subtreeFlags&15990)!==0||H){H=La.transition,La.transition=null;var ne=Js;Js=1;var ve=hn;hn|=4,_x.current=null,GT(l,y),YN(y,l),yT($p),Va=!!Bp,$p=Bp=null,l.current=y,KT(y),Cs(),hn=ve,Js=ne,La.transition=H}else l.current=y;if(Hh&&(Hh=!1,Bl=l,Wh=B),H=l.pendingLanes,H===0&&(Fl=null),Ds(y.stateNode),ea(l,Mt()),c!==null)for(k=l.onRecoverableError,y=0;y<c.length;y++)B=c[y],k(B.value,{componentStack:B.stack,digest:B.digest});if(Vh)throw Vh=!1,l=Ox,Ox=null,l;return(Wh&1)!==0&&l.tag!==0&&Fc(),H=l.pendingLanes,(H&1)!==0?l===Lx?Zd++:(Zd=0,Lx=l):Zd=0,Ol(),null}function Fc(){if(Bl!==null){var l=Sa(Wh),c=La.transition,y=Js;try{if(La.transition=null,Js=16>l?16:l,Bl===null)var k=!1;else{if(l=Bl,Bl=null,Wh=0,(hn&6)!==0)throw Error(n(331));var B=hn;for(hn|=4,hs=l.current;hs!==null;){var H=hs,ne=H.child;if((hs.flags&16)!==0){var ve=H.deletions;if(ve!==null){for(var De=0;De<ve.length;De++){var Qe=ve[De];for(hs=Qe;hs!==null;){var Dt=hs;switch(Dt.tag){case 0:case 11:case 15:Gd(8,Dt,H)}var Lt=Dt.child;if(Lt!==null)Lt.return=Dt,hs=Lt;else for(;hs!==null;){Dt=hs;var At=Dt.sibling,ls=Dt.return;if(VN(Dt),Dt===Qe){hs=null;break}if(At!==null){At.return=ls,hs=At;break}hs=ls}}}var xs=H.alternate;if(xs!==null){var vs=xs.child;if(vs!==null){xs.child=null;do{var Gn=vs.sibling;vs.sibling=null,vs=Gn}while(vs!==null)}}hs=H}}if((H.subtreeFlags&2064)!==0&&ne!==null)ne.return=H,hs=ne;else e:for(;hs!==null;){if(H=hs,(H.flags&2048)!==0)switch(H.tag){case 0:case 11:case 15:Gd(9,H,H.return)}var He=H.sibling;if(He!==null){He.return=H.return,hs=He;break e}hs=H.return}}var Te=l.current;for(hs=Te;hs!==null;){ne=hs;var Ge=ne.child;if((ne.subtreeFlags&2064)!==0&&Ge!==null)Ge.return=ne,hs=Ge;else e:for(ne=Te;hs!==null;){if(ve=hs,(ve.flags&2048)!==0)try{switch(ve.tag){case 0:case 11:case 15:qh(9,ve)}}catch(Ns){Un(ve,ve.return,Ns)}if(ve===ne){hs=null;break e}var Ut=ve.sibling;if(Ut!==null){Ut.return=ve.return,hs=Ut;break e}hs=ve.return}}if(hn=B,Ol(),ns&&typeof ns.onPostCommitFiberRoot=="function")try{ns.onPostCommitFiberRoot(bs,l)}catch{}k=!0}return k}finally{Js=y,La.transition=c}}return!1}function iw(l,c,y){c=Oc(y,c),c=SN(l,c,1),l=Il(l,c,1),c=zr(),l!==null&&(Er(l,1,c),ea(l,c))}function Un(l,c,y){if(l.tag===3)iw(l,l,y);else for(;c!==null;){if(c.tag===3){iw(c,l,y);break}else if(c.tag===1){var k=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Fl===null||!Fl.has(k))){l=Oc(y,l),l=CN(c,l,1),c=Il(c,l,1),l=zr(),c!==null&&(Er(c,1,l),ea(c,l));break}}c=c.return}}function eP(l,c,y){var k=l.pingCache;k!==null&&k.delete(c),c=zr(),l.pingedLanes|=l.suspendedLanes&y,mr===l&&(kr&y)===y&&(ir===4||ir===3&&(kr&130023424)===kr&&500>Mt()-Px?Lo(l,0):Tx|=y),ea(l,c)}function lw(l,c){c===0&&((l.mode&1)===0?c=1:(c=xn,xn<<=1,(xn&130023424)===0&&(xn=4194304)));var y=zr();l=Qi(l,c),l!==null&&(Er(l,c,y),ea(l,y))}function tP(l){var c=l.memoizedState,y=0;c!==null&&(y=c.retryLane),lw(l,y)}function sP(l,c){var y=0;switch(l.tag){case 13:var k=l.stateNode,B=l.memoizedState;B!==null&&(y=B.retryLane);break;case 19:k=l.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(c),lw(l,y)}var ow;ow=function(l,c,y){if(l!==null)if(l.memoizedProps!==c.pendingProps||Zr.current)Xr=!0;else{if((l.lanes&y)===0&&(c.flags&128)===0)return Xr=!1,UT(l,c,y);Xr=(l.flags&131072)!==0}else Xr=!1,Ln&&(c.flags&1048576)!==0&&qj(c,Sh,c.index);switch(c.lanes=0,c.tag){case 2:var k=c.type;Bh(l,c),l=c.pendingProps;var B=Ac(c,Tr.current);Tc(c,y),B=dx(null,c,k,l,B,y);var H=ux();return c.flags|=1,typeof B=="object"&&B!==null&&typeof B.render=="function"&&B.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,Qr(k)?(H=!0,jh(c)):H=!1,c.memoizedState=B.state!==null&&B.state!==void 0?B.state:null,nx(c),B.updater=Mh,c.stateNode=B,B._reactInternals=c,gx(c,k,l,y),c=jx(null,c,k,!0,H,y)):(c.tag=0,Ln&&H&&Gp(c),qr(null,c,B,y),c=c.child),c;case 16:k=c.elementType;e:{switch(Bh(l,c),l=c.pendingProps,B=k._init,k=B(k._payload),c.type=k,B=c.tag=rP(k),l=Za(k,l),B){case 0:c=bx(null,c,k,l,y);break e;case 1:c=ON(null,c,k,l,y);break e;case 11:c=RN(null,c,k,l,y);break e;case 14:c=EN(null,c,k,Za(k.type,l),y);break e}throw Error(n(306,k,""))}return c;case 0:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),bx(l,c,k,B,y);case 1:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),ON(l,c,k,B,y);case 3:e:{if(LN(c),l===null)throw Error(n(387));k=c.pendingProps,H=c.memoizedState,B=H.element,Zj(l,c),Eh(c,k,null,y);var ne=c.memoizedState;if(k=ne.element,H.isDehydrated)if(H={element:k,isDehydrated:!1,cache:ne.cache,pendingSuspenseBoundaries:ne.pendingSuspenseBoundaries,transitions:ne.transitions},c.updateQueue.baseState=H,c.memoizedState=H,c.flags&256){B=Oc(Error(n(423)),c),c=IN(l,c,k,y,B);break e}else if(k!==B){B=Oc(Error(n(424)),c),c=IN(l,c,k,y,B);break e}else for(ma=_l(c.stateNode.containerInfo.firstChild),ha=c,Ln=!0,Ya=null,y=Kj(c,null,k,y),c.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Rc(),k===B){c=Ji(l,c,y);break e}qr(l,c,k,y)}c=c.child}return c;case 5:return Jj(c),l===null&&Zp(c),k=c.type,B=c.pendingProps,H=l!==null?l.memoizedProps:null,ne=B.children,qp(k,B)?ne=null:H!==null&&qp(k,H)&&(c.flags|=32),PN(l,c),qr(l,c,ne,y),c.child;case 6:return l===null&&Zp(c),null;case 13:return MN(l,c,y);case 4:return rx(c,c.stateNode.containerInfo),k=c.pendingProps,l===null?c.child=Ec(c,null,k,y):qr(l,c,k,y),c.child;case 11:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),RN(l,c,k,B,y);case 7:return qr(l,c,c.pendingProps,y),c.child;case 8:return qr(l,c,c.pendingProps.children,y),c.child;case 12:return qr(l,c,c.pendingProps.children,y),c.child;case 10:e:{if(k=c.type._context,B=c.pendingProps,H=c.memoizedProps,ne=B.value,Cn(kh,k._currentValue),k._currentValue=ne,H!==null)if(Ka(H.value,ne)){if(H.children===B.children&&!Zr.current){c=Ji(l,c,y);break e}}else for(H=c.child,H!==null&&(H.return=c);H!==null;){var ve=H.dependencies;if(ve!==null){ne=H.child;for(var De=ve.firstContext;De!==null;){if(De.context===k){if(H.tag===1){De=Xi(-1,y&-y),De.tag=2;var Qe=H.updateQueue;if(Qe!==null){Qe=Qe.shared;var Dt=Qe.pending;Dt===null?De.next=De:(De.next=Dt.next,Dt.next=De),Qe.pending=De}}H.lanes|=y,De=H.alternate,De!==null&&(De.lanes|=y),tx(H.return,y,c),ve.lanes|=y;break}De=De.next}}else if(H.tag===10)ne=H.type===c.type?null:H.child;else if(H.tag===18){if(ne=H.return,ne===null)throw Error(n(341));ne.lanes|=y,ve=ne.alternate,ve!==null&&(ve.lanes|=y),tx(ne,y,c),ne=H.sibling}else ne=H.child;if(ne!==null)ne.return=H;else for(ne=H;ne!==null;){if(ne===c){ne=null;break}if(H=ne.sibling,H!==null){H.return=ne.return,ne=H;break}ne=ne.return}H=ne}qr(l,c,B.children,y),c=c.child}return c;case 9:return B=c.type,k=c.pendingProps.children,Tc(c,y),B=Pa(B),k=k(B),c.flags|=1,qr(l,c,k,y),c.child;case 14:return k=c.type,B=Za(k,c.pendingProps),B=Za(k.type,B),EN(l,c,k,B,y);case 15:return _N(l,c,c.type,c.pendingProps,y);case 17:return k=c.type,B=c.pendingProps,B=c.elementType===k?B:Za(k,B),Bh(l,c),c.tag=1,Qr(k)?(l=!0,jh(c)):l=!1,Tc(c,y),NN(c,k,B),gx(c,k,B,y),jx(null,c,k,!0,l,y);case 19:return BN(l,c,y);case 22:return TN(l,c,y)}throw Error(n(156,c.tag))};function cw(l,c){return Ee(l,c)}function nP(l,c,y,k){this.tag=l,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ia(l,c,y,k){return new nP(l,c,y,k)}function qx(l){return l=l.prototype,!(!l||!l.isReactComponent)}function rP(l){if(typeof l=="function")return qx(l)?1:0;if(l!=null){if(l=l.$$typeof,l===P)return 11;if(l===Z)return 14}return 2}function zl(l,c){var y=l.alternate;return y===null?(y=Ia(l.tag,c,l.key,l.mode),y.elementType=l.elementType,y.type=l.type,y.stateNode=l.stateNode,y.alternate=l,l.alternate=y):(y.pendingProps=c,y.type=l.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=l.flags&14680064,y.childLanes=l.childLanes,y.lanes=l.lanes,y.child=l.child,y.memoizedProps=l.memoizedProps,y.memoizedState=l.memoizedState,y.updateQueue=l.updateQueue,c=l.dependencies,y.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},y.sibling=l.sibling,y.index=l.index,y.ref=l.ref,y}function Zh(l,c,y,k,B,H){var ne=2;if(k=l,typeof l=="function")qx(l)&&(ne=1);else if(typeof l=="string")ne=5;else e:switch(l){case A:return Mo(y.children,B,H,c);case E:ne=8,B|=8;break;case q:return l=Ia(12,y,c,B|2),l.elementType=q,l.lanes=H,l;case L:return l=Ia(13,y,c,B),l.elementType=L,l.lanes=H,l;case $:return l=Ia(19,y,c,B),l.elementType=$,l.lanes=H,l;case W:return Qh(y,B,H,c);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case O:ne=10;break e;case R:ne=9;break e;case P:ne=11;break e;case Z:ne=14;break e;case Q:ne=16,k=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return c=Ia(ne,y,c,B),c.elementType=l,c.type=k,c.lanes=H,c}function Mo(l,c,y,k){return l=Ia(7,l,k,c),l.lanes=y,l}function Qh(l,c,y,k){return l=Ia(22,l,k,c),l.elementType=W,l.lanes=y,l.stateNode={isHidden:!1},l}function zx(l,c,y){return l=Ia(6,l,null,c),l.lanes=y,l}function Ux(l,c,y){return c=Ia(4,l.children!==null?l.children:[],l.key,c),c.lanes=y,c.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},c}function aP(l,c,y,k,B){this.tag=c,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qn(0),this.expirationTimes=qn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qn(0),this.identifierPrefix=k,this.onRecoverableError=B,this.mutableSourceEagerHydrationData=null}function Vx(l,c,y,k,B,H,ne,ve,De){return l=new aP(l,c,y,ve,De),c===1?(c=1,H===!0&&(c|=8)):c=0,H=Ia(3,null,null,c),l.current=H,H.stateNode=l,H.memoizedState={element:k,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},nx(H),l}function iP(l,c,y){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:k==null?null:""+k,children:l,containerInfo:c,implementation:y}}function dw(l){if(!l)return Pl;l=l._reactInternals;e:{if(gt(l)!==l||l.tag!==1)throw Error(n(170));var c=l;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(Qr(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(l.tag===1){var y=l.type;if(Qr(y))return Fj(l,y,c)}return c}function uw(l,c,y,k,B,H,ne,ve,De){return l=Vx(y,k,!0,l,B,H,ne,ve,De),l.context=dw(null),y=l.current,k=zr(),B=$l(y),H=Xi(k,B),H.callback=c??null,Il(y,H,B),l.current.lanes=B,Er(l,B,k),ea(l,k),l}function Xh(l,c,y,k){var B=c.current,H=zr(),ne=$l(B);return y=dw(y),c.context===null?c.context=y:c.pendingContext=y,c=Xi(H,ne),c.payload={element:l},k=k===void 0?null:k,k!==null&&(c.callback=k),l=Il(B,c,ne),l!==null&&(Ja(l,B,ne,H),Rh(l,B,ne)),ne}function Jh(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function hw(l,c){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var y=l.retryLane;l.retryLane=y!==0&&y<c?y:c}}function Hx(l,c){hw(l,c),(l=l.alternate)&&hw(l,c)}function lP(){return null}var mw=typeof reportError=="function"?reportError:function(l){console.error(l)};function Wx(l){this._internalRoot=l}em.prototype.render=Wx.prototype.render=function(l){var c=this._internalRoot;if(c===null)throw Error(n(409));Xh(l,c,null,null)},em.prototype.unmount=Wx.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var c=l.containerInfo;Oo(function(){Xh(null,l,null,null)}),c[Gi]=null}};function em(l){this._internalRoot=l}em.prototype.unstable_scheduleHydration=function(l){if(l){var c=ca();l={blockedOn:null,target:l,priority:c};for(var y=0;y<yn.length&&c!==0&&c<yn[y].priority;y++);yn.splice(y,0,l),y===0&&xi(l)}};function Gx(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function tm(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function fw(){}function oP(l,c,y,k,B){if(B){if(typeof k=="function"){var H=k;k=function(){var Qe=Jh(ne);H.call(Qe)}}var ne=uw(c,k,l,0,null,!1,!1,"",fw);return l._reactRootContainer=ne,l[Gi]=ne.current,Od(l.nodeType===8?l.parentNode:l),Oo(),ne}for(;B=l.lastChild;)l.removeChild(B);if(typeof k=="function"){var ve=k;k=function(){var Qe=Jh(De);ve.call(Qe)}}var De=Vx(l,0,!1,null,null,!1,!1,"",fw);return l._reactRootContainer=De,l[Gi]=De.current,Od(l.nodeType===8?l.parentNode:l),Oo(function(){Xh(c,De,y,k)}),De}function sm(l,c,y,k,B){var H=y._reactRootContainer;if(H){var ne=H;if(typeof B=="function"){var ve=B;B=function(){var De=Jh(ne);ve.call(De)}}Xh(c,ne,l,B)}else ne=oP(y,c,l,B,k);return Jh(ne)}It=function(l){switch(l.tag){case 3:var c=l.stateNode;if(c.current.memoizedState.isDehydrated){var y=gn(c.pendingLanes);y!==0&&(wn(c,y|1),ea(c,Mt()),(hn&6)===0&&(Mc=Mt()+500,Ol()))}break;case 13:Oo(function(){var k=Qi(l,1);if(k!==null){var B=zr();Ja(k,l,1,B)}}),Hx(l,1)}},As=function(l){if(l.tag===13){var c=Qi(l,134217728);if(c!==null){var y=zr();Ja(c,l,134217728,y)}Hx(l,134217728)}},_r=function(l){if(l.tag===13){var c=$l(l),y=Qi(l,c);if(y!==null){var k=zr();Ja(y,l,c,k)}Hx(l,c)}},ca=function(){return Js},Ca=function(l,c){var y=Js;try{return Js=l,c()}finally{Js=y}},ie=function(l,c,y){switch(c){case"input":if(ft(l,y),c=y.name,y.type==="radio"&&c!=null){for(y=l;y.parentNode;)y=y.parentNode;for(y=y.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<y.length;c++){var k=y[c];if(k!==l&&k.form===l.form){var B=yh(k);if(!B)throw Error(n(90));ce(k),ft(k,B)}}}break;case"textarea":ht(l,y);break;case"select":c=y.value,c!=null&&We(l,!!y.multiple,c,!1)}},Le=Fx,Ue=Oo;var cP={usingClientEntryPoint:!1,Events:[Md,Sc,yh,Fe,Ke,Fx]},Qd={findFiberByHostInstance:Ao,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},dP={bundleType:Qd.bundleType,version:Qd.version,rendererPackageName:Qd.rendererPackageName,rendererConfig:Qd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=Ws(l),l===null?null:l.stateNode},findFiberByHostInstance:Qd.findFiberByHostInstance||lP,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{bs=nm.inject(dP),ns=nm}catch{}}return ta.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=cP,ta.createPortal=function(l,c){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Gx(c))throw Error(n(200));return iP(l,c,null,y)},ta.createRoot=function(l,c){if(!Gx(l))throw Error(n(299));var y=!1,k="",B=mw;return c!=null&&(c.unstable_strictMode===!0&&(y=!0),c.identifierPrefix!==void 0&&(k=c.identifierPrefix),c.onRecoverableError!==void 0&&(B=c.onRecoverableError)),c=Vx(l,1,!1,null,null,y,!1,k,B),l[Gi]=c.current,Od(l.nodeType===8?l.parentNode:l),new Wx(c)},ta.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var c=l._reactInternals;if(c===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=Ws(c),l=l===null?null:l.stateNode,l},ta.flushSync=function(l){return Oo(l)},ta.hydrate=function(l,c,y){if(!tm(c))throw Error(n(200));return sm(null,l,c,!0,y)},ta.hydrateRoot=function(l,c,y){if(!Gx(l))throw Error(n(405));var k=y!=null&&y.hydratedSources||null,B=!1,H="",ne=mw;if(y!=null&&(y.unstable_strictMode===!0&&(B=!0),y.identifierPrefix!==void 0&&(H=y.identifierPrefix),y.onRecoverableError!==void 0&&(ne=y.onRecoverableError)),c=uw(c,null,l,1,y??null,B,!1,H,ne),l[Gi]=c.current,Od(l),k)for(l=0;l<k.length;l++)y=k[l],B=y._getVersion,B=B(y._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[y,B]:c.mutableSourceEagerHydrationData.push(y,B);return new em(c)},ta.render=function(l,c,y){if(!tm(c))throw Error(n(200));return sm(null,l,c,!1,y)},ta.unmountComponentAtNode=function(l){if(!tm(l))throw Error(n(40));return l._reactRootContainer?(Oo(function(){sm(null,null,l,!1,function(){l._reactRootContainer=null,l[Gi]=null})}),!0):!1},ta.unstable_batchedUpdates=Fx,ta.unstable_renderSubtreeIntoContainer=function(l,c,y,k){if(!tm(y))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return sm(l,c,y,!1,k)},ta.version="18.3.1-next-f1338f8080-20240426",ta}var Nw;function Oy(){if(Nw)return Qx.exports;Nw=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Qx.exports=bP(),Qx.exports}var ww;function jP(){if(ww)return rm;ww=1;var t=Oy();return rm.createRoot=t.createRoot,rm.hydrateRoot=t.hydrateRoot,rm}var NP=jP();const wP=Nf(NP);var eg={exports:{}},tg={};/**
|
||
* @license React
|
||
* use-sync-external-store-with-selector.production.js
|
||
*
|
||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var Sw;function SP(){if(Sw)return tg;Sw=1;var t=fd();function s(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:s,r=t.useSyncExternalStore,a=t.useRef,i=t.useEffect,o=t.useMemo,d=t.useDebugValue;return tg.useSyncExternalStoreWithSelector=function(m,f,p,h,x){var u=a(null);if(u.current===null){var N={hasValue:!1,value:null};u.current=N}else N=u.current;u=o(function(){function w(D){if(!j){if(j=!0,b=D,D=h(D),x!==void 0&&N.hasValue){var _=N.value;if(x(_,D))return C=_}return C=D}if(_=C,n(b,D))return _;var A=h(D);return x!==void 0&&x(_,A)?(b=D,_):(b=D,C=A)}var j=!1,b,C,S=p===void 0?null:p;return[function(){return w(f())},S===null?void 0:function(){return w(S())}]},[f,p,h,x]);var v=r(m,u[0],u[1]);return i(function(){N.hasValue=!0,N.value=v},[v]),d(v),v},tg}var Cw;function CP(){return Cw||(Cw=1,eg.exports=SP()),eg.exports}var AP=CP();function kP(t){t()}function DP(){let t=null,s=null;return{clear(){t=null,s=null},notify(){kP(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const a=s={callback:n,next:null,prev:s};return a.prev?a.prev.next=a:t=a,function(){!r||t===null||(r=!1,a.next?a.next.prev=a.prev:s=a.prev,a.prev?a.prev.next=a.next:t=a.next)}}}}var Aw={notify(){},get:()=>[]};function RP(t,s){let n,r=Aw,a=0,i=!1;function o(v){p();const w=r.subscribe(v);let j=!1;return()=>{j||(j=!0,w(),h())}}function d(){r.notify()}function m(){N.onStateChange&&N.onStateChange()}function f(){return i}function p(){a++,n||(n=t.subscribe(m),r=DP())}function h(){a--,n&&a===0&&(n(),n=void 0,r.clear(),r=Aw)}function x(){i||(i=!0,p())}function u(){i&&(i=!1,h())}const N={addNestedSub:o,notifyNestedSubs:d,handleChangeWrapper:m,isSubscribed:f,trySubscribe:x,tryUnsubscribe:u,getListeners:()=>r};return N}var EP=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_P=EP(),TP=()=>typeof navigator<"u"&&navigator.product==="ReactNative",PP=TP(),OP=()=>_P||PP?g.useLayoutEffect:g.useEffect,LP=OP(),sg=Symbol.for("react-redux-context"),ng=typeof globalThis<"u"?globalThis:{};function IP(){if(!g.createContext)return{};const t=ng[sg]??(ng[sg]=new Map);let s=t.get(g.createContext);return s||(s=g.createContext(null),t.set(g.createContext,s)),s}var eo=IP();function MP(t){const{children:s,context:n,serverState:r,store:a}=t,i=g.useMemo(()=>{const m=RP(a);return{store:a,subscription:m,getServerState:r?()=>r:void 0}},[a,r]),o=g.useMemo(()=>a.getState(),[a]);LP(()=>{const{subscription:m}=i;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),o!==a.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[i,o]);const d=n||eo;return g.createElement(d.Provider,{value:i},s)}var FP=MP;function Ly(t=eo){return function(){return g.useContext(t)}}var M2=Ly();function F2(t=eo){const s=t===eo?M2:Ly(t),n=()=>{const{store:r}=s();return r};return Object.assign(n,{withTypes:()=>n}),n}var BP=F2();function $P(t=eo){const s=t===eo?BP:F2(t),n=()=>s().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var Lu=$P(),qP=(t,s)=>t===s;function zP(t=eo){const s=t===eo?M2:Ly(t),n=(r,a={})=>{const{equalityFn:i=qP}=typeof a=="function"?{equalityFn:a}:a,o=s(),{store:d,subscription:m,getServerState:f}=o;g.useRef(!0);const p=g.useCallback({[r.name](x){return r(x)}}[r.name],[r]),h=AP.useSyncExternalStoreWithSelector(m.addNestedSub,d.getState,f||d.getState,p,i);return g.useDebugValue(h),h};return Object.assign(n,{withTypes:()=>n}),n}var Pn=zP();function Dr(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var UP=typeof Symbol=="function"&&Symbol.observable||"@@observable",kw=UP,rg=()=>Math.random().toString(36).substring(7).split("").join("."),VP={INIT:`@@redux/INIT${rg()}`,REPLACE:`@@redux/REPLACE${rg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${rg()}`},Km=VP;function Iy(t){if(typeof t!="object"||t===null)return!1;let s=t;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return Object.getPrototypeOf(t)===s||Object.getPrototypeOf(t)===null}function B2(t,s,n){if(typeof t!="function")throw new Error(Dr(2));if(typeof s=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Dr(0));if(typeof s=="function"&&typeof n>"u"&&(n=s,s=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Dr(1));return n(B2)(t,s)}let r=t,a=s,i=new Map,o=i,d=0,m=!1;function f(){o===i&&(o=new Map,i.forEach((w,j)=>{o.set(j,w)}))}function p(){if(m)throw new Error(Dr(3));return a}function h(w){if(typeof w!="function")throw new Error(Dr(4));if(m)throw new Error(Dr(5));let j=!0;f();const b=d++;return o.set(b,w),function(){if(j){if(m)throw new Error(Dr(6));j=!1,f(),o.delete(b),i=null}}}function x(w){if(!Iy(w))throw new Error(Dr(7));if(typeof w.type>"u")throw new Error(Dr(8));if(typeof w.type!="string")throw new Error(Dr(17));if(m)throw new Error(Dr(9));try{m=!0,a=r(a,w)}finally{m=!1}return(i=o).forEach(b=>{b()}),w}function u(w){if(typeof w!="function")throw new Error(Dr(10));r=w,x({type:Km.REPLACE})}function N(){const w=h;return{subscribe(j){if(typeof j!="object"||j===null)throw new Error(Dr(11));function b(){const S=j;S.next&&S.next(p())}return b(),{unsubscribe:w(b)}},[kw](){return this}}}return x({type:Km.INIT}),{dispatch:x,subscribe:h,getState:p,replaceReducer:u,[kw]:N}}function HP(t){Object.keys(t).forEach(s=>{const n=t[s];if(typeof n(void 0,{type:Km.INIT})>"u")throw new Error(Dr(12));if(typeof n(void 0,{type:Km.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Dr(13))})}function WP(t){const s=Object.keys(t),n={};for(let i=0;i<s.length;i++){const o=s[i];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let a;try{HP(n)}catch(i){a=i}return function(o={},d){if(a)throw a;let m=!1;const f={};for(let p=0;p<r.length;p++){const h=r[p],x=n[h],u=o[h],N=x(u,d);if(typeof N>"u")throw d&&d.type,new Error(Dr(14));f[h]=N,m=m||N!==u}return m=m||r.length!==Object.keys(o).length,m?f:o}}function Ym(...t){return t.length===0?s=>s:t.length===1?t[0]:t.reduce((s,n)=>(...r)=>s(n(...r)))}function GP(...t){return s=>(n,r)=>{const a=s(n,r);let i=()=>{throw new Error(Dr(15))};const o={getState:a.getState,dispatch:(m,...f)=>i(m,...f)},d=t.map(m=>m(o));return i=Ym(...d)(a.dispatch),{...a,dispatch:i}}}function KP(t){return Iy(t)&&"type"in t&&typeof t.type=="string"}var $2=Symbol.for("immer-nothing"),Dw=Symbol.for("immer-draftable"),Vr=Symbol.for("immer-state");function ri(t,...s){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ba=Object,td=ba.getPrototypeOf,Zm="constructor",Sf="prototype",Bv="configurable",Qm="enumerable",_m="writable",ju="value",ul=t=>!!t&&!!t[Vr];function ii(t){var s;return t?q2(t)||Af(t)||!!t[Dw]||!!((s=t[Zm])!=null&&s[Dw])||kf(t)||Df(t):!1}var YP=ba[Sf][Zm].toString(),Rw=new WeakMap;function q2(t){if(!t||!My(t))return!1;const s=td(t);if(s===null||s===ba[Sf])return!0;const n=ba.hasOwnProperty.call(s,Zm)&&s[Zm];if(n===Object)return!0;if(!Gc(n))return!1;let r=Rw.get(n);return r===void 0&&(r=Function.toString.call(n),Rw.set(n,r)),r===YP}function Cf(t,s,n=!0){Iu(t)===0?(n?Reflect.ownKeys(t):ba.keys(t)).forEach(a=>{s(a,t[a],t)}):t.forEach((r,a)=>s(a,r,t))}function Iu(t){const s=t[Vr];return s?s.type_:Af(t)?1:kf(t)?2:Df(t)?3:0}var Ew=(t,s,n=Iu(t))=>n===2?t.has(s):ba[Sf].hasOwnProperty.call(t,s),$v=(t,s,n=Iu(t))=>n===2?t.get(s):t[s],Xm=(t,s,n,r=Iu(t))=>{r===2?t.set(s,n):r===3?t.add(n):t[s]=n};function ZP(t,s){return t===s?t!==0||1/t===1/s:t!==t&&s!==s}var Af=Array.isArray,kf=t=>t instanceof Map,Df=t=>t instanceof Set,My=t=>typeof t=="object",Gc=t=>typeof t=="function",ag=t=>typeof t=="boolean";function QP(t){const s=+t;return Number.isInteger(s)&&String(s)===t}var al=t=>t.copy_||t.base_,Fy=t=>t.modified_?t.copy_:t.base_;function qv(t,s){if(kf(t))return new Map(t);if(Df(t))return new Set(t);if(Af(t))return Array[Sf].slice.call(t);const n=q2(t);if(s===!0||s==="class_only"&&!n){const r=ba.getOwnPropertyDescriptors(t);delete r[Vr];let a=Reflect.ownKeys(r);for(let i=0;i<a.length;i++){const o=a[i],d=r[o];d[_m]===!1&&(d[_m]=!0,d[Bv]=!0),(d.get||d.set)&&(r[o]={[Bv]:!0,[_m]:!0,[Qm]:d[Qm],[ju]:t[o]})}return ba.create(td(t),r)}else{const r=td(t);if(r!==null&&n)return{...t};const a=ba.create(r);return ba.assign(a,t)}}function By(t,s=!1){return Rf(t)||ul(t)||!ii(t)||(Iu(t)>1&&ba.defineProperties(t,{set:am,add:am,clear:am,delete:am}),ba.freeze(t),s&&Cf(t,(n,r)=>{By(r,!0)},!1)),t}function XP(){ri(2)}var am={[ju]:XP};function Rf(t){return t===null||!My(t)?!0:ba.isFrozen(t)}var Jm="MapSet",zv="Patches",_w="ArrayMethods",z2={};function ec(t){const s=z2[t];return s||ri(0,t),s}var Tw=t=>!!z2[t],Nu,U2=()=>Nu,JP=(t,s)=>({drafts_:[],parent_:t,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Tw(Jm)?ec(Jm):void 0,arrayMethodsPlugin_:Tw(_w)?ec(_w):void 0});function Pw(t,s){s&&(t.patchPlugin_=ec(zv),t.patches_=[],t.inversePatches_=[],t.patchListener_=s)}function Uv(t){Vv(t),t.drafts_.forEach(e4),t.drafts_=null}function Vv(t){t===Nu&&(Nu=t.parent_)}var Ow=t=>Nu=JP(Nu,t);function e4(t){const s=t[Vr];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function Lw(t,s){s.unfinalizedDrafts_=s.drafts_.length;const n=s.drafts_[0];if(t!==void 0&&t!==n){n[Vr].modified_&&(Uv(s),ri(4)),ii(t)&&(t=Iw(s,t));const{patchPlugin_:a}=s;a&&a.generateReplacementPatches_(n[Vr].base_,t,s)}else t=Iw(s,n);return t4(s,t,!0),Uv(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),t!==$2?t:void 0}function Iw(t,s){if(Rf(s))return s;const n=s[Vr];if(!n)return ef(s,t.handledSet_,t);if(!Ef(n,t))return s;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);W2(n,t)}return n.copy_}function t4(t,s,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&By(s,n)}function V2(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Ef=(t,s)=>t.scope_===s,s4=[];function H2(t,s,n,r){const a=al(t),i=t.type_;if(r!==void 0&&$v(a,r,i)===s){Xm(a,r,n,i);return}if(!t.draftLocations_){const d=t.draftLocations_=new Map;Cf(a,(m,f)=>{if(ul(f)){const p=d.get(f)||[];p.push(m),d.set(f,p)}})}const o=t.draftLocations_.get(s)??s4;for(const d of o)Xm(a,d,n,i)}function n4(t,s,n){t.callbacks_.push(function(a){var d;const i=s;if(!i||!Ef(i,a))return;(d=a.mapSetPlugin_)==null||d.fixSetContents(i);const o=Fy(i);H2(t,i.draft_??i,o,n),W2(i,a)})}function W2(t,s){var r;if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(((r=t.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:a}=s;if(a){const i=a.getPath(t);i&&a.generatePatches_(t,i,s)}V2(t)}}function r4(t,s,n){const{scope_:r}=t;if(ul(n)){const a=n[Vr];Ef(a,r)&&a.callbacks_.push(function(){Tm(t);const o=Fy(a);H2(t,n,o,s)})}else ii(n)&&t.callbacks_.push(function(){const i=al(t);t.type_===3?i.has(n)&&ef(n,r.handledSet_,r):$v(i,s,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(s)??!1)===!0&&t.copy_&&ef($v(t.copy_,s,t.type_),r.handledSet_,r)})}function ef(t,s,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ul(t)||s.has(t)||!ii(t)||Rf(t)||(s.add(t),Cf(t,(r,a)=>{if(ul(a)){const i=a[Vr];if(Ef(i,n)){const o=Fy(i);Xm(t,r,o,t.type_),V2(i)}}else ii(a)&&ef(a,s,n)})),t}function a4(t,s){const n=Af(t),r={type_:n?1:0,scope_:s?s.scope_:U2(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let a=r,i=tf;n&&(a=[r],i=wu);const{revoke:o,proxy:d}=Proxy.revocable(a,i);return r.draft_=d,r.revoke_=o,[d,r]}var tf={get(t,s){if(s===Vr)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof s=="string";if(r&&n!=null&&n.isArrayOperationMethod(s))return n.createMethodInterceptor(t,s);const a=al(t);if(!Ew(a,s,t.type_))return i4(t,a,s);const i=a[s];if(t.finalized_||!ii(i)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&QP(s))return i;if(i===ig(t.base_,s)){Tm(t);const o=t.type_===1?+s:s,d=Wv(t.scope_,i,t,o);return t.copy_[o]=d}return i},has(t,s){return s in al(t)},ownKeys(t){return Reflect.ownKeys(al(t))},set(t,s,n){const r=G2(al(t),s);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const a=ig(al(t),s),i=a==null?void 0:a[Vr];if(i&&i.base_===n)return t.copy_[s]=n,t.assigned_.set(s,!1),!0;if(ZP(n,a)&&(n!==void 0||Ew(t.base_,s,t.type_)))return!0;Tm(t),Hv(t)}return t.copy_[s]===n&&(n!==void 0||s in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[s])||(t.copy_[s]=n,t.assigned_.set(s,!0),r4(t,s,n)),!0},deleteProperty(t,s){return Tm(t),ig(t.base_,s)!==void 0||s in t.base_?(t.assigned_.set(s,!1),Hv(t)):t.assigned_.delete(s),t.copy_&&delete t.copy_[s],!0},getOwnPropertyDescriptor(t,s){const n=al(t),r=Reflect.getOwnPropertyDescriptor(n,s);return r&&{[_m]:!0,[Bv]:t.type_!==1||s!=="length",[Qm]:r[Qm],[ju]:n[s]}},defineProperty(){ri(11)},getPrototypeOf(t){return td(t.base_)},setPrototypeOf(){ri(12)}},wu={};for(let t in tf){let s=tf[t];wu[t]=function(){const n=arguments;return n[0]=n[0][0],s.apply(this,n)}}wu.deleteProperty=function(t,s){return wu.set.call(this,t,s,void 0)};wu.set=function(t,s,n){return tf.set.call(this,t[0],s,n,t[0])};function ig(t,s){const n=t[Vr];return(n?al(n):t)[s]}function i4(t,s,n){var a;const r=G2(s,n);return r?ju in r?r[ju]:(a=r.get)==null?void 0:a.call(t.draft_):void 0}function G2(t,s){if(!(s in t))return;let n=td(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,s);if(r)return r;n=td(n)}}function Hv(t){t.modified_||(t.modified_=!0,t.parent_&&Hv(t.parent_))}function Tm(t){t.copy_||(t.assigned_=new Map,t.copy_=qv(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var l4=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,n,r)=>{if(Gc(s)&&!Gc(n)){const i=n;n=s;const o=this;return function(m=i,...f){return o.produce(m,p=>n.call(this,p,...f))}}Gc(n)||ri(6),r!==void 0&&!Gc(r)&&ri(7);let a;if(ii(s)){const i=Ow(this),o=Wv(i,s,void 0);let d=!0;try{a=n(o),d=!1}finally{d?Uv(i):Vv(i)}return Pw(i,r),Lw(a,i)}else if(!s||!My(s)){if(a=n(s),a===void 0&&(a=s),a===$2&&(a=void 0),this.autoFreeze_&&By(a,!0),r){const i=[],o=[];ec(zv).generateReplacementPatches_(s,a,{patches_:i,inversePatches_:o}),r(i,o)}return a}else ri(1,s)},this.produceWithPatches=(s,n)=>{if(Gc(s))return(o,...d)=>this.produceWithPatches(o,m=>s(m,...d));let r,a;return[this.produce(s,n,(o,d)=>{r=o,a=d}),r,a]},ag(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),ag(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),ag(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){ii(t)||ri(8),ul(t)&&(t=o4(t));const s=Ow(this),n=Wv(s,t,void 0);return n[Vr].isManual_=!0,Vv(s),n}finishDraft(t,s){const n=t&&t[Vr];(!n||!n.isManual_)&&ri(9);const{scope_:r}=n;return Pw(r,s),Lw(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,s){let n;for(n=s.length-1;n>=0;n--){const a=s[n];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}n>-1&&(s=s.slice(n+1));const r=ec(zv).applyPatches_;return ul(t)?r(t,s):this.produce(t,a=>r(a,s))}};function Wv(t,s,n,r){const[a,i]=kf(s)?ec(Jm).proxyMap_(s,n):Df(s)?ec(Jm).proxySet_(s,n):a4(s,n);return((n==null?void 0:n.scope_)??U2()).drafts_.push(a),i.callbacks_=(n==null?void 0:n.callbacks_)??[],i.key_=r,n&&r!==void 0?n4(n,i,r):i.callbacks_.push(function(m){var p;(p=m.mapSetPlugin_)==null||p.fixSetContents(i);const{patchPlugin_:f}=m;i.modified_&&f&&f.generatePatches_(i,[],m)}),a}function o4(t){return ul(t)||ri(10,t),K2(t)}function K2(t){if(!ii(t)||Rf(t))return t;const s=t[Vr];let n,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,n=qv(t,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else n=qv(t,!0);return Cf(n,(a,i)=>{Xm(n,a,K2(i))},r),s&&(s.finalized_=!1),n}var c4=new l4,Y2=c4.produce;function Z2(t){return({dispatch:n,getState:r})=>a=>i=>typeof i=="function"?i(n,r,t):a(i)}var d4=Z2(),u4=Z2,h4=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Ym:Ym.apply(null,arguments)},m4=t=>t&&typeof t.match=="function";function vu(t,s){function n(...r){if(s){let a=s(...r);if(!a)throw new Error(ol(0));return{type:t,payload:a.payload,..."meta"in a&&{meta:a.meta},..."error"in a&&{error:a.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>KP(r)&&r.type===t,n}var Q2=class uu extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,uu.prototype)}static get[Symbol.species](){return uu}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new uu(...s[0].concat(this)):new uu(...s.concat(this))}};function Mw(t){return ii(t)?Y2(t,()=>{}):t}function im(t,s,n){return t.has(s)?t.get(s):t.set(s,n(s)).get(s)}function f4(t){return typeof t=="boolean"}var p4=()=>function(s){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:a=!0,actionCreatorCheck:i=!0}=s??{};let o=new Q2;return n&&(f4(n)?o.push(d4):o.push(u4(n.extraArgument))),o},x4="RTK_autoBatch",Fw=t=>s=>{setTimeout(s,t)},g4=(t={type:"raf"})=>s=>(...n)=>{const r=s(...n);let a=!0,i=!1,o=!1;const d=new Set,m=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Fw(10):t.type==="callback"?t.queueNotification:Fw(t.timeout),f=()=>{o=!1,i&&(i=!1,d.forEach(p=>p()))};return Object.assign({},r,{subscribe(p){const h=()=>a&&p(),x=r.subscribe(h);return d.add(p),()=>{x(),d.delete(p)}},dispatch(p){var h;try{return a=!((h=p==null?void 0:p.meta)!=null&&h[x4]),i=!a,i&&(o||(o=!0,m(f))),r.dispatch(p)}finally{a=!0}}})},v4=t=>function(n){const{autoBatch:r=!0}=n??{};let a=new Q2(t);return r&&a.push(g4(typeof r=="object"?r:void 0)),a};function y4(t){const s=p4(),{reducer:n=void 0,middleware:r,devTools:a=!0,preloadedState:i=void 0,enhancers:o=void 0}=t||{};let d;if(typeof n=="function")d=n;else if(Iy(n))d=WP(n);else throw new Error(ol(1));let m;typeof r=="function"?m=r(s):m=s();let f=Ym;a&&(f=h4({trace:!1,...typeof a=="object"&&a}));const p=GP(...m),h=v4(p);let x=typeof o=="function"?o(h):h();const u=f(...x);return B2(d,i,u)}function X2(t){const s={},n=[];let r;const a={addCase(i,o){const d=typeof i=="string"?i:i.type;if(!d)throw new Error(ol(28));if(d in s)throw new Error(ol(29));return s[d]=o,a},addAsyncThunk(i,o){return o.pending&&(s[i.pending.type]=o.pending),o.rejected&&(s[i.rejected.type]=o.rejected),o.fulfilled&&(s[i.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:i.settled,reducer:o.settled}),a},addMatcher(i,o){return n.push({matcher:i,reducer:o}),a},addDefaultCase(i){return r=i,a}};return t(a),[s,n,r]}function b4(t){return typeof t=="function"}function j4(t,s){let[n,r,a]=X2(s),i;if(b4(t))i=()=>Mw(t());else{const d=Mw(t);i=()=>d}function o(d=i(),m){let f=[n[m.type],...r.filter(({matcher:p})=>p(m)).map(({reducer:p})=>p)];return f.filter(p=>!!p).length===0&&(f=[a]),f.reduce((p,h)=>{if(h)if(ul(p)){const u=h(p,m);return u===void 0?p:u}else{if(ii(p))return Y2(p,x=>h(x,m));{const x=h(p,m);if(x===void 0){if(p===null)return p;throw Error("A case reducer on a non-draftable value must not return undefined")}return x}}return p},d)}return o.getInitialState=i,o}var N4=(t,s)=>m4(t)?t.match(s):t(s);function w4(...t){return s=>t.some(n=>N4(n,s))}var S4="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",C4=(t=21)=>{let s="",n=t;for(;n--;)s+=S4[Math.random()*64|0];return s},A4=["name","message","stack","code"],lg=class{constructor(t,s){Kx(this,"_type");this.payload=t,this.meta=s}},Bw=class{constructor(t,s){Kx(this,"_type");this.payload=t,this.meta=s}},k4=t=>{if(typeof t=="object"&&t!==null){const s={};for(const n of A4)typeof t[n]=="string"&&(s[n]=t[n]);return s}return{message:String(t)}},$w="External signal was aborted",D4=(()=>{function t(s,n,r){const a=vu(s+"/fulfilled",(m,f,p,h)=>({payload:m,meta:{...h||{},arg:p,requestId:f,requestStatus:"fulfilled"}})),i=vu(s+"/pending",(m,f,p)=>({payload:void 0,meta:{...p||{},arg:f,requestId:m,requestStatus:"pending"}})),o=vu(s+"/rejected",(m,f,p,h,x)=>({payload:h,error:(r&&r.serializeError||k4)(m||"Rejected"),meta:{...x||{},arg:p,requestId:f,rejectedWithValue:!!h,requestStatus:"rejected",aborted:(m==null?void 0:m.name)==="AbortError",condition:(m==null?void 0:m.name)==="ConditionError"}}));function d(m,{signal:f}={}){return(p,h,x)=>{const u=r!=null&&r.idGenerator?r.idGenerator(m):C4(),N=new AbortController;let v,w;function j(C){w=C,N.abort()}f&&(f.aborted?j($w):f.addEventListener("abort",()=>j($w),{once:!0}));const b=(async function(){var D,_;let C;try{let A=(D=r==null?void 0:r.condition)==null?void 0:D.call(r,m,{getState:h,extra:x});if(E4(A)&&(A=await A),A===!1||N.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const E=new Promise((q,O)=>{v=()=>{O({name:"AbortError",message:w||"Aborted"})},N.signal.addEventListener("abort",v,{once:!0})});p(i(u,m,(_=r==null?void 0:r.getPendingMeta)==null?void 0:_.call(r,{requestId:u,arg:m},{getState:h,extra:x}))),C=await Promise.race([E,Promise.resolve(n(m,{dispatch:p,getState:h,extra:x,requestId:u,signal:N.signal,abort:j,rejectWithValue:(q,O)=>new lg(q,O),fulfillWithValue:(q,O)=>new Bw(q,O)})).then(q=>{if(q instanceof lg)throw q;return q instanceof Bw?a(q.payload,u,m,q.meta):a(q,u,m)})])}catch(A){C=A instanceof lg?o(null,u,m,A.payload,A.meta):o(A,u,m)}finally{v&&N.signal.removeEventListener("abort",v)}return r&&!r.dispatchConditionRejection&&o.match(C)&&C.meta.condition||p(C),C})();return Object.assign(b,{abort:j,requestId:u,arg:m,unwrap(){return b.then(R4)}})}}return Object.assign(d,{pending:i,rejected:o,fulfilled:a,settled:w4(o,a),typePrefix:s})}return t.withTypes=()=>t,t})();function R4(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function E4(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var _4=Symbol.for("rtk-slice-createasyncthunk");function T4(t,s){return`${t}/${s}`}function P4({creators:t}={}){var n;const s=(n=t==null?void 0:t.asyncThunk)==null?void 0:n[_4];return function(a){const{name:i,reducerPath:o=i}=a;if(!i)throw new Error(ol(11));const d=(typeof a.reducers=="function"?a.reducers(L4()):a.reducers)||{},m=Object.keys(d),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},p={addCase(S,D){const _=typeof S=="string"?S:S.type;if(!_)throw new Error(ol(12));if(_ in f.sliceCaseReducersByType)throw new Error(ol(13));return f.sliceCaseReducersByType[_]=D,p},addMatcher(S,D){return f.sliceMatchers.push({matcher:S,reducer:D}),p},exposeAction(S,D){return f.actionCreators[S]=D,p},exposeCaseReducer(S,D){return f.sliceCaseReducersByName[S]=D,p}};m.forEach(S=>{const D=d[S],_={reducerName:S,type:T4(i,S),createNotation:typeof a.reducers=="function"};M4(D)?B4(_,D,p,s):I4(_,D,p)});function h(){const[S={},D=[],_=void 0]=typeof a.extraReducers=="function"?X2(a.extraReducers):[a.extraReducers],A={...S,...f.sliceCaseReducersByType};return j4(a.initialState,E=>{for(let q in A)E.addCase(q,A[q]);for(let q of f.sliceMatchers)E.addMatcher(q.matcher,q.reducer);for(let q of D)E.addMatcher(q.matcher,q.reducer);_&&E.addDefaultCase(_)})}const x=S=>S,u=new Map,N=new WeakMap;let v;function w(S,D){return v||(v=h()),v(S,D)}function j(){return v||(v=h()),v.getInitialState()}function b(S,D=!1){function _(E){let q=E[S];return typeof q>"u"&&D&&(q=im(N,_,j)),q}function A(E=x){const q=im(u,D,()=>new WeakMap);return im(q,E,()=>{const O={};for(const[R,P]of Object.entries(a.selectors??{}))O[R]=O4(P,E,()=>im(N,E,j),D);return O})}return{reducerPath:S,getSelectors:A,get selectors(){return A(_)},selectSlice:_}}const C={name:i,reducer:w,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:j,...b(o),injectInto(S,{reducerPath:D,..._}={}){const A=D??o;return S.inject({reducerPath:A,reducer:w},_),{...C,...b(A,!0)}}};return C}}function O4(t,s,n,r){function a(i,...o){let d=s(i);return typeof d>"u"&&r&&(d=n()),t(d,...o)}return a.unwrapped=t,a}var J2=P4();function L4(){function t(s,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:s,...n}}return t.withTypes=()=>t,{reducer(s){return Object.assign({[s.name](...n){return s(...n)}}[s.name],{_reducerDefinitionType:"reducer"})},preparedReducer(s,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:s,reducer:n}},asyncThunk:t}}function I4({type:t,reducerName:s,createNotation:n},r,a){let i,o;if("reducer"in r){if(n&&!F4(r))throw new Error(ol(17));i=r.reducer,o=r.prepare}else i=r;a.addCase(t,i).exposeCaseReducer(s,i).exposeAction(s,o?vu(t,o):vu(t))}function M4(t){return t._reducerDefinitionType==="asyncThunk"}function F4(t){return t._reducerDefinitionType==="reducerWithPrepare"}function B4({type:t,reducerName:s},n,r,a){if(!a)throw new Error(ol(18));const{payloadCreator:i,fulfilled:o,pending:d,rejected:m,settled:f,options:p}=n,h=a(t,i,p);r.exposeAction(s,h),o&&r.addCase(h.fulfilled,o),d&&r.addCase(h.pending,d),m&&r.addCase(h.rejected,m),f&&r.addMatcher(h.settled,f),r.exposeCaseReducer(s,{fulfilled:o||lm,pending:d||lm,rejected:m||lm,settled:f||lm})}function lm(){}function ol(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var pr={};/*! Axios v1.13.6 Copyright (c) 2026 Matt Zabriskie and contributors */var og,qw;function $4(){if(qw)return og;qw=1;function t(ee,se){return function(){return ee.apply(se,arguments)}}const{toString:s}=Object.prototype,{getPrototypeOf:n}=Object,{iterator:r,toStringTag:a}=Symbol,i=(ee=>se=>{const he=s.call(se);return ee[he]||(ee[he]=he.slice(8,-1).toLowerCase())})(Object.create(null)),o=ee=>(ee=ee.toLowerCase(),se=>i(se)===ee),d=ee=>se=>typeof se===ee,{isArray:m}=Array,f=d("undefined");function p(ee){return ee!==null&&!f(ee)&&ee.constructor!==null&&!f(ee.constructor)&&N(ee.constructor.isBuffer)&&ee.constructor.isBuffer(ee)}const h=o("ArrayBuffer");function x(ee){let se;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?se=ArrayBuffer.isView(ee):se=ee&&ee.buffer&&h(ee.buffer),se}const u=d("string"),N=d("function"),v=d("number"),w=ee=>ee!==null&&typeof ee=="object",j=ee=>ee===!0||ee===!1,b=ee=>{if(i(ee)!=="object")return!1;const se=n(ee);return(se===null||se===Object.prototype||Object.getPrototypeOf(se)===null)&&!(a in ee)&&!(r in ee)},C=ee=>{if(!w(ee)||p(ee))return!1;try{return Object.keys(ee).length===0&&Object.getPrototypeOf(ee)===Object.prototype}catch{return!1}},S=o("Date"),D=o("File"),_=ee=>!!(ee&&typeof ee.uri<"u"),A=ee=>ee&&typeof ee.getParts<"u",E=o("Blob"),q=o("FileList"),O=ee=>w(ee)&&N(ee.pipe);function R(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof Vo<"u"?Vo:{}}const P=R(),L=typeof P.FormData<"u"?P.FormData:void 0,$=ee=>{let se;return ee&&(L&&ee instanceof L||N(ee.append)&&((se=i(ee))==="formdata"||se==="object"&&N(ee.toString)&&ee.toString()==="[object FormData]"))},Z=o("URLSearchParams"),[Q,W,U,M]=["ReadableStream","Request","Response","Headers"].map(o),z=ee=>ee.trim?ee.trim():ee.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function T(ee,se,{allOwnKeys:he=!1}={}){if(ee===null||typeof ee>"u")return;let pe,Ne;if(typeof ee!="object"&&(ee=[ee]),m(ee))for(pe=0,Ne=ee.length;pe<Ne;pe++)se.call(null,ee[pe],pe,ee);else{if(p(ee))return;const $e=he?Object.getOwnPropertyNames(ee):Object.keys(ee),qe=$e.length;let ct;for(pe=0;pe<qe;pe++)ct=$e[pe],se.call(null,ee[ct],ct,ee)}}function F(ee,se){if(p(ee))return null;se=se.toLowerCase();const he=Object.keys(ee);let pe=he.length,Ne;for(;pe-- >0;)if(Ne=he[pe],se===Ne.toLowerCase())return Ne;return null}const I=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Vo,K=ee=>!f(ee)&&ee!==I;function G(){const{caseless:ee,skipUndefined:se}=K(this)&&this||{},he={},pe=(Ne,$e)=>{if($e==="__proto__"||$e==="constructor"||$e==="prototype")return;const qe=ee&&F(he,$e)||$e;b(he[qe])&&b(Ne)?he[qe]=G(he[qe],Ne):b(Ne)?he[qe]=G({},Ne):m(Ne)?he[qe]=Ne.slice():(!se||!f(Ne))&&(he[qe]=Ne)};for(let Ne=0,$e=arguments.length;Ne<$e;Ne++)arguments[Ne]&&T(arguments[Ne],pe);return he}const V=(ee,se,he,{allOwnKeys:pe}={})=>(T(se,(Ne,$e)=>{he&&N(Ne)?Object.defineProperty(ee,$e,{value:t(Ne,he),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(ee,$e,{value:Ne,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:pe}),ee),Y=ee=>(ee.charCodeAt(0)===65279&&(ee=ee.slice(1)),ee),re=(ee,se,he,pe)=>{ee.prototype=Object.create(se.prototype,pe),Object.defineProperty(ee.prototype,"constructor",{value:ee,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(ee,"super",{value:se.prototype}),he&&Object.assign(ee.prototype,he)},ae=(ee,se,he,pe)=>{let Ne,$e,qe;const ct={};if(se=se||{},ee==null)return se;do{for(Ne=Object.getOwnPropertyNames(ee),$e=Ne.length;$e-- >0;)qe=Ne[$e],(!pe||pe(qe,ee,se))&&!ct[qe]&&(se[qe]=ee[qe],ct[qe]=!0);ee=he!==!1&&n(ee)}while(ee&&(!he||he(ee,se))&&ee!==Object.prototype);return se},ue=(ee,se,he)=>{ee=String(ee),(he===void 0||he>ee.length)&&(he=ee.length),he-=se.length;const pe=ee.indexOf(se,he);return pe!==-1&&pe===he},ye=ee=>{if(!ee)return null;if(m(ee))return ee;let se=ee.length;if(!v(se))return null;const he=new Array(se);for(;se-- >0;)he[se]=ee[se];return he},ce=(ee=>se=>ee&&se instanceof ee)(typeof Uint8Array<"u"&&n(Uint8Array)),je=(ee,se)=>{const pe=(ee&&ee[r]).call(ee);let Ne;for(;(Ne=pe.next())&&!Ne.done;){const $e=Ne.value;se.call(ee,$e[0],$e[1])}},Me=(ee,se)=>{let he;const pe=[];for(;(he=ee.exec(se))!==null;)pe.push(he);return pe},ut=o("HTMLFormElement"),jt=ee=>ee.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(he,pe,Ne){return pe.toUpperCase()+Ne}),ft=(({hasOwnProperty:ee})=>(se,he)=>ee.call(se,he))(Object.prototype),X=o("RegExp"),Ce=(ee,se)=>{const he=Object.getOwnPropertyDescriptors(ee),pe={};T(he,(Ne,$e)=>{let qe;(qe=se(Ne,$e,ee))!==!1&&(pe[$e]=qe||Ne)}),Object.defineProperties(ee,pe)},xe=ee=>{Ce(ee,(se,he)=>{if(N(ee)&&["arguments","caller","callee"].indexOf(he)!==-1)return!1;const pe=ee[he];if(N(pe)){if(se.enumerable=!1,"writable"in se){se.writable=!1;return}se.set||(se.set=()=>{throw Error("Can not rewrite read-only method '"+he+"'")})}})},We=(ee,se)=>{const he={},pe=Ne=>{Ne.forEach($e=>{he[$e]=!0})};return m(ee)?pe(ee):pe(String(ee).split(se)),he},Be=()=>{},rt=(ee,se)=>ee!=null&&Number.isFinite(ee=+ee)?ee:se;function ht(ee){return!!(ee&&N(ee.append)&&ee[a]==="FormData"&&ee[r])}const ge=ee=>{const se=new Array(10),he=(pe,Ne)=>{if(w(pe)){if(se.indexOf(pe)>=0)return;if(p(pe))return pe;if(!("toJSON"in pe)){se[Ne]=pe;const $e=m(pe)?[]:{};return T(pe,(qe,ct)=>{const ds=he(qe,Ne+1);!f(ds)&&($e[ct]=ds)}),se[Ne]=void 0,$e}}return pe};return he(ee,0)},Je=o("AsyncFunction"),mt=ee=>ee&&(w(ee)||N(ee))&&N(ee.then)&&N(ee.catch),de=((ee,se)=>ee?setImmediate:se?((he,pe)=>(I.addEventListener("message",({source:Ne,data:$e})=>{Ne===I&&$e===he&&pe.length&&pe.shift()()},!1),Ne=>{pe.push(Ne),I.postMessage(he,"*")}))(`axios@${Math.random()}`,[]):he=>setTimeout(he))(typeof setImmediate=="function",N(I.postMessage)),at=typeof queueMicrotask<"u"?queueMicrotask.bind(I):typeof process<"u"&&process.nextTick||de;var ke={isArray:m,isArrayBuffer:h,isBuffer:p,isFormData:$,isArrayBufferView:x,isString:u,isNumber:v,isBoolean:j,isObject:w,isPlainObject:b,isEmptyObject:C,isReadableStream:Q,isRequest:W,isResponse:U,isHeaders:M,isUndefined:f,isDate:S,isFile:D,isReactNativeBlob:_,isReactNative:A,isBlob:E,isRegExp:X,isFunction:N,isStream:O,isURLSearchParams:Z,isTypedArray:ce,isFileList:q,forEach:T,merge:G,extend:V,trim:z,stripBOM:Y,inherits:re,toFlatObject:ae,kindOf:i,kindOfTest:o,endsWith:ue,toArray:ye,forEachEntry:je,matchAll:Me,isHTMLForm:ut,hasOwnProperty:ft,hasOwnProp:ft,reduceDescriptors:Ce,freezeMethods:xe,toObjectSet:We,toCamelCase:jt,noop:Be,toFiniteNumber:rt,findKey:F,global:I,isContextDefined:K,isSpecCompliantForm:ht,toJSONObject:ge,isAsyncFn:Je,isThenable:mt,setImmediate:de,asap:at,isIterable:ee=>ee!=null&&N(ee[r])};class Zt extends Error{static from(se,he,pe,Ne,$e,qe){const ct=new Zt(se.message,he||se.code,pe,Ne,$e);return ct.cause=se,ct.name=se.name,se.status!=null&&ct.status==null&&(ct.status=se.status),qe&&Object.assign(ct,qe),ct}constructor(se,he,pe,Ne,$e){super(se),Object.defineProperty(this,"message",{value:se,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,he&&(this.code=he),pe&&(this.config=pe),Ne&&(this.request=Ne),$e&&(this.response=$e,this.status=$e.status)}toJSON(){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:ke.toJSONObject(this.config),code:this.code,status:this.status}}}Zt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Zt.ERR_BAD_OPTION="ERR_BAD_OPTION",Zt.ECONNABORTED="ECONNABORTED",Zt.ETIMEDOUT="ETIMEDOUT",Zt.ERR_NETWORK="ERR_NETWORK",Zt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Zt.ERR_DEPRECATED="ERR_DEPRECATED",Zt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Zt.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Zt.ERR_CANCELED="ERR_CANCELED",Zt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Zt.ERR_INVALID_URL="ERR_INVALID_URL";var Bt=Zt,_s=null;function Us(ee){return ke.isPlainObject(ee)||ke.isArray(ee)}function fs(ee){return ke.endsWith(ee,"[]")?ee.slice(0,-2):ee}function Vs(ee,se,he){return ee?ee.concat(se).map(function(Ne,$e){return Ne=fs(Ne),!he&&$e?"["+Ne+"]":Ne}).join(he?".":""):se}function Qs(ee){return ke.isArray(ee)&&!ee.some(Us)}const Xs=ke.toFlatObject(ke,{},null,function(se){return/^is[A-Z]/.test(se)});function ie(ee,se,he){if(!ke.isObject(ee))throw new TypeError("target must be an object");se=se||new FormData,he=ke.toFlatObject(he,{metaTokens:!0,dots:!1,indexes:!1},!1,function(Es,os){return!ke.isUndefined(os[Es])});const pe=he.metaTokens,Ne=he.visitor||Ft,$e=he.dots,qe=he.indexes,ds=(he.Blob||typeof Blob<"u"&&Blob)&&ke.isSpecCompliantForm(se);if(!ke.isFunction(Ne))throw new TypeError("visitor must be a function");function Kt(zt){if(zt===null)return"";if(ke.isDate(zt))return zt.toISOString();if(ke.isBoolean(zt))return zt.toString();if(!ds&&ke.isBlob(zt))throw new Bt("Blob is not supported. Use a Buffer instead.");return ke.isArrayBuffer(zt)||ke.isTypedArray(zt)?ds&&typeof Blob=="function"?new Blob([zt]):Buffer.from(zt):zt}function Ft(zt,Es,os){let On=zt;if(ke.isReactNative(se)&&ke.isReactNativeBlob(zt))return se.append(Vs(os,Es,$e),Kt(zt)),!1;if(zt&&!os&&typeof zt=="object"){if(ke.endsWith(Es,"{}"))Es=pe?Es:Es.slice(0,-2),zt=JSON.stringify(zt);else if(ke.isArray(zt)&&Qs(zt)||(ke.isFileList(zt)||ke.endsWith(Es,"[]"))&&(On=ke.toArray(zt)))return Es=fs(Es),On.forEach(function(zn,cr){!(ke.isUndefined(zn)||zn===null)&&se.append(qe===!0?Vs([Es],cr,$e):qe===null?Es:Es+"[]",Kt(zn))}),!1}return Us(zt)?!0:(se.append(Vs(os,Es,$e),Kt(zt)),!1)}const Rs=[],cn=Object.assign(Xs,{defaultVisitor:Ft,convertValue:Kt,isVisitable:Us});function Kn(zt,Es){if(!ke.isUndefined(zt)){if(Rs.indexOf(zt)!==-1)throw Error("Circular reference detected in "+Es.join("."));Rs.push(zt),ke.forEach(zt,function(On,Cr){(!(ke.isUndefined(On)||On===null)&&Ne.call(se,On,ke.isString(Cr)?Cr.trim():Cr,Es,cn))===!0&&Kn(On,Es?Es.concat(Cr):[Cr])}),Rs.pop()}}if(!ke.isObject(ee))throw new TypeError("data must be an object");return Kn(ee),se}function nt(ee){const se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(ee).replace(/[!'()~]|%20|%00/g,function(pe){return se[pe]})}function fe(ee,se){this._pairs=[],ee&&ie(ee,this,se)}const Ae=fe.prototype;Ae.append=function(se,he){this._pairs.push([se,he])},Ae.toString=function(se){const he=se?function(pe){return se.call(this,pe,nt)}:nt;return this._pairs.map(function(Ne){return he(Ne[0])+"="+he(Ne[1])},"").join("&")};function Fe(ee){return encodeURIComponent(ee).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ke(ee,se,he){if(!se)return ee;const pe=he&&he.encode||Fe,Ne=ke.isFunction(he)?{serialize:he}:he,$e=Ne&&Ne.serialize;let qe;if($e?qe=$e(se,Ne):qe=ke.isURLSearchParams(se)?se.toString():new fe(se,Ne).toString(pe),qe){const ct=ee.indexOf("#");ct!==-1&&(ee=ee.slice(0,ct)),ee+=(ee.indexOf("?")===-1?"?":"&")+qe}return ee}class Le{constructor(){this.handlers=[]}use(se,he,pe){return this.handlers.push({fulfilled:se,rejected:he,synchronous:pe?pe.synchronous:!1,runWhen:pe?pe.runWhen:null}),this.handlers.length-1}eject(se){this.handlers[se]&&(this.handlers[se]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(se){ke.forEach(this.handlers,function(pe){pe!==null&&se(pe)})}}var Ue=Le,et={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},dt=typeof URLSearchParams<"u"?URLSearchParams:fe,ss=typeof FormData<"u"?FormData:null,Wt=typeof Blob<"u"?Blob:null,kt={isBrowser:!0,classes:{URLSearchParams:dt,FormData:ss,Blob:Wt},protocols:["http","https","file","blob","url","data"]};const wt=typeof window<"u"&&typeof document<"u",Os=typeof navigator=="object"&&navigator||void 0,as=wt&&(!Os||["ReactNative","NativeScript","NS"].indexOf(Os.product)<0),Se=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",be=wt&&window.location.href||"http://localhost";var pt=Object.freeze({__proto__:null,hasBrowserEnv:wt,hasStandardBrowserWebWorkerEnv:Se,hasStandardBrowserEnv:as,navigator:Os,origin:be}),Ve={...pt,...kt};function bt(ee,se){return ie(ee,new Ve.classes.URLSearchParams,{visitor:function(he,pe,Ne,$e){return Ve.isNode&&ke.isBuffer(he)?(this.append(pe,he.toString("base64")),!1):$e.defaultVisitor.apply(this,arguments)},...se})}function gt(ee){return ke.matchAll(/\w+|\[(\w*)]/g,ee).map(se=>se[0]==="[]"?"":se[1]||se[0])}function rs(ee){const se={},he=Object.keys(ee);let pe;const Ne=he.length;let $e;for(pe=0;pe<Ne;pe++)$e=he[pe],se[$e]=ee[$e];return se}function is(ee){function se(he,pe,Ne,$e){let qe=he[$e++];if(qe==="__proto__")return!0;const ct=Number.isFinite(+qe),ds=$e>=he.length;return qe=!qe&&ke.isArray(Ne)?Ne.length:qe,ds?(ke.hasOwnProp(Ne,qe)?Ne[qe]=[Ne[qe],pe]:Ne[qe]=pe,!ct):((!Ne[qe]||!ke.isObject(Ne[qe]))&&(Ne[qe]=[]),se(he,pe,Ne[qe],$e)&&ke.isArray(Ne[qe])&&(Ne[qe]=rs(Ne[qe])),!ct)}if(ke.isFormData(ee)&&ke.isFunction(ee.entries)){const he={};return ke.forEachEntry(ee,(pe,Ne)=>{se(gt(pe),Ne,he,0)}),he}return null}function Ts(ee,se,he){if(ke.isString(ee))try{return(se||JSON.parse)(ee),ke.trim(ee)}catch(pe){if(pe.name!=="SyntaxError")throw pe}return(he||JSON.stringify)(ee)}const Ws={transitional:et,adapter:["xhr","http","fetch"],transformRequest:[function(se,he){const pe=he.getContentType()||"",Ne=pe.indexOf("application/json")>-1,$e=ke.isObject(se);if($e&&ke.isHTMLForm(se)&&(se=new FormData(se)),ke.isFormData(se))return Ne?JSON.stringify(is(se)):se;if(ke.isArrayBuffer(se)||ke.isBuffer(se)||ke.isStream(se)||ke.isFile(se)||ke.isBlob(se)||ke.isReadableStream(se))return se;if(ke.isArrayBufferView(se))return se.buffer;if(ke.isURLSearchParams(se))return he.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),se.toString();let ct;if($e){if(pe.indexOf("application/x-www-form-urlencoded")>-1)return bt(se,this.formSerializer).toString();if((ct=ke.isFileList(se))||pe.indexOf("multipart/form-data")>-1){const ds=this.env&&this.env.FormData;return ie(ct?{"files[]":se}:se,ds&&new ds,this.formSerializer)}}return $e||Ne?(he.setContentType("application/json",!1),Ts(se)):se}],transformResponse:[function(se){const he=this.transitional||Ws.transitional,pe=he&&he.forcedJSONParsing,Ne=this.responseType==="json";if(ke.isResponse(se)||ke.isReadableStream(se))return se;if(se&&ke.isString(se)&&(pe&&!this.responseType||Ne)){const qe=!(he&&he.silentJSONParsing)&&Ne;try{return JSON.parse(se,this.parseReviver)}catch(ct){if(qe)throw ct.name==="SyntaxError"?Bt.from(ct,Bt.ERR_BAD_RESPONSE,this,null,this.response):ct}}return se}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ve.classes.FormData,Blob:Ve.classes.Blob},validateStatus:function(se){return se>=200&&se<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ke.forEach(["delete","get","head","post","put","patch"],ee=>{Ws.headers[ee]={}});var nn=Ws;const Ee=ke.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"]);var $t=ee=>{const se={};let he,pe,Ne;return ee&&ee.split(`
|
||
`).forEach(function(qe){Ne=qe.indexOf(":"),he=qe.substring(0,Ne).trim().toLowerCase(),pe=qe.substring(Ne+1).trim(),!(!he||se[he]&&Ee[he])&&(he==="set-cookie"?se[he]?se[he].push(pe):se[he]=[pe]:se[he]=se[he]?se[he]+", "+pe:pe)}),se};const Xt=Symbol("internals");function Cs(ee){return ee&&String(ee).trim().toLowerCase()}function Mt(ee){return ee===!1||ee==null?ee:ke.isArray(ee)?ee.map(Mt):String(ee)}function ze(ee){const se=Object.create(null),he=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let pe;for(;pe=he.exec(ee);)se[pe[1]]=pe[2];return se}const xt=ee=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(ee.trim());function yt(ee,se,he,pe,Ne){if(ke.isFunction(pe))return pe.call(this,se,he);if(Ne&&(se=he),!!ke.isString(se)){if(ke.isString(pe))return se.indexOf(pe)!==-1;if(ke.isRegExp(pe))return pe.test(se)}}function Ot(ee){return ee.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(se,he,pe)=>he.toUpperCase()+pe)}function Pt(ee,se){const he=ke.toCamelCase(" "+se);["get","set","has"].forEach(pe=>{Object.defineProperty(ee,pe+he,{value:function(Ne,$e,qe){return this[pe].call(this,se,Ne,$e,qe)},configurable:!0})})}class Jt{constructor(se){se&&this.set(se)}set(se,he,pe){const Ne=this;function $e(ct,ds,Kt){const Ft=Cs(ds);if(!Ft)throw new Error("header name must be a non-empty string");const Rs=ke.findKey(Ne,Ft);(!Rs||Ne[Rs]===void 0||Kt===!0||Kt===void 0&&Ne[Rs]!==!1)&&(Ne[Rs||ds]=Mt(ct))}const qe=(ct,ds)=>ke.forEach(ct,(Kt,Ft)=>$e(Kt,Ft,ds));if(ke.isPlainObject(se)||se instanceof this.constructor)qe(se,he);else if(ke.isString(se)&&(se=se.trim())&&!xt(se))qe($t(se),he);else if(ke.isObject(se)&&ke.isIterable(se)){let ct={},ds,Kt;for(const Ft of se){if(!ke.isArray(Ft))throw TypeError("Object iterator must return a key-value pair");ct[Kt=Ft[0]]=(ds=ct[Kt])?ke.isArray(ds)?[...ds,Ft[1]]:[ds,Ft[1]]:Ft[1]}qe(ct,he)}else se!=null&&$e(he,se,pe);return this}get(se,he){if(se=Cs(se),se){const pe=ke.findKey(this,se);if(pe){const Ne=this[pe];if(!he)return Ne;if(he===!0)return ze(Ne);if(ke.isFunction(he))return he.call(this,Ne,pe);if(ke.isRegExp(he))return he.exec(Ne);throw new TypeError("parser must be boolean|regexp|function")}}}has(se,he){if(se=Cs(se),se){const pe=ke.findKey(this,se);return!!(pe&&this[pe]!==void 0&&(!he||yt(this,this[pe],pe,he)))}return!1}delete(se,he){const pe=this;let Ne=!1;function $e(qe){if(qe=Cs(qe),qe){const ct=ke.findKey(pe,qe);ct&&(!he||yt(pe,pe[ct],ct,he))&&(delete pe[ct],Ne=!0)}}return ke.isArray(se)?se.forEach($e):$e(se),Ne}clear(se){const he=Object.keys(this);let pe=he.length,Ne=!1;for(;pe--;){const $e=he[pe];(!se||yt(this,this[$e],$e,se,!0))&&(delete this[$e],Ne=!0)}return Ne}normalize(se){const he=this,pe={};return ke.forEach(this,(Ne,$e)=>{const qe=ke.findKey(pe,$e);if(qe){he[qe]=Mt(Ne),delete he[$e];return}const ct=se?Ot($e):String($e).trim();ct!==$e&&delete he[$e],he[ct]=Mt(Ne),pe[ct]=!0}),this}concat(...se){return this.constructor.concat(this,...se)}toJSON(se){const he=Object.create(null);return ke.forEach(this,(pe,Ne)=>{pe!=null&&pe!==!1&&(he[Ne]=se&&ke.isArray(pe)?pe.join(", "):pe)}),he}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([se,he])=>se+": "+he).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(se){return se instanceof this?se:new this(se)}static concat(se,...he){const pe=new this(se);return he.forEach(Ne=>pe.set(Ne)),pe}static accessor(se){const pe=(this[Xt]=this[Xt]={accessors:{}}).accessors,Ne=this.prototype;function $e(qe){const ct=Cs(qe);pe[ct]||(Pt(Ne,qe),pe[ct]=!0)}return ke.isArray(se)?se.forEach($e):$e(se),this}}Jt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ke.reduceDescriptors(Jt.prototype,({value:ee},se)=>{let he=se[0].toUpperCase()+se.slice(1);return{get:()=>ee,set(pe){this[he]=pe}}}),ke.freezeMethods(Jt);var bs=Jt;function ns(ee,se){const he=this||nn,pe=se||he,Ne=bs.from(pe.headers);let $e=pe.data;return ke.forEach(ee,function(ct){$e=ct.call(he,$e,Ne.normalize(),se?se.status:void 0)}),Ne.normalize(),$e}function Ds(ee){return!!(ee&&ee.__CANCEL__)}class ts extends Bt{constructor(se,he,pe){super(se??"canceled",Bt.ERR_CANCELED,he,pe),this.name="CanceledError",this.__CANCEL__=!0}}var js=ts;function tn(ee,se,he){const pe=he.config.validateStatus;!he.status||!pe||pe(he.status)?ee(he):se(new Bt("Request failed with status code "+he.status,[Bt.ERR_BAD_REQUEST,Bt.ERR_BAD_RESPONSE][Math.floor(he.status/100)-4],he.config,he.request,he))}function vn(ee){const se=/^([-+\w]{1,25})(:?\/\/|:)/.exec(ee);return se&&se[1]||""}function jn(ee,se){ee=ee||10;const he=new Array(ee),pe=new Array(ee);let Ne=0,$e=0,qe;return se=se!==void 0?se:1e3,function(ds){const Kt=Date.now(),Ft=pe[$e];qe||(qe=Kt),he[Ne]=ds,pe[Ne]=Kt;let Rs=$e,cn=0;for(;Rs!==Ne;)cn+=he[Rs++],Rs=Rs%ee;if(Ne=(Ne+1)%ee,Ne===$e&&($e=($e+1)%ee),Kt-qe<se)return;const Kn=Ft&&Kt-Ft;return Kn?Math.round(cn*1e3/Kn):void 0}}function xn(ee,se){let he=0,pe=1e3/se,Ne,$e;const qe=(Kt,Ft=Date.now())=>{he=Ft,Ne=null,$e&&(clearTimeout($e),$e=null),ee(...Kt)};return[(...Kt)=>{const Ft=Date.now(),Rs=Ft-he;Rs>=pe?qe(Kt,Ft):(Ne=Kt,$e||($e=setTimeout(()=>{$e=null,qe(Ne)},pe-Rs)))},()=>Ne&&qe(Ne)]}const gn=(ee,se,he=3)=>{let pe=0;const Ne=jn(50,250);return xn($e=>{const qe=$e.loaded,ct=$e.lengthComputable?$e.total:void 0,ds=qe-pe,Kt=Ne(ds),Ft=qe<=ct;pe=qe;const Rs={loaded:qe,total:ct,progress:ct?qe/ct:void 0,bytes:ds,rate:Kt||void 0,estimated:Kt&&ct&&Ft?(ct-qe)/Kt:void 0,event:$e,lengthComputable:ct!=null,[se?"download":"upload"]:!0};ee(Rs)},he)},Ye=(ee,se)=>{const he=ee!=null;return[pe=>se[0]({lengthComputable:he,total:ee,loaded:pe}),se[1]]},qt=ee=>(...se)=>ke.asap(()=>ee(...se));var Ze=Ve.hasStandardBrowserEnv?((ee,se)=>he=>(he=new URL(he,Ve.origin),ee.protocol===he.protocol&&ee.host===he.host&&(se||ee.port===he.port)))(new URL(Ve.origin),Ve.navigator&&/(msie|trident)/i.test(Ve.navigator.userAgent)):()=>!0,Gt=Ve.hasStandardBrowserEnv?{write(ee,se,he,pe,Ne,$e,qe){if(typeof document>"u")return;const ct=[`${ee}=${encodeURIComponent(se)}`];ke.isNumber(he)&&ct.push(`expires=${new Date(he).toUTCString()}`),ke.isString(pe)&&ct.push(`path=${pe}`),ke.isString(Ne)&&ct.push(`domain=${Ne}`),$e===!0&&ct.push("secure"),ke.isString(qe)&&ct.push(`SameSite=${qe}`),document.cookie=ct.join("; ")},read(ee){if(typeof document>"u")return null;const se=document.cookie.match(new RegExp("(?:^|; )"+ee+"=([^;]*)"));return se?decodeURIComponent(se[1]):null},remove(ee){this.write(ee,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function St(ee){return typeof ee!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(ee)}function qn(ee,se){return se?ee.replace(/\/?\/$/,"")+"/"+se.replace(/^\/+/,""):ee}function Er(ee,se,he){let pe=!St(se);return ee&&(pe||he==!1)?qn(ee,se):se}const Fr=ee=>ee instanceof bs?{...ee}:ee;function wn(ee,se){se=se||{};const he={};function pe(Kt,Ft,Rs,cn){return ke.isPlainObject(Kt)&&ke.isPlainObject(Ft)?ke.merge.call({caseless:cn},Kt,Ft):ke.isPlainObject(Ft)?ke.merge({},Ft):ke.isArray(Ft)?Ft.slice():Ft}function Ne(Kt,Ft,Rs,cn){if(ke.isUndefined(Ft)){if(!ke.isUndefined(Kt))return pe(void 0,Kt,Rs,cn)}else return pe(Kt,Ft,Rs,cn)}function $e(Kt,Ft){if(!ke.isUndefined(Ft))return pe(void 0,Ft)}function qe(Kt,Ft){if(ke.isUndefined(Ft)){if(!ke.isUndefined(Kt))return pe(void 0,Kt)}else return pe(void 0,Ft)}function ct(Kt,Ft,Rs){if(Rs in se)return pe(Kt,Ft);if(Rs in ee)return pe(void 0,Kt)}const ds={url:$e,method:$e,data:$e,baseURL:qe,transformRequest:qe,transformResponse:qe,paramsSerializer:qe,timeout:qe,timeoutMessage:qe,withCredentials:qe,withXSRFToken:qe,adapter:qe,responseType:qe,xsrfCookieName:qe,xsrfHeaderName:qe,onUploadProgress:qe,onDownloadProgress:qe,decompress:qe,maxContentLength:qe,maxBodyLength:qe,beforeRedirect:qe,transport:qe,httpAgent:qe,httpsAgent:qe,cancelToken:qe,socketPath:qe,responseEncoding:qe,validateStatus:ct,headers:(Kt,Ft,Rs)=>Ne(Fr(Kt),Fr(Ft),Rs,!0)};return ke.forEach(Object.keys({...ee,...se}),function(Ft){if(Ft==="__proto__"||Ft==="constructor"||Ft==="prototype")return;const Rs=ke.hasOwnProp(ds,Ft)?ds[Ft]:Ne,cn=Rs(ee[Ft],se[Ft],Ft);ke.isUndefined(cn)&&Rs!==ct||(he[Ft]=cn)}),he}var Js=ee=>{const se=wn({},ee);let{data:he,withXSRFToken:pe,xsrfHeaderName:Ne,xsrfCookieName:$e,headers:qe,auth:ct}=se;if(se.headers=qe=bs.from(qe),se.url=Ke(Er(se.baseURL,se.url,se.allowAbsoluteUrls),ee.params,ee.paramsSerializer),ct&&qe.set("Authorization","Basic "+btoa((ct.username||"")+":"+(ct.password?unescape(encodeURIComponent(ct.password)):""))),ke.isFormData(he)){if(Ve.hasStandardBrowserEnv||Ve.hasStandardBrowserWebWorkerEnv)qe.setContentType(void 0);else if(ke.isFunction(he.getHeaders)){const ds=he.getHeaders(),Kt=["content-type","content-length"];Object.entries(ds).forEach(([Ft,Rs])=>{Kt.includes(Ft.toLowerCase())&&qe.set(Ft,Rs)})}}if(Ve.hasStandardBrowserEnv&&(pe&&ke.isFunction(pe)&&(pe=pe(se)),pe||pe!==!1&&Ze(se.url))){const ds=Ne&&$e&&Gt.read($e);ds&&qe.set(Ne,ds)}return se},It=typeof XMLHttpRequest<"u"&&function(ee){return new Promise(function(he,pe){const Ne=Js(ee);let $e=Ne.data;const qe=bs.from(Ne.headers).normalize();let{responseType:ct,onUploadProgress:ds,onDownloadProgress:Kt}=Ne,Ft,Rs,cn,Kn,zt;function Es(){Kn&&Kn(),zt&&zt(),Ne.cancelToken&&Ne.cancelToken.unsubscribe(Ft),Ne.signal&&Ne.signal.removeEventListener("abort",Ft)}let os=new XMLHttpRequest;os.open(Ne.method.toUpperCase(),Ne.url,!0),os.timeout=Ne.timeout;function On(){if(!os)return;const zn=bs.from("getAllResponseHeaders"in os&&os.getAllResponseHeaders()),$r={data:!ct||ct==="text"||ct==="json"?os.responseText:os.response,status:os.status,statusText:os.statusText,headers:zn,config:ee,request:os};tn(function(dr){he(dr),Es()},function(dr){pe(dr),Es()},$r),os=null}"onloadend"in os?os.onloadend=On:os.onreadystatechange=function(){!os||os.readyState!==4||os.status===0&&!(os.responseURL&&os.responseURL.indexOf("file:")===0)||setTimeout(On)},os.onabort=function(){os&&(pe(new Bt("Request aborted",Bt.ECONNABORTED,ee,os)),os=null)},os.onerror=function(cr){const $r=cr&&cr.message?cr.message:"Network Error",Ha=new Bt($r,Bt.ERR_NETWORK,ee,os);Ha.event=cr||null,pe(Ha),os=null},os.ontimeout=function(){let cr=Ne.timeout?"timeout of "+Ne.timeout+"ms exceeded":"timeout exceeded";const $r=Ne.transitional||et;Ne.timeoutErrorMessage&&(cr=Ne.timeoutErrorMessage),pe(new Bt(cr,$r.clarifyTimeoutError?Bt.ETIMEDOUT:Bt.ECONNABORTED,ee,os)),os=null},$e===void 0&&qe.setContentType(null),"setRequestHeader"in os&&ke.forEach(qe.toJSON(),function(cr,$r){os.setRequestHeader($r,cr)}),ke.isUndefined(Ne.withCredentials)||(os.withCredentials=!!Ne.withCredentials),ct&&ct!=="json"&&(os.responseType=Ne.responseType),Kt&&([cn,zt]=gn(Kt,!0),os.addEventListener("progress",cn)),ds&&os.upload&&([Rs,Kn]=gn(ds),os.upload.addEventListener("progress",Rs),os.upload.addEventListener("loadend",Kn)),(Ne.cancelToken||Ne.signal)&&(Ft=zn=>{os&&(pe(!zn||zn.type?new js(null,ee,os):zn),os.abort(),os=null)},Ne.cancelToken&&Ne.cancelToken.subscribe(Ft),Ne.signal&&(Ne.signal.aborted?Ft():Ne.signal.addEventListener("abort",Ft)));const Cr=vn(Ne.url);if(Cr&&Ve.protocols.indexOf(Cr)===-1){pe(new Bt("Unsupported protocol "+Cr+":",Bt.ERR_BAD_REQUEST,ee));return}os.send($e||null)})},_r=(ee,se)=>{const{length:he}=ee=ee?ee.filter(Boolean):[];if(se||he){let pe=new AbortController,Ne;const $e=function(Kt){if(!Ne){Ne=!0,ct();const Ft=Kt instanceof Error?Kt:this.reason;pe.abort(Ft instanceof Bt?Ft:new js(Ft instanceof Error?Ft.message:Ft))}};let qe=se&&setTimeout(()=>{qe=null,$e(new Bt(`timeout of ${se}ms exceeded`,Bt.ETIMEDOUT))},se);const ct=()=>{ee&&(qe&&clearTimeout(qe),qe=null,ee.forEach(Kt=>{Kt.unsubscribe?Kt.unsubscribe($e):Kt.removeEventListener("abort",$e)}),ee=null)};ee.forEach(Kt=>Kt.addEventListener("abort",$e));const{signal:ds}=pe;return ds.unsubscribe=()=>ke.asap(ct),ds}};const ca=function*(ee,se){let he=ee.byteLength;if(he<se){yield ee;return}let pe=0,Ne;for(;pe<he;)Ne=pe+se,yield ee.slice(pe,Ne),pe=Ne},Ca=async function*(ee,se){for await(const he of Yr(ee))yield*ca(he,se)},Yr=async function*(ee){if(ee[Symbol.asyncIterator]){yield*ee;return}const se=ee.getReader();try{for(;;){const{done:he,value:pe}=await se.read();if(he)break;yield pe}}finally{await se.cancel()}},Nr=(ee,se,he,pe)=>{const Ne=Ca(ee,se);let $e=0,qe,ct=ds=>{qe||(qe=!0,pe&&pe(ds))};return new ReadableStream({async pull(ds){try{const{done:Kt,value:Ft}=await Ne.next();if(Kt){ct(),ds.close();return}let Rs=Ft.byteLength;if(he){let cn=$e+=Rs;he(cn)}ds.enqueue(new Uint8Array(Ft))}catch(Kt){throw ct(Kt),Kt}},cancel(ds){return ct(ds),Ne.return()}},{highWaterMark:2})},kn=64*1024,{isFunction:Sn}=ke,sr=(({Request:ee,Response:se})=>({Request:ee,Response:se}))(ke.global),{ReadableStream:wr,TextEncoder:Sr}=ke.global,yn=(ee,...se)=>{try{return!!ee(...se)}catch{return!1}},Dn=ee=>{ee=ke.merge.call({skipUndefined:!0},sr,ee);const{fetch:se,Request:he,Response:pe}=ee,Ne=se?Sn(se):typeof fetch=="function",$e=Sn(he),qe=Sn(pe);if(!Ne)return!1;const ct=Ne&&Sn(wr),ds=Ne&&(typeof Sr=="function"?(zt=>Es=>zt.encode(Es))(new Sr):async zt=>new Uint8Array(await new he(zt).arrayBuffer())),Kt=$e&&ct&&yn(()=>{let zt=!1;const Es=new he(Ve.origin,{body:new wr,method:"POST",get duplex(){return zt=!0,"half"}}).headers.has("Content-Type");return zt&&!Es}),Ft=qe&&ct&&yn(()=>ke.isReadableStream(new pe("").body)),Rs={stream:Ft&&(zt=>zt.body)};Ne&&["text","arrayBuffer","blob","formData","stream"].forEach(zt=>{!Rs[zt]&&(Rs[zt]=(Es,os)=>{let On=Es&&Es[zt];if(On)return On.call(Es);throw new Bt(`Response type '${zt}' is not supported`,Bt.ERR_NOT_SUPPORT,os)})});const cn=async zt=>{if(zt==null)return 0;if(ke.isBlob(zt))return zt.size;if(ke.isSpecCompliantForm(zt))return(await new he(Ve.origin,{method:"POST",body:zt}).arrayBuffer()).byteLength;if(ke.isArrayBufferView(zt)||ke.isArrayBuffer(zt))return zt.byteLength;if(ke.isURLSearchParams(zt)&&(zt=zt+""),ke.isString(zt))return(await ds(zt)).byteLength},Kn=async(zt,Es)=>{const os=ke.toFiniteNumber(zt.getContentLength());return os??cn(Es)};return async zt=>{let{url:Es,method:os,data:On,signal:Cr,cancelToken:zn,timeout:cr,onDownloadProgress:$r,onUploadProgress:Ha,responseType:dr,headers:jo,withCredentials:Sl="same-origin",fetchOptions:pc}=Js(zt),No=se||fetch;dr=dr?(dr+"").toLowerCase():"text";let Cl=_r([Cr,zn&&zn.toAbortSignal()],cr),Vi=null;const Wa=Cl&&Cl.unsubscribe&&(()=>{Cl.unsubscribe()});let xc;try{if(Ha&&Kt&&os!=="get"&&os!=="head"&&(xc=await Kn(jo,On))!==0){let Ea=new he(Es,{method:"POST",body:On,duplex:"half"}),Ga;if(ke.isFormData(On)&&(Ga=Ea.headers.get("content-type"))&&jo.setContentType(Ga),Ea.body){const[kl,Wi]=Ye(xc,gn(qt(Ha)));On=Nr(Ea.body,kn,kl,Wi)}}ke.isString(Sl)||(Sl=Sl?"include":"omit");const rr=$e&&"credentials"in he.prototype,gc={...pc,signal:Cl,method:os.toUpperCase(),headers:jo.normalize().toJSON(),body:On,duplex:"half",credentials:rr?Sl:void 0};Vi=$e&&new he(Es,gc);let Ra=await($e?No(Vi,pc):No(Es,gc));const Al=Ft&&(dr==="stream"||dr==="response");if(Ft&&($r||Al&&Wa)){const Ea={};["status","statusText","headers"].forEach(wo=>{Ea[wo]=Ra[wo]});const Ga=ke.toFiniteNumber(Ra.headers.get("content-length")),[kl,Wi]=$r&&Ye(Ga,gn(qt($r),!0))||[];Ra=new pe(Nr(Ra.body,kn,kl,()=>{Wi&&Wi(),Wa&&Wa()}),Ea)}dr=dr||"text";let Hi=await Rs[ke.findKey(Rs,dr)||"text"](Ra,zt);return!Al&&Wa&&Wa(),await new Promise((Ea,Ga)=>{tn(Ea,Ga,{data:Hi,headers:bs.from(Ra.headers),status:Ra.status,statusText:Ra.statusText,config:zt,request:Vi})})}catch(rr){throw Wa&&Wa(),rr&&rr.name==="TypeError"&&/Load failed|fetch/i.test(rr.message)?Object.assign(new Bt("Network Error",Bt.ERR_NETWORK,zt,Vi,rr&&rr.response),{cause:rr.cause||rr}):Bt.from(rr,rr&&rr.code,zt,Vi,rr&&rr.response)}}},Aa=new Map,ka=ee=>{let se=ee&&ee.env||{};const{fetch:he,Request:pe,Response:Ne}=se,$e=[pe,Ne,he];let qe=$e.length,ct=qe,ds,Kt,Ft=Aa;for(;ct--;)ds=$e[ct],Kt=Ft.get(ds),Kt===void 0&&Ft.set(ds,Kt=ct?new Map:Dn(se)),Ft=Kt;return Kt};ka();const qi={http:_s,xhr:It,fetch:{get:ka}};ke.forEach(qi,(ee,se)=>{if(ee){try{Object.defineProperty(ee,"name",{value:se})}catch{}Object.defineProperty(ee,"adapterName",{value:se})}});const xi=ee=>`- ${ee}`,gi=ee=>ke.isFunction(ee)||ee===null||ee===!1;function bl(ee,se){ee=ke.isArray(ee)?ee:[ee];const{length:he}=ee;let pe,Ne;const $e={};for(let qe=0;qe<he;qe++){pe=ee[qe];let ct;if(Ne=pe,!gi(pe)&&(Ne=qi[(ct=String(pe)).toLowerCase()],Ne===void 0))throw new Bt(`Unknown adapter '${ct}'`);if(Ne&&(ke.isFunction(Ne)||(Ne=Ne.get(se))))break;$e[ct||"#"+qe]=Ne}if(!Ne){const qe=Object.entries($e).map(([ds,Kt])=>`adapter ${ds} `+(Kt===!1?"is not supported by the environment":"is not available in the build"));let ct=he?qe.length>1?`since :
|
||
`+qe.map(xi).join(`
|
||
`):" "+xi(qe[0]):"as no adapter specified";throw new Bt("There is no suitable adapter to dispatch the request "+ct,"ERR_NOT_SUPPORT")}return Ne}var jl={getAdapter:bl,adapters:qi};function da(ee){if(ee.cancelToken&&ee.cancelToken.throwIfRequested(),ee.signal&&ee.signal.aborted)throw new js(null,ee)}function Da(ee){return da(ee),ee.headers=bs.from(ee.headers),ee.data=ns.call(ee,ee.transformRequest),["post","put","patch"].indexOf(ee.method)!==-1&&ee.headers.setContentType("application/x-www-form-urlencoded",!1),jl.getAdapter(ee.adapter||nn.adapter,ee)(ee).then(function(pe){return da(ee),pe.data=ns.call(ee,ee.transformResponse,pe),pe.headers=bs.from(pe.headers),pe},function(pe){return Ds(pe)||(da(ee),pe&&pe.response&&(pe.response.data=ns.call(ee,ee.transformResponse,pe.response),pe.response.headers=bs.from(pe.response.headers))),Promise.reject(pe)})}const ua="1.13.6",Va={};["object","boolean","number","function","string","symbol"].forEach((ee,se)=>{Va[ee]=function(pe){return typeof pe===ee||"a"+(se<1?"n ":" ")+ee}});const fc={};Va.transitional=function(se,he,pe){function Ne($e,qe){return"[Axios v"+ua+"] Transitional option '"+$e+"'"+qe+(pe?". "+pe:"")}return($e,qe,ct)=>{if(se===!1)throw new Bt(Ne(qe," has been removed"+(he?" in "+he:"")),Bt.ERR_DEPRECATED);return he&&!fc[qe]&&(fc[qe]=!0,console.warn(Ne(qe," has been deprecated since v"+he+" and will be removed in the near future"))),se?se($e,qe,ct):!0}},Va.spelling=function(se){return(he,pe)=>(console.warn(`${pe} is likely a misspelling of ${se}`),!0)};function Rd(ee,se,he){if(typeof ee!="object")throw new Bt("options must be an object",Bt.ERR_BAD_OPTION_VALUE);const pe=Object.keys(ee);let Ne=pe.length;for(;Ne-- >0;){const $e=pe[Ne],qe=se[$e];if(qe){const ct=ee[$e],ds=ct===void 0||qe(ct,$e,ee);if(ds!==!0)throw new Bt("option "+$e+" must be "+ds,Bt.ERR_BAD_OPTION_VALUE);continue}if(he!==!0)throw new Bt("Unknown option "+$e,Bt.ERR_BAD_OPTION)}}var vi={assertOptions:Rd,validators:Va};const nr=vi.validators;class yi{constructor(se){this.defaults=se||{},this.interceptors={request:new Ue,response:new Ue}}async request(se,he){try{return await this._request(se,he)}catch(pe){if(pe instanceof Error){let Ne={};Error.captureStackTrace?Error.captureStackTrace(Ne):Ne=new Error;const $e=Ne.stack?Ne.stack.replace(/^.+\n/,""):"";try{pe.stack?$e&&!String(pe.stack).endsWith($e.replace(/^.+\n.+\n/,""))&&(pe.stack+=`
|
||
`+$e):pe.stack=$e}catch{}}throw pe}}_request(se,he){typeof se=="string"?(he=he||{},he.url=se):he=se||{},he=wn(this.defaults,he);const{transitional:pe,paramsSerializer:Ne,headers:$e}=he;pe!==void 0&&vi.assertOptions(pe,{silentJSONParsing:nr.transitional(nr.boolean),forcedJSONParsing:nr.transitional(nr.boolean),clarifyTimeoutError:nr.transitional(nr.boolean),legacyInterceptorReqResOrdering:nr.transitional(nr.boolean)},!1),Ne!=null&&(ke.isFunction(Ne)?he.paramsSerializer={serialize:Ne}:vi.assertOptions(Ne,{encode:nr.function,serialize:nr.function},!0)),he.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?he.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:he.allowAbsoluteUrls=!0),vi.assertOptions(he,{baseUrl:nr.spelling("baseURL"),withXsrfToken:nr.spelling("withXSRFToken")},!0),he.method=(he.method||this.defaults.method||"get").toLowerCase();let qe=$e&&ke.merge($e.common,$e[he.method]);$e&&ke.forEach(["delete","get","head","post","put","patch","common"],zt=>{delete $e[zt]}),he.headers=bs.concat(qe,$e);const ct=[];let ds=!0;this.interceptors.request.forEach(function(Es){if(typeof Es.runWhen=="function"&&Es.runWhen(he)===!1)return;ds=ds&&Es.synchronous;const os=he.transitional||et;os&&os.legacyInterceptorReqResOrdering?ct.unshift(Es.fulfilled,Es.rejected):ct.push(Es.fulfilled,Es.rejected)});const Kt=[];this.interceptors.response.forEach(function(Es){Kt.push(Es.fulfilled,Es.rejected)});let Ft,Rs=0,cn;if(!ds){const zt=[Da.bind(this),void 0];for(zt.unshift(...ct),zt.push(...Kt),cn=zt.length,Ft=Promise.resolve(he);Rs<cn;)Ft=Ft.then(zt[Rs++],zt[Rs++]);return Ft}cn=ct.length;let Kn=he;for(;Rs<cn;){const zt=ct[Rs++],Es=ct[Rs++];try{Kn=zt(Kn)}catch(os){Es.call(this,os);break}}try{Ft=Da.call(this,Kn)}catch(zt){return Promise.reject(zt)}for(Rs=0,cn=Kt.length;Rs<cn;)Ft=Ft.then(Kt[Rs++],Kt[Rs++]);return Ft}getUri(se){se=wn(this.defaults,se);const he=Er(se.baseURL,se.url,se.allowAbsoluteUrls);return Ke(he,se.params,se.paramsSerializer)}}ke.forEach(["delete","get","head","options"],function(se){yi.prototype[se]=function(he,pe){return this.request(wn(pe||{},{method:se,url:he,data:(pe||{}).data}))}}),ke.forEach(["post","put","patch"],function(se){function he(pe){return function($e,qe,ct){return this.request(wn(ct||{},{method:se,headers:pe?{"Content-Type":"multipart/form-data"}:{},url:$e,data:qe}))}}yi.prototype[se]=he(),yi.prototype[se+"Form"]=he(!0)});var zi=yi;class Br{constructor(se){if(typeof se!="function")throw new TypeError("executor must be a function.");let he;this.promise=new Promise(function($e){he=$e});const pe=this;this.promise.then(Ne=>{if(!pe._listeners)return;let $e=pe._listeners.length;for(;$e-- >0;)pe._listeners[$e](Ne);pe._listeners=null}),this.promise.then=Ne=>{let $e;const qe=new Promise(ct=>{pe.subscribe(ct),$e=ct}).then(Ne);return qe.cancel=function(){pe.unsubscribe($e)},qe},se(function($e,qe,ct){pe.reason||(pe.reason=new js($e,qe,ct),he(pe.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(se){if(this.reason){se(this.reason);return}this._listeners?this._listeners.push(se):this._listeners=[se]}unsubscribe(se){if(!this._listeners)return;const he=this._listeners.indexOf(se);he!==-1&&this._listeners.splice(he,1)}toAbortSignal(){const se=new AbortController,he=pe=>{se.abort(pe)};return this.subscribe(he),se.signal.unsubscribe=()=>this.unsubscribe(he),se.signal}static source(){let se;return{token:new Br(function(Ne){se=Ne}),cancel:se}}}var yo=Br;function Ui(ee){return function(he){return ee.apply(null,he)}}function bo(ee){return ke.isObject(ee)&&ee.isAxiosError===!0}const bi={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(bi).forEach(([ee,se])=>{bi[se]=ee});var Nl=bi;function wl(ee){const se=new zi(ee),he=t(zi.prototype.request,se);return ke.extend(he,zi.prototype,se,{allOwnKeys:!0}),ke.extend(he,se,null,{allOwnKeys:!0}),he.create=function(Ne){return wl(wn(ee,Ne))},he}const rn=wl(nn);return rn.Axios=zi,rn.CanceledError=js,rn.CancelToken=yo,rn.isCancel=Ds,rn.VERSION=ua,rn.toFormData=ie,rn.AxiosError=Bt,rn.Cancel=rn.CanceledError,rn.all=function(se){return Promise.all(se)},rn.spread=Ui,rn.isAxiosError=bo,rn.mergeConfig=wn,rn.AxiosHeaders=bs,rn.formToJSON=ee=>is(ke.isHTMLForm(ee)?new FormData(ee):ee),rn.getAdapter=jl.getAdapter,rn.HttpStatusCode=Nl,rn.default=rn,og=rn,og}var zw;function q4(){if(zw)return pr;zw=1;function t($){return $&&typeof $=="object"&&"default"in $?$.default:$}Object.defineProperty(pr,"__esModule",{value:!0});var s=t($4()),n=function(){return(n=Object.assign||function($){for(var Z,Q=1,W=arguments.length;Q<W;Q++)for(var U in Z=arguments[Q])Object.prototype.hasOwnProperty.call(Z,U)&&($[U]=Z[U]);return $}).apply(this,arguments)},r=function($,Z,Q,W){return new(Q||(Q=Promise))(function(U,M){function z(I){try{F(W.next(I))}catch(K){M(K)}}function T(I){try{F(W.throw(I))}catch(K){M(K)}}function F(I){var K;I.done?U(I.value):(K=I.value,K instanceof Q?K:new Q(function(G){G(K)})).then(z,T)}F((W=W.apply($,[])).next())})},a=function($,Z){var Q,W,U,M,z={label:0,sent:function(){if(1&U[0])throw U[1];return U[1]},trys:[],ops:[]};return M={next:T(0),throw:T(1),return:T(2)},typeof Symbol=="function"&&(M[Symbol.iterator]=function(){return this}),M;function T(F){return function(I){return(function(K){if(Q)throw new TypeError("Generator is already executing.");for(;M&&(M=0,K[0]&&(z=0)),z;)try{if(Q=1,W&&(U=2&K[0]?W.return:K[0]?W.throw||((U=W.return)&&U.call(W),0):W.next)&&!(U=U.call(W,K[1])).done)return U;switch(W=0,U&&(K=[2&K[0],U.value]),K[0]){case 0:case 1:U=K;break;case 4:return z.label++,{value:K[1],done:!1};case 5:z.label++,W=K[1],K=[0];continue;case 7:K=z.ops.pop(),z.trys.pop();continue;default:if(!(U=(U=z.trys).length>0&&U[U.length-1])&&(K[0]===6||K[0]===2)){z=0;continue}if(K[0]===3&&(!U||K[1]>U[0]&&K[1]<U[3])){z.label=K[1];break}if(K[0]===6&&z.label<U[1]){z.label=U[1],U=K;break}if(U&&z.label<U[2]){z.label=U[2],z.ops.push(K);break}U[2]&&z.ops.pop(),z.trys.pop();continue}K=Z.call($,z)}catch(G){K=[6,G],W=0}finally{Q=U=0}if(5&K[0])throw K[1];return{value:K[0]?K[1]:void 0,done:!0}})([F,I])}}},i=function($){return $ instanceof Date?$.getTime():typeof $=="number"||$===null||$===void 0?$:Number($)},o=function($,Z,Q){return Q>=$&&Q<=Z},d=function($){return!!$&&(typeof $=="object"||typeof $=="function")&&typeof $.then=="function"},m={Accept:"application/json","Content-Type":"application/json"},f={timeout:0},p=null,h="CLIENT_ERROR",x="SERVER_ERROR",u="TIMEOUT_ERROR",N="CONNECTION_ERROR",v="NETWORK_ERROR",w="UNKNOWN_ERROR",j="CANCEL_ERROR",b=["ECONNABORTED"],C=["ENOTFOUND","ECONNREFUSED","ECONNRESET"],S=["ERR_BAD_REQUEST","ERR_BAD_RESPONSE"],D=function($){return o(200,299,$)},_=function($){return o(400,499,$)},A=function($){return o(500,599,$)},E=function($){return $.message==="Network Error"?v:s.isCancel($)?j:$.code?S.includes($.code)?q($.response.status):b.includes($.code)?u:C.includes($.code)?N:w:q($.response?$.response.status:null)},q=function($){return $?D($)?p:_($)?h:A($)?x:w:w},O=function($){var Z,Q=n(n({},m),$.headers||{});if($.axiosInstance)Z=$.axiosInstance;else{var W=n(n({},$),{headers:void 0}),U=n(n({},f),W);Z=s.create(U)}var M=[],z=[],T=[],F=[],I=[],K=function(ue,ye){return Q[ue]=ye,Z},G=function(ue){return function(ye,ce,je){return ce===void 0&&(ce={}),je===void 0&&(je={}),Y(n(n({},je),{url:ye,params:ce,method:ue}))}},V=function(ue){return function(ye,ce,je){return je===void 0&&(je={}),Y(n(n({},je),{url:ye,method:ue,data:ce}))}},Y=function(ue){return r(void 0,void 0,void 0,function(){var ye,ce,je,Me;return a(this,function(ut){switch(ut.label){case 0:if(ue.headers=n(n({},Q),ue.headers),z.length>0&&z.forEach(function(jt){return jt(ue)}),!(T.length>0))return[3,6];ye=0,ut.label=1;case 1:return ye<T.length?(ce=T[ye](ue),d(ce)?[4,ce]:[3,3]):[3,6];case 2:return ut.sent(),[3,5];case 3:return[4,ce(ue)];case 4:ut.sent(),ut.label=5;case 5:return ye++,[3,1];case 6:return je=i(new Date),Me=function(jt){return r(void 0,void 0,void 0,function(){var ft;return a(this,function(X){switch(X.label){case 0:return[4,ae(je,jt)];case 1:return ft=X.sent(),[2,re(ft)]}})})},[2,Z.request(ue).then(Me).catch(Me)]}})})},re=function(ue){return M.forEach(function(ye){try{ye(ue)}catch{}}),ue},ae=function(ue,ye){return r(void 0,void 0,void 0,function(){var ce,je,Me,ut,jt,ft,X,Ce,xe,We,Be,rt,ht,ge,Je,mt,de;return a(this,function(at){switch(at.label){case 0:if(ce=i(new Date),je=ce-ue,Me=ye instanceof Error||s.isCancel(ye),ut=ye,jt=ye,ft=Me?jt.response:ut,X=ft&&ft.status||null,Ce=Me?E(ye):q(X),xe=Me?jt:null,We=D(X),Be=ye.config||null,rt=ft&&ft.headers||null,ht=(de=ft&&ft.data)!==null&&de!==void 0?de:null,ge={duration:je,problem:Ce,originalError:xe,ok:We,status:X,headers:rt,config:Be,data:ht},F.length>0&&F.forEach(function(ot){return ot(ge)}),!(I.length>0))return[3,6];Je=0,at.label=1;case 1:return Je<I.length?(mt=I[Je](ge),d(mt)?[4,mt]:[3,3]):[3,6];case 2:return at.sent(),[3,5];case 3:return[4,mt(ge)];case 4:at.sent(),at.label=5;case 5:return Je++,[3,1];case 6:return[2,ge]}})})};return{axiosInstance:Z,monitors:M,addMonitor:function(ue){M.push(ue)},requestTransforms:z,asyncRequestTransforms:T,responseTransforms:F,asyncResponseTransforms:I,addRequestTransform:function(ue){return z.push(ue)},addAsyncRequestTransform:function(ue){return T.push(ue)},addResponseTransform:function(ue){return F.push(ue)},addAsyncResponseTransform:function(ue){return I.push(ue)},setHeader:K,setHeaders:function(ue){return Object.keys(ue).forEach(function(ye){return K(ye,ue[ye])}),Z},deleteHeader:function(ue){return delete Q[ue],Z},headers:Q,setBaseURL:function(ue){return Z.defaults.baseURL=ue,Z},getBaseURL:function(){return Z.defaults.baseURL},any:Y,get:G("get"),delete:G("delete"),head:G("head"),post:V("post"),put:V("put"),patch:V("patch"),link:G("link"),unlink:G("unlink")}},R=s.isCancel,P=s.CancelToken,L={DEFAULT_HEADERS:m,NONE:p,CLIENT_ERROR:h,SERVER_ERROR:x,TIMEOUT_ERROR:u,CONNECTION_ERROR:N,NETWORK_ERROR:v,UNKNOWN_ERROR:w,create:O,isCancel:R,CancelToken:P};return pr.DEFAULT_HEADERS=m,pr.NONE=p,pr.CLIENT_ERROR=h,pr.SERVER_ERROR=x,pr.TIMEOUT_ERROR=u,pr.CONNECTION_ERROR=N,pr.NETWORK_ERROR=v,pr.UNKNOWN_ERROR=w,pr.CANCEL_ERROR=j,pr.getProblemFromError=E,pr.getProblemFromStatus=q,pr.create=O,pr.isCancel=R,pr.CancelToken=P,pr.default=L,pr}var z4=q4();const U4="https://dealeronboarding-uat.royalenfield.com/api",Ie=z4.create({baseURL:U4,headers:{"Content-Type":"application/json",Accept:"application/json"},timeout:3e4});Ie.addRequestTransform(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`)});Ie.addResponseTransform(t=>{var s,n;if(!t.ok&&t.status===401){const r=localStorage.getItem("token");console.error("Unauthorized access - potential token expiration. Token exists in localStorage:",!!r),console.error("Full 401 Response Details:",{url:(s=t.config)==null?void 0:s.url,method:(n=t.config)==null?void 0:n.method,data:t.data}),window.dispatchEvent(new Event("auth:logout"))}});function eA(t,s){return function(){return t.apply(s,arguments)}}const{toString:V4}=Object.prototype,{getPrototypeOf:$y}=Object,{iterator:_f,toStringTag:tA}=Symbol,Tf=(t=>s=>{const n=V4.call(s);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),hi=t=>(t=t.toLowerCase(),s=>Tf(s)===t),Pf=t=>s=>typeof s===t,{isArray:pd}=Array,sd=Pf("undefined");function Mu(t){return t!==null&&!sd(t)&&t.constructor!==null&&!sd(t.constructor)&&ra(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const sA=hi("ArrayBuffer");function H4(t){let s;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?s=ArrayBuffer.isView(t):s=t&&t.buffer&&sA(t.buffer),s}const W4=Pf("string"),ra=Pf("function"),nA=Pf("number"),Fu=t=>t!==null&&typeof t=="object",G4=t=>t===!0||t===!1,Pm=t=>{if(Tf(t)!=="object")return!1;const s=$y(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(tA in t)&&!(_f in t)},K4=t=>{if(!Fu(t)||Mu(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Y4=hi("Date"),Z4=hi("File"),Q4=t=>!!(t&&typeof t.uri<"u"),X4=t=>t&&typeof t.getParts<"u",J4=hi("Blob"),eO=hi("FileList"),tO=t=>Fu(t)&&ra(t.pipe);function sO(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Uw=sO(),Vw=typeof Uw.FormData<"u"?Uw.FormData:void 0,nO=t=>{let s;return t&&(Vw&&t instanceof Vw||ra(t.append)&&((s=Tf(t))==="formdata"||s==="object"&&ra(t.toString)&&t.toString()==="[object FormData]"))},rO=hi("URLSearchParams"),[aO,iO,lO,oO]=["ReadableStream","Request","Response","Headers"].map(hi),cO=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bu(t,s,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,a;if(typeof t!="object"&&(t=[t]),pd(t))for(r=0,a=t.length;r<a;r++)s.call(null,t[r],r,t);else{if(Mu(t))return;const i=n?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let d;for(r=0;r<o;r++)d=i[r],s.call(null,t[d],d,t)}}function rA(t,s){if(Mu(t))return null;s=s.toLowerCase();const n=Object.keys(t);let r=n.length,a;for(;r-- >0;)if(a=n[r],s===a.toLowerCase())return a;return null}const Ho=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,aA=t=>!sd(t)&&t!==Ho;function Gv(){const{caseless:t,skipUndefined:s}=aA(this)&&this||{},n={},r=(a,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const o=t&&rA(n,i)||i;Pm(n[o])&&Pm(a)?n[o]=Gv(n[o],a):Pm(a)?n[o]=Gv({},a):pd(a)?n[o]=a.slice():(!s||!sd(a))&&(n[o]=a)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&Bu(arguments[a],r);return n}const dO=(t,s,n,{allOwnKeys:r}={})=>(Bu(s,(a,i)=>{n&&ra(a)?Object.defineProperty(t,i,{value:eA(a,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,i,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),uO=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),hO=(t,s,n,r)=>{t.prototype=Object.create(s.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:s.prototype}),n&&Object.assign(t.prototype,n)},mO=(t,s,n,r)=>{let a,i,o;const d={};if(s=s||{},t==null)return s;do{for(a=Object.getOwnPropertyNames(t),i=a.length;i-- >0;)o=a[i],(!r||r(o,t,s))&&!d[o]&&(s[o]=t[o],d[o]=!0);t=n!==!1&&$y(t)}while(t&&(!n||n(t,s))&&t!==Object.prototype);return s},fO=(t,s,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=s.length;const r=t.indexOf(s,n);return r!==-1&&r===n},pO=t=>{if(!t)return null;if(pd(t))return t;let s=t.length;if(!nA(s))return null;const n=new Array(s);for(;s-- >0;)n[s]=t[s];return n},xO=(t=>s=>t&&s instanceof t)(typeof Uint8Array<"u"&&$y(Uint8Array)),gO=(t,s)=>{const r=(t&&t[_f]).call(t);let a;for(;(a=r.next())&&!a.done;){const i=a.value;s.call(t,i[0],i[1])}},vO=(t,s)=>{let n;const r=[];for(;(n=t.exec(s))!==null;)r.push(n);return r},yO=hi("HTMLFormElement"),bO=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),Hw=(({hasOwnProperty:t})=>(s,n)=>t.call(s,n))(Object.prototype),jO=hi("RegExp"),iA=(t,s)=>{const n=Object.getOwnPropertyDescriptors(t),r={};Bu(n,(a,i)=>{let o;(o=s(a,i,t))!==!1&&(r[i]=o||a)}),Object.defineProperties(t,r)},NO=t=>{iA(t,(s,n)=>{if(ra(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(ra(r)){if(s.enumerable=!1,"writable"in s){s.writable=!1;return}s.set||(s.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},wO=(t,s)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return pd(t)?r(t):r(String(t).split(s)),n},SO=()=>{},CO=(t,s)=>t!=null&&Number.isFinite(t=+t)?t:s;function AO(t){return!!(t&&ra(t.append)&&t[tA]==="FormData"&&t[_f])}const kO=t=>{const s=new Array(10),n=(r,a)=>{if(Fu(r)){if(s.indexOf(r)>=0)return;if(Mu(r))return r;if(!("toJSON"in r)){s[a]=r;const i=pd(r)?[]:{};return Bu(r,(o,d)=>{const m=n(o,a+1);!sd(m)&&(i[d]=m)}),s[a]=void 0,i}}return r};return n(t,0)},DO=hi("AsyncFunction"),RO=t=>t&&(Fu(t)||ra(t))&&ra(t.then)&&ra(t.catch),lA=((t,s)=>t?setImmediate:s?((n,r)=>(Ho.addEventListener("message",({source:a,data:i})=>{a===Ho&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),Ho.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ra(Ho.postMessage)),EO=typeof queueMicrotask<"u"?queueMicrotask.bind(Ho):typeof process<"u"&&process.nextTick||lA,_O=t=>t!=null&&ra(t[_f]),tt={isArray:pd,isArrayBuffer:sA,isBuffer:Mu,isFormData:nO,isArrayBufferView:H4,isString:W4,isNumber:nA,isBoolean:G4,isObject:Fu,isPlainObject:Pm,isEmptyObject:K4,isReadableStream:aO,isRequest:iO,isResponse:lO,isHeaders:oO,isUndefined:sd,isDate:Y4,isFile:Z4,isReactNativeBlob:Q4,isReactNative:X4,isBlob:J4,isRegExp:jO,isFunction:ra,isStream:tO,isURLSearchParams:rO,isTypedArray:xO,isFileList:eO,forEach:Bu,merge:Gv,extend:dO,trim:cO,stripBOM:uO,inherits:hO,toFlatObject:mO,kindOf:Tf,kindOfTest:hi,endsWith:fO,toArray:pO,forEachEntry:gO,matchAll:vO,isHTMLForm:yO,hasOwnProperty:Hw,hasOwnProp:Hw,reduceDescriptors:iA,freezeMethods:NO,toObjectSet:wO,toCamelCase:bO,noop:SO,toFiniteNumber:CO,findKey:rA,global:Ho,isContextDefined:aA,isSpecCompliantForm:AO,toJSONObject:kO,isAsyncFn:DO,isThenable:RO,setImmediate:lA,asap:EO,isIterable:_O};let zs=class oA extends Error{static from(s,n,r,a,i,o){const d=new oA(s.message,n||s.code,r,a,i);return d.cause=s,d.name=s.name,s.status!=null&&d.status==null&&(d.status=s.status),o&&Object.assign(d,o),d}constructor(s,n,r,a,i){super(s),Object.defineProperty(this,"message",{value:s,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),a&&(this.request=a),i&&(this.response=i,this.status=i.status)}toJSON(){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:tt.toJSONObject(this.config),code:this.code,status:this.status}}};zs.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";zs.ERR_BAD_OPTION="ERR_BAD_OPTION";zs.ECONNABORTED="ECONNABORTED";zs.ETIMEDOUT="ETIMEDOUT";zs.ERR_NETWORK="ERR_NETWORK";zs.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";zs.ERR_DEPRECATED="ERR_DEPRECATED";zs.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";zs.ERR_BAD_REQUEST="ERR_BAD_REQUEST";zs.ERR_CANCELED="ERR_CANCELED";zs.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";zs.ERR_INVALID_URL="ERR_INVALID_URL";const TO=null;function Kv(t){return tt.isPlainObject(t)||tt.isArray(t)}function cA(t){return tt.endsWith(t,"[]")?t.slice(0,-2):t}function cg(t,s,n){return t?t.concat(s).map(function(a,i){return a=cA(a),!n&&i?"["+a+"]":a}).join(n?".":""):s}function PO(t){return tt.isArray(t)&&!t.some(Kv)}const OO=tt.toFlatObject(tt,{},null,function(s){return/^is[A-Z]/.test(s)});function Of(t,s,n){if(!tt.isObject(t))throw new TypeError("target must be an object");s=s||new FormData,n=tt.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,w){return!tt.isUndefined(w[v])});const r=n.metaTokens,a=n.visitor||p,i=n.dots,o=n.indexes,m=(n.Blob||typeof Blob<"u"&&Blob)&&tt.isSpecCompliantForm(s);if(!tt.isFunction(a))throw new TypeError("visitor must be a function");function f(N){if(N===null)return"";if(tt.isDate(N))return N.toISOString();if(tt.isBoolean(N))return N.toString();if(!m&&tt.isBlob(N))throw new zs("Blob is not supported. Use a Buffer instead.");return tt.isArrayBuffer(N)||tt.isTypedArray(N)?m&&typeof Blob=="function"?new Blob([N]):Buffer.from(N):N}function p(N,v,w){let j=N;if(tt.isReactNative(s)&&tt.isReactNativeBlob(N))return s.append(cg(w,v,i),f(N)),!1;if(N&&!w&&typeof N=="object"){if(tt.endsWith(v,"{}"))v=r?v:v.slice(0,-2),N=JSON.stringify(N);else if(tt.isArray(N)&&PO(N)||(tt.isFileList(N)||tt.endsWith(v,"[]"))&&(j=tt.toArray(N)))return v=cA(v),j.forEach(function(C,S){!(tt.isUndefined(C)||C===null)&&s.append(o===!0?cg([v],S,i):o===null?v:v+"[]",f(C))}),!1}return Kv(N)?!0:(s.append(cg(w,v,i),f(N)),!1)}const h=[],x=Object.assign(OO,{defaultVisitor:p,convertValue:f,isVisitable:Kv});function u(N,v){if(!tt.isUndefined(N)){if(h.indexOf(N)!==-1)throw Error("Circular reference detected in "+v.join("."));h.push(N),tt.forEach(N,function(j,b){(!(tt.isUndefined(j)||j===null)&&a.call(s,j,tt.isString(b)?b.trim():b,v,x))===!0&&u(j,v?v.concat(b):[b])}),h.pop()}}if(!tt.isObject(t))throw new TypeError("data must be an object");return u(t),s}function Ww(t){const s={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return s[r]})}function qy(t,s){this._pairs=[],t&&Of(t,this,s)}const dA=qy.prototype;dA.append=function(s,n){this._pairs.push([s,n])};dA.toString=function(s){const n=s?function(r){return s.call(this,r,Ww)}:Ww;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function LO(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function uA(t,s,n){if(!s)return t;const r=n&&n.encode||LO,a=tt.isFunction(n)?{serialize:n}:n,i=a&&a.serialize;let o;if(i?o=i(s,a):o=tt.isURLSearchParams(s)?s.toString():new qy(s,a).toString(r),o){const d=t.indexOf("#");d!==-1&&(t=t.slice(0,d)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Gw{constructor(){this.handlers=[]}use(s,n,r){return this.handlers.push({fulfilled:s,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(s){this.handlers[s]&&(this.handlers[s]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(s){tt.forEach(this.handlers,function(r){r!==null&&s(r)})}}const zy={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},IO=typeof URLSearchParams<"u"?URLSearchParams:qy,MO=typeof FormData<"u"?FormData:null,FO=typeof Blob<"u"?Blob:null,BO={isBrowser:!0,classes:{URLSearchParams:IO,FormData:MO,Blob:FO},protocols:["http","https","file","blob","url","data"]},Uy=typeof window<"u"&&typeof document<"u",Yv=typeof navigator=="object"&&navigator||void 0,$O=Uy&&(!Yv||["ReactNative","NativeScript","NS"].indexOf(Yv.product)<0),qO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",zO=Uy&&window.location.href||"http://localhost",UO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Uy,hasStandardBrowserEnv:$O,hasStandardBrowserWebWorkerEnv:qO,navigator:Yv,origin:zO},Symbol.toStringTag,{value:"Module"})),Ir={...UO,...BO};function VO(t,s){return Of(t,new Ir.classes.URLSearchParams,{visitor:function(n,r,a,i){return Ir.isNode&&tt.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...s})}function HO(t){return tt.matchAll(/\w+|\[(\w*)]/g,t).map(s=>s[0]==="[]"?"":s[1]||s[0])}function WO(t){const s={},n=Object.keys(t);let r;const a=n.length;let i;for(r=0;r<a;r++)i=n[r],s[i]=t[i];return s}function hA(t){function s(n,r,a,i){let o=n[i++];if(o==="__proto__")return!0;const d=Number.isFinite(+o),m=i>=n.length;return o=!o&&tt.isArray(a)?a.length:o,m?(tt.hasOwnProp(a,o)?a[o]=[a[o],r]:a[o]=r,!d):((!a[o]||!tt.isObject(a[o]))&&(a[o]=[]),s(n,r,a[o],i)&&tt.isArray(a[o])&&(a[o]=WO(a[o])),!d)}if(tt.isFormData(t)&&tt.isFunction(t.entries)){const n={};return tt.forEachEntry(t,(r,a)=>{s(HO(r),a,n,0)}),n}return null}function GO(t,s,n){if(tt.isString(t))try{return(s||JSON.parse)(t),tt.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const $u={transitional:zy,adapter:["xhr","http","fetch"],transformRequest:[function(s,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=tt.isObject(s);if(i&&tt.isHTMLForm(s)&&(s=new FormData(s)),tt.isFormData(s))return a?JSON.stringify(hA(s)):s;if(tt.isArrayBuffer(s)||tt.isBuffer(s)||tt.isStream(s)||tt.isFile(s)||tt.isBlob(s)||tt.isReadableStream(s))return s;if(tt.isArrayBufferView(s))return s.buffer;if(tt.isURLSearchParams(s))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let d;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return VO(s,this.formSerializer).toString();if((d=tt.isFileList(s))||r.indexOf("multipart/form-data")>-1){const m=this.env&&this.env.FormData;return Of(d?{"files[]":s}:s,m&&new m,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),GO(s)):s}],transformResponse:[function(s){const n=this.transitional||$u.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(tt.isResponse(s)||tt.isReadableStream(s))return s;if(s&&tt.isString(s)&&(r&&!this.responseType||a)){const o=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(s,this.parseReviver)}catch(d){if(o)throw d.name==="SyntaxError"?zs.from(d,zs.ERR_BAD_RESPONSE,this,null,this.response):d}}return s}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ir.classes.FormData,Blob:Ir.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};tt.forEach(["delete","get","head","post","put","patch"],t=>{$u.headers[t]={}});const KO=tt.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"]),YO=t=>{const s={};let n,r,a;return t&&t.split(`
|
||
`).forEach(function(o){a=o.indexOf(":"),n=o.substring(0,a).trim().toLowerCase(),r=o.substring(a+1).trim(),!(!n||s[n]&&KO[n])&&(n==="set-cookie"?s[n]?s[n].push(r):s[n]=[r]:s[n]=s[n]?s[n]+", "+r:r)}),s},Kw=Symbol("internals");function Jd(t){return t&&String(t).trim().toLowerCase()}function Om(t){return t===!1||t==null?t:tt.isArray(t)?t.map(Om):String(t)}function ZO(t){const s=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)s[r[1]]=r[2];return s}const QO=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function dg(t,s,n,r,a){if(tt.isFunction(r))return r.call(this,s,n);if(a&&(s=n),!!tt.isString(s)){if(tt.isString(r))return s.indexOf(r)!==-1;if(tt.isRegExp(r))return r.test(s)}}function XO(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(s,n,r)=>n.toUpperCase()+r)}function JO(t,s){const n=tt.toCamelCase(" "+s);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(a,i,o){return this[r].call(this,s,a,i,o)},configurable:!0})})}let aa=class{constructor(s){s&&this.set(s)}set(s,n,r){const a=this;function i(d,m,f){const p=Jd(m);if(!p)throw new Error("header name must be a non-empty string");const h=tt.findKey(a,p);(!h||a[h]===void 0||f===!0||f===void 0&&a[h]!==!1)&&(a[h||m]=Om(d))}const o=(d,m)=>tt.forEach(d,(f,p)=>i(f,p,m));if(tt.isPlainObject(s)||s instanceof this.constructor)o(s,n);else if(tt.isString(s)&&(s=s.trim())&&!QO(s))o(YO(s),n);else if(tt.isObject(s)&&tt.isIterable(s)){let d={},m,f;for(const p of s){if(!tt.isArray(p))throw TypeError("Object iterator must return a key-value pair");d[f=p[0]]=(m=d[f])?tt.isArray(m)?[...m,p[1]]:[m,p[1]]:p[1]}o(d,n)}else s!=null&&i(n,s,r);return this}get(s,n){if(s=Jd(s),s){const r=tt.findKey(this,s);if(r){const a=this[r];if(!n)return a;if(n===!0)return ZO(a);if(tt.isFunction(n))return n.call(this,a,r);if(tt.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,n){if(s=Jd(s),s){const r=tt.findKey(this,s);return!!(r&&this[r]!==void 0&&(!n||dg(this,this[r],r,n)))}return!1}delete(s,n){const r=this;let a=!1;function i(o){if(o=Jd(o),o){const d=tt.findKey(r,o);d&&(!n||dg(r,r[d],d,n))&&(delete r[d],a=!0)}}return tt.isArray(s)?s.forEach(i):i(s),a}clear(s){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const i=n[r];(!s||dg(this,this[i],i,s,!0))&&(delete this[i],a=!0)}return a}normalize(s){const n=this,r={};return tt.forEach(this,(a,i)=>{const o=tt.findKey(r,i);if(o){n[o]=Om(a),delete n[i];return}const d=s?XO(i):String(i).trim();d!==i&&delete n[i],n[d]=Om(a),r[d]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const n=Object.create(null);return tt.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=s&&tt.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([s,n])=>s+": "+n).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(s){return s instanceof this?s:new this(s)}static concat(s,...n){const r=new this(s);return n.forEach(a=>r.set(a)),r}static accessor(s){const r=(this[Kw]=this[Kw]={accessors:{}}).accessors,a=this.prototype;function i(o){const d=Jd(o);r[d]||(JO(a,o),r[d]=!0)}return tt.isArray(s)?s.forEach(i):i(s),this}};aa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);tt.reduceDescriptors(aa.prototype,({value:t},s)=>{let n=s[0].toUpperCase()+s.slice(1);return{get:()=>t,set(r){this[n]=r}}});tt.freezeMethods(aa);function ug(t,s){const n=this||$u,r=s||n,a=aa.from(r.headers);let i=r.data;return tt.forEach(t,function(d){i=d.call(n,i,a.normalize(),s?s.status:void 0)}),a.normalize(),i}function mA(t){return!!(t&&t.__CANCEL__)}let qu=class extends zs{constructor(s,n,r){super(s??"canceled",zs.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function fA(t,s,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):s(new zs("Request failed with status code "+n.status,[zs.ERR_BAD_REQUEST,zs.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function e5(t){const s=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return s&&s[1]||""}function t5(t,s){t=t||10;const n=new Array(t),r=new Array(t);let a=0,i=0,o;return s=s!==void 0?s:1e3,function(m){const f=Date.now(),p=r[i];o||(o=f),n[a]=m,r[a]=f;let h=i,x=0;for(;h!==a;)x+=n[h++],h=h%t;if(a=(a+1)%t,a===i&&(i=(i+1)%t),f-o<s)return;const u=p&&f-p;return u?Math.round(x*1e3/u):void 0}}function s5(t,s){let n=0,r=1e3/s,a,i;const o=(f,p=Date.now())=>{n=p,a=null,i&&(clearTimeout(i),i=null),t(...f)};return[(...f)=>{const p=Date.now(),h=p-n;h>=r?o(f,p):(a=f,i||(i=setTimeout(()=>{i=null,o(a)},r-h)))},()=>a&&o(a)]}const sf=(t,s,n=3)=>{let r=0;const a=t5(50,250);return s5(i=>{const o=i.loaded,d=i.lengthComputable?i.total:void 0,m=o-r,f=a(m),p=o<=d;r=o;const h={loaded:o,total:d,progress:d?o/d:void 0,bytes:m,rate:f||void 0,estimated:f&&d&&p?(d-o)/f:void 0,event:i,lengthComputable:d!=null,[s?"download":"upload"]:!0};t(h)},n)},Yw=(t,s)=>{const n=t!=null;return[r=>s[0]({lengthComputable:n,total:t,loaded:r}),s[1]]},Zw=t=>(...s)=>tt.asap(()=>t(...s)),n5=Ir.hasStandardBrowserEnv?((t,s)=>n=>(n=new URL(n,Ir.origin),t.protocol===n.protocol&&t.host===n.host&&(s||t.port===n.port)))(new URL(Ir.origin),Ir.navigator&&/(msie|trident)/i.test(Ir.navigator.userAgent)):()=>!0,r5=Ir.hasStandardBrowserEnv?{write(t,s,n,r,a,i,o){if(typeof document>"u")return;const d=[`${t}=${encodeURIComponent(s)}`];tt.isNumber(n)&&d.push(`expires=${new Date(n).toUTCString()}`),tt.isString(r)&&d.push(`path=${r}`),tt.isString(a)&&d.push(`domain=${a}`),i===!0&&d.push("secure"),tt.isString(o)&&d.push(`SameSite=${o}`),document.cookie=d.join("; ")},read(t){if(typeof document>"u")return null;const s=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function a5(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function i5(t,s){return s?t.replace(/\/?\/$/,"")+"/"+s.replace(/^\/+/,""):t}function pA(t,s,n){let r=!a5(s);return t&&(r||n==!1)?i5(t,s):s}const Qw=t=>t instanceof aa?{...t}:t;function tc(t,s){s=s||{};const n={};function r(f,p,h,x){return tt.isPlainObject(f)&&tt.isPlainObject(p)?tt.merge.call({caseless:x},f,p):tt.isPlainObject(p)?tt.merge({},p):tt.isArray(p)?p.slice():p}function a(f,p,h,x){if(tt.isUndefined(p)){if(!tt.isUndefined(f))return r(void 0,f,h,x)}else return r(f,p,h,x)}function i(f,p){if(!tt.isUndefined(p))return r(void 0,p)}function o(f,p){if(tt.isUndefined(p)){if(!tt.isUndefined(f))return r(void 0,f)}else return r(void 0,p)}function d(f,p,h){if(h in s)return r(f,p);if(h in t)return r(void 0,f)}const m={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:d,headers:(f,p,h)=>a(Qw(f),Qw(p),h,!0)};return tt.forEach(Object.keys({...t,...s}),function(p){if(p==="__proto__"||p==="constructor"||p==="prototype")return;const h=tt.hasOwnProp(m,p)?m[p]:a,x=h(t[p],s[p],p);tt.isUndefined(x)&&h!==d||(n[p]=x)}),n}const xA=t=>{const s=tc({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:o,auth:d}=s;if(s.headers=o=aa.from(o),s.url=uA(pA(s.baseURL,s.url,s.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&o.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),tt.isFormData(n)){if(Ir.hasStandardBrowserEnv||Ir.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(tt.isFunction(n.getHeaders)){const m=n.getHeaders(),f=["content-type","content-length"];Object.entries(m).forEach(([p,h])=>{f.includes(p.toLowerCase())&&o.set(p,h)})}}if(Ir.hasStandardBrowserEnv&&(r&&tt.isFunction(r)&&(r=r(s)),r||r!==!1&&n5(s.url))){const m=a&&i&&r5.read(i);m&&o.set(a,m)}return s},l5=typeof XMLHttpRequest<"u",o5=l5&&function(t){return new Promise(function(n,r){const a=xA(t);let i=a.data;const o=aa.from(a.headers).normalize();let{responseType:d,onUploadProgress:m,onDownloadProgress:f}=a,p,h,x,u,N;function v(){u&&u(),N&&N(),a.cancelToken&&a.cancelToken.unsubscribe(p),a.signal&&a.signal.removeEventListener("abort",p)}let w=new XMLHttpRequest;w.open(a.method.toUpperCase(),a.url,!0),w.timeout=a.timeout;function j(){if(!w)return;const C=aa.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),D={data:!d||d==="text"||d==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:C,config:t,request:w};fA(function(A){n(A),v()},function(A){r(A),v()},D),w=null}"onloadend"in w?w.onloadend=j:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(j)},w.onabort=function(){w&&(r(new zs("Request aborted",zs.ECONNABORTED,t,w)),w=null)},w.onerror=function(S){const D=S&&S.message?S.message:"Network Error",_=new zs(D,zs.ERR_NETWORK,t,w);_.event=S||null,r(_),w=null},w.ontimeout=function(){let S=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const D=a.transitional||zy;a.timeoutErrorMessage&&(S=a.timeoutErrorMessage),r(new zs(S,D.clarifyTimeoutError?zs.ETIMEDOUT:zs.ECONNABORTED,t,w)),w=null},i===void 0&&o.setContentType(null),"setRequestHeader"in w&&tt.forEach(o.toJSON(),function(S,D){w.setRequestHeader(D,S)}),tt.isUndefined(a.withCredentials)||(w.withCredentials=!!a.withCredentials),d&&d!=="json"&&(w.responseType=a.responseType),f&&([x,N]=sf(f,!0),w.addEventListener("progress",x)),m&&w.upload&&([h,u]=sf(m),w.upload.addEventListener("progress",h),w.upload.addEventListener("loadend",u)),(a.cancelToken||a.signal)&&(p=C=>{w&&(r(!C||C.type?new qu(null,t,w):C),w.abort(),w=null)},a.cancelToken&&a.cancelToken.subscribe(p),a.signal&&(a.signal.aborted?p():a.signal.addEventListener("abort",p)));const b=e5(a.url);if(b&&Ir.protocols.indexOf(b)===-1){r(new zs("Unsupported protocol "+b+":",zs.ERR_BAD_REQUEST,t));return}w.send(i||null)})},c5=(t,s)=>{const{length:n}=t=t?t.filter(Boolean):[];if(s||n){let r=new AbortController,a;const i=function(f){if(!a){a=!0,d();const p=f instanceof Error?f:this.reason;r.abort(p instanceof zs?p:new qu(p instanceof Error?p.message:p))}};let o=s&&setTimeout(()=>{o=null,i(new zs(`timeout of ${s}ms exceeded`,zs.ETIMEDOUT))},s);const d=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(i):f.removeEventListener("abort",i)}),t=null)};t.forEach(f=>f.addEventListener("abort",i));const{signal:m}=r;return m.unsubscribe=()=>tt.asap(d),m}},d5=function*(t,s){let n=t.byteLength;if(n<s){yield t;return}let r=0,a;for(;r<n;)a=r+s,yield t.slice(r,a),r=a},u5=async function*(t,s){for await(const n of h5(t))yield*d5(n,s)},h5=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const s=t.getReader();try{for(;;){const{done:n,value:r}=await s.read();if(n)break;yield r}}finally{await s.cancel()}},Xw=(t,s,n,r)=>{const a=u5(t,s);let i=0,o,d=m=>{o||(o=!0,r&&r(m))};return new ReadableStream({async pull(m){try{const{done:f,value:p}=await a.next();if(f){d(),m.close();return}let h=p.byteLength;if(n){let x=i+=h;n(x)}m.enqueue(new Uint8Array(p))}catch(f){throw d(f),f}},cancel(m){return d(m),a.return()}},{highWaterMark:2})},Jw=64*1024,{isFunction:om}=tt,m5=(({Request:t,Response:s})=>({Request:t,Response:s}))(tt.global),{ReadableStream:e1,TextEncoder:t1}=tt.global,s1=(t,...s)=>{try{return!!t(...s)}catch{return!1}},f5=t=>{t=tt.merge.call({skipUndefined:!0},m5,t);const{fetch:s,Request:n,Response:r}=t,a=s?om(s):typeof fetch=="function",i=om(n),o=om(r);if(!a)return!1;const d=a&&om(e1),m=a&&(typeof t1=="function"?(N=>v=>N.encode(v))(new t1):async N=>new Uint8Array(await new n(N).arrayBuffer())),f=i&&d&&s1(()=>{let N=!1;const v=new n(Ir.origin,{body:new e1,method:"POST",get duplex(){return N=!0,"half"}}).headers.has("Content-Type");return N&&!v}),p=o&&d&&s1(()=>tt.isReadableStream(new r("").body)),h={stream:p&&(N=>N.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(N=>{!h[N]&&(h[N]=(v,w)=>{let j=v&&v[N];if(j)return j.call(v);throw new zs(`Response type '${N}' is not supported`,zs.ERR_NOT_SUPPORT,w)})});const x=async N=>{if(N==null)return 0;if(tt.isBlob(N))return N.size;if(tt.isSpecCompliantForm(N))return(await new n(Ir.origin,{method:"POST",body:N}).arrayBuffer()).byteLength;if(tt.isArrayBufferView(N)||tt.isArrayBuffer(N))return N.byteLength;if(tt.isURLSearchParams(N)&&(N=N+""),tt.isString(N))return(await m(N)).byteLength},u=async(N,v)=>{const w=tt.toFiniteNumber(N.getContentLength());return w??x(v)};return async N=>{let{url:v,method:w,data:j,signal:b,cancelToken:C,timeout:S,onDownloadProgress:D,onUploadProgress:_,responseType:A,headers:E,withCredentials:q="same-origin",fetchOptions:O}=xA(N),R=s||fetch;A=A?(A+"").toLowerCase():"text";let P=c5([b,C&&C.toAbortSignal()],S),L=null;const $=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let Z;try{if(_&&f&&w!=="get"&&w!=="head"&&(Z=await u(E,j))!==0){let T=new n(v,{method:"POST",body:j,duplex:"half"}),F;if(tt.isFormData(j)&&(F=T.headers.get("content-type"))&&E.setContentType(F),T.body){const[I,K]=Yw(Z,sf(Zw(_)));j=Xw(T.body,Jw,I,K)}}tt.isString(q)||(q=q?"include":"omit");const Q=i&&"credentials"in n.prototype,W={...O,signal:P,method:w.toUpperCase(),headers:E.normalize().toJSON(),body:j,duplex:"half",credentials:Q?q:void 0};L=i&&new n(v,W);let U=await(i?R(L,O):R(v,W));const M=p&&(A==="stream"||A==="response");if(p&&(D||M&&$)){const T={};["status","statusText","headers"].forEach(G=>{T[G]=U[G]});const F=tt.toFiniteNumber(U.headers.get("content-length")),[I,K]=D&&Yw(F,sf(Zw(D),!0))||[];U=new r(Xw(U.body,Jw,I,()=>{K&&K(),$&&$()}),T)}A=A||"text";let z=await h[tt.findKey(h,A)||"text"](U,N);return!M&&$&&$(),await new Promise((T,F)=>{fA(T,F,{data:z,headers:aa.from(U.headers),status:U.status,statusText:U.statusText,config:N,request:L})})}catch(Q){throw $&&$(),Q&&Q.name==="TypeError"&&/Load failed|fetch/i.test(Q.message)?Object.assign(new zs("Network Error",zs.ERR_NETWORK,N,L,Q&&Q.response),{cause:Q.cause||Q}):zs.from(Q,Q&&Q.code,N,L,Q&&Q.response)}}},p5=new Map,gA=t=>{let s=t&&t.env||{};const{fetch:n,Request:r,Response:a}=s,i=[r,a,n];let o=i.length,d=o,m,f,p=p5;for(;d--;)m=i[d],f=p.get(m),f===void 0&&p.set(m,f=d?new Map:f5(s)),p=f;return f};gA();const Vy={http:TO,xhr:o5,fetch:{get:gA}};tt.forEach(Vy,(t,s)=>{if(t){try{Object.defineProperty(t,"name",{value:s})}catch{}Object.defineProperty(t,"adapterName",{value:s})}});const n1=t=>`- ${t}`,x5=t=>tt.isFunction(t)||t===null||t===!1;function g5(t,s){t=tt.isArray(t)?t:[t];const{length:n}=t;let r,a;const i={};for(let o=0;o<n;o++){r=t[o];let d;if(a=r,!x5(r)&&(a=Vy[(d=String(r)).toLowerCase()],a===void 0))throw new zs(`Unknown adapter '${d}'`);if(a&&(tt.isFunction(a)||(a=a.get(s))))break;i[d||"#"+o]=a}if(!a){const o=Object.entries(i).map(([m,f])=>`adapter ${m} `+(f===!1?"is not supported by the environment":"is not available in the build"));let d=n?o.length>1?`since :
|
||
`+o.map(n1).join(`
|
||
`):" "+n1(o[0]):"as no adapter specified";throw new zs("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return a}const vA={getAdapter:g5,adapters:Vy};function hg(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new qu(null,t)}function r1(t){return hg(t),t.headers=aa.from(t.headers),t.data=ug.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),vA.getAdapter(t.adapter||$u.adapter,t)(t).then(function(r){return hg(t),r.data=ug.call(t,t.transformResponse,r),r.headers=aa.from(r.headers),r},function(r){return mA(r)||(hg(t),r&&r.response&&(r.response.data=ug.call(t,t.transformResponse,r.response),r.response.headers=aa.from(r.response.headers))),Promise.reject(r)})}const yA="1.13.6",Lf={};["object","boolean","number","function","string","symbol"].forEach((t,s)=>{Lf[t]=function(r){return typeof r===t||"a"+(s<1?"n ":" ")+t}});const a1={};Lf.transitional=function(s,n,r){function a(i,o){return"[Axios v"+yA+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,d)=>{if(s===!1)throw new zs(a(o," has been removed"+(n?" in "+n:"")),zs.ERR_DEPRECATED);return n&&!a1[o]&&(a1[o]=!0,console.warn(a(o," has been deprecated since v"+n+" and will be removed in the near future"))),s?s(i,o,d):!0}};Lf.spelling=function(s){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${s}`),!0)};function v5(t,s,n){if(typeof t!="object")throw new zs("options must be an object",zs.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let a=r.length;for(;a-- >0;){const i=r[a],o=s[i];if(o){const d=t[i],m=d===void 0||o(d,i,t);if(m!==!0)throw new zs("option "+i+" must be "+m,zs.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new zs("Unknown option "+i,zs.ERR_BAD_OPTION)}}const Lm={assertOptions:v5,validators:Lf},Ma=Lm.validators;let Zo=class{constructor(s){this.defaults=s||{},this.interceptors={request:new Gw,response:new Gw}}async request(s,n){try{return await this._request(s,n)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const i=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
||
`+i):r.stack=i}catch{}}throw r}}_request(s,n){typeof s=="string"?(n=n||{},n.url=s):n=s||{},n=tc(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&Lm.assertOptions(r,{silentJSONParsing:Ma.transitional(Ma.boolean),forcedJSONParsing:Ma.transitional(Ma.boolean),clarifyTimeoutError:Ma.transitional(Ma.boolean),legacyInterceptorReqResOrdering:Ma.transitional(Ma.boolean)},!1),a!=null&&(tt.isFunction(a)?n.paramsSerializer={serialize:a}:Lm.assertOptions(a,{encode:Ma.function,serialize:Ma.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Lm.assertOptions(n,{baseUrl:Ma.spelling("baseURL"),withXsrfToken:Ma.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&tt.merge(i.common,i[n.method]);i&&tt.forEach(["delete","get","head","post","put","patch","common"],N=>{delete i[N]}),n.headers=aa.concat(o,i);const d=[];let m=!0;this.interceptors.request.forEach(function(v){if(typeof v.runWhen=="function"&&v.runWhen(n)===!1)return;m=m&&v.synchronous;const w=n.transitional||zy;w&&w.legacyInterceptorReqResOrdering?d.unshift(v.fulfilled,v.rejected):d.push(v.fulfilled,v.rejected)});const f=[];this.interceptors.response.forEach(function(v){f.push(v.fulfilled,v.rejected)});let p,h=0,x;if(!m){const N=[r1.bind(this),void 0];for(N.unshift(...d),N.push(...f),x=N.length,p=Promise.resolve(n);h<x;)p=p.then(N[h++],N[h++]);return p}x=d.length;let u=n;for(;h<x;){const N=d[h++],v=d[h++];try{u=N(u)}catch(w){v.call(this,w);break}}try{p=r1.call(this,u)}catch(N){return Promise.reject(N)}for(h=0,x=f.length;h<x;)p=p.then(f[h++],f[h++]);return p}getUri(s){s=tc(this.defaults,s);const n=pA(s.baseURL,s.url,s.allowAbsoluteUrls);return uA(n,s.params,s.paramsSerializer)}};tt.forEach(["delete","get","head","options"],function(s){Zo.prototype[s]=function(n,r){return this.request(tc(r||{},{method:s,url:n,data:(r||{}).data}))}});tt.forEach(["post","put","patch"],function(s){function n(r){return function(i,o,d){return this.request(tc(d||{},{method:s,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Zo.prototype[s]=n(),Zo.prototype[s+"Form"]=n(!0)});let y5=class bA{constructor(s){if(typeof s!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(a=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const o=new Promise(d=>{r.subscribe(d),i=d}).then(a);return o.cancel=function(){r.unsubscribe(i)},o},s(function(i,o,d){r.reason||(r.reason=new qu(i,o,d),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(s){if(this.reason){s(this.reason);return}this._listeners?this._listeners.push(s):this._listeners=[s]}unsubscribe(s){if(!this._listeners)return;const n=this._listeners.indexOf(s);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const s=new AbortController,n=r=>{s.abort(r)};return this.subscribe(n),s.signal.unsubscribe=()=>this.unsubscribe(n),s.signal}static source(){let s;return{token:new bA(function(a){s=a}),cancel:s}}};function b5(t){return function(n){return t.apply(null,n)}}function j5(t){return tt.isObject(t)&&t.isAxiosError===!0}const Zv={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(Zv).forEach(([t,s])=>{Zv[s]=t});function jA(t){const s=new Zo(t),n=eA(Zo.prototype.request,s);return tt.extend(n,Zo.prototype,s,{allOwnKeys:!0}),tt.extend(n,s,null,{allOwnKeys:!0}),n.create=function(a){return jA(tc(t,a))},n}const Wn=jA($u);Wn.Axios=Zo;Wn.CanceledError=qu;Wn.CancelToken=y5;Wn.isCancel=mA;Wn.VERSION=yA;Wn.toFormData=Of;Wn.AxiosError=zs;Wn.Cancel=Wn.CanceledError;Wn.all=function(s){return Promise.all(s)};Wn.spread=b5;Wn.isAxiosError=j5;Wn.mergeConfig=tc;Wn.AxiosHeaders=aa;Wn.formToJSON=t=>hA(tt.isHTMLForm(t)?new FormData(t):t);Wn.getAdapter=vA.getAdapter;Wn.HttpStatusCode=Zv;Wn.default=Wn;const{Axios:tY,AxiosError:sY,CanceledError:nY,isCancel:rY,CancelToken:aY,VERSION:iY,all:lY,Cancel:oY,isAxiosError:cY,spread:dY,toFormData:uY,AxiosHeaders:hY,HttpStatusCode:mY,formToJSON:fY,getAdapter:pY,mergeConfig:xY}=Wn,i1="https://dealeronboarding-uat.royalenfield.com/api",Re={login:t=>Ie.post("/auth/login",t),logout:()=>Ie.post("/auth/logout"),getCurrentUser:()=>Ie.get("/auth/me"),getRoles:()=>Ie.get("/admin/roles"),createRole:t=>Ie.post("/admin/roles",t),getPermissions:()=>Ie.get("/admin/permissions"),updateRole:(t,s)=>Ie.put(`/admin/roles/${t}`,s),getZones:()=>Ie.get("/master/zones"),createZone:t=>Ie.post("/master/zones",t),updateZone:(t,s)=>Ie.put(`/master/zones/${t}`,s),createRegion:t=>Ie.post("/master/regions",t),updateRegion:(t,s)=>Ie.put(`/master/regions/${t}`,s),getRegions:()=>Ie.get("/master/regions"),getOutlets:()=>Ie.get("/outlets"),getOutletByCode:t=>Ie.get(`/master/outlets/code/${t}`),getStates:t=>Ie.get("/master/states",typeof t=="string"?{zoneId:t}:t),getDistricts:t=>Ie.get("/master/districts",typeof t=="string"?{stateId:t}:t),getAreas:t=>Ie.get("/master/areas",t),updateArea:(t,s)=>Ie.put(`/master/areas/${t}`,s),createArea:t=>Ie.post("/master/areas",t),getAreaManagers:()=>Ie.get("/master/area-managers"),getASMs:()=>Ie.get("/master/asms"),getZonalManagers:()=>Ie.get("/master/zonal-managers"),saveZonalManager:t=>Ie.post("/master/zonal-managers",t),getDDLeads:()=>Ie.get("/master/dd-leads"),saveDDLead:t=>Ie.post("/master/dd-leads",t),getManagersByRole:t=>Ie.get("/master/managers",t),submitApplication:t=>Ie.post("/onboarding/apply",t),exportApplicationResponses:t=>Ie.get("/onboarding/applications/export-responses",t),getApplications:t=>Ie.get("/onboarding/applications",t),shortlistApplications:t=>Ie.post("/onboarding/applications/shortlist",t),sendBulkReminders:t=>Ie.post("/onboarding/applications/reminders",t),getApplicationById:t=>Ie.get(`/onboarding/applications/${t}`),updateApplication:(t,s)=>Ie.put(`/onboarding/applications/${t}`,s),getLatestQuestionnaire:()=>Ie.get("/questionnaire/latest"),createQuestionnaireVersion:t=>Ie.post("/questionnaire/version",t),submitQuestionnaireResponse:t=>Ie.post("/questionnaire/response",t),getAllQuestionnaires:()=>Ie.get("/onboarding/questionnaires"),getQuestionnaireById:t=>Ie.get(`/onboarding/questionnaires/${t}`),assignArchitectureTeam:(t,s)=>Ie.post(`/onboarding/applications/${t}/assign-architecture`,{assignedTo:s}),updateArchitectureStatus:(t,s,n)=>Ie.post(`/onboarding/applications/${t}/architecture-status`,{status:s,remarks:n}),generateDealerCodes:t=>Ie.post(`/onboarding/applications/${t}/generate-codes`),updateApplicationStatus:(t,s)=>Ie.put(`/onboarding/applications/${t}/status`,s),convertToOpportunity:(t,s)=>Ie.post(`/onboarding/applications/${t}/convert-to-opportunity`,s),bulkConvertToOpportunity:t=>Ie.post("/onboarding/applications/bulk-convert-to-opportunity",t),retriggerEvaluators:t=>Ie.post(`/onboarding/applications/${t}/retrigger-evaluators`),getSecurityDeposit:t=>Ie.get(`/loa/security-deposit/${t}`),updateSecurityDeposit:t=>Ie.post("/loa/security-deposit",t),uploadDocument:(t,s)=>Ie.post(`/onboarding/applications/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getDocuments:t=>Ie.get(`/onboarding/applications/${t}/documents`),getDocumentConfigMetadata:()=>Ie.get("/onboarding/document-configs/metadata"),getDocumentConfigs:t=>Ie.get("/onboarding/document-configs",t),createDocumentConfig:t=>Ie.post("/onboarding/document-configs",t),updateDocumentConfig:(t,s)=>Ie.put(`/onboarding/document-configs/${t}`,s),deleteDocumentConfig:t=>Ie.delete(`/onboarding/document-configs/${t}`),getPublicQuestionnaire:t=>Wn.get(`${i1}/questionnaire/public/${t}`),submitPublicResponse:t=>Wn.post(`${i1}/questionnaire/public/submit`,t),getAiSummary:t=>Ie.get(`/assessment/ai-summary/${t}`),scheduleInterview:t=>Ie.post("/assessment/interviews",t),updateInterview:(t,s)=>Ie.put(`/assessment/interviews/${t}`,s),submitEvaluation:(t,s)=>Ie.post(`/assessment/interviews/${t}/evaluation`,s),submitKTMatrix:t=>Ie.post("/assessment/kt-matrix",t),submitLevel2Feedback:t=>Ie.post("/assessment/level2-feedback",t),getInterviews:t=>Ie.get(`/assessment/interviews/${t}`),updateRecommendation:t=>Ie.post("/assessment/recommendation",t),updateInterviewDecision:t=>Ie.post("/assessment/decision",t),submitStageDecision:t=>Ie.post("/assessment/stage-decision",t),getInterviewApprovalStatus:t=>Ie.get(`/assessment/interviews/${t}/approval-status`),getApprovalPolicies:()=>Ie.get("/assessment/approval-policies"),upsertApprovalPolicy:(t,s)=>Ie.put(`/assessment/approval-policies/${t}`,s),getWorknotes:(t,s)=>Ie.get("/collaboration/worknotes",{requestId:t,requestType:s}),addWorknote:t=>Ie.post("/collaboration/worknotes",t),addParticipant:t=>Ie.post("/collaboration/participants",t),removeParticipant:t=>Ie.delete(`/collaboration/participants/${t}`),getUsers:t=>Ie.get("/admin/users",t),createUser:t=>Ie.post("/admin/users",t),updateUser:(t,s)=>Ie.put(`/admin/users/${t}`,s),updateUserStatus:(t,s)=>Ie.patch(`/admin/users/${t}/status`,s),deleteUser:t=>Ie.delete(`/admin/users/${t}`),getDealers:t=>Ie.get("/dealer",t),createDealer:t=>Ie.post("/dealer",t),getDealerById:t=>Ie.get(`/dealer/${t}`),updateDealer:(t,s)=>Ie.put(`/dealer/${t}`,s),getDealerDashboard:()=>Ie.get("/dealer/dashboard"),getDealerBankDetails:t=>Ie.get(`/dealer/${t}/bank-details`),saveBankDetail:(t,s)=>Ie.post(`/dealer/${t}/bank-details`,s),deleteBankDetail:t=>Ie.delete(`/dealer/bank-details/${t}`),getEmailTemplates:()=>Ie.get("/admin/email-templates"),getEmailTemplate:t=>Ie.get(`/admin/email-templates/${t}`),createEmailTemplate:t=>Ie.post("/admin/email-templates",t),updateEmailTemplate:(t,s)=>Ie.put(`/admin/email-templates/${t}`,s),deleteEmailTemplate:t=>Ie.delete(`/admin/email-templates/${t}`),previewEmailTemplate:t=>Ie.post("/admin/email-templates/preview",t),getAuditLogs:(t,s,n=1,r=50)=>Ie.get("/audit/logs",{entityType:t,entityId:s,page:n,limit:r}),getAuditSummary:(t,s)=>Ie.get("/audit/summary",{entityType:t,entityId:s}),sendOtp:t=>Ie.post("/prospective-login/send-otp",{phone:t}),verifyOtp:(t,s)=>Ie.post("/prospective-login/verify-otp",{phone:t,otp:s}),getResignationById:t=>Ie.get(`/resignation/${t}`),uploadResignationDocument:(t,s)=>Ie.post(`/resignation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateClearance:(t,s)=>Ie.put(`/resignation/${t}/clearance`,s,{headers:s instanceof FormData?{"Content-Type":"multipart/form-data"}:{}}),updateResignationStatus:(t,s)=>Ie.post(`/resignation/${t}/status`,s),getTerminationById:t=>Ie.get(`/termination/${t}`),uploadTerminationDocument:(t,s)=>Ie.post(`/termination/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateTerminationStatus:(t,s)=>Ie.post(`/termination/${t}/status`,s),issueSCN:(t,s)=>Ie.post(`/termination/${t}/scn`,s),uploadSCNResponse:(t,s)=>Ie.post(`/termination/${t}/scn-response`,s,{headers:{"Content-Type":"multipart/form-data"}}),finalizeTermination:(t,s)=>Ie.post(`/termination/${t}/finalize`,s),getResignations:t=>Ie.get("/resignation",t),createResignation:t=>Ie.post("/resignation",t),approveResignation:(t,s)=>Ie.post(`/resignation/${t}/approve`,s),rejectResignation:(t,s)=>Ie.post(`/resignation/${t}/reject`,s),withdrawResignation:(t,s)=>Ie.post(`/resignation/${t}/withdraw`,{reason:s}),getTerminations:t=>Ie.get("/termination",t),createTermination:t=>Ie.post("/termination",t),updateTermination:(t,s)=>Ie.post(`/termination/${t}/status`,s),getOnboardingPayments:()=>Ie.get("/settlement/onboarding"),updatePayment:(t,s)=>Ie.put(`/settlement/payments/${t}`,s),getFnFSettlements:()=>Ie.get("/settlement/fnf"),getFnFSettlementById:t=>Ie.get(`/settlement/fnf/${t}`),calculateFnF:t=>Ie.post(`/settlement/fnf/${t}/calculate`),updateFnF:(t,s)=>Ie.put(`/settlement/fnf/${t}`,s),uploadFnFDocument:(t,s)=>Ie.post(`/settlement/fnf/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getSettlementDepartments:()=>Ie.get("/settlement/departments"),addLineItem:(t,s)=>Ie.post(`/settlement/fnf/${t}/line-items`,s),updateFnFClearance:(t,s,n)=>Ie.put(`/settlement/fnf/${t}/clearances/${s}`,n,{headers:{"Content-Type":"multipart/form-data"}}),updateLineItem:(t,s)=>Ie.put(`/settlement/fnf/line-items/${t}`,s),deleteLineItem:t=>Ie.delete(`/settlement/fnf/line-items/${t}`),getRelocationRequests:t=>Ie.get("/relocation",t),getRelocationRequestById:t=>Ie.get(`/relocation/${t}`),createRelocationRequest:t=>Ie.post("/relocation",t),updateRelocationRequest:(t,s,n)=>Ie.post(`/relocation/${t}/action`,{action:s,...n}),uploadRelocationDocument:(t,s)=>Ie.post(`/relocation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),verifyRelocationDocument:(t,s)=>Ie.post(`/relocation/${t}/documents/${s}/verify`),rejectRelocationDocument:(t,s,n)=>Ie.post(`/relocation/${t}/documents/${s}/reject`,n||{}),getConstitutionalChanges:t=>Ie.get("/constitutional-change",t),getConstitutionalChangeMeta:()=>Ie.get("/constitutional-change/meta"),getConstitutionalChangeById:t=>Ie.get(`/constitutional-change/${t}`),createConstitutionalChange:t=>Ie.post("/constitutional-change",t),updateConstitutionalChange:(t,s,n)=>Ie.post(`/constitutional-change/${t}/action`,{action:s,...n}),uploadConstitutionalDocuments:(t,s)=>Ie.post(`/constitutional-change/${t}/documents`,{documents:s}),verifyConstitutionalDocument:(t,s)=>Ie.post(`/constitutional-change/${t}/documents/${s}/verify`),rejectConstitutionalDocument:(t,s,n)=>Ie.post(`/constitutional-change/${t}/documents/${s}/reject`,n||{}),getSlaConfigs:()=>Ie.get("/master/sla-configs"),saveSlaConfig:t=>Ie.post("/master/sla-configs",t),initializeDefaultSlas:()=>Ie.post("/master/sla-configs/initialize"),getSlaOperationsDashboard:t=>Ie.get("/sla/operations/dashboard",t),postSlaBatchStatus:t=>Ie.post("/sla/status/batch",t),getQuestionnaireReminderSettings:()=>Ie.get("/sla/settings/questionnaire-reminder"),updateQuestionnaireReminderSettings:t=>Ie.put("/sla/settings/questionnaire-reminder",t),getInterviewConfigs:t=>Ie.get("/master/interview-configs",t),getInterviewConfigById:t=>Ie.get(`/master/interview-configs/${t}`),getInterviewConfigByType:t=>Ie.get(`/master/interview-configs/active/${t}`),createInterviewConfig:t=>Ie.post("/master/interview-configs",t),updateInterviewConfig:(t,s)=>Ie.put(`/master/interview-configs/${t}`,s),deleteInterviewConfig:t=>Ie.delete(`/master/interview-configs/${t}`),initializeDefaultInterviewConfigs:()=>Ie.post("/master/interview-configs/initialize"),getSystemConfigs:t=>Ie.get("/master/system-configs",t),saveSystemConfig:t=>Ie.post("/master/system-configs",t),getDealerAsmMappings:()=>Ie.get("/master/dealer-asm-mappings"),saveDealerAsmMapping:t=>Ie.post("/master/dealer-asm-mappings",t),getEorChecklistForApplication:t=>Ie.get(`/eor/application/${t}`),getEorChecklistForRelocation:t=>Ie.get(`/eor/relocation/${t}`),updateEorChecklistItem:(t,s)=>Ie.post(`/eor/item/${t}`,s),submitEorAudit:(t,s)=>Ie.post(`/eor/audit/${t}`,s),submitFddReport:t=>Ie.post("/fdd/report",t),getFddAssignment:t=>Ie.get(`/fdd/${t}`),assignFddAgency:t=>Ie.post("/fdd/assign",t),flagNonResponsive:t=>Ie.post("/flag",t),getSystemAuditLogs:t=>Ie.get("/audit/system-logs",t),getSystemAuditSummary:()=>Ie.get("/audit/system-summary")},cm=Object.freeze(Object.defineProperty({__proto__:null,API:Re,default:Re},Symbol.toStringTag,{value:"Module"})),N5={user:null,token:localStorage.getItem("token"),isAuthenticated:!1,loading:!0,error:null},Im=D4("auth/initializeAuth",async(t,{rejectWithValue:s})=>{const n=localStorage.getItem("token");if(!n)return s("No token found");try{const r=await Re.getCurrentUser();if(r.ok&&r.data){const{user:a}=r.data;return{user:{id:a.id,name:a.fullName||a.email.split("@")[0],email:a.email,password:"",role:typeof a.role=="string"?a.role:a.roleCode||"User",roleCode:a.roleCode||(typeof a.role=="string"?a.role:"User")},token:n}}return s("Failed to fetch user")}catch(r){return s(r.message||"Session restoration failed")}}),NA=J2({name:"auth",initialState:N5,reducers:{setCredentials:(t,s)=>{t.user=s.payload.user,t.token=s.payload.token,t.isAuthenticated=!0,t.loading=!1,localStorage.setItem("token",s.payload.token)},logout:t=>{t.user=null,t.token=null,t.isAuthenticated=!1,t.loading=!1,localStorage.removeItem("token")},setLoading:(t,s)=>{t.loading=s.payload}},extraReducers:t=>{t.addCase(Im.pending,s=>{s.loading=!0}).addCase(Im.fulfilled,(s,n)=>{s.user=n.payload.user,s.token=n.payload.token,s.isAuthenticated=!0,s.loading=!1}).addCase(Im.rejected,s=>{s.user=null,s.token=null,s.isAuthenticated=!1,s.loading=!1,localStorage.removeItem("token")})}}),{setCredentials:wA,logout:SA,setLoading:gY}=NA.actions,w5=NA.reducer,S5={zones:[],regionalOffices:[],asms:[],zonalManagerMappings:[],zonalManagers:[],roles:[],allStates:[],allDistricts:[],allAreas:[],availablePermissions:[],emailTemplates:[],slaConfigs:[],users:[],ddLeads:[],areasPagination:{total:0,page:1,limit:10,totalPages:0},loading:!1,isAreasLoading:!1,error:null},CA=J2({name:"master",initialState:S5,reducers:{setMasterData:(t,s)=>({...t,...s.payload}),setAreasData:(t,s)=>{t.allAreas=s.payload.data,t.areasPagination=s.payload.pagination},setAreasLoading:(t,s)=>{t.isAreasLoading=s.payload},setZones:(t,s)=>{t.zones=s.payload},setRegionalOffices:(t,s)=>{t.regionalOffices=s.payload},setAsms:(t,s)=>{t.asms=s.payload},setZonalManagerMappings:(t,s)=>{t.zonalManagerMappings=s.payload},setUsers:(t,s)=>{t.users=s.payload},setLoading:(t,s)=>{t.loading=s.payload},setError:(t,s)=>{t.error=s.payload},setDdLeads:(t,s)=>{t.ddLeads=s.payload}}}),{setMasterData:AA,setZones:vY,setRegionalOffices:yY,setAsms:bY,setZonalManagerMappings:jY,setUsers:NY,setLoading:l1,setError:C5,setAreasData:A5,setAreasLoading:o1,setDdLeads:wY}=CA.actions,k5=CA.reducer,D5=y4({reducer:{auth:w5,master:k5}});var zu=Oy();const Hy=Nf(zu);/**
|
||
* @remix-run/router v1.23.2
|
||
*
|
||
* Copyright (c) Remix Software Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE.md file in the root directory of this source tree.
|
||
*
|
||
* @license MIT
|
||
*/function Su(){return Su=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Su.apply(this,arguments)}var Kl;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Kl||(Kl={}));const c1="popstate";function R5(t){t===void 0&&(t={});function s(r,a){let{pathname:i,search:o,hash:d}=r.location;return Qv("",{pathname:i,search:o,hash:d},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:kA(a)}return _5(s,n,null,t)}function Xn(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Wy(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function E5(){return Math.random().toString(36).substr(2,8)}function d1(t,s){return{usr:t.state,key:t.key,idx:s}}function Qv(t,s,n,r){return n===void 0&&(n=null),Su({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?xd(s):s,{state:n,key:s&&s.key||r||E5()})}function kA(t){let{pathname:s="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(s+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(s+=r.charAt(0)==="#"?r:"#"+r),s}function xd(t){let s={};if(t){let n=t.indexOf("#");n>=0&&(s.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(s.search=t.substr(r),t=t.substr(0,r)),t&&(s.pathname=t)}return s}function _5(t,s,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,d=Kl.Pop,m=null,f=p();f==null&&(f=0,o.replaceState(Su({},o.state,{idx:f}),""));function p(){return(o.state||{idx:null}).idx}function h(){d=Kl.Pop;let w=p(),j=w==null?null:w-f;f=w,m&&m({action:d,location:v.location,delta:j})}function x(w,j){d=Kl.Push;let b=Qv(v.location,w,j);f=p()+1;let C=d1(b,f),S=v.createHref(b);try{o.pushState(C,"",S)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;a.location.assign(S)}i&&m&&m({action:d,location:v.location,delta:1})}function u(w,j){d=Kl.Replace;let b=Qv(v.location,w,j);f=p();let C=d1(b,f),S=v.createHref(b);o.replaceState(C,"",S),i&&m&&m({action:d,location:v.location,delta:0})}function N(w){let j=a.location.origin!=="null"?a.location.origin:a.location.href,b=typeof w=="string"?w:kA(w);return b=b.replace(/ $/,"%20"),Xn(j,"No window.location.(origin|href) available to create URL for href: "+b),new URL(b,j)}let v={get action(){return d},get location(){return t(a,o)},listen(w){if(m)throw new Error("A history only accepts one active listener");return a.addEventListener(c1,h),m=w,()=>{a.removeEventListener(c1,h),m=null}},createHref(w){return s(a,w)},createURL:N,encodeLocation(w){let j=N(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:x,replace:u,go(w){return o.go(w)}};return v}var u1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(u1||(u1={}));function T5(t,s,n){return n===void 0&&(n="/"),P5(t,s,n)}function P5(t,s,n,r){let a=typeof s=="string"?xd(s):s,i=EA(a.pathname||"/",n);if(i==null)return null;let o=DA(t);O5(o);let d=null;for(let m=0;d==null&&m<o.length;++m){let f=W5(i);d=U5(o[m],f)}return d}function DA(t,s,n,r){s===void 0&&(s=[]),n===void 0&&(n=[]),r===void 0&&(r="");let a=(i,o,d)=>{let m={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};m.relativePath.startsWith("/")&&(Xn(m.relativePath.startsWith(r),'Absolute route path "'+m.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),m.relativePath=m.relativePath.slice(r.length));let f=Qo([r,m.relativePath]),p=n.concat(m);i.children&&i.children.length>0&&(Xn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+f+'".')),DA(i.children,s,p,f)),!(i.path==null&&!i.index)&&s.push({path:f,score:q5(f,i.index),routesMeta:p})};return t.forEach((i,o)=>{var d;if(i.path===""||!((d=i.path)!=null&&d.includes("?")))a(i,o);else for(let m of RA(i.path))a(i,o,m)}),s}function RA(t){let s=t.split("/");if(s.length===0)return[];let[n,...r]=s,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=RA(r.join("/")),d=[];return d.push(...o.map(m=>m===""?i:[i,m].join("/"))),a&&d.push(...o),d.map(m=>t.startsWith("/")&&m===""?"/":m)}function O5(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:z5(s.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const L5=/^:[\w-]+$/,I5=3,M5=2,F5=1,B5=10,$5=-2,h1=t=>t==="*";function q5(t,s){let n=t.split("/"),r=n.length;return n.some(h1)&&(r+=$5),s&&(r+=M5),n.filter(a=>!h1(a)).reduce((a,i)=>a+(L5.test(i)?I5:i===""?F5:B5),r)}function z5(t,s){return t.length===s.length&&t.slice(0,-1).every((r,a)=>r===s[a])?t[t.length-1]-s[s.length-1]:0}function U5(t,s,n){let{routesMeta:r}=t,a={},i="/",o=[];for(let d=0;d<r.length;++d){let m=r[d],f=d===r.length-1,p=i==="/"?s:s.slice(i.length)||"/",h=V5({path:m.relativePath,caseSensitive:m.caseSensitive,end:f},p),x=m.route;if(!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:Qo([i,h.pathname]),pathnameBase:Q5(Qo([i,h.pathnameBase])),route:x}),h.pathnameBase!=="/"&&(i=Qo([i,h.pathnameBase]))}return o}function V5(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=H5(t.path,t.caseSensitive,t.end),a=s.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),d=a.slice(1);return{params:r.reduce((f,p,h)=>{let{paramName:x,isOptional:u}=p;if(x==="*"){let v=d[h]||"";o=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const N=d[h];return u&&!N?f[x]=void 0:f[x]=(N||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:o,pattern:t}}function H5(t,s,n){s===void 0&&(s=!1),n===void 0&&(n=!0),Wy(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,d,m)=>(r.push({paramName:d,isOptional:m!=null}),m?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),r]}function W5(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Wy(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function EA(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let n=s.endsWith("/")?s.length-1:s.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const G5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,K5=t=>G5.test(t);function Y5(t,s){s===void 0&&(s="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?xd(t):t,i;if(n)if(K5(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Wy(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=m1(n.substring(1),"/"):i=m1(n,s)}else i=s;return{pathname:i,search:X5(r),hash:J5(a)}}function m1(t,s){let n=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function mg(t,s,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Z5(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function _A(t,s){let n=Z5(t);return s?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function TA(t,s,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=xd(t):(a=Su({},t),Xn(!a.pathname||!a.pathname.includes("?"),mg("?","pathname","search",a)),Xn(!a.pathname||!a.pathname.includes("#"),mg("#","pathname","hash",a)),Xn(!a.search||!a.search.includes("#"),mg("#","search","hash",a)));let i=t===""||a.pathname==="",o=i?"/":a.pathname,d;if(o==null)d=n;else{let h=s.length-1;if(!r&&o.startsWith("..")){let x=o.split("/");for(;x[0]==="..";)x.shift(),h-=1;a.pathname=x.join("/")}d=h>=0?s[h]:"/"}let m=Y5(a,d),f=o&&o!=="/"&&o.endsWith("/"),p=(i||o===".")&&n.endsWith("/");return!m.pathname.endsWith("/")&&(f||p)&&(m.pathname+="/"),m}const Qo=t=>t.join("/").replace(/\/\/+/g,"/"),Q5=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),X5=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,J5=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function eL(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const PA=["post","put","patch","delete"];new Set(PA);const tL=["get",...PA];new Set(tL);/**
|
||
* React Router v6.30.3
|
||
*
|
||
* Copyright (c) Remix Software Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE.md file in the root directory of this source tree.
|
||
*
|
||
* @license MIT
|
||
*/function Cu(){return Cu=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cu.apply(this,arguments)}const Gy=g.createContext(null),sL=g.createContext(null),Uu=g.createContext(null),If=g.createContext(null),pl=g.createContext({outlet:null,matches:[],isDataRoute:!1}),OA=g.createContext(null);function Vu(){return g.useContext(If)!=null}function xl(){return Vu()||Xn(!1),g.useContext(If).location}function LA(t){g.useContext(Uu).static||g.useLayoutEffect(t)}function tr(){let{isDataRoute:t}=g.useContext(pl);return t?gL():nL()}function nL(){Vu()||Xn(!1);let t=g.useContext(Gy),{basename:s,future:n,navigator:r}=g.useContext(Uu),{matches:a}=g.useContext(pl),{pathname:i}=xl(),o=JSON.stringify(_A(a,n.v7_relativeSplatPath)),d=g.useRef(!1);return LA(()=>{d.current=!0}),g.useCallback(function(f,p){if(p===void 0&&(p={}),!d.current)return;if(typeof f=="number"){r.go(f);return}let h=TA(f,JSON.parse(o),i,p.relative==="path");t==null&&s!=="/"&&(h.pathname=h.pathname==="/"?s:Qo([s,h.pathname])),(p.replace?r.replace:r.push)(h,p.state,p)},[s,r,o,i,t])}const rL=g.createContext(null);function aL(t){let s=g.useContext(pl).outlet;return s&&g.createElement(rL.Provider,{value:t},s)}function gd(){let{matches:t}=g.useContext(pl),s=t[t.length-1];return s?s.params:{}}function iL(t,s){return lL(t,s)}function lL(t,s,n,r){Vu()||Xn(!1);let{navigator:a}=g.useContext(Uu),{matches:i}=g.useContext(pl),o=i[i.length-1],d=o?o.params:{};o&&o.pathname;let m=o?o.pathnameBase:"/";o&&o.route;let f=xl(),p;if(s){var h;let w=typeof s=="string"?xd(s):s;m==="/"||(h=w.pathname)!=null&&h.startsWith(m)||Xn(!1),p=w}else p=f;let x=p.pathname||"/",u=x;if(m!=="/"){let w=m.replace(/^\//,"").split("/");u="/"+x.replace(/^\//,"").split("/").slice(w.length).join("/")}let N=T5(t,{pathname:u}),v=hL(N&&N.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:Qo([m,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?m:Qo([m,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),i,n,r);return s&&v?g.createElement(If.Provider,{value:{location:Cu({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:Kl.Pop}},v):v}function oL(){let t=xL(),s=eL(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},s),n?g.createElement("pre",{style:a},n):null,null)}const cL=g.createElement(oL,null);class dL extends g.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,n){return n.location!==s.location||n.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:n.error,location:n.location,revalidation:s.revalidation||n.revalidation}}componentDidCatch(s,n){console.error("React Router caught the following error during render",s,n)}render(){return this.state.error!==void 0?g.createElement(pl.Provider,{value:this.props.routeContext},g.createElement(OA.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function uL(t){let{routeContext:s,match:n,children:r}=t,a=g.useContext(Gy);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(pl.Provider,{value:s},r)}function hL(t,s,n,r){var a;if(s===void 0&&(s=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&s.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,d=(a=n)==null?void 0:a.errors;if(d!=null){let p=o.findIndex(h=>h.route.id&&(d==null?void 0:d[h.route.id])!==void 0);p>=0||Xn(!1),o=o.slice(0,Math.min(o.length,p+1))}let m=!1,f=-1;if(n&&r&&r.v7_partialHydration)for(let p=0;p<o.length;p++){let h=o[p];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(f=p),h.route.id){let{loaderData:x,errors:u}=n,N=h.route.loader&&x[h.route.id]===void 0&&(!u||u[h.route.id]===void 0);if(h.route.lazy||N){m=!0,f>=0?o=o.slice(0,f+1):o=[o[0]];break}}}return o.reduceRight((p,h,x)=>{let u,N=!1,v=null,w=null;n&&(u=d&&h.route.id?d[h.route.id]:void 0,v=h.route.errorElement||cL,m&&(f<0&&x===0?(vL("route-fallback"),N=!0,w=null):f===x&&(N=!0,w=h.route.hydrateFallbackElement||null)));let j=s.concat(o.slice(0,x+1)),b=()=>{let C;return u?C=v:N?C=w:h.route.Component?C=g.createElement(h.route.Component,null):h.route.element?C=h.route.element:C=p,g.createElement(uL,{match:h,routeContext:{outlet:p,matches:j,isDataRoute:n!=null},children:C})};return n&&(h.route.ErrorBoundary||h.route.errorElement||x===0)?g.createElement(dL,{location:n.location,revalidation:n.revalidation,component:v,error:u,children:b(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):b()},null)}var IA=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(IA||{}),MA=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(MA||{});function mL(t){let s=g.useContext(Gy);return s||Xn(!1),s}function fL(t){let s=g.useContext(sL);return s||Xn(!1),s}function pL(t){let s=g.useContext(pl);return s||Xn(!1),s}function FA(t){let s=pL(),n=s.matches[s.matches.length-1];return n.route.id||Xn(!1),n.route.id}function xL(){var t;let s=g.useContext(OA),n=fL(),r=FA();return s!==void 0?s:(t=n.errors)==null?void 0:t[r]}function gL(){let{router:t}=mL(IA.UseNavigateStable),s=FA(MA.UseNavigateStable),n=g.useRef(!1);return LA(()=>{n.current=!0}),g.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Cu({fromRouteId:s},i)))},[t,s])}const f1={};function vL(t,s,n){f1[t]||(f1[t]=!0)}function yL(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Vn(t){let{to:s,replace:n,state:r,relative:a}=t;Vu()||Xn(!1);let{future:i,static:o}=g.useContext(Uu),{matches:d}=g.useContext(pl),{pathname:m}=xl(),f=tr(),p=TA(s,_A(d,i.v7_relativeSplatPath),m,a==="path"),h=JSON.stringify(p);return g.useEffect(()=>f(JSON.parse(h),{replace:n,state:r,relative:a}),[f,h,a,n,r]),null}function bL(t){return aL(t.context)}function Ps(t){Xn(!1)}function jL(t){let{basename:s="/",children:n=null,location:r,navigationType:a=Kl.Pop,navigator:i,static:o=!1,future:d}=t;Vu()&&Xn(!1);let m=s.replace(/^\/*/,"/"),f=g.useMemo(()=>({basename:m,navigator:i,static:o,future:Cu({v7_relativeSplatPath:!1},d)}),[m,d,i,o]);typeof r=="string"&&(r=xd(r));let{pathname:p="/",search:h="",hash:x="",state:u=null,key:N="default"}=r,v=g.useMemo(()=>{let w=EA(p,m);return w==null?null:{location:{pathname:w,search:h,hash:x,state:u,key:N},navigationType:a}},[m,p,h,x,u,N,a]);return v==null?null:g.createElement(Uu.Provider,{value:f},g.createElement(If.Provider,{children:n,value:v}))}function Xv(t){let{children:s,location:n}=t;return iL(Jv(s),n)}new Promise(()=>{});function Jv(t,s){s===void 0&&(s=[]);let n=[];return g.Children.forEach(t,(r,a)=>{if(!g.isValidElement(r))return;let i=[...s,a];if(r.type===g.Fragment){n.push.apply(n,Jv(r.props.children,i));return}r.type!==Ps&&Xn(!1),!r.props.index||!r.props.children||Xn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Jv(r.props.children,i)),n.push(o)}),n}/**
|
||
* React Router DOM v6.30.3
|
||
*
|
||
* Copyright (c) Remix Software Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE.md file in the root directory of this source tree.
|
||
*
|
||
* @license MIT
|
||
*/const NL="6";try{window.__reactRouterVersion=NL}catch{}const wL="startTransition",p1=wf[wL];function SL(t){let{basename:s,children:n,future:r,window:a}=t,i=g.useRef();i.current==null&&(i.current=R5({window:a,v5Compat:!0}));let o=i.current,[d,m]=g.useState({action:o.action,location:o.location}),{v7_startTransition:f}=r||{},p=g.useCallback(h=>{f&&p1?p1(()=>m(h)):m(h)},[m,f]);return g.useLayoutEffect(()=>o.listen(p),[o,p]),g.useEffect(()=>yL(r),[r]),g.createElement(jL,{basename:s,children:n,location:d.location,navigationType:d.action,navigator:o,future:r})}var x1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(x1||(x1={}));var g1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(g1||(g1={}));const v1=({children:t,allowedRoles:s,excludeRoles:n,redirectTo:r})=>{const{user:a,isAuthenticated:i,loading:o}=Pn(h=>h.auth),d=xl(),m=String((a==null?void 0:a.role)||(a==null?void 0:a.roleCode)||"").trim().toLowerCase(),f=(s||[]).map(h=>String(h).trim().toLowerCase()),p=(n||[]).map(h=>String(h).trim().toLowerCase());return o?e.jsx("div",{className:"flex h-screen items-center justify-center",children:"Loading..."}):i?n&&a&&p.includes(m)?m==="prospective dealer"?e.jsx(Vn,{to:"/prospective-dashboard",replace:!0}):e.jsx(Vn,{to:r||"/dashboard",replace:!0}):s&&a&&!f.includes(m)?e.jsx(Vn,{to:r||"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Vn,{to:"/admin-login",state:{from:d},replace:!0})};function y1(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Hr(...t){return s=>{let n=!1;const r=t.map(a=>{const i=y1(a,s);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<r.length;a++){const i=r[a];typeof i=="function"?i():y1(t[a],null)}}}}function Ys(...t){return g.useCallback(Hr(...t),t)}var CL=Symbol.for("react.lazy"),nf=wf[" use ".trim().toString()];function AL(t){return typeof t=="object"&&t!==null&&"then"in t}function BA(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===CL&&"_payload"in t&&AL(t._payload)}function Hu(t){const s=kL(t),n=g.forwardRef((r,a)=>{let{children:i,...o}=r;BA(i)&&typeof nf=="function"&&(i=nf(i._payload));const d=g.Children.toArray(i),m=d.find(RL);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}var $A=Hu("Slot");function kL(t){const s=g.forwardRef((n,r)=>{let{children:a,...i}=n;if(BA(a)&&typeof nf=="function"&&(a=nf(a._payload)),g.isValidElement(a)){const o=_L(a),d=EL(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var DL=Symbol("radix.slottable");function RL(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===DL}function EL(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function _L(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function qA(t){var s,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(s=0;s<a;s++)t[s]&&(n=qA(t[s]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function zA(){for(var t,s,n=0,r="",a=arguments.length;n<a;n++)(t=arguments[n])&&(s=qA(t))&&(r&&(r+=" "),r+=s);return r}const b1=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,j1=zA,Ky=(t,s)=>n=>{var r;if((s==null?void 0:s.variants)==null)return j1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:i}=s,o=Object.keys(a).map(f=>{const p=n==null?void 0:n[f],h=i==null?void 0:i[f];if(p===null)return null;const x=b1(p)||b1(h);return a[f][x]}),d=n&&Object.entries(n).reduce((f,p)=>{let[h,x]=p;return x===void 0||(f[h]=x),f},{}),m=s==null||(r=s.compoundVariants)===null||r===void 0?void 0:r.reduce((f,p)=>{let{class:h,className:x,...u}=p;return Object.entries(u).every(N=>{let[v,w]=N;return Array.isArray(w)?w.includes({...i,...d}[v]):{...i,...d}[v]===w})?[...f,h,x]:f},[]);return j1(t,o,m,n==null?void 0:n.class,n==null?void 0:n.className)},Yy="-",TL=t=>{const s=OL(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const d=o.split(Yy);return d[0]===""&&d.length!==1&&d.shift(),UA(d,s)||PL(o)},getConflictingClassGroupIds:(o,d)=>{const m=n[o]||[];return d&&r[o]?[...m,...r[o]]:m}}},UA=(t,s)=>{var o;if(t.length===0)return s.classGroupId;const n=t[0],r=s.nextPart.get(n),a=r?UA(t.slice(1),r):void 0;if(a)return a;if(s.validators.length===0)return;const i=t.join(Yy);return(o=s.validators.find(({validator:d})=>d(i)))==null?void 0:o.classGroupId},N1=/^\[(.+)\]$/,PL=t=>{if(N1.test(t)){const s=N1.exec(t)[1],n=s==null?void 0:s.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},OL=t=>{const{theme:s,prefix:n}=t,r={nextPart:new Map,validators:[]};return IL(Object.entries(t.classGroups),n).forEach(([i,o])=>{ey(o,r,i,s)}),r},ey=(t,s,n,r)=>{t.forEach(a=>{if(typeof a=="string"){const i=a===""?s:w1(s,a);i.classGroupId=n;return}if(typeof a=="function"){if(LL(a)){ey(a(r),s,n,r);return}s.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{ey(o,w1(s,i),n,r)})})},w1=(t,s)=>{let n=t;return s.split(Yy).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},LL=t=>t.isThemeGetter,IL=(t,s)=>s?t.map(([n,r])=>{const a=r.map(i=>typeof i=="string"?s+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,d])=>[s+o,d])):i);return[n,a]}):t,ML=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,r=new Map;const a=(i,o)=>{n.set(i,o),s++,s>t&&(s=0,r=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=r.get(i))!==void 0)return a(i,o),o},set(i,o){n.has(i)?n.set(i,o):a(i,o)}}},VA="!",FL=t=>{const{separator:s,experimentalParseClassName:n}=t,r=s.length===1,a=s[0],i=s.length,o=d=>{const m=[];let f=0,p=0,h;for(let w=0;w<d.length;w++){let j=d[w];if(f===0){if(j===a&&(r||d.slice(w,w+i)===s)){m.push(d.slice(p,w)),p=w+i;continue}if(j==="/"){h=w;continue}}j==="["?f++:j==="]"&&f--}const x=m.length===0?d:d.substring(p),u=x.startsWith(VA),N=u?x.substring(1):x,v=h&&h>p?h-p:void 0;return{modifiers:m,hasImportantModifier:u,baseClassName:N,maybePostfixModifierPosition:v}};return n?d=>n({className:d,parseClassName:o}):o},BL=t=>{if(t.length<=1)return t;const s=[];let n=[];return t.forEach(r=>{r[0]==="["?(s.push(...n.sort(),r),n=[]):n.push(r)}),s.push(...n.sort()),s},$L=t=>({cache:ML(t.cacheSize),parseClassName:FL(t),...TL(t)}),qL=/\s+/,zL=(t,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a}=s,i=[],o=t.trim().split(qL);let d="";for(let m=o.length-1;m>=0;m-=1){const f=o[m],{modifiers:p,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:u}=n(f);let N=!!u,v=r(N?x.substring(0,u):x);if(!v){if(!N){d=f+(d.length>0?" "+d:d);continue}if(v=r(x),!v){d=f+(d.length>0?" "+d:d);continue}N=!1}const w=BL(p).join(":"),j=h?w+VA:w,b=j+v;if(i.includes(b))continue;i.push(b);const C=a(v,N);for(let S=0;S<C.length;++S){const D=C[S];i.push(j+D)}d=f+(d.length>0?" "+d:d)}return d};function UL(){let t=0,s,n,r="";for(;t<arguments.length;)(s=arguments[t++])&&(n=HA(s))&&(r&&(r+=" "),r+=n);return r}const HA=t=>{if(typeof t=="string")return t;let s,n="";for(let r=0;r<t.length;r++)t[r]&&(s=HA(t[r]))&&(n&&(n+=" "),n+=s);return n};function VL(t,...s){let n,r,a,i=o;function o(m){const f=s.reduce((p,h)=>h(p),t());return n=$L(f),r=n.cache.get,a=n.cache.set,i=d,d(m)}function d(m){const f=r(m);if(f)return f;const p=zL(m,n);return a(m,p),p}return function(){return i(UL.apply(null,arguments))}}const _n=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},WA=/^\[(?:([a-z-]+):)?(.+)\]$/i,HL=/^\d+\/\d+$/,WL=new Set(["px","full","screen"]),GL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,YL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ZL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,QL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tl=t=>Zc(t)||WL.has(t)||HL.test(t),Vl=t=>vd(t,"length",aI),Zc=t=>!!t&&!Number.isNaN(Number(t)),fg=t=>vd(t,"number",Zc),eu=t=>!!t&&Number.isInteger(Number(t)),XL=t=>t.endsWith("%")&&Zc(t.slice(0,-1)),Zs=t=>WA.test(t),Hl=t=>GL.test(t),JL=new Set(["length","size","percentage"]),eI=t=>vd(t,JL,GA),tI=t=>vd(t,"position",GA),sI=new Set(["image","url"]),nI=t=>vd(t,sI,lI),rI=t=>vd(t,"",iI),tu=()=>!0,vd=(t,s,n)=>{const r=WA.exec(t);return r?r[1]?typeof s=="string"?r[1]===s:s.has(r[1]):n(r[2]):!1},aI=t=>KL.test(t)&&!YL.test(t),GA=()=>!1,iI=t=>ZL.test(t),lI=t=>QL.test(t),oI=()=>{const t=_n("colors"),s=_n("spacing"),n=_n("blur"),r=_n("brightness"),a=_n("borderColor"),i=_n("borderRadius"),o=_n("borderSpacing"),d=_n("borderWidth"),m=_n("contrast"),f=_n("grayscale"),p=_n("hueRotate"),h=_n("invert"),x=_n("gap"),u=_n("gradientColorStops"),N=_n("gradientColorStopPositions"),v=_n("inset"),w=_n("margin"),j=_n("opacity"),b=_n("padding"),C=_n("saturate"),S=_n("scale"),D=_n("sepia"),_=_n("skew"),A=_n("space"),E=_n("translate"),q=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",Zs,s],P=()=>[Zs,s],L=()=>["",tl,Vl],$=()=>["auto",Zc,Zs],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Q=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",Zs],z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>[Zc,Zs];return{cacheSize:500,separator:":",theme:{colors:[tu],spacing:[tl,Vl],blur:["none","",Hl,Zs],brightness:T(),borderColor:[t],borderRadius:["none","","full",Hl,Zs],borderSpacing:P(),borderWidth:L(),contrast:T(),grayscale:M(),hueRotate:T(),invert:M(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[XL,Vl],inset:R(),margin:R(),opacity:T(),padding:P(),saturate:T(),scale:T(),sepia:M(),skew:T(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",Zs]}],container:["container"],columns:[{columns:[Hl]}],"break-after":[{"break-after":z()}],"break-before":[{"break-before":z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Z(),Zs]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",eu,Zs]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Zs]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",eu,Zs]}],"grid-cols":[{"grid-cols":[tu]}],"col-start-end":[{col:["auto",{span:["full",eu,Zs]},Zs]}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":[tu]}],"row-start-end":[{row:["auto",{span:[eu,Zs]},Zs]}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Zs]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Zs]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...U()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...U(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...U(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[A]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[A]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Zs,s]}],"min-w":[{"min-w":[Zs,s,"min","max","fit"]}],"max-w":[{"max-w":[Zs,s,"none","full","min","max","fit","prose",{screen:[Hl]},Hl]}],h:[{h:[Zs,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Zs,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Zs,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Zs,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Hl,Vl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",fg]}],"font-family":[{font:[tu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Zs]}],"line-clamp":[{"line-clamp":["none",Zc,fg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",tl,Zs]}],"list-image":[{"list-image":["none",Zs]}],"list-style-type":[{list:["none","disc","decimal",Zs]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",tl,Vl]}],"underline-offset":[{"underline-offset":["auto",tl,Zs]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Zs]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Zs]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),tI]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",eI]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},nI]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[N]}],"gradient-via-pos":[{via:[N]}],"gradient-to-pos":[{to:[N]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[j]}],"border-style":[{border:[...Q(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[j]}],"divide-style":[{divide:Q()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...Q()]}],"outline-offset":[{"outline-offset":[tl,Zs]}],"outline-w":[{outline:[tl,Vl]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[tl,Vl]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Hl,rI]}],"shadow-color":[{shadow:[tu]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[m]}],"drop-shadow":[{"drop-shadow":["","none",Hl,Zs]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[h]}],saturate:[{saturate:[C]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[m]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Zs]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",Zs]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",Zs]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[eu,Zs]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Zs]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Zs]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Zs]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[tl,Vl,fg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},cI=VL(oI);function Nt(...t){return cI(zA(t))}function Qt(t,s="full"){const n=new Date(t),r={day:"2-digit",month:"short",year:"numeric"};return(s==="full"||s==="time")&&(r.hour="2-digit",r.minute="2-digit",r.hour12=!0),s==="time"?n.toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit",hour12:!0}):s==="full"?n.toLocaleString("en-IN",r):n.toLocaleDateString("en-IN",r)}const nd=Ky("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),te=g.forwardRef(({className:t,variant:s,size:n,asChild:r=!1,...a},i)=>{const o=r?$A:"button";return e.jsx(o,{"data-slot":"button",className:Nt(nd({variant:s,size:n,className:t})),ref:i,...a})});te.displayName="Button";const it=g.forwardRef(({className:t,type:s,...n},r)=>e.jsx("input",{type:s,ref:r,"data-slot":"input",className:Nt("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n}));it.displayName="Input";function Ks({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:Nt("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...s})}function dI(t,s){const n=g.createContext(s),r=i=>{const{children:o,...d}=i,m=g.useMemo(()=>d,Object.values(d));return e.jsx(n.Provider,{value:m,children:o})};r.displayName=t+"Provider";function a(i){const o=g.useContext(n);if(o)return o;if(s!==void 0)return s;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function oa(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o),m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,uI(a,...s)]}function uI(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}function Yt(t,s,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}var Jn=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},hI=wf[" useInsertionEffect ".trim().toString()]||Jn;function Li({prop:t,defaultProp:s,onChange:n=()=>{},caller:r}){const[a,i,o]=mI({defaultProp:s,onChange:n}),d=t!==void 0,m=d?t:a;{const p=g.useRef(t!==void 0);g.useEffect(()=>{const h=p.current;h!==d&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=d},[d,r])}const f=g.useCallback(p=>{var h;if(d){const x=fI(p)?p(t):p;x!==t&&((h=o.current)==null||h.call(o,x))}else i(p)},[d,t,i,o]);return[m,f]}function mI({defaultProp:t,onChange:s}){const[n,r]=g.useState(t),a=g.useRef(n),i=g.useRef(s);return hI(()=>{i.current=s},[s]),g.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function fI(t){return typeof t=="function"}function Zy(t){const s=g.useRef({value:t,previous:t});return g.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}function Qy(t){const[s,n]=g.useState(void 0);return Jn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,d;if("borderBoxSize"in i){const m=i.borderBoxSize,f=Array.isArray(m)?m[0]:m;o=f.inlineSize,d=f.blockSize}else o=t.offsetWidth,d=t.offsetHeight;n({width:o,height:d})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),s}function pI(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var jr=t=>{const{present:s,children:n}=t,r=xI(s),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),i=Ys(r.ref,gI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:i}):null};jr.displayName="Presence";function xI(t){const[s,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),i=g.useRef("none"),o=t?"mounted":"unmounted",[d,m]=pI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const f=dm(r.current);i.current=d==="mounted"?f:"none"},[d]),Jn(()=>{const f=r.current,p=a.current;if(p!==t){const x=i.current,u=dm(f);t?m("MOUNT"):u==="none"||(f==null?void 0:f.display)==="none"?m("UNMOUNT"):m(p&&x!==u?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,m]),Jn(()=>{if(s){let f;const p=s.ownerDocument.defaultView??window,h=u=>{const v=dm(r.current).includes(CSS.escape(u.animationName));if(u.target===s&&v&&(m("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",f=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},x=u=>{u.target===s&&(i.current=dm(r.current))};return s.addEventListener("animationstart",x),s.addEventListener("animationcancel",h),s.addEventListener("animationend",h),()=>{p.clearTimeout(f),s.removeEventListener("animationstart",x),s.removeEventListener("animationcancel",h),s.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[s,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:g.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function dm(t){return(t==null?void 0:t.animationName)||"none"}function gI(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function vI(t){const s=yI(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(jI);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function yI(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=wI(a),d=NI(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var bI=Symbol("radix.slottable");function jI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===bI}function NI(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function wI(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var SI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ss=SI.reduce((t,s)=>{const n=vI(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{});function KA(t,s){t&&zu.flushSync(()=>t.dispatchEvent(s))}var Mf="Checkbox",[CI]=oa(Mf),[AI,Xy]=CI(Mf);function kI(t){const{__scopeCheckbox:s,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:d,onCheckedChange:m,required:f,value:p="on",internal_do_not_use_render:h}=t,[x,u]=Li({prop:n,defaultProp:a??!1,onChange:m,caller:Mf}),[N,v]=g.useState(null),[w,j]=g.useState(null),b=g.useRef(!1),C=N?!!o||!!N.closest("form"):!0,S={checked:x,disabled:i,setChecked:u,control:N,setControl:v,name:d,form:o,value:p,hasConsumerStoppedPropagationRef:b,required:f,defaultChecked:Zl(a)?!1:a,isFormControl:C,bubbleInput:w,setBubbleInput:j};return e.jsx(AI,{scope:s,...S,children:DI(h)?h(S):r})}var YA="CheckboxTrigger",ZA=g.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:n,...r},a)=>{const{control:i,value:o,disabled:d,checked:m,required:f,setControl:p,setChecked:h,hasConsumerStoppedPropagationRef:x,isFormControl:u,bubbleInput:N}=Xy(YA,t),v=Ys(a,p),w=g.useRef(m);return g.useEffect(()=>{const j=i==null?void 0:i.form;if(j){const b=()=>h(w.current);return j.addEventListener("reset",b),()=>j.removeEventListener("reset",b)}},[i,h]),e.jsx(Ss.button,{type:"button",role:"checkbox","aria-checked":Zl(m)?"mixed":m,"aria-required":f,"data-state":sk(m),"data-disabled":d?"":void 0,disabled:d,value:o,...r,ref:v,onKeyDown:Yt(s,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Yt(n,j=>{h(b=>Zl(b)?!0:!b),N&&u&&(x.current=j.isPropagationStopped(),x.current||j.stopPropagation())})})});ZA.displayName=YA;var QA=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:d,value:m,onCheckedChange:f,form:p,...h}=t;return e.jsx(kI,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:d,required:o,onCheckedChange:f,name:r,form:p,value:m,internal_do_not_use_render:({isFormControl:x})=>e.jsxs(e.Fragment,{children:[e.jsx(ZA,{...h,ref:s,__scopeCheckbox:n}),x&&e.jsx(tk,{__scopeCheckbox:n})]})})});QA.displayName=Mf;var XA="CheckboxIndicator",JA=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,forceMount:r,...a}=t,i=Xy(XA,n);return e.jsx(jr,{present:r||Zl(i.checked)||i.checked===!0,children:e.jsx(Ss.span,{"data-state":sk(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});JA.displayName=XA;var ek="CheckboxBubbleInput",tk=g.forwardRef(({__scopeCheckbox:t,...s},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:d,disabled:m,name:f,value:p,form:h,bubbleInput:x,setBubbleInput:u}=Xy(ek,t),N=Ys(n,u),v=Zy(i),w=Qy(r);g.useEffect(()=>{const b=x;if(!b)return;const C=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(C,"checked").set,_=!a.current;if(v!==i&&D){const A=new Event("click",{bubbles:_});b.indeterminate=Zl(i),D.call(b,Zl(i)?!1:i),b.dispatchEvent(A)}},[x,v,i,a]);const j=g.useRef(Zl(i)?!1:i);return e.jsx(Ss.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:d,disabled:m,name:f,value:p,form:h,...s,tabIndex:-1,ref:N,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});tk.displayName=ek;function DI(t){return typeof t=="function"}function Zl(t){return t==="indeterminate"}function sk(t){return Zl(t)?"indeterminate":t?"checked":"unchecked"}/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/var RI={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const EI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),vt=(t,s)=>{const n=g.forwardRef(({color:r="currentColor",size:a=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:d="",children:m,...f},p)=>g.createElement("svg",{ref:p,...RI,width:a,height:a,stroke:r,strokeWidth:o?Number(i)*24/Number(a):i,className:["lucide",`lucide-${EI(t)}`,d].join(" "),...f},[...s.map(([h,x])=>g.createElement(h,x)),...Array.isArray(m)?m:[m]]));return n.displayName=`${t}`,n};/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const rd=vt("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const sn=vt("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ba=vt("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Wr=vt("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Wo=vt("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const _I=vt("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const nk=vt("Award",[["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}],["path",{d:"M15.477 12.89 17 22l-5-3-5 3 1.523-9.11",key:"em7aur"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Jy=vt("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const TI=vt("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const PI=vt("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Au=vt("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const S1=vt("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const to=vt("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ad=vt("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const rk=vt("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const er=vt("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Hn=vt("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ln=vt("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const OI=vt("CheckSquare",[["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}],["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",key:"1jnkn4"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const $n=vt("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const va=vt("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const io=vt("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const mi=vt("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const yu=vt("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const LI=vt("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ak=vt("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const sc=vt("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dn=vt("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const C1=vt("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Wu=vt("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ty=vt("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const fi=vt("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ik=vt("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const II=vt("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const un=vt("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const hu=vt("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const MI=vt("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ks=vt("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const FI=vt("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const rf=vt("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const eb=vt("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const BI=vt("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const $I=vt("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const sy=vt("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ku=vt("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const qI=vt("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const lk=vt("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ok=vt("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const A1=vt("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const zI=vt("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ya=vt("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const qa=vt("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ck=vt("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const UI=vt("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const um=vt("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const VI=vt("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dk=vt("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const cs=vt("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ny=vt("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const HI=vt("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const uk=vt("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Gr=vt("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Mr=vt("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const li=vt("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const WI=vt("MoreHorizontal",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const hk=vt("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const bu=vt("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const GI=vt("PauseCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const k1=vt("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",key:"ymcmye"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const gr=vt("Pen",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ry=vt("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const tb=vt("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const pg=vt("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const bn=vt("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ay=vt("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const cl=vt("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const or=vt("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const KI=vt("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const sb=vt("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dl=vt("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const wa=vt("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Gu=vt("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const YI=vt("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ff=vt("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Qc=vt("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const mk=vt("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const so=vt("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dc=vt("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ZI=vt("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const QI=vt("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const XI=vt("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const JI=vt("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const eM=vt("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const tM=vt("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2v0a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12v0a2 2 0 0 1-2-2V7",key:"jon5kx"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const sM=vt("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Zn=vt("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Go=vt("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ll=vt("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const nM=vt("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const rM=vt("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11",key:"llx8ln"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const vr=vt("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const aM=vt("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const iM=vt("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const xg=vt("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const nb=vt("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const gg=vt("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Rr=vt("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ja=vt("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const af=vt("Wallet",[["path",{d:"M21 12V7H5a2 2 0 0 1 0-4h14v4",key:"195gfw"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h16v-5",key:"195n9w"}],["path",{d:"M18 12a2 2 0 0 0 0 4h4v-4Z",key:"vllfpd"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ai=vt("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const id=vt("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
||
* @license lucide-react v0.344.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const D1=vt("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function Tn({className:t,...s}){return e.jsx(QA,{"data-slot":"checkbox",className:Nt("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(JA,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx($n,{className:"size-3.5"})})})}var lM=t=>{switch(t){case"success":return dM;case"info":return hM;case"warning":return uM;case"error":return mM;default:return null}},oM=Array(12).fill(0),cM=({visible:t,className:s})=>Ct.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},Ct.createElement("div",{className:"sonner-spinner"},oM.map((n,r)=>Ct.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),dM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ct.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),uM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Ct.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),hM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ct.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),mM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ct.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),fM=Ct.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Ct.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ct.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),pM=()=>{let[t,s]=Ct.useState(document.hidden);return Ct.useEffect(()=>{let n=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},iy=1,xM=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let s=this.subscribers.indexOf(t);this.subscribers.splice(s,1)}),this.publish=t=>{this.subscribers.forEach(s=>s(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var s;let{message:n,...r}=t,a=typeof(t==null?void 0:t.id)=="number"||((s=t.id)==null?void 0:s.length)>0?t.id:iy++,i=this.toasts.find(d=>d.id===a),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(d=>d.id===a?(this.publish({...d,...t,id:a,title:n}),{...d,...t,id:a,dismissible:o,title:n}):d):this.addToast({title:n,...r,dismissible:o,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(s=>{this.subscribers.forEach(n=>n({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:t,dismiss:!0})),t),this.message=(t,s)=>this.create({...s,message:t}),this.error=(t,s)=>this.create({...s,message:t,type:"error"}),this.success=(t,s)=>this.create({...s,type:"success",message:t}),this.info=(t,s)=>this.create({...s,type:"info",message:t}),this.warning=(t,s)=>this.create({...s,type:"warning",message:t}),this.loading=(t,s)=>this.create({...s,type:"loading",message:t}),this.promise=(t,s)=>{if(!s)return;let n;s.loading!==void 0&&(n=this.create({...s,promise:t,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let r=t instanceof Promise?t:t(),a=n!==void 0,i,o=r.then(async m=>{if(i=["resolve",m],Ct.isValidElement(m))a=!1,this.create({id:n,type:"default",message:m});else if(vM(m)&&!m.ok){a=!1;let f=typeof s.error=="function"?await s.error(`HTTP error! status: ${m.status}`):s.error,p=typeof s.description=="function"?await s.description(`HTTP error! status: ${m.status}`):s.description;this.create({id:n,type:"error",message:f,description:p})}else if(s.success!==void 0){a=!1;let f=typeof s.success=="function"?await s.success(m):s.success,p=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"success",message:f,description:p})}}).catch(async m=>{if(i=["reject",m],s.error!==void 0){a=!1;let f=typeof s.error=="function"?await s.error(m):s.error,p=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"error",message:f,description:p})}}).finally(()=>{var m;a&&(this.dismiss(n),n=void 0),(m=s.finally)==null||m.call(s)}),d=()=>new Promise((m,f)=>o.then(()=>i[0]==="reject"?f(i[1]):m(i[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:d}:Object.assign(n,{unwrap:d})},this.custom=(t,s)=>{let n=(s==null?void 0:s.id)||iy++;return this.create({jsx:t(n),id:n,...s}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},sa=new xM,gM=(t,s)=>{let n=(s==null?void 0:s.id)||iy++;return sa.addToast({title:t,...s,id:n}),n},vM=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",yM=gM,bM=()=>sa.toasts,jM=()=>sa.getActiveToasts(),J=Object.assign(yM,{success:sa.success,info:sa.info,warning:sa.warning,error:sa.error,custom:sa.custom,message:sa.message,promise:sa.promise,dismiss:sa.dismiss,loading:sa.loading},{getHistory:bM,getToasts:jM});function NM(t,{insertAt:s}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",s==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}NM(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
||
`);function hm(t){return t.label!==void 0}var wM=3,SM="32px",CM="16px",R1=4e3,AM=356,kM=14,DM=20,RM=200;function ei(...t){return t.filter(Boolean).join(" ")}function EM(t){let[s,n]=t.split("-"),r=[];return s&&r.push(s),n&&r.push(n),r}var _M=t=>{var s,n,r,a,i,o,d,m,f,p,h;let{invert:x,toast:u,unstyled:N,interacting:v,setHeights:w,visibleToasts:j,heights:b,index:C,toasts:S,expanded:D,removeToast:_,defaultRichColors:A,closeButton:E,style:q,cancelButtonStyle:O,actionButtonStyle:R,className:P="",descriptionClassName:L="",duration:$,position:Z,gap:Q,loadingIcon:W,expandByDefault:U,classNames:M,icons:z,closeButtonAriaLabel:T="Close toast",pauseWhenPageIsHidden:F}=t,[I,K]=Ct.useState(null),[G,V]=Ct.useState(null),[Y,re]=Ct.useState(!1),[ae,ue]=Ct.useState(!1),[ye,ce]=Ct.useState(!1),[je,Me]=Ct.useState(!1),[ut,jt]=Ct.useState(!1),[ft,X]=Ct.useState(0),[Ce,xe]=Ct.useState(0),We=Ct.useRef(u.duration||$||R1),Be=Ct.useRef(null),rt=Ct.useRef(null),ht=C===0,ge=C+1<=j,Je=u.type,mt=u.dismissible!==!1,de=u.className||"",at=u.descriptionClassName||"",ot=Ct.useMemo(()=>b.findIndex(Ke=>Ke.toastId===u.id)||0,[b,u.id]),ke=Ct.useMemo(()=>{var Ke;return(Ke=u.closeButton)!=null?Ke:E},[u.closeButton,E]),Zt=Ct.useMemo(()=>u.duration||$||R1,[u.duration,$]),Bt=Ct.useRef(0),_s=Ct.useRef(0),Us=Ct.useRef(0),fs=Ct.useRef(null),[Vs,Qs]=Z.split("-"),Xs=Ct.useMemo(()=>b.reduce((Ke,Le,Ue)=>Ue>=ot?Ke:Ke+Le.height,0),[b,ot]),ie=pM(),nt=u.invert||x,fe=Je==="loading";_s.current=Ct.useMemo(()=>ot*Q+Xs,[ot,Xs]),Ct.useEffect(()=>{We.current=Zt},[Zt]),Ct.useEffect(()=>{re(!0)},[]),Ct.useEffect(()=>{let Ke=rt.current;if(Ke){let Le=Ke.getBoundingClientRect().height;return xe(Le),w(Ue=>[{toastId:u.id,height:Le,position:u.position},...Ue]),()=>w(Ue=>Ue.filter(et=>et.toastId!==u.id))}},[w,u.id]),Ct.useLayoutEffect(()=>{if(!Y)return;let Ke=rt.current,Le=Ke.style.height;Ke.style.height="auto";let Ue=Ke.getBoundingClientRect().height;Ke.style.height=Le,xe(Ue),w(et=>et.find(dt=>dt.toastId===u.id)?et.map(dt=>dt.toastId===u.id?{...dt,height:Ue}:dt):[{toastId:u.id,height:Ue,position:u.position},...et])},[Y,u.title,u.description,w,u.id]);let Ae=Ct.useCallback(()=>{ue(!0),X(_s.current),w(Ke=>Ke.filter(Le=>Le.toastId!==u.id)),setTimeout(()=>{_(u)},RM)},[u,_,w,_s]);Ct.useEffect(()=>{if(u.promise&&Je==="loading"||u.duration===1/0||u.type==="loading")return;let Ke;return D||v||F&&ie?(()=>{if(Us.current<Bt.current){let Le=new Date().getTime()-Bt.current;We.current=We.current-Le}Us.current=new Date().getTime()})():We.current!==1/0&&(Bt.current=new Date().getTime(),Ke=setTimeout(()=>{var Le;(Le=u.onAutoClose)==null||Le.call(u,u),Ae()},We.current)),()=>clearTimeout(Ke)},[D,v,u,Je,F,ie,Ae]),Ct.useEffect(()=>{u.delete&&Ae()},[Ae,u.delete]);function Fe(){var Ke,Le,Ue;return z!=null&&z.loading?Ct.createElement("div",{className:ei(M==null?void 0:M.loader,(Ke=u==null?void 0:u.classNames)==null?void 0:Ke.loader,"sonner-loader"),"data-visible":Je==="loading"},z.loading):W?Ct.createElement("div",{className:ei(M==null?void 0:M.loader,(Le=u==null?void 0:u.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":Je==="loading"},W):Ct.createElement(cM,{className:ei(M==null?void 0:M.loader,(Ue=u==null?void 0:u.classNames)==null?void 0:Ue.loader),visible:Je==="loading"})}return Ct.createElement("li",{tabIndex:0,ref:rt,className:ei(P,de,M==null?void 0:M.toast,(s=u==null?void 0:u.classNames)==null?void 0:s.toast,M==null?void 0:M.default,M==null?void 0:M[Je],(n=u==null?void 0:u.classNames)==null?void 0:n[Je]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:A,"data-styled":!(u.jsx||u.unstyled||N),"data-mounted":Y,"data-promise":!!u.promise,"data-swiped":ut,"data-removed":ae,"data-visible":ge,"data-y-position":Vs,"data-x-position":Qs,"data-index":C,"data-front":ht,"data-swiping":ye,"data-dismissible":mt,"data-type":Je,"data-invert":nt,"data-swipe-out":je,"data-swipe-direction":G,"data-expanded":!!(D||U&&Y),style:{"--index":C,"--toasts-before":C,"--z-index":S.length-C,"--offset":`${ae?ft:_s.current}px`,"--initial-height":U?"auto":`${Ce}px`,...q,...u.style},onDragEnd:()=>{ce(!1),K(null),fs.current=null},onPointerDown:Ke=>{fe||!mt||(Be.current=new Date,X(_s.current),Ke.target.setPointerCapture(Ke.pointerId),Ke.target.tagName!=="BUTTON"&&(ce(!0),fs.current={x:Ke.clientX,y:Ke.clientY}))},onPointerUp:()=>{var Ke,Le,Ue,et;if(je||!mt)return;fs.current=null;let dt=Number(((Ke=rt.current)==null?void 0:Ke.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ss=Number(((Le=rt.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Wt=new Date().getTime()-((Ue=Be.current)==null?void 0:Ue.getTime()),kt=I==="x"?dt:ss,wt=Math.abs(kt)/Wt;if(Math.abs(kt)>=DM||wt>.11){X(_s.current),(et=u.onDismiss)==null||et.call(u,u),V(I==="x"?dt>0?"right":"left":ss>0?"down":"up"),Ae(),Me(!0),jt(!1);return}ce(!1),K(null)},onPointerMove:Ke=>{var Le,Ue,et,dt;if(!fs.current||!mt||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;let ss=Ke.clientY-fs.current.y,Wt=Ke.clientX-fs.current.x,kt=(Ue=t.swipeDirections)!=null?Ue:EM(Z);!I&&(Math.abs(Wt)>1||Math.abs(ss)>1)&&K(Math.abs(Wt)>Math.abs(ss)?"x":"y");let wt={x:0,y:0};I==="y"?(kt.includes("top")||kt.includes("bottom"))&&(kt.includes("top")&&ss<0||kt.includes("bottom")&&ss>0)&&(wt.y=ss):I==="x"&&(kt.includes("left")||kt.includes("right"))&&(kt.includes("left")&&Wt<0||kt.includes("right")&&Wt>0)&&(wt.x=Wt),(Math.abs(wt.x)>0||Math.abs(wt.y)>0)&&jt(!0),(et=rt.current)==null||et.style.setProperty("--swipe-amount-x",`${wt.x}px`),(dt=rt.current)==null||dt.style.setProperty("--swipe-amount-y",`${wt.y}px`)}},ke&&!u.jsx?Ct.createElement("button",{"aria-label":T,"data-disabled":fe,"data-close-button":!0,onClick:fe||!mt?()=>{}:()=>{var Ke;Ae(),(Ke=u.onDismiss)==null||Ke.call(u,u)},className:ei(M==null?void 0:M.closeButton,(a=u==null?void 0:u.classNames)==null?void 0:a.closeButton)},(i=z==null?void 0:z.close)!=null?i:fM):null,u.jsx||g.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:Ct.createElement(Ct.Fragment,null,Je||u.icon||u.promise?Ct.createElement("div",{"data-icon":"",className:ei(M==null?void 0:M.icon,(o=u==null?void 0:u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Fe():null,u.type!=="loading"?u.icon||(z==null?void 0:z[Je])||lM(Je):null):null,Ct.createElement("div",{"data-content":"",className:ei(M==null?void 0:M.content,(d=u==null?void 0:u.classNames)==null?void 0:d.content)},Ct.createElement("div",{"data-title":"",className:ei(M==null?void 0:M.title,(m=u==null?void 0:u.classNames)==null?void 0:m.title)},typeof u.title=="function"?u.title():u.title),u.description?Ct.createElement("div",{"data-description":"",className:ei(L,at,M==null?void 0:M.description,(f=u==null?void 0:u.classNames)==null?void 0:f.description)},typeof u.description=="function"?u.description():u.description):null),g.isValidElement(u.cancel)?u.cancel:u.cancel&&hm(u.cancel)?Ct.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||O,onClick:Ke=>{var Le,Ue;hm(u.cancel)&&mt&&((Ue=(Le=u.cancel).onClick)==null||Ue.call(Le,Ke),Ae())},className:ei(M==null?void 0:M.cancelButton,(p=u==null?void 0:u.classNames)==null?void 0:p.cancelButton)},u.cancel.label):null,g.isValidElement(u.action)?u.action:u.action&&hm(u.action)?Ct.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||R,onClick:Ke=>{var Le,Ue;hm(u.action)&&((Ue=(Le=u.action).onClick)==null||Ue.call(Le,Ke),!Ke.defaultPrevented&&Ae())},className:ei(M==null?void 0:M.actionButton,(h=u==null?void 0:u.classNames)==null?void 0:h.actionButton)},u.action.label):null))};function E1(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function TM(t,s){let n={};return[t,s].forEach((r,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",d=i?CM:SM;function m(f){["top","right","bottom","left"].forEach(p=>{n[`${o}-${p}`]=typeof f=="number"?`${f}px`:f})}typeof r=="number"||typeof r=="string"?m(r):typeof r=="object"?["top","right","bottom","left"].forEach(f=>{r[f]===void 0?n[`${o}-${f}`]=d:n[`${o}-${f}`]=typeof r[f]=="number"?`${r[f]}px`:r[f]}):m(d)}),n}var PM=g.forwardRef(function(t,s){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:d,offset:m,mobileOffset:f,theme:p="light",richColors:h,duration:x,style:u,visibleToasts:N=wM,toastOptions:v,dir:w=E1(),gap:j=kM,loadingIcon:b,icons:C,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:D}=t,[_,A]=Ct.useState([]),E=Ct.useMemo(()=>Array.from(new Set([r].concat(_.filter(F=>F.position).map(F=>F.position)))),[_,r]),[q,O]=Ct.useState([]),[R,P]=Ct.useState(!1),[L,$]=Ct.useState(!1),[Z,Q]=Ct.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=Ct.useRef(null),U=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=Ct.useRef(null),z=Ct.useRef(!1),T=Ct.useCallback(F=>{A(I=>{var K;return(K=I.find(G=>G.id===F.id))!=null&&K.delete||sa.dismiss(F.id),I.filter(({id:G})=>G!==F.id)})},[]);return Ct.useEffect(()=>sa.subscribe(F=>{if(F.dismiss){A(I=>I.map(K=>K.id===F.id?{...K,delete:!0}:K));return}setTimeout(()=>{Hy.flushSync(()=>{A(I=>{let K=I.findIndex(G=>G.id===F.id);return K!==-1?[...I.slice(0,K),{...I[K],...F},...I.slice(K+1)]:[F,...I]})})})}),[]),Ct.useEffect(()=>{if(p!=="system"){Q(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Q("dark"):Q("light")),typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:I})=>{Q(I?"dark":"light")})}catch{F.addListener(({matches:K})=>{try{Q(K?"dark":"light")}catch(G){console.error(G)}})}},[p]),Ct.useEffect(()=>{_.length<=1&&P(!1)},[_]),Ct.useEffect(()=>{let F=I=>{var K,G;a.every(V=>I[V]||I.code===V)&&(P(!0),(K=W.current)==null||K.focus()),I.code==="Escape"&&(document.activeElement===W.current||(G=W.current)!=null&&G.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[a]),Ct.useEffect(()=>{if(W.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,z.current=!1)}},[W.current]),Ct.createElement("section",{ref:s,"aria-label":`${S} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((F,I)=>{var K;let[G,V]=F.split("-");return _.length?Ct.createElement("ol",{key:F,dir:w==="auto"?E1():w,tabIndex:-1,ref:W,className:d,"data-sonner-toaster":!0,"data-theme":Z,"data-y-position":G,"data-lifted":R&&_.length>1&&!i,"data-x-position":V,style:{"--front-toast-height":`${((K=q[0])==null?void 0:K.height)||0}px`,"--width":`${AM}px`,"--gap":`${j}px`,...u,...TM(m,f)},onBlur:Y=>{z.current&&!Y.currentTarget.contains(Y.relatedTarget)&&(z.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||z.current||(z.current=!0,M.current=Y.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{L||P(!1)},onDragEnd:()=>P(!1),onPointerDown:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},_.filter(Y=>!Y.position&&I===0||Y.position===F).map((Y,re)=>{var ae,ue;return Ct.createElement(_M,{key:Y.id,icons:C,index:re,toast:Y,defaultRichColors:h,duration:(ae=v==null?void 0:v.duration)!=null?ae:x,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:n,visibleToasts:N,closeButton:(ue=v==null?void 0:v.closeButton)!=null?ue:o,interacting:L,position:F,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,removeToast:T,toasts:_.filter(ye=>ye.position==Y.position),heights:q.filter(ye=>ye.position==Y.position),setHeights:O,expandByDefault:i,gap:j,loadingIcon:b,expanded:R,pauseWhenPageIsHidden:D,swipeDirections:t.swipeDirections})})):null}))});const ps={submitApplication:async t=>{var n;const s=await Re.submitApplication(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit application");return s.data},getApplications:async t=>{var n;const s=await Re.getApplications(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch applications");return s.data},shortlistApplications:async(t,s,n)=>{var a;const r=await Re.shortlistApplications({applicationIds:t,assignedTo:s,remarks:n});if(!r.ok)throw new Error(((a=r.data)==null?void 0:a.message)||"Failed to shortlist applications");return r.data},getApplicationById:async t=>{var n,r;const s=await Re.getApplicationById(t);if(!s.ok)throw console.error("API Error Response:",s.status,s.data),new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch application details");return((r=s.data)==null?void 0:r.data)||s.data},getUsers:async t=>{var n,r;const s=await Re.getUsers(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch users");return((r=s.data)==null?void 0:r.data)||s.data},addParticipant:async t=>{var n;const s=await Re.addParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to add participant");return s.data},scheduleInterview:async t=>{var n;const s=await Re.scheduleInterview(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to schedule interview");return s.data},updateInterview:async(t,s)=>{var r;const n=await Re.updateInterview(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update interview");return n.data},getInterviews:async t=>{var r,a;const s=await Re.getInterviews(t);if(!s.ok)throw new Error(((r=s.data)==null?void 0:r.message)||"Failed to fetch interviews");const n=((a=s.data)==null?void 0:a.data)||s.data;return Array.isArray(n)?n:[]},getDocuments:async t=>{var n,r;const s=await Re.getDocuments(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch documents");return((r=s.data)==null?void 0:r.data)||s.data},uploadDocument:async(t,s)=>{var r;const n=await Re.uploadDocument(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to upload document");return n.data},submitKTMatrix:async t=>{var n;const s=await Re.submitKTMatrix(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit KT Matrix");return s.data},submitLevel2Feedback:async t=>{var n;const s=await Re.submitLevel2Feedback(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit feedback");return s.data},updateRecommendation:async t=>{var n;const s=await Re.updateRecommendation(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to update recommendation");return s.data},submitStageDecision:async t=>{var n;const s=await Re.submitStageDecision(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to process stage decision");return s.data},updateInterviewDecision:async t=>{var n;const s=await Re.updateInterviewDecision(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to update interview decision");return s.data},assignArchitectureTeam:async(t,s)=>{var r;const n=await Re.assignArchitectureTeam(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to assign architecture team");return n.data},updateArchitectureStatus:async(t,s,n)=>{var a;const r=await Re.updateArchitectureStatus(t,s,n);if(!r.ok)throw new Error(((a=r.data)==null?void 0:a.message)||"Failed to update architecture status");return r.data},generateDealerCodes:async t=>{var n;const s=await Re.generateDealerCodes(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to generate dealer codes");return s.data},updateApplicationStatus:async(t,s)=>{var r;const n=await Re.updateApplicationStatus(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update application status");return n.data},convertToOpportunity:async(t,s)=>{var r;const n=await Re.convertToOpportunity(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to convert application to opportunity");return n.data},bulkConvertToOpportunity:async t=>{var n;const s=await Re.bulkConvertToOpportunity(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to perform bulk conversion");return s.data},sendBulkReminders:async t=>{var n;const s=await Re.sendBulkReminders({applicationIds:t});if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to send reminders");return s.data},createDealer:async t=>{var n;const s=await Re.createDealer(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to create dealer profile");return s.data},retriggerEvaluators:async t=>{var n;const s=await Re.retriggerEvaluators(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to retrigger evaluators");return s.data},getSecurityDeposit:async t=>{var n,r;const s=await Re.getSecurityDeposit(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch Security Deposit");return((r=s.data)==null?void 0:r.data)||s.data},updateSecurityDeposit:async t=>{var n;const s=await Re.updateSecurityDeposit(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to update Security Deposit");return s.data},getSystemConfigs:async t=>{var n,r;const s=await Re.getSystemConfigs(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch system configurations");return((r=s.data)==null?void 0:r.data)||s.data},getDocumentConfigMetadata:async()=>{var s,n;const t=await Re.getDocumentConfigMetadata();if(!t.ok)throw new Error(((s=t.data)==null?void 0:s.message)||"Failed to fetch metadata");return((n=t.data)==null?void 0:n.data)||t.data},getDocumentConfigs:async t=>{var n;const s=await Re.getDocumentConfigs(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch document configurations");return s.data},createDocumentConfig:async t=>{var n,r;const s=await Re.createDocumentConfig(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to create document configuration");return((r=s.data)==null?void 0:r.data)||s.data},updateDocumentConfig:async(t,s)=>{var r,a;const n=await Re.updateDocumentConfig(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update document configuration");return((a=n.data)==null?void 0:a.data)||n.data},deleteDocumentConfig:async t=>{var n;const s=await Re.deleteDocumentConfig(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to delete document configuration");return s.data},updateApplication:async(t,s)=>{var r;const n=await Re.updateApplication(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update application");return n.data},submitFddReport:async t=>{var n;const s=await Re.submitFddReport(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to submit FDD report");return s.data},getFddAssignment:async t=>{var n;const s=await Re.getFddAssignment(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch FDD assignment");return s.data},assignFddAgency:async t=>{var n;const s=await Re.assignFddAgency(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to assign FDD agency");return s.data},exportResponses:async t=>{var n,r;const s=await Re.exportApplicationResponses({applicationIds:t.join(",")});if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to export responses");return((r=s.data)==null?void 0:r.data)||[]}},$s={getRoles:async()=>(await Re.getRoles()).data,getPermissions:async()=>(await Re.getPermissions()).data,updateRole:async(t,s)=>(await Re.updateRole(t,s)).data,createRole:async t=>(await Re.createRole(t)).data,getZones:async()=>(await Re.getZones()).data,updateZone:async(t,s)=>(await Re.updateZone(t,s)).data,createZone:async t=>(await Re.createZone(t)).data,createRegion:async t=>(await Re.createRegion(t)).data,updateRegion:async(t,s)=>(await Re.updateRegion(t,s)).data,getRegions:async()=>(await Re.getRegions()).data,getStates:async t=>(await Re.getStates(t)).data,getDistricts:async t=>{const s=typeof t=="string"?{stateId:t,limit:"all"}:{limit:"all",...t};return(await Re.getDistricts(s)).data},getAreas:async t=>(await Re.getAreas(t)).data,updateArea:async(t,s)=>(await Re.updateArea(t,s)).data,createArea:async t=>(await Re.createArea(t)).data,deleteArea:async t=>(await Re.deleteArea(t)).data,getAreaManagers:async()=>(await Re.getAreaManagers()).data,getASMs:async()=>(await Re.getASMs()).data,getZonalManagers:async()=>(await Re.getZonalManagers()).data,saveZonalManager:async t=>Re.saveZonalManager(t).then(s=>s.data),getDDLeads:async()=>(await Re.getDDLeads()).data,saveDDLead:async t=>Re.saveDDLead(t).then(s=>s.data),getUsers:async()=>(await Re.getUsers()).data,updateUser:async(t,s)=>(await Re.updateUser(t,s)).data,getEmailTemplates:async()=>(await Re.getEmailTemplates()).data,getEmailTemplate:async t=>(await Re.getEmailTemplate(t)).data,createEmailTemplate:async t=>(await Re.createEmailTemplate(t)).data,updateEmailTemplate:async(t,s)=>(await Re.updateEmailTemplate(t,s)).data,deleteEmailTemplate:async t=>(await Re.deleteEmailTemplate(t)).data,previewEmailTemplate:async t=>(await Re.previewEmailTemplate(t)).data,getSlaConfigs:async()=>(await Re.getSlaConfigs()).data,saveSlaConfig:async t=>(await Re.saveSlaConfig(t)).data,initializeDefaultSlas:async()=>(await Re.initializeDefaultSlas()).data,saveZone:async t=>t.id?$s.updateZone(t.id,t):$s.createZone(t),saveRegion:async t=>t.id?$s.updateRegion(t.id,t):$s.createRegion(t),saveASM:async t=>Re.updateUser(t.userId,t).then(s=>s.data),getSystemConfigs:async t=>(await Re.getSystemConfigs(t)).data,saveSystemConfig:async t=>(await Re.saveSystemConfig(t)).data,getDealerAsmMappings:async()=>(await Re.getDealerAsmMappings()).data,saveDealerAsmMapping:async t=>(await Re.saveDealerAsmMapping(t)).data};function OM({onAdminLogin:t}){const[s,n]=g.useState({country:"India",stateId:"",districtId:"",name:"",interestedCity:"",email:"",pincode:"",mobile:"",ownRoyalEnfield:"",royalEnfieldModel:"",age:"",education:"",companyName:"",source:"",existingDealer:"",description:"",address:"",acceptTerms:!1}),[r,a]=g.useState(!1),[i,o]=g.useState([]),[d,m]=g.useState([]);g.useEffect(()=>{f()},[]);const f=async()=>{try{const C=await $s.getStates(),S=Array.isArray(C)?C:(C==null?void 0:C.data)||(C==null?void 0:C.states)||[];o(S)}catch(C){console.error("Error fetching states:",C)}},p=async C=>{if(C){n(S=>({...S,stateId:C,districtId:""})),m([]);try{const S=await $s.getDistricts(C),D=Array.isArray(S)?S:(S==null?void 0:S.data)||(S==null?void 0:S.districts)||[];m(D)}catch(S){console.error("Error fetching districts:",S)}}},h=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),x=C=>/^[0-9]{10}$/.test(C),u=C=>/^[0-9]{6}$/.test(C),N=!!(s.country&&s.stateId&&s.districtId&&s.name&&s.interestedCity&&s.email&&s.pincode&&s.mobile&&s.ownRoyalEnfield&&s.age&&s.education&&s.companyName&&s.source&&s.existingDealer&&s.description&&s.address&&s.acceptTerms&&r&&h(s.email)&&x(s.mobile)&&u(s.pincode)&&(s.ownRoyalEnfield==="no"||s.ownRoyalEnfield==="yes"&&s.royalEnfieldModel)),v=()=>{if(!s.mobile||s.mobile.length<10){J.error("Please enter a valid mobile number");return}J.success("OTP sent to "+s.mobile),setTimeout(()=>{a(!0),J.success("Mobile number verified")},1500)},w=async C=>{var S,D;if(C.preventDefault(),!s.country||!s.stateId||!s.districtId||!s.name||!s.interestedCity||!s.email||!s.pincode||!s.mobile||!s.ownRoyalEnfield||!s.age||!s.education||!s.companyName||!s.source||!s.existingDealer||!s.description||!s.address){J.error("Please fill in all required fields");return}if(!r){J.error("Please verify your mobile number");return}if(s.ownRoyalEnfield==="yes"&&!s.royalEnfieldModel){J.error("Please select your motorcycle model");return}if(!s.acceptTerms){J.error("Please accept the terms and conditions");return}try{const _=i.find(R=>R.id===s.stateId),A=d.find(R=>R.id===s.districtId),E=(_==null?void 0:_.name)||(_==null?void 0:_.stateName)||"",q=(A==null?void 0:A.name)||(A==null?void 0:A.districtName)||"",O={applicantName:s.name,email:s.email,phone:s.mobile,state:E,city:s.interestedCity,district:q,preferredLocation:`${s.interestedCity}, ${E}`,businessType:"Dealership",locationType:"district",locationId:s.districtId,address:s.address,pincode:s.pincode,age:s.age,education:s.education,companyName:s.companyName,source:s.source,existingDealer:s.existingDealer==="yes",ownRoyalEnfield:s.ownRoyalEnfield==="yes",royalEnfieldModel:s.royalEnfieldModel,description:s.description,experienceYears:0,investmentCapacity:"Unknown"};await ps.submitApplication(O),J.success("Application submitted successfully"),n({country:"India",stateId:"",districtId:"",name:"",interestedCity:"",email:"",pincode:"",mobile:"",ownRoyalEnfield:"",royalEnfieldModel:"",age:"",education:"",companyName:"",source:"",existingDealer:"",description:"",address:"",acceptTerms:!1}),a(!1)}catch(_){J.error(((D=(S=_.response)==null?void 0:S.data)==null?void 0:D.message)||"Failed to submit application.")}},j=["Continental GT","Interceptor 650","Himalayan","Classic 350","Classic 500","Thunderbird 350","Thunderbird 500","Thunderbird X 350","Thunderbird X 500","Bullet 350","Bullet 500","Bullet ES","Bullet Trials 350","Bullet Trials 500","Other Royal Enfield motorcycle"],b=["Existing RE dealer","Customer","RE Employee","News Paper","Website","Friends","Others"];return e.jsxs("div",{className:"min-h-screen relative flex flex-col",children:[e.jsxs("div",{className:"fixed inset-0 z-0",children:[e.jsx("img",{src:"/assets/images/become_a_dealer.webp",alt:"Royal Enfield Background",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/20"})]}),e.jsxs("nav",{className:"relative z-10 bg-black px-6 md:px-12 py-4 flex items-center justify-between border-b border-white/10",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-10 md:h-12 w-auto"}),e.jsxs(te,{variant:"ghost",onClick:t,className:"text-[10px] uppercase tracking-widest font-bold text-slate-400 hover:text-white transition-colors",children:[e.jsx(HI,{className:"w-3.5 h-3.5 mr-2"}),"Login"]})]}),e.jsx("main",{className:"relative z-10 flex-grow flex flex-col items-center pt-24 pb-24 px-6",children:e.jsxs("div",{className:"w-full max-w-[1240px] bg-white shadow-2xl p-8 md:p-16",children:[e.jsxs("section",{className:"text-[#333333] mb-12",children:[e.jsx("h1",{className:"text-[28px] font-bold mb-8 uppercase tracking-wide text-black",children:"Become a Dealer"}),e.jsxs("div",{className:"space-y-6 text-[15px] leading-relaxed",children:[e.jsx("p",{children:"At Royal Enfield, we endeavour to partner our patrons and customers in their journeys of exploration. Our main objective is to provide an immersive brand and retail experience in addition to ensuring a superior product experience. Our dealers, distributors and network teams are our extended partners in this task."}),e.jsx("p",{children:"Royal Enfield employs a comprehensive and professional process for Dealership allotment. Dealer selection is done based on a variety of criteria including a personal meeting with the applicant. It is only post completion of the evaluation and selection process, that other formalities are considered."}),e.jsx("p",{children:"Royal Enfield does not accept or demand money / deposits from prospective partners prior to processing the application or candidature of the Dealership."}),e.jsxs("p",{children:["If you receive any communication offering allotment of Royal Enfield Dealership against payment / transfer of money and / or otherwise, we advise you to seek information / clarifications by writing to us at ",e.jsx("b",{children:e.jsx("a",{href:"mailto:support@royalenfield.com",className:"text-red-600",children:"support@royalenfield.com"})})," or by contacting us on our customer care toll-free number ",e.jsx("b",{children:e.jsx("a",{href:"tel:18002100008",className:"text-red-600",children:"1800 210 0008"})}),"."]}),e.jsx("p",{className:"font-bold py-1 mt-8 text-black text-[15px]",children:"*This is the ONLY official website and central number for dealership enquiries for Royal Enfield and we do not have any other partner website(s)."})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.country,onChange:C=>n({...s,country:C.target.value}),children:[e.jsx("option",{value:"India",children:"India"}),e.jsx("option",{value:"Other",children:"Others"})]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.stateId,onChange:C=>p(C.target.value),children:[e.jsx("option",{value:"",children:"Select State*"}),i.map(C=>e.jsx("option",{value:C.id,children:C.name||C.stateName},C.id))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.districtId,onChange:C=>n({...s,districtId:C.target.value}),children:[e.jsx("option",{value:"",children:"Select District*"}),d.map(C=>e.jsx("option",{value:C.id,children:C.name||C.districtName},C.id))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-10 gap-y-6",children:[e.jsx(it,{placeholder:"Name*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.name,onChange:C=>n({...s,name:C.target.value})}),e.jsx(it,{placeholder:"Interested city for Dealership*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.interestedCity,onChange:C=>n({...s,interestedCity:C.target.value})}),e.jsx(it,{type:"email",placeholder:"Email Id*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.email,onChange:C=>n({...s,email:C.target.value})}),e.jsx(it,{type:"text",maxLength:6,placeholder:"Pincode*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.pincode,onChange:C=>{const S=C.target.value.replace(/\D/g,"");n({...s,pincode:S})}}),e.jsxs("div",{className:"relative",children:[e.jsx(it,{type:"text",maxLength:10,placeholder:"Mobile No.*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.mobile,onChange:C=>{const S=C.target.value.replace(/\D/g,"");n({...s,mobile:S})}}),r?e.jsx("span",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-[12px] font-bold text-green-600",children:"Verified"}):e.jsx("button",{type:"button",onClick:v,className:"absolute right-4 top-1/2 -translate-y-1/2 text-[12px] font-bold text-red-600 hover:text-black transition-colors",children:"Verify"})]}),e.jsxs("div",{className:"flex items-center gap-10 h-[44px]",children:[e.jsxs("span",{className:"text-[14px] font-medium text-[#333333]",children:["Own a Royal Enfield? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-8",children:["yes","no"].map(C=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s.ownRoyalEnfield===C?"border-red-600":"border-[#cccccc]"}`,children:s.ownRoyalEnfield===C&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-600"})}),e.jsx("input",{type:"radio",className:"hidden",checked:s.ownRoyalEnfield===C,onChange:()=>{n({...s,ownRoyalEnfield:C,royalEnfieldModel:C==="no"?"":s.royalEnfieldModel})}}),e.jsx("span",{className:"text-[14px] capitalize",children:C})]},C))})]}),e.jsx(it,{placeholder:"Age*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.age,onChange:C=>n({...s,age:C.target.value})}),s.ownRoyalEnfield==="yes"&&e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.royalEnfieldModel,onChange:C=>n({...s,royalEnfieldModel:C.target.value}),children:[e.jsx("option",{value:"",children:"Select Motorcycle*"}),j.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsx(it,{placeholder:"Education Qualification*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.education,onChange:C=>n({...s,education:C.target.value})}),e.jsx(it,{placeholder:"Company Name*",className:"h-[44px] border-[#cccccc] rounded-none px-4 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999]",value:s.companyName,onChange:C=>n({...s,companyName:C.target.value})}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full h-[44px] px-4 border border-[#cccccc] appearance-none bg-white text-[14px] outline-none",value:s.source,onChange:C=>n({...s,source:C.target.value}),children:[e.jsx("option",{value:"",children:"Select Source*"}),b.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(va,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsxs("div",{className:"flex flex-col justify-center h-auto min-h-[44px] space-y-1",children:[e.jsxs("span",{className:"text-[13px] font-medium text-[#333333]",children:["Are you an existing Dealer / Vendor of Royal Enfield? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-8",children:["yes","no"].map(C=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${s.existingDealer===C?"border-red-600":"border-[#cccccc]"}`,children:s.existingDealer===C&&e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-600"})}),e.jsx("input",{type:"radio",className:"hidden",checked:s.existingDealer===C,onChange:()=>n({...s,existingDealer:C})}),e.jsx("span",{className:"text-[14px] capitalize",children:C})]},C))})]})]}),e.jsxs("div",{className:"space-y-6 pt-4",children:[e.jsx(Ks,{placeholder:"Description*",className:"min-h-[120px] border-[#cccccc] rounded-none px-4 py-3 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999] resize-none",value:s.description,onChange:C=>n({...s,description:C.target.value})}),e.jsx(Ks,{placeholder:"Address*",className:"min-h-[120px] border-[#cccccc] rounded-none px-4 py-3 text-[14px] focus-visible:ring-1 focus-visible:ring-black placeholder:text-[#999999] resize-none",value:s.address,onChange:C=>n({...s,address:C.target.value})})]}),e.jsxs("div",{className:"pt-6 space-y-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("p",{className:"text-[14px] text-[#666666] leading-relaxed",children:["Disclaimer: By signing this form/checking this box, you acknowledge and agree that we may use the information you share with us, to communicate with you through e-mails, text messages, WhatsApp and calls, in order to provide our product or service related information and/or for promotional and marketing purposes. All information provided will be secured and processed as per our ",e.jsx("b",{children:"privacy policy"}),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tn,{id:"terms",className:"w-5 h-5 border-[#cccccc] rounded-none data-[state=checked]:bg-black data-[state=checked]:border-black",checked:s.acceptTerms,onCheckedChange:C=>n({...s,acceptTerms:C})}),e.jsxs("label",{htmlFor:"terms",className:"text-[14px] font-medium cursor-pointer",children:["I accept the ",e.jsx("b",{children:"terms and conditions"})," as well as ",e.jsx("b",{children:"privacy policy"}),".",e.jsx("span",{className:"text-red-500",children:"*"})]})]})]}),e.jsxs("button",{type:"submit",disabled:!N,className:"h-12 px-10 bg-black text-white flex items-center gap-3 hover:bg-slate-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-[14px]",children:"Submit"}),e.jsx(mi,{className:"w-4 h-4"})]})]})]})]})}),e.jsx("footer",{className:"relative z-10 bg-black py-16",children:e.jsxs("div",{className:"max-w-[1240px] mx-auto px-6 grid grid-cols-1 md:grid-cols-3 items-center gap-8",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-10 w-auto opacity-100"}),e.jsxs("div",{className:"flex justify-center gap-12 text-[10px] font-bold uppercase tracking-widest text-slate-500",children:[e.jsx("a",{href:"#",className:"hover:text-white transition-all",children:"Legal"}),e.jsx("a",{href:"#",className:"hover:text-white transition-all",children:"Privacy"}),e.jsx("a",{href:"#",className:"hover:text-white transition-all",children:"Terms"})]}),e.jsx("p",{className:"text-[10px] text-center md:text-right uppercase tracking-widest text-slate-500 font-bold",children:"© 2026 Royal Enfield. All Rights Reserved."})]})})]})}const LM=()=>{const{applicationId:t}=gd(),s=tr(),{user:n}=Pn(A=>A.auth),[r,a]=g.useState(!0),[i,o]=g.useState([]),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState({}),[u,N]=g.useState(!1),[v,w]=g.useState("none");g.useEffect(()=>{(async()=>{var E,q;if(t)try{const O=await Re.getPublicQuestionnaire(t);if(O.data.success){const R=O.data.data.questions||[];o(R);const P=Array.from(new Set(R.map(L=>L.sectionName)));m(P),P.length>0&&p(P[0])}}catch(O){console.error("Error fetching questionnaire:",O),((q=(E=O.response)==null?void 0:E.data)==null?void 0:q.code)==="ALREADY_SUBMITTED"?w("already"):J.error("Failed to load questionnaire")}finally{a(!1)}})()},[t]);const j=(A,E)=>{x(q=>({...q,[A]:E}))},b=()=>{const A=d.indexOf(f);A<d.length-1&&(p(d[A+1]),window.scrollTo({top:0,behavior:"smooth"}))},C=()=>{const A=d.indexOf(f);A>0&&(p(d[A-1]),window.scrollTo({top:0,behavior:"smooth"}))},S=async()=>{const A=i.filter(E=>E.isMandatory&&!h[E.id]);if(A.length>0){J.error(`Please answer all mandatory questions. Missing: ${A.length}`);return}try{N(!0);const E=Object.entries(h).map(([q,O])=>({questionId:q,value:O}));await Re.submitPublicResponse({applicationId:t,responses:E}),J.success("Responses submitted successfully"),w("success")}catch(E){console.error(E),J.error("Failed to submit responses")}finally{N(!1)}};if(r)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-slate-50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})});if(v!=="none"){const A=v==="already";return e.jsx("div",{className:"min-h-screen bg-slate-50 flex flex-col items-center justify-center p-6",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center border-t-4 border-re-red",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4 ${A?"bg-slate-100 text-slate-600":"bg-green-100 text-green-600"}`,children:A?e.jsx(qa,{className:"w-8 h-8"}):e.jsx(ln,{className:"w-8 h-8"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-slate-900",children:A?"Already submitted":"Thank you"}),e.jsx("p",{className:"text-slate-600 leading-relaxed",children:A?e.jsx(e.Fragment,{children:"This questionnaire has already been submitted for your application. You do not need to complete it again. If you think this is a mistake, contact support using the same email you used to apply. You may close this page when you are done."}):e.jsx(e.Fragment,{children:"Your assessment has been submitted successfully. We have received your responses and will review them as part of your application. You may close this page when you are done."})})]})})}const D=i.filter(A=>A.sectionName===f),_=d.indexOf(f);return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden h-screen bg-slate-50",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 font-bold text-xl",children:"Dealer Questionnaire Form"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-2xl leading-snug",children:"Answer each section accurately. Your responses are part of the dealership application assessment and may be verified."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[n&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center",children:e.jsx(Rr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:n.name||"Applicant"}),e.jsx("p",{className:"text-slate-600 text-xs",children:n.role||"Prospective Dealer"})]})]}),e.jsx("button",{className:"p-2 text-slate-500 hover:bg-slate-100 rounded-lg",title:"Refresh",onClick:()=>window.location.reload(),children:e.jsx(or,{className:"w-4 h-4"})}),e.jsx("button",{className:"p-2 text-slate-500 hover:bg-slate-100 rounded-lg",title:"Help",children:e.jsx(ok,{className:"w-4 h-4"})})]})]})}),e.jsxs("main",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"bg-white border-b border-slate-200 sticky top-0 z-20 shadow-sm",children:e.jsx("div",{className:"max-w-5xl mx-auto px-8 py-3",children:e.jsxs("button",{onClick:()=>s("/prospective-dashboard"),className:"inline-flex items-center gap-2 text-sm font-medium text-slate-600 hover:text-slate-900 transition-colors px-3 py-2 rounded-lg hover:bg-slate-100",children:[e.jsx(Wr,{className:"w-4 h-4"}),"Back to Applicant Portal"]})})}),e.jsxs("div",{className:"max-w-5xl mx-auto py-8 px-6",children:[e.jsxs("div",{className:"bg-re-black rounded-t-lg overflow-hidden shadow-xl",children:[e.jsx("div",{className:"relative px-8 py-12",children:e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-7",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-12 w-auto"})}),e.jsx("div",{className:"h-1 w-24 bg-re-red mx-auto mb-4"}),e.jsx("h2",{className:"text-re-red text-xl mb-4 font-light",children:"Dealership Partner Application"}),e.jsx("p",{className:"text-slate-300 max-w-2xl mx-auto leading-relaxed text-sm",children:"Thank you for your interest in becoming a Royal Enfield business partner. Please complete this questionnaire to help us understand your profile and aspirations."}),e.jsxs("div",{className:"flex items-center justify-center gap-8 mt-8 border-t border-slate-700/50 pt-6 inline-flex mx-auto",children:[e.jsxs("div",{className:"text-center px-4",children:[e.jsx("div",{className:"text-re-red text-2xl font-bold",children:i.length}),e.jsx("div",{className:"text-slate-400 text-xs uppercase tracking-wider",children:"Questions"})]}),e.jsx("div",{className:"h-10 w-px bg-slate-700"}),e.jsxs("div",{className:"text-center px-4",children:[e.jsx("div",{className:"text-re-red text-2xl font-bold",children:d.length}),e.jsx("div",{className:"text-slate-400 text-xs uppercase tracking-wider",children:"Sections"})]})]})]})}),e.jsx("div",{className:"bg-slate-800/50 backdrop-blur-sm border-t border-slate-700",children:e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide px-8 py-4 no-scrollbar",children:d.map(A=>e.jsxs("button",{onClick:()=>p(A),className:`flex items-center gap-2 px-4 py-2 rounded-lg whitespace-nowrap transition-all text-sm font-medium
|
||
${f===A?"bg-re-red text-white shadow-lg":"bg-slate-700/50 text-slate-300 hover:bg-slate-700 hover:text-white"}`,children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{children:A}),f===A&&e.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded text-xs",children:i.filter(E=>E.sectionName===A).length})]},A))})})]}),e.jsx("div",{className:"bg-white rounded-b-lg shadow-xl border border-slate-200 border-t-0 min-h-[400px]",children:e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-start gap-4 pb-6 border-b-2 border-red-100 mb-8",children:[e.jsx("div",{className:"w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center flex-shrink-0 text-re-red",children:e.jsx(ja,{className:"w-6 h-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-slate-900 text-xl font-bold mb-1",children:f}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["Section ",_+1," of ",d.length," • ",D.length," questions"]})]})]}),e.jsxs("div",{className:"space-y-10",children:[D.map((A,E)=>e.jsx("div",{className:"group animate-in fade-in duration-500",style:{animationDelay:`${E*100}ms`},children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:"w-8 h-8 bg-slate-100 rounded-full flex items-center justify-center flex-shrink-0 group-hover:bg-red-50 transition-colors text-slate-600 group-hover:text-re-red-hover font-semibold text-sm",children:E+1}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("label",{className:"text-sm font-medium text-slate-900 leading-relaxed block",children:[A.questionText,A.isMandatory&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}),e.jsxs("div",{className:"max-w-xl",children:[(A.inputType==="text"||A.inputType==="email"||A.inputType==="number")&&e.jsx("input",{type:A.inputType,className:"w-full h-10 px-3 rounded-lg border border-slate-300 focus:border-re-red focus:ring-2 focus:ring-red-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:h[A.id]||"",onChange:q=>j(A.id,q.target.value)}),A.inputType==="textarea"&&e.jsx("textarea",{className:"w-full h-32 p-3 rounded-lg border border-slate-300 focus:border-re-red focus:ring-2 focus:ring-red-200 outline-none transition-all placeholder:text-slate-400",placeholder:"Type your answer here...",value:h[A.id]||"",onChange:q=>j(A.id,q.target.value)}),(A.inputType==="select"||A.inputType==="yesno"||A.inputType==="radio"||A.inputType==="mcq")&&e.jsx("div",{className:"space-y-2",children:(A.questionOptions||(A.inputType==="yesno"?[{optionText:"Yes"},{optionText:"No"}]:[])).map((q,O)=>{const R=q.optionText||q.text;return e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group/opt",children:[e.jsx("input",{type:"radio",name:`q-${A.id}`,className:"w-4 h-4 text-re-red focus:ring-re-red border-slate-300",checked:h[A.id]===R,onChange:()=>j(A.id,R)}),e.jsx("span",{className:"text-slate-700 group-hover/opt:text-slate-900 transition-colors",children:R})]},O)})})]})]})]})},A.id)),D.length===0&&e.jsx("div",{className:"text-center py-10 text-slate-500 italic",children:"No questions in this section."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-10 mt-10 border-t border-slate-100",children:[e.jsx("button",{onClick:C,disabled:_===0,className:"px-6 py-2.5 rounded-lg text-sm font-medium border border-slate-300 text-slate-700 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Previous Section"}),_<d.length-1?e.jsxs("button",{onClick:b,className:"px-6 py-2.5 rounded-lg text-sm font-medium bg-re-red text-white hover:bg-re-red-hover flex items-center gap-2 transition-colors shadow-md hover:shadow-lg",children:["Next Section",e.jsx(mi,{className:"w-4 h-4"})]}):e.jsxs("button",{onClick:S,disabled:u,className:"px-8 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 flex items-center gap-2 transition-colors shadow-md hover:shadow-lg disabled:bg-slate-400",children:[u?"Submitting...":"Submit Application",!u&&e.jsx(ln,{className:"w-4 h-4"})]})]})]})}),e.jsx("div",{className:"mt-8 text-center text-slate-500 text-sm",children:"© 2026 Royal Enfield. All rights reserved."})]})]})]})};var IM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],MM=IM.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),FM="Label",fk=g.forwardRef((t,s)=>e.jsx(MM.label,{...t,ref:s,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));fk.displayName=FM;var BM=fk;function le({className:t,...s}){return e.jsx(BM,{"data-slot":"label",className:Nt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...s})}const $M=[{id:"15",name:"Super Admin",email:"admin@royalenfield.com",password:"Admin@123",role:"Super Admin"},{id:"13",name:"piyush",email:"piyush@royalenfield.com",password:"Admin@123",role:"DD-ZM"},{id:"14",name:"manish",email:"manish@royalenfield.com",password:"Admin@123",role:"RBM"},{id:"14",name:"manav",email:"manav@royalenfield.com",password:"Admin@123",role:"ZBH"},{id:"5",name:"Jaya",email:"jaya@royalenfield.com",password:"Admin@123",role:"DD Lead"},{id:"14",name:"ganesh",email:"ganesh@royalenfield.com",password:"Admin@123",role:"DD Head"},{id:"16",name:"Yashwin",email:"yashwin@royalenfield.com",password:"Admin@123",role:"NBH"},{id:"15",name:"FDD Team",email:"fdd@royalenfield.com",password:"Admin@123",role:"FDD"},{id:"13",name:"Finance Admin",email:"finance@royalenfield.com",password:"Admin@123",role:"Finance"},{id:"13",name:"abhishek",email:"abhishek@royalenfield.com",password:"Admin@123",role:"ASM"},{id:"18",name:"Lince",email:"lince@royalenfield.com",password:"Admin@123",role:"DD Admin"},{id:"18",name:"Legal Admin",email:"legal@royalenfield.com",password:"Admin@123",role:"Legal Admin"},{id:"18",name:"CEO",email:"ceo@royalenfield.com",password:"Admin@123",role:"CEO"},{id:"18",name:"CCO",email:"cco@royalenfield.com",password:"Admin@123",role:"CCO"}],Ci={totalApplications:0,loaIssued:0,level1Pending:0,level2Pending:0,level3Pending:0,eorInProgress:0,disqualified:0,pendingReminders:0,shortlistedToday:0,pendingShortlisting:0},qM=[];function _1({onLogin:t}){const[s,n]=g.useState(""),[r,a]=g.useState(""),[i,o]=g.useState(!1),[d,m]=g.useState(""),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState(null),j=async(D,_)=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(D),w(_),setTimeout(()=>w(null),2e3);return}}catch{}try{const A=document.createElement("textarea");A.value=D,A.style.position="fixed",A.style.left="-999999px",A.style.top="-999999px",document.body.appendChild(A),A.focus(),A.select();const E=document.execCommand("copy");document.body.removeChild(A),E&&(w(_),setTimeout(()=>w(null),2e3))}catch{}},b=async(D,_)=>{var A,E;n(D),a(_),m(""),x(!0);try{await t(D,_)}catch(q){const O=((E=(A=q.response)==null?void 0:A.data)==null?void 0:E.message)||q.message||"Auto-login failed";m(O),J.error(O)}finally{x(!1)}},C=async D=>{var _,A;if(D.preventDefault(),!h){if(m(""),!s||!r){m("Please enter both email and password");return}x(!0);try{await t(s,r)}catch(E){const q=((A=(_=E.response)==null?void 0:_.data)==null?void 0:A.message)||E.message||"Login failed";m(q),J.error(q)}finally{x(!1)}}},S=D=>{D.preventDefault(),alert("Password reset link sent to "+s),p(!1)};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-black p-4 overflow-y-auto",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-red-700/15 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-red-700/15 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-6xl grid md:grid-cols-2 gap-8 my-8",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-16 w-auto object-contain"})}),e.jsx("p",{className:"text-slate-400",children:"Dealership Onboarding System"})]}),e.jsx("div",{className:"bg-white rounded-lg shadow-2xl p-8",children:f?e.jsxs("form",{onSubmit:S,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"mb-2",children:"Reset Password"}),e.jsx("p",{className:"text-slate-600",children:"Enter your email to receive a password reset link"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reset-email",children:"Email Address"}),e.jsx(it,{id:"reset-email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:D=>n(D.target.value),required:!0,className:"w-full"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>p(!1),className:"flex-1",children:"Back to Login"}),e.jsx(te,{type:"submit",className:"flex-1 bg-re-red hover:bg-re-red-hover text-white",children:"Send Reset Link"})]})]}):e.jsxs("form",{onSubmit:C,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"email",children:"Email Address"}),e.jsx(it,{id:"email",type:"email",placeholder:"you@royalenfield.com",value:s,onChange:D=>n(D.target.value),className:"w-full",disabled:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(it,{id:"password",type:u?"text":"password",placeholder:"Enter your password",value:r,onChange:D=>a(D.target.value),className:"no-native-password-reveal w-full pr-10",autoComplete:"current-password",disabled:h}),e.jsx("button",{type:"button",onClick:()=>N(!u),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 focus:outline-none",disabled:h,children:u?e.jsx(II,{className:"w-5 h-5"}):e.jsx(un,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:"remember",checked:i,onCheckedChange:D=>o(D),disabled:h}),e.jsx(le,{htmlFor:"remember",className:"cursor-pointer",children:"Remember Me"})]}),e.jsx("button",{type:"button",onClick:()=>p(!0),className:"text-re-red hover:text-re-red-hover disabled:opacity-50",disabled:h,children:"Forgot Password?"})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:d})]}),e.jsx(te,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-11 text-white",disabled:h,children:h?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),e.jsx("span",{children:"Logging in..."})]}):"Login"}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-slate-200"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-white px-2 text-slate-500",children:"Or"})})]}),e.jsx(te,{type:"button",variant:"outline",className:"w-full border-re-red text-re-red hover:bg-red-50 h-11",onClick:()=>window.location.href="/prospective-login",children:"Prospective User Login"})]})]})}),e.jsx("div",{className:"text-center mt-6 text-slate-400",children:e.jsx("p",{children:"© 2026 Royal Enfield. All rights reserved."})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl p-8 overflow-y-auto max-h-[800px]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"mb-2",children:"Test User Credentials"}),e.jsx("p",{className:"text-slate-600",children:"Click on any user to auto-login"})]}),e.jsx("div",{className:"space-y-3",children:$M.map((D,_)=>e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 hover:border-re-red hover:bg-red-50 transition-all cursor-pointer",onClick:()=>b(D.email,D.password),children:[e.jsx("div",{className:"flex items-start justify-between mb-2",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("span",{className:"px-2 py-1 bg-red-100 text-re-red rounded text-xs",children:D.role})}),e.jsx("p",{className:"text-slate-900",children:D.name})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-slate-500",children:"Email:"}),e.jsx("p",{className:"text-slate-900 font-mono break-all",children:D.email})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),j(D.email,_*2)},className:"p-2 hover:bg-slate-100 rounded",children:v===_*2?e.jsx($n,{className:"w-4 h-4 text-green-600"}):e.jsx(C1,{className:"w-4 h-4 text-slate-400"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-slate-500",children:"Password:"}),e.jsx("p",{className:"text-slate-900 font-mono",children:D.password})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),j(D.password,_*2+1)},className:"p-2 hover:bg-slate-100 rounded",children:v===_*2+1?e.jsx($n,{className:"w-4 h-4 text-green-600"}):e.jsx(C1,{className:"w-4 h-4 text-slate-400"})})]})]}),e.jsx("div",{className:"mt-3 pt-3 border-t border-slate-200",children:e.jsxs("p",{className:"text-re-red text-center",children:["Click to login as ",D.role]})})]},D.email))})]})]})]})}function zM(){const t=tr(),s=Lu(),[n,r]=g.useState("PHONE"),[a,i]=g.useState(""),[o,d]=g.useState(""),[m,f]=g.useState(!1),[p,h]=g.useState(""),x=async N=>{var v;if(N.preventDefault(),!a||a.length<10){h("Please enter a valid 10-digit phone number");return}f(!0),h("");try{const w=await Re.sendOtp(a);if(w.ok)r("OTP"),J.success("OTP sent successfully!");else{console.error("Send OTP error response:",w);const j=((v=w.data)==null?void 0:v.message)||"Failed to send OTP";h(j),J.error(j)}}catch(w){console.error("Send OTP network error:",w),h("Network error. Please try again."),J.error("Network error. Please try again.")}finally{f(!1)}},u=async N=>{var v;if(N.preventDefault(),!o||o.length<6){h("Please enter a valid 6-digit OTP");return}f(!0),h("");try{const w=await Re.verifyOtp(a,o);if(w.ok&&w.data){const{token:j,user:b}=w.data.data||w.data;if(!j||!b)throw new Error("Invalid response format");s(wA({user:b,token:j})),localStorage.setItem("token",j),J.success("Logged in successfully!"),t("/prospective-dashboard")}else{const j=((v=w.data)==null?void 0:v.message)||"Invalid OTP";h(j),J.error(j)}}catch(w){console.error("Verify OTP error:",w),h("An unexpected error occurred"),J.error("An unexpected error occurred")}finally{f(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 p-4 overflow-y-auto",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-re-red/10 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-re-red/10 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 bg-re-red rounded-full mb-4",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"w-12 h-12 text-white",fill:"currentColor",children:[e.jsx("path",{d:"M12 2L4 6v6c0 5.5 3.8 10.7 8 12 4.2-1.3 8-6.5 8-12V6l-8-4zm0 2.2l6 3v4.8c0 4.5-3.1 8.7-6 10-2.9-1.3-6-5.5-6-10V7.2l6-3z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),e.jsx("h1",{className:"text-white mb-2",children:"Royal Enfield"}),e.jsx("p",{className:"text-slate-400",children:"Dealer Login"})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl p-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs(te,{variant:"ghost",className:"px-0 flex items-center gap-2 text-slate-600 hover:text-slate-900 mb-4 hover:bg-transparent",onClick:()=>n==="OTP"?r("PHONE"):t("/admin-login"),children:[e.jsx(Wr,{className:"w-4 h-4"}),n==="OTP"?"Change Phone Number":"Back to Login"]}),e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(XI,{className:"w-6 h-6 text-re-red"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-slate-900 text-lg font-semibold",children:"Dealer Login"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Login with your registered phone number"})]})]})]}),n==="PHONE"?e.jsxs("form",{onSubmit:x,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"phone",children:"Registered Phone Number"}),e.jsx(it,{id:"phone",type:"tel",placeholder:"Enter 10-digit phone number",maxLength:10,value:a,onChange:N=>i(N.target.value.replace(/\D/g,"")),className:"w-full",disabled:m}),e.jsx("p",{className:"text-slate-500 text-xs",children:"Enter the phone number you used during application"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:p})]}),e.jsx(te,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:m||a.length<10,children:m?"Sending...":"Send OTP"}),e.jsx("div",{className:"text-center text-slate-500 text-xs",children:e.jsx("p",{children:"You will receive a 6-digit OTP on your registered mobile number"})})]}):e.jsxs("form",{onSubmit:u,className:"space-y-6",children:[e.jsx("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:e.jsxs("p",{className:"text-green-800 text-center text-sm",children:["OTP sent to +91 ",a]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"otp",children:"Enter OTP"}),e.jsx(it,{id:"otp",type:"text",placeholder:"Enter 6-digit OTP",maxLength:6,value:o,onChange:N=>d(N.target.value.replace(/\D/g,"")),className:"w-full text-center text-2xl tracking-widest",disabled:m}),e.jsx("p",{className:"text-slate-500 text-xs text-center",children:"Check your SMS for the OTP"})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:p})]}),e.jsx(te,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:m||o.length<6,children:m?"Verifying...":"Verify OTP"}),e.jsxs("div",{className:"text-center text-sm",children:[e.jsx("button",{type:"button",className:"text-re-red hover:text-re-red-hover font-medium",onClick:()=>r("PHONE"),children:"Change Phone Number"}),e.jsx("span",{className:"mx-2 text-slate-400",children:"|"}),e.jsx("button",{type:"button",className:"text-re-red hover:text-re-red-hover font-medium",onClick:x,disabled:m,children:"Resend OTP"})]})]})]}),e.jsx("div",{className:"text-center mt-6 text-slate-400",children:e.jsx("p",{children:"© 2025 Royal Enfield. All rights reserved."})})]})]})}function UM({onLogout:t}){const s=tr(),r=xl().pathname.substring(1)||"dashboard",{user:a}=Pn(L=>L.auth),[i,o]=g.useState(!1),[d,m]=g.useState(""),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(null),v=g.useRef(null),w=L=>{const $=L.map(W=>W.toLowerCase()),Z=String((a==null?void 0:a.role)||"").toLowerCase(),Q=String((a==null?void 0:a.roleCode)||"").toLowerCase();return $.includes(Z)||$.includes(Q)},j=["DD Admin","DD_ADMIN","ASM","RBM","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","ZBH","NBH","Legal","Legal Admin","LEGAL_ADMIN","Super Admin","SUPER_ADMIN"],b=["ASM","RBM","DD-ZM","DD_ZM","ZBH","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Legal Admin","LEGAL_ADMIN","Legal","DD Admin","DD_ADMIN","CCO","CEO","Super Admin","SUPER_ADMIN"],C=["DD Admin","DD_ADMIN","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Finance","Finance Admin","FINANCE_ADMIN","Super Admin","SUPER_ADMIN"],S=w(j),D=w(b),_=w(C),A=[S?{id:"resignation",label:"Resignation"}:null,D?{id:"termination",label:"Termination"}:null,_?{id:"fnf",label:"F&F"}:null].filter(Boolean),E=w(["Finance","Finance Admin"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"finance-onboarding",label:"Onboarding",icon:ks},{id:"finance-fnf",label:"F&F",icon:xg}]:w(["Dealer"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"dealer-resignation",label:"My Resignations",icon:xg},{id:"dealer-constitutional",label:"Constitutional Change",icon:cl},{id:"dealer-relocation",label:"Relocation Requests",icon:Mr}]:w(["FDD"])?[{id:"fdd-dashboard",label:"FDD Dashboard",icon:um}]:[{id:"dashboard",label:"Dashboard",icon:um},{id:"applications",label:"Dealership Requests",icon:ks},...A.length>0?[{id:"offboarding",label:"Offboarding",icon:xg,hasSubmenu:!0,submenuKey:"offboarding",submenu:A}]:[],{id:"constitutional-change",label:"Constitutional Change",icon:cl},{id:"relocation-requests",label:"Relocation Requests",icon:Mr}];w(["DD Lead","DD Admin","Super Admin"])&&E.splice(1,0,{id:"all-requests",label:"All Requests",icon:BI,hasSubmenu:!0,submenuKey:"allRequests",submenu:[{id:"opportunity-requests",label:"Opportunity Requests"},{id:"non-opportunities",label:"Non-opportunities"}]}),w(["Super Admin","DD Admin","DD Lead"])&&(E.push({id:"master",label:"Master",icon:Qc}),E.push({id:"sla-configurations",label:"SLA Matrix",icon:cl})),w(["Super Admin"])&&(E.push({id:"users",label:"User Management",icon:ja}),E.push({id:"questionnaires",label:"Questionnaire Templates",icon:sc}),E.push({id:"interview-configs",label:"Interview Configs",icon:VI}),E.push({id:"system-logs",label:"System Logs",icon:rd}));const q=L=>{L.preventDefault(),d.trim()&&s("/applications")},O=g.useCallback((L,$)=>{v.current&&clearTimeout(v.current);const Z=$.getBoundingClientRect();N({submenuKey:L,top:Z.top,left:Z.right+8})},[]),R=g.useCallback((L=!1)=>{L?(v.current&&clearTimeout(v.current),N(null)):v.current=setTimeout(()=>N(null),150)},[]),P=g.useCallback(()=>{v.current&&clearTimeout(v.current)},[]);return g.useEffect(()=>{i||N(null)},[i]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-black text-white h-screen flex flex-col transition-all duration-300 overflow-hidden relative flex-shrink-0 ${i?"w-20":"w-64"}`,children:[e.jsx("div",{className:"border-b border-white/10",children:i?e.jsxs("div",{className:"flex flex-col items-center py-3 gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-white flex items-center justify-center p-1 shadow-md",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"RE",className:"w-full h-full object-contain"})}),e.jsx("button",{onClick:()=>o(!1),className:"p-1.5 hover:bg-white/10 rounded-lg transition-colors text-slate-400 hover:text-white",title:"Expand sidebar",children:e.jsx(mi,{className:"w-4 h-4"})})]}):e.jsxs("div",{className:"flex items-center justify-between px-4 py-4",children:[e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"h-6 w-auto"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-slate-400 mt-1 whitespace-nowrap",children:"Dealer Network"})]}),e.jsx("button",{onClick:()=>o(!0),className:"p-1.5 hover:bg-white/10 rounded-lg transition-colors text-slate-400 hover:text-white flex-shrink-0 ml-2",title:"Collapse sidebar",children:e.jsx(io,{className:"w-4 h-4"})})]})}),!i&&e.jsx("div",{className:"p-4 border-b border-white/10",children:e.jsxs("form",{onSubmit:q,className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search applications...",value:d,onChange:L=>m(L.target.value),className:"w-full pl-10 bg-white/5 border-white/10 text-white placeholder:text-slate-500"})]})}),e.jsx("nav",{className:"flex-1 p-3 space-y-1 overflow-y-auto custom-scrollbar",children:E.map(L=>{var z,T;const $=L.icon,Z=r===L.id,Q=!!L.hasSubmenu,W=Q&&((z=L.submenu)==null?void 0:z.some(F=>r===F.id)),U=L.submenuKey,M=U==="offboarding"?f:U==="allRequests"?h:!1;return e.jsxs("div",{children:[e.jsxs("button",{onMouseEnter:F=>{i&&Q&&U&&O(U,F.currentTarget)},onMouseLeave:()=>{i&&Q&&R()},onClick:()=>{Q?i?(o(!1),U==="offboarding"?p(!0):U==="allRequests"&&x(!0)):U==="offboarding"?p(!f):U==="allRequests"&&x(!h):s(`/${L.id}`)},className:`w-full flex items-center gap-3 px-3 py-3 rounded-lg transition-colors ${i?"justify-center":""} ${Z||W?"bg-re-red text-white shadow-lg shadow-re-red/20":"text-slate-400 hover:bg-white/5 hover:text-white"}`,title:i?L.label:void 0,children:[e.jsx($,{className:"w-5 h-5 flex-shrink-0"}),!i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left text-sm",children:L.label}),Q&&(M?e.jsx(yu,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(va,{className:"w-4 h-4 flex-shrink-0"}))]})]}),Q&&M&&!i&&e.jsx("div",{className:"ml-3 mt-1 space-y-1 border-l border-white/10 pl-3",children:(T=L.submenu)==null?void 0:T.map(F=>{const I=r===F.id;return e.jsxs("button",{onClick:()=>s(`/${F.id}`),className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-sm ${I?"bg-re-red/20 text-re-red font-semibold":"text-slate-500 hover:bg-white/5 hover:text-white"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{children:F.label})]},F.id)})})]},L.id)})}),e.jsxs("div",{className:"p-4 border-t border-white/10 space-y-2",children:[!i&&a&&e.jsx("div",{className:"px-4 py-2 bg-white/5 rounded-lg mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-re-red rounded-full flex items-center justify-center font-bold flex-shrink-0",children:e.jsx("span",{children:a.name.charAt(0)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold",children:a.name}),e.jsx("p",{className:"text-slate-500 truncate text-[11px] uppercase tracking-wider",children:a.role})]})]})}),i&&a&&e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("div",{className:"w-9 h-9 bg-re-red rounded-full flex items-center justify-center font-bold text-sm",title:a.name,children:e.jsx("span",{children:a.name.charAt(0)})})}),e.jsxs(te,{onClick:t,variant:"ghost",className:`w-full ${i?"px-2 justify-center":"justify-start"} text-slate-400 hover:bg-white/5 hover:text-white`,title:i?"Logout":void 0,children:[e.jsx(uk,{className:"w-5 h-5 flex-shrink-0"}),!i&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),u&&i&&(()=>{const L=E.find($=>$.submenuKey===u.submenuKey);return!L||!L.submenu?null:Hy.createPortal(e.jsxs("div",{style:{top:u.top,left:u.left},className:"fixed z-[9999] min-w-[200px] bg-gray-900 border border-white/10 rounded-xl shadow-2xl py-2",onMouseEnter:P,onMouseLeave:()=>R(),children:[e.jsx("div",{className:"px-4 py-1.5 text-xs font-bold uppercase tracking-widest text-slate-400 border-b border-white/10 mb-1",children:L.label}),L.submenu.map($=>{const Z=r===$.id;return e.jsxs("button",{onClick:()=>{s(`/${$.id}`),R(!0)},className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors ${Z?"bg-re-red/20 text-re-red font-semibold":"text-slate-300 hover:bg-white/10 hover:text-white"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{children:$.label})]},$.id)})]}),document.body)})()]})}function T1(t){const s=VM(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(WM);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function VM(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=KM(a),d=GM(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var HM=Symbol("radix.slottable");function WM(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===HM}function GM(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function KM(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function rb(t){const s=t+"CollectionProvider",[n,r]=oa(s),[a,i]=n(s,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:w,children:j}=v,b=Ct.useRef(null),C=Ct.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:C,collectionRef:b,children:j})};o.displayName=s;const d=t+"CollectionSlot",m=T1(d),f=Ct.forwardRef((v,w)=>{const{scope:j,children:b}=v,C=i(d,j),S=Ys(w,C.collectionRef);return e.jsx(m,{ref:S,children:b})});f.displayName=d;const p=t+"CollectionItemSlot",h="data-radix-collection-item",x=T1(p),u=Ct.forwardRef((v,w)=>{const{scope:j,children:b,...C}=v,S=Ct.useRef(null),D=Ys(w,S),_=i(p,j);return Ct.useEffect(()=>(_.itemMap.set(S,{ref:S,...C}),()=>void _.itemMap.delete(S))),e.jsx(x,{[h]:"",ref:D,children:b})});u.displayName=p;function N(v){const w=i(t+"CollectionConsumer",v);return Ct.useCallback(()=>{const b=w.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((_,A)=>C.indexOf(_.ref.current)-C.indexOf(A.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:f,ItemSlot:u},N,r]}var YM=g.createContext(void 0);function Ku(t){const s=g.useContext(YM);return t||s||"ltr"}function xr(t){const s=g.useRef(t);return g.useEffect(()=>{s.current=t}),g.useMemo(()=>(...n)=>{var r;return(r=s.current)==null?void 0:r.call(s,...n)},[])}function ZM(t,s=globalThis==null?void 0:globalThis.document){const n=xr(t);g.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return s.addEventListener("keydown",r,{capture:!0}),()=>s.removeEventListener("keydown",r,{capture:!0})},[n,s])}var QM="DismissableLayer",ly="dismissableLayer.update",XM="dismissableLayer.pointerDownOutside",JM="dismissableLayer.focusOutside",P1,pk=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yd=g.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:d,...m}=t,f=g.useContext(pk),[p,h]=g.useState(null),x=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=g.useState({}),N=Ys(s,A=>h(A)),v=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(w),b=p?v.indexOf(p):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,S=b>=j,D=s3(A=>{const E=A.target,q=[...f.branches].some(O=>O.contains(E));!S||q||(a==null||a(A),o==null||o(A),A.defaultPrevented||d==null||d())},x),_=n3(A=>{const E=A.target;[...f.branches].some(O=>O.contains(E))||(i==null||i(A),o==null||o(A),A.defaultPrevented||d==null||d())},x);return ZM(A=>{b===f.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&d&&(A.preventDefault(),d()))},x),g.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(P1=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),O1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=P1)}},[p,x,n,f]),g.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),O1())},[p,f]),g.useEffect(()=>{const A=()=>u({});return document.addEventListener(ly,A),()=>document.removeEventListener(ly,A)},[]),e.jsx(Ss.div,{...m,ref:N,style:{pointerEvents:C?S?"auto":"none":void 0,...t.style},onFocusCapture:Yt(t.onFocusCapture,_.onFocusCapture),onBlurCapture:Yt(t.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Yt(t.onPointerDownCapture,D.onPointerDownCapture)})});yd.displayName=QM;var e3="DismissableLayerBranch",t3=g.forwardRef((t,s)=>{const n=g.useContext(pk),r=g.useRef(null),a=Ys(s,r);return g.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),e.jsx(Ss.div,{...t,ref:a})});t3.displayName=e3;function s3(t,s=globalThis==null?void 0:globalThis.document){const n=xr(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const i=d=>{if(d.target&&!r.current){let m=function(){xk(XM,n,f,{discrete:!0})};const f={originalEvent:d};d.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=m,s.addEventListener("click",a.current,{once:!0})):m()}else s.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,n]),{onPointerDownCapture:()=>r.current=!0}}function n3(t,s=globalThis==null?void 0:globalThis.document){const n=xr(t),r=g.useRef(!1);return g.useEffect(()=>{const a=i=>{i.target&&!r.current&&xk(JM,n,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function O1(){const t=new CustomEvent(ly);document.dispatchEvent(t)}function xk(t,s,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&a.addEventListener(t,s,{once:!0}),r?KA(a,i):a.dispatchEvent(i)}var vg=0;function Bf(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??L1()),document.body.insertAdjacentElement("beforeend",t[1]??L1()),vg++,()=>{vg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),vg--}},[])}function L1(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var yg="focusScope.autoFocusOnMount",bg="focusScope.autoFocusOnUnmount",I1={bubbles:!1,cancelable:!0},r3="FocusScope",Yu=g.forwardRef((t,s)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[d,m]=g.useState(null),f=xr(a),p=xr(i),h=g.useRef(null),x=Ys(s,v=>m(v)),u=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(C){if(u.paused||!d)return;const S=C.target;d.contains(S)?h.current=S:Gl(h.current,{select:!0})},w=function(C){if(u.paused||!d)return;const S=C.relatedTarget;S!==null&&(d.contains(S)||Gl(h.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&Gl(d)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const b=new MutationObserver(j);return d&&b.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),b.disconnect()}}},[r,d,u.paused]),g.useEffect(()=>{if(d){F1.add(u);const v=document.activeElement;if(!d.contains(v)){const j=new CustomEvent(yg,I1);d.addEventListener(yg,f),d.dispatchEvent(j),j.defaultPrevented||(a3(d3(gk(d)),{select:!0}),document.activeElement===v&&Gl(d))}return()=>{d.removeEventListener(yg,f),setTimeout(()=>{const j=new CustomEvent(bg,I1);d.addEventListener(bg,p),d.dispatchEvent(j),j.defaultPrevented||Gl(v??document.body,{select:!0}),d.removeEventListener(bg,p),F1.remove(u)},0)}}},[d,f,p,u]);const N=g.useCallback(v=>{if(!n&&!r||u.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,j=document.activeElement;if(w&&j){const b=v.currentTarget,[C,S]=i3(b);C&&S?!v.shiftKey&&j===S?(v.preventDefault(),n&&Gl(C,{select:!0})):v.shiftKey&&j===C&&(v.preventDefault(),n&&Gl(S,{select:!0})):j===b&&v.preventDefault()}},[n,r,u.paused]);return e.jsx(Ss.div,{tabIndex:-1,...o,ref:x,onKeyDown:N})});Yu.displayName=r3;function a3(t,{select:s=!1}={}){const n=document.activeElement;for(const r of t)if(Gl(r,{select:s}),document.activeElement!==n)return}function i3(t){const s=gk(t),n=M1(s,t),r=M1(s.reverse(),t);return[n,r]}function gk(t){const s=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)s.push(n.currentNode);return s}function M1(t,s){for(const n of t)if(!l3(n,{upTo:s}))return n}function l3(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function o3(t){return t instanceof HTMLInputElement&&"select"in t}function Gl(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&o3(t)&&s&&t.select()}}var F1=c3();function c3(){let t=[];return{add(s){const n=t[0];s!==n&&(n==null||n.pause()),t=B1(t,s),t.unshift(s)},remove(s){var n;t=B1(t,s),(n=t[0])==null||n.resume()}}}function B1(t,s){const n=[...t],r=n.indexOf(s);return r!==-1&&n.splice(r,1),n}function d3(t){return t.filter(s=>s.tagName!=="A")}var u3=wf[" useId ".trim().toString()]||(()=>{}),h3=0;function yr(t){const[s,n]=g.useState(u3());return Jn(()=>{n(r=>r??String(h3++))},[t]),t||(s?`radix-${s}`:"")}const m3=["top","right","bottom","left"],no=Math.min,ga=Math.max,lf=Math.round,mm=Math.floor,Pi=t=>({x:t,y:t}),f3={left:"right",right:"left",bottom:"top",top:"bottom"};function oy(t,s,n){return ga(t,no(s,n))}function hl(t,s){return typeof t=="function"?t(s):t}function ml(t){return t.split("-")[0]}function bd(t){return t.split("-")[1]}function ab(t){return t==="x"?"y":"x"}function ib(t){return t==="y"?"height":"width"}function _i(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function lb(t){return ab(_i(t))}function p3(t,s,n){n===void 0&&(n=!1);const r=bd(t),a=lb(t),i=ib(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[i]>s.floating[i]&&(o=of(o)),[o,of(o)]}function x3(t){const s=of(t);return[cy(t),s,cy(s)]}function cy(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const $1=["left","right"],q1=["right","left"],g3=["top","bottom"],v3=["bottom","top"];function y3(t,s,n){switch(t){case"top":case"bottom":return n?s?q1:$1:s?$1:q1;case"left":case"right":return s?g3:v3;default:return[]}}function b3(t,s,n,r){const a=bd(t);let i=y3(ml(t),n==="start",r);return a&&(i=i.map(o=>o+"-"+a),s&&(i=i.concat(i.map(cy)))),i}function of(t){const s=ml(t);return f3[s]+t.slice(s.length)}function j3(t){return{top:0,right:0,bottom:0,left:0,...t}}function vk(t){return typeof t!="number"?j3(t):{top:t,right:t,bottom:t,left:t}}function cf(t){const{x:s,y:n,width:r,height:a}=t;return{width:r,height:a,top:n,left:s,right:s+r,bottom:n+a,x:s,y:n}}function z1(t,s,n){let{reference:r,floating:a}=t;const i=_i(s),o=lb(s),d=ib(o),m=ml(s),f=i==="y",p=r.x+r.width/2-a.width/2,h=r.y+r.height/2-a.height/2,x=r[d]/2-a[d]/2;let u;switch(m){case"top":u={x:p,y:r.y-a.height};break;case"bottom":u={x:p,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:h};break;case"left":u={x:r.x-a.width,y:h};break;default:u={x:r.x,y:r.y}}switch(bd(s)){case"start":u[o]-=x*(n&&f?-1:1);break;case"end":u[o]+=x*(n&&f?-1:1);break}return u}async function N3(t,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:i,rects:o,elements:d,strategy:m}=t,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:x=!1,padding:u=0}=hl(s,t),N=vk(u),w=d[x?h==="floating"?"reference":"floating":h],j=cf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(w)))==null||n?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:p,strategy:m})),b=h==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),S=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},D=cf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:b,offsetParent:C,strategy:m}):b);return{top:(j.top-D.top+N.top)/S.y,bottom:(D.bottom-j.bottom+N.bottom)/S.y,left:(j.left-D.left+N.left)/S.x,right:(D.right-j.right+N.right)/S.x}}const w3=50,S3=async(t,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:o}=n,d=o.detectOverflow?o:{...o,detectOverflow:N3},m=await(o.isRTL==null?void 0:o.isRTL(s));let f=await o.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:h}=z1(f,r,m),x=r,u=0;const N={};for(let v=0;v<i.length;v++){const w=i[v];if(!w)continue;const{name:j,fn:b}=w,{x:C,y:S,data:D,reset:_}=await b({x:p,y:h,initialPlacement:r,placement:x,strategy:a,middlewareData:N,rects:f,platform:d,elements:{reference:t,floating:s}});p=C??p,h=S??h,N[j]={...N[j],...D},_&&u<w3&&(u++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(f=_.rects===!0?await o.getElementRects({reference:t,floating:s,strategy:a}):_.rects),{x:p,y:h}=z1(f,x,m)),v=-1)}return{x:p,y:h,placement:x,strategy:a,middlewareData:N}},C3=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:r,placement:a,rects:i,platform:o,elements:d,middlewareData:m}=s,{element:f,padding:p=0}=hl(t,s)||{};if(f==null)return{};const h=vk(p),x={x:n,y:r},u=lb(a),N=ib(u),v=await o.getDimensions(f),w=u==="y",j=w?"top":"left",b=w?"bottom":"right",C=w?"clientHeight":"clientWidth",S=i.reference[N]+i.reference[u]-x[u]-i.floating[N],D=x[u]-i.reference[u],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let A=_?_[C]:0;(!A||!await(o.isElement==null?void 0:o.isElement(_)))&&(A=d.floating[C]||i.floating[N]);const E=S/2-D/2,q=A/2-v[N]/2-1,O=no(h[j],q),R=no(h[b],q),P=O,L=A-v[N]-R,$=A/2-v[N]/2+E,Z=oy(P,$,L),Q=!m.arrow&&bd(a)!=null&&$!==Z&&i.reference[N]/2-($<P?O:R)-v[N]/2<0,W=Q?$<P?$-P:$-L:0;return{[u]:x[u]+W,data:{[u]:Z,centerOffset:$-Z-W,...Q&&{alignmentOffset:W}},reset:Q}}}),A3=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,r;const{placement:a,middlewareData:i,rects:o,initialPlacement:d,platform:m,elements:f}=s,{mainAxis:p=!0,crossAxis:h=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:N="none",flipAlignment:v=!0,...w}=hl(t,s);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const j=ml(a),b=_i(d),C=ml(d)===d,S=await(m.isRTL==null?void 0:m.isRTL(f.floating)),D=x||(C||!v?[of(d)]:x3(d)),_=N!=="none";!x&&_&&D.push(...b3(d,v,N,S));const A=[d,...D],E=await m.detectOverflow(s,w),q=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&q.push(E[j]),h){const $=p3(a,o,S);q.push(E[$[0]],E[$[1]])}if(O=[...O,{placement:a,overflows:q}],!q.every($=>$<=0)){var R,P;const $=(((R=i.flip)==null?void 0:R.index)||0)+1,Z=A[$];if(Z&&(!(h==="alignment"?b!==_i(Z):!1)||O.every(U=>_i(U.placement)===b?U.overflows[0]>0:!0)))return{data:{index:$,overflows:O},reset:{placement:Z}};let Q=(P=O.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:P.placement;if(!Q)switch(u){case"bestFit":{var L;const W=(L=O.filter(U=>{if(_){const M=_i(U.placement);return M===b||M==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(M=>M>0).reduce((M,z)=>M+z,0)]).sort((U,M)=>U[1]-M[1])[0])==null?void 0:L[0];W&&(Q=W);break}case"initialPlacement":Q=d;break}if(a!==Q)return{reset:{placement:Q}}}return{}}}};function U1(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function V1(t){return m3.some(s=>t[s]>=0)}const k3=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...i}=hl(t,s);switch(a){case"referenceHidden":{const o=await r.detectOverflow(s,{...i,elementContext:"reference"}),d=U1(o,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:V1(d)}}}case"escaped":{const o=await r.detectOverflow(s,{...i,altBoundary:!0}),d=U1(o,n.floating);return{data:{escapedOffsets:d,escaped:V1(d)}}}default:return{}}}}},yk=new Set(["left","top"]);async function D3(t,s){const{placement:n,platform:r,elements:a}=t,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=ml(n),d=bd(n),m=_i(n)==="y",f=yk.has(o)?-1:1,p=i&&m?-1:1,h=hl(s,t);let{mainAxis:x,crossAxis:u,alignmentAxis:N}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return d&&typeof N=="number"&&(u=d==="end"?N*-1:N),m?{x:u*p,y:x*f}:{x:x*f,y:u*p}}const R3=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,r;const{x:a,y:i,placement:o,middlewareData:d}=s,m=await D3(s,t);return o===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+m.x,y:i+m.y,data:{...m,placement:o}}}}},E3=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:r,placement:a,platform:i}=s,{mainAxis:o=!0,crossAxis:d=!1,limiter:m={fn:j=>{let{x:b,y:C}=j;return{x:b,y:C}}},...f}=hl(t,s),p={x:n,y:r},h=await i.detectOverflow(s,f),x=_i(ml(a)),u=ab(x);let N=p[u],v=p[x];if(o){const j=u==="y"?"top":"left",b=u==="y"?"bottom":"right",C=N+h[j],S=N-h[b];N=oy(C,N,S)}if(d){const j=x==="y"?"top":"left",b=x==="y"?"bottom":"right",C=v+h[j],S=v-h[b];v=oy(C,v,S)}const w=m.fn({...s,[u]:N,[x]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[u]:o,[x]:d}}}}}},_3=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:r,placement:a,rects:i,middlewareData:o}=s,{offset:d=0,mainAxis:m=!0,crossAxis:f=!0}=hl(t,s),p={x:n,y:r},h=_i(a),x=ab(h);let u=p[x],N=p[h];const v=hl(d,s),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(m){const C=x==="y"?"height":"width",S=i.reference[x]-i.floating[C]+w.mainAxis,D=i.reference[x]+i.reference[C]-w.mainAxis;u<S?u=S:u>D&&(u=D)}if(f){var j,b;const C=x==="y"?"width":"height",S=yk.has(ml(a)),D=i.reference[h]-i.floating[C]+(S&&((j=o.offset)==null?void 0:j[h])||0)+(S?0:w.crossAxis),_=i.reference[h]+i.reference[C]+(S?0:((b=o.offset)==null?void 0:b[h])||0)-(S?w.crossAxis:0);N<D?N=D:N>_&&(N=_)}return{[x]:u,[h]:N}}}},T3=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,r;const{placement:a,rects:i,platform:o,elements:d}=s,{apply:m=()=>{},...f}=hl(t,s),p=await o.detectOverflow(s,f),h=ml(a),x=bd(a),u=_i(a)==="y",{width:N,height:v}=i.floating;let w,j;h==="top"||h==="bottom"?(w=h,j=x===(await(o.isRTL==null?void 0:o.isRTL(d.floating))?"start":"end")?"left":"right"):(j=h,w=x==="end"?"top":"bottom");const b=v-p.top-p.bottom,C=N-p.left-p.right,S=no(v-p[w],b),D=no(N-p[j],C),_=!s.middlewareData.shift;let A=S,E=D;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(E=C),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(A=b),_&&!x){const O=ga(p.left,0),R=ga(p.right,0),P=ga(p.top,0),L=ga(p.bottom,0);u?E=N-2*(O!==0||R!==0?O+R:ga(p.left,p.right)):A=v-2*(P!==0||L!==0?P+L:ga(p.top,p.bottom))}await m({...s,availableWidth:E,availableHeight:A});const q=await o.getDimensions(d.floating);return N!==q.width||v!==q.height?{reset:{rects:!0}}:{}}}};function $f(){return typeof window<"u"}function jd(t){return bk(t)?(t.nodeName||"").toLowerCase():"#document"}function Na(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Fi(t){var s;return(s=(bk(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function bk(t){return $f()?t instanceof Node||t instanceof Na(t).Node:!1}function oi(t){return $f()?t instanceof Element||t instanceof Na(t).Element:!1}function gl(t){return $f()?t instanceof HTMLElement||t instanceof Na(t).HTMLElement:!1}function H1(t){return!$f()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Na(t).ShadowRoot}function Zu(t){const{overflow:s,overflowX:n,overflowY:r,display:a}=ci(t);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function P3(t){return/^(table|td|th)$/.test(jd(t))}function qf(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const O3=/transform|translate|scale|rotate|perspective|filter/,L3=/paint|layout|strict|content/,Fo=t=>!!t&&t!=="none";let jg;function ob(t){const s=oi(t)?ci(t):t;return Fo(s.transform)||Fo(s.translate)||Fo(s.scale)||Fo(s.rotate)||Fo(s.perspective)||!cb()&&(Fo(s.backdropFilter)||Fo(s.filter))||O3.test(s.willChange||"")||L3.test(s.contain||"")}function I3(t){let s=ro(t);for(;gl(s)&&!ld(s);){if(ob(s))return s;if(qf(s))return null;s=ro(s)}return null}function cb(){return jg==null&&(jg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),jg}function ld(t){return/^(html|body|#document)$/.test(jd(t))}function ci(t){return Na(t).getComputedStyle(t)}function zf(t){return oi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ro(t){if(jd(t)==="html")return t;const s=t.assignedSlot||t.parentNode||H1(t)&&t.host||Fi(t);return H1(s)?s.host:s}function jk(t){const s=ro(t);return ld(s)?t.ownerDocument?t.ownerDocument.body:t.body:gl(s)&&Zu(s)?s:jk(s)}function Du(t,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=jk(t),i=a===((r=t.ownerDocument)==null?void 0:r.body),o=Na(a);if(i){const d=dy(o);return s.concat(o,o.visualViewport||[],Zu(a)?a:[],d&&n?Du(d):[])}else return s.concat(a,Du(a,[],n))}function dy(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Nk(t){const s=ci(t);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=gl(t),i=a?t.offsetWidth:n,o=a?t.offsetHeight:r,d=lf(n)!==i||lf(r)!==o;return d&&(n=i,r=o),{width:n,height:r,$:d}}function db(t){return oi(t)?t:t.contextElement}function Xc(t){const s=db(t);if(!gl(s))return Pi(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:i}=Nk(s);let o=(i?lf(n.width):n.width)/r,d=(i?lf(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!d||!Number.isFinite(d))&&(d=1),{x:o,y:d}}const M3=Pi(0);function wk(t){const s=Na(t);return!cb()||!s.visualViewport?M3:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function F3(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==Na(t)?!1:s}function nc(t,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),i=db(t);let o=Pi(1);s&&(r?oi(r)&&(o=Xc(r)):o=Xc(t));const d=F3(i,n,r)?wk(i):Pi(0);let m=(a.left+d.x)/o.x,f=(a.top+d.y)/o.y,p=a.width/o.x,h=a.height/o.y;if(i){const x=Na(i),u=r&&oi(r)?Na(r):r;let N=x,v=dy(N);for(;v&&r&&u!==N;){const w=Xc(v),j=v.getBoundingClientRect(),b=ci(v),C=j.left+(v.clientLeft+parseFloat(b.paddingLeft))*w.x,S=j.top+(v.clientTop+parseFloat(b.paddingTop))*w.y;m*=w.x,f*=w.y,p*=w.x,h*=w.y,m+=C,f+=S,N=Na(v),v=dy(N)}}return cf({width:p,height:h,x:m,y:f})}function Uf(t,s){const n=zf(t).scrollLeft;return s?s.left+n:nc(Fi(t)).left+n}function Sk(t,s){const n=t.getBoundingClientRect(),r=n.left+s.scrollLeft-Uf(t,n),a=n.top+s.scrollTop;return{x:r,y:a}}function B3(t){let{elements:s,rect:n,offsetParent:r,strategy:a}=t;const i=a==="fixed",o=Fi(r),d=s?qf(s.floating):!1;if(r===o||d&&i)return n;let m={scrollLeft:0,scrollTop:0},f=Pi(1);const p=Pi(0),h=gl(r);if((h||!h&&!i)&&((jd(r)!=="body"||Zu(o))&&(m=zf(r)),h)){const u=nc(r);f=Xc(r),p.x=u.x+r.clientLeft,p.y=u.y+r.clientTop}const x=o&&!h&&!i?Sk(o,m):Pi(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-m.scrollLeft*f.x+p.x+x.x,y:n.y*f.y-m.scrollTop*f.y+p.y+x.y}}function $3(t){return Array.from(t.getClientRects())}function q3(t){const s=Fi(t),n=zf(t),r=t.ownerDocument.body,a=ga(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),i=ga(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Uf(t);const d=-n.scrollTop;return ci(r).direction==="rtl"&&(o+=ga(s.clientWidth,r.clientWidth)-a),{width:a,height:i,x:o,y:d}}const W1=25;function z3(t,s){const n=Na(t),r=Fi(t),a=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,d=0,m=0;if(a){i=a.width,o=a.height;const p=cb();(!p||p&&s==="fixed")&&(d=a.offsetLeft,m=a.offsetTop)}const f=Uf(r);if(f<=0){const p=r.ownerDocument,h=p.body,x=getComputedStyle(h),u=p.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,N=Math.abs(r.clientWidth-h.clientWidth-u);N<=W1&&(i-=N)}else f<=W1&&(i+=f);return{width:i,height:o,x:d,y:m}}function U3(t,s){const n=nc(t,!0,s==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,i=gl(t)?Xc(t):Pi(1),o=t.clientWidth*i.x,d=t.clientHeight*i.y,m=a*i.x,f=r*i.y;return{width:o,height:d,x:m,y:f}}function G1(t,s,n){let r;if(s==="viewport")r=z3(t,n);else if(s==="document")r=q3(Fi(t));else if(oi(s))r=U3(s,n);else{const a=wk(t);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return cf(r)}function Ck(t,s){const n=ro(t);return n===s||!oi(n)||ld(n)?!1:ci(n).position==="fixed"||Ck(n,s)}function V3(t,s){const n=s.get(t);if(n)return n;let r=Du(t,[],!1).filter(d=>oi(d)&&jd(d)!=="body"),a=null;const i=ci(t).position==="fixed";let o=i?ro(t):t;for(;oi(o)&&!ld(o);){const d=ci(o),m=ob(o);!m&&d.position==="fixed"&&(a=null),(i?!m&&!a:!m&&d.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Zu(o)&&!m&&Ck(t,o))?r=r.filter(p=>p!==o):a=d,o=ro(o)}return s.set(t,r),r}function H3(t){let{element:s,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?qf(s)?[]:V3(s,this._c):[].concat(n),r],d=G1(s,o[0],a);let m=d.top,f=d.right,p=d.bottom,h=d.left;for(let x=1;x<o.length;x++){const u=G1(s,o[x],a);m=ga(u.top,m),f=no(u.right,f),p=no(u.bottom,p),h=ga(u.left,h)}return{width:f-h,height:p-m,x:h,y:m}}function W3(t){const{width:s,height:n}=Nk(t);return{width:s,height:n}}function G3(t,s,n){const r=gl(s),a=Fi(s),i=n==="fixed",o=nc(t,!0,i,s);let d={scrollLeft:0,scrollTop:0};const m=Pi(0);function f(){m.x=Uf(a)}if(r||!r&&!i)if((jd(s)!=="body"||Zu(a))&&(d=zf(s)),r){const u=nc(s,!0,i,s);m.x=u.x+s.clientLeft,m.y=u.y+s.clientTop}else a&&f();i&&!r&&a&&f();const p=a&&!r&&!i?Sk(a,d):Pi(0),h=o.left+d.scrollLeft-m.x-p.x,x=o.top+d.scrollTop-m.y-p.y;return{x:h,y:x,width:o.width,height:o.height}}function Ng(t){return ci(t).position==="static"}function K1(t,s){if(!gl(t)||ci(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return Fi(t)===n&&(n=n.ownerDocument.body),n}function Ak(t,s){const n=Na(t);if(qf(t))return n;if(!gl(t)){let a=ro(t);for(;a&&!ld(a);){if(oi(a)&&!Ng(a))return a;a=ro(a)}return n}let r=K1(t,s);for(;r&&P3(r)&&Ng(r);)r=K1(r,s);return r&&ld(r)&&Ng(r)&&!ob(r)?n:r||I3(t)||n}const K3=async function(t){const s=this.getOffsetParent||Ak,n=this.getDimensions,r=await n(t.floating);return{reference:G3(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Y3(t){return ci(t).direction==="rtl"}const Z3={convertOffsetParentRelativeRectToViewportRelativeRect:B3,getDocumentElement:Fi,getClippingRect:H3,getOffsetParent:Ak,getElementRects:K3,getClientRects:$3,getDimensions:W3,getScale:Xc,isElement:oi,isRTL:Y3};function kk(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function Q3(t,s){let n=null,r;const a=Fi(t);function i(){var d;clearTimeout(r),(d=n)==null||d.disconnect(),n=null}function o(d,m){d===void 0&&(d=!1),m===void 0&&(m=1),i();const f=t.getBoundingClientRect(),{left:p,top:h,width:x,height:u}=f;if(d||s(),!x||!u)return;const N=mm(h),v=mm(a.clientWidth-(p+x)),w=mm(a.clientHeight-(h+u)),j=mm(p),C={rootMargin:-N+"px "+-v+"px "+-w+"px "+-j+"px",threshold:ga(0,no(1,m))||1};let S=!0;function D(_){const A=_[0].intersectionRatio;if(A!==m){if(!S)return o();A?o(!1,A):r=setTimeout(()=>{o(!1,1e-7)},1e3)}A===1&&!kk(f,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(D,{...C,root:a.ownerDocument})}catch{n=new IntersectionObserver(D,C)}n.observe(t)}return o(!0),i}function X3(t,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:m=!1}=r,f=db(t),p=a||i?[...f?Du(f):[],...s?Du(s):[]]:[];p.forEach(j=>{a&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&d?Q3(f,n):null;let x=-1,u=null;o&&(u=new ResizeObserver(j=>{let[b]=j;b&&b.target===f&&u&&s&&(u.unobserve(s),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var C;(C=u)==null||C.observe(s)})),n()}),f&&!m&&u.observe(f),s&&u.observe(s));let N,v=m?nc(t):null;m&&w();function w(){const j=nc(t);v&&!kk(v,j)&&n(),v=j,N=requestAnimationFrame(w)}return n(),()=>{var j;p.forEach(b=>{a&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),h==null||h(),(j=u)==null||j.disconnect(),u=null,m&&cancelAnimationFrame(N)}}const J3=R3,eF=E3,tF=A3,sF=T3,nF=k3,Y1=C3,rF=_3,aF=(t,s,n)=>{const r=new Map,a={platform:Z3,...n},i={...a.platform,_c:r};return S3(t,s,{...a,platform:i})};var iF=typeof document<"u",lF=function(){},Mm=iF?g.useLayoutEffect:lF;function df(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let n,r,a;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==s.length)return!1;for(r=n;r--!==0;)if(!df(t[r],s[r]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(s).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(s,a[r]))return!1;for(r=n;r--!==0;){const i=a[r];if(!(i==="_owner"&&t.$$typeof)&&!df(t[i],s[i]))return!1}return!0}return t!==t&&s!==s}function Dk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Z1(t,s){const n=Dk(t);return Math.round(s*n)/n}function wg(t){const s=g.useRef(t);return Mm(()=>{s.current=t}),s}function oF(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:o}={},transform:d=!0,whileElementsMounted:m,open:f}=t,[p,h]=g.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[x,u]=g.useState(r);df(x,r)||u(r);const[N,v]=g.useState(null),[w,j]=g.useState(null),b=g.useCallback(U=>{U!==_.current&&(_.current=U,v(U))},[]),C=g.useCallback(U=>{U!==A.current&&(A.current=U,j(U))},[]),S=i||N,D=o||w,_=g.useRef(null),A=g.useRef(null),E=g.useRef(p),q=m!=null,O=wg(m),R=wg(a),P=wg(f),L=g.useCallback(()=>{if(!_.current||!A.current)return;const U={placement:s,strategy:n,middleware:x};R.current&&(U.platform=R.current),aF(_.current,A.current,U).then(M=>{const z={...M,isPositioned:P.current!==!1};$.current&&!df(E.current,z)&&(E.current=z,zu.flushSync(()=>{h(z)}))})},[x,s,n,R,P]);Mm(()=>{f===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h(U=>({...U,isPositioned:!1})))},[f]);const $=g.useRef(!1);Mm(()=>($.current=!0,()=>{$.current=!1}),[]),Mm(()=>{if(S&&(_.current=S),D&&(A.current=D),S&&D){if(O.current)return O.current(S,D,L);L()}},[S,D,L,O,q]);const Z=g.useMemo(()=>({reference:_,floating:A,setReference:b,setFloating:C}),[b,C]),Q=g.useMemo(()=>({reference:S,floating:D}),[S,D]),W=g.useMemo(()=>{const U={position:n,left:0,top:0};if(!Q.floating)return U;const M=Z1(Q.floating,p.x),z=Z1(Q.floating,p.y);return d?{...U,transform:"translate("+M+"px, "+z+"px)",...Dk(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:z}},[n,d,Q.floating,p.x,p.y]);return g.useMemo(()=>({...p,update:L,refs:Z,elements:Q,floatingStyles:W}),[p,L,Z,Q,W])}const cF=t=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:a}=typeof t=="function"?t(n):t;return r&&s(r)?r.current!=null?Y1({element:r.current,padding:a}).fn(n):{}:r?Y1({element:r,padding:a}).fn(n):{}}}},dF=(t,s)=>{const n=J3(t);return{name:n.name,fn:n.fn,options:[t,s]}},uF=(t,s)=>{const n=eF(t);return{name:n.name,fn:n.fn,options:[t,s]}},hF=(t,s)=>({fn:rF(t).fn,options:[t,s]}),mF=(t,s)=>{const n=tF(t);return{name:n.name,fn:n.fn,options:[t,s]}},fF=(t,s)=>{const n=sF(t);return{name:n.name,fn:n.fn,options:[t,s]}},pF=(t,s)=>{const n=nF(t);return{name:n.name,fn:n.fn,options:[t,s]}},xF=(t,s)=>{const n=cF(t);return{name:n.name,fn:n.fn,options:[t,s]}};var gF="Arrow",Rk=g.forwardRef((t,s)=>{const{children:n,width:r=10,height:a=5,...i}=t;return e.jsx(Ss.svg,{...i,ref:s,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});Rk.displayName=gF;var vF=Rk,ub="Popper",[Ek,lo]=oa(ub),[yF,_k]=Ek(ub),Tk=t=>{const{__scopePopper:s,children:n}=t,[r,a]=g.useState(null);return e.jsx(yF,{scope:s,anchor:r,onAnchorChange:a,children:n})};Tk.displayName=ub;var Pk="PopperAnchor",Ok=g.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:r,...a}=t,i=_k(Pk,n),o=g.useRef(null),d=Ys(s,o),m=g.useRef(null);return g.useEffect(()=>{const f=m.current;m.current=(r==null?void 0:r.current)||o.current,f!==m.current&&i.onAnchorChange(m.current)}),r?null:e.jsx(Ss.div,{...a,ref:d})});Ok.displayName=Pk;var hb="PopperContent",[bF,jF]=Ek(hb),Lk=g.forwardRef((t,s)=>{var Y,re,ae,ue,ye,ce;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:d=0,avoidCollisions:m=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:u="optimized",onPlaced:N,...v}=t,w=_k(hb,n),[j,b]=g.useState(null),C=Ys(s,je=>b(je)),[S,D]=g.useState(null),_=Qy(S),A=(_==null?void 0:_.width)??0,E=(_==null?void 0:_.height)??0,q=r+(i!=="center"?"-"+i:""),O=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},R=Array.isArray(f)?f:[f],P=R.length>0,L={padding:O,boundary:R.filter(wF),altBoundary:P},{refs:$,floatingStyles:Z,placement:Q,isPositioned:W,middlewareData:U}=oF({strategy:"fixed",placement:q,whileElementsMounted:(...je)=>X3(...je,{animationFrame:u==="always"}),elements:{reference:w.anchor},middleware:[dF({mainAxis:a+E,alignmentAxis:o}),m&&uF({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?hF():void 0,...L}),m&&mF({...L}),fF({...L,apply:({elements:je,rects:Me,availableWidth:ut,availableHeight:jt})=>{const{width:ft,height:X}=Me.reference,Ce=je.floating.style;Ce.setProperty("--radix-popper-available-width",`${ut}px`),Ce.setProperty("--radix-popper-available-height",`${jt}px`),Ce.setProperty("--radix-popper-anchor-width",`${ft}px`),Ce.setProperty("--radix-popper-anchor-height",`${X}px`)}}),S&&xF({element:S,padding:d}),SF({arrowWidth:A,arrowHeight:E}),x&&pF({strategy:"referenceHidden",...L})]}),[M,z]=Fk(Q),T=xr(N);Jn(()=>{W&&(T==null||T())},[W,T]);const F=(Y=U.arrow)==null?void 0:Y.x,I=(re=U.arrow)==null?void 0:re.y,K=((ae=U.arrow)==null?void 0:ae.centerOffset)!==0,[G,V]=g.useState();return Jn(()=>{j&&V(window.getComputedStyle(j).zIndex)},[j]),e.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:W?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[(ue=U.transformOrigin)==null?void 0:ue.x,(ye=U.transformOrigin)==null?void 0:ye.y].join(" "),...((ce=U.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(bF,{scope:n,placedSide:M,onArrowChange:D,arrowX:F,arrowY:I,shouldHideArrow:K,children:e.jsx(Ss.div,{"data-side":M,"data-align":z,...v,ref:C,style:{...v.style,animation:W?void 0:"none"}})})})});Lk.displayName=hb;var Ik="PopperArrow",NF={top:"bottom",right:"left",bottom:"top",left:"right"},Mk=g.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,i=jF(Ik,r),o=NF[i.placedSide];return e.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:e.jsx(vF,{...a,ref:n,style:{...a.style,display:"block"}})})});Mk.displayName=Ik;function wF(t){return t!==null}var SF=t=>({name:"transformOrigin",options:t,fn(s){var w,j,b;const{placement:n,rects:r,middlewareData:a}=s,o=((w=a.arrow)==null?void 0:w.centerOffset)!==0,d=o?0:t.arrowWidth,m=o?0:t.arrowHeight,[f,p]=Fk(n),h={start:"0%",center:"50%",end:"100%"}[p],x=(((j=a.arrow)==null?void 0:j.x)??0)+d/2,u=(((b=a.arrow)==null?void 0:b.y)??0)+m/2;let N="",v="";return f==="bottom"?(N=o?h:`${x}px`,v=`${-m}px`):f==="top"?(N=o?h:`${x}px`,v=`${r.floating.height+m}px`):f==="right"?(N=`${-m}px`,v=o?h:`${u}px`):f==="left"&&(N=`${r.floating.width+m}px`,v=o?h:`${u}px`),{data:{x:N,y:v}}}});function Fk(t){const[s,n="center"]=t.split("-");return[s,n]}var Vf=Tk,Qu=Ok,Hf=Lk,Wf=Mk,CF="Portal",Nd=g.forwardRef((t,s)=>{var d;const{container:n,...r}=t,[a,i]=g.useState(!1);Jn(()=>i(!0),[]);const o=n||a&&((d=globalThis==null?void 0:globalThis.document)==null?void 0:d.body);return o?Hy.createPortal(e.jsx(Ss.div,{...r,ref:s}),o):null});Nd.displayName=CF;var Sg="rovingFocusGroup.onEntryFocus",AF={bubbles:!1,cancelable:!0},Xu="RovingFocusGroup",[uy,Bk,kF]=rb(Xu),[DF,Gf]=oa(Xu,[kF]),[RF,EF]=DF(Xu),$k=g.forwardRef((t,s)=>e.jsx(uy.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(uy.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(_F,{...t,ref:s})})}));$k.displayName=Xu;var _F=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:m,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=t,x=g.useRef(null),u=Ys(s,x),N=Ku(i),[v,w]=Li({prop:o,defaultProp:d??null,onChange:m,caller:Xu}),[j,b]=g.useState(!1),C=xr(f),S=Bk(n),D=g.useRef(!1),[_,A]=g.useState(0);return g.useEffect(()=>{const E=x.current;if(E)return E.addEventListener(Sg,C),()=>E.removeEventListener(Sg,C)},[C]),e.jsx(RF,{scope:n,orientation:r,dir:N,loop:a,currentTabStopId:v,onItemFocus:g.useCallback(E=>w(E),[w]),onItemShiftTab:g.useCallback(()=>b(!0),[]),onFocusableItemAdd:g.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:g.useCallback(()=>A(E=>E-1),[]),children:e.jsx(Ss.div,{tabIndex:j||_===0?-1:0,"data-orientation":r,...h,ref:u,style:{outline:"none",...t.style},onMouseDown:Yt(t.onMouseDown,()=>{D.current=!0}),onFocus:Yt(t.onFocus,E=>{const q=!D.current;if(E.target===E.currentTarget&&q&&!j){const O=new CustomEvent(Sg,AF);if(E.currentTarget.dispatchEvent(O),!O.defaultPrevented){const R=S().filter(Q=>Q.focusable),P=R.find(Q=>Q.active),L=R.find(Q=>Q.id===v),Z=[P,L,...R].filter(Boolean).map(Q=>Q.ref.current);Uk(Z,p)}}D.current=!1}),onBlur:Yt(t.onBlur,()=>b(!1))})})}),qk="RovingFocusGroupItem",zk=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...d}=t,m=yr(),f=i||m,p=EF(qk,n),h=p.currentTabStopId===f,x=Bk(n),{onFocusableItemAdd:u,onFocusableItemRemove:N,currentTabStopId:v}=p;return g.useEffect(()=>{if(r)return u(),()=>N()},[r,u,N]),e.jsx(uy.ItemSlot,{scope:n,id:f,focusable:r,active:a,children:e.jsx(Ss.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...d,ref:s,onMouseDown:Yt(t.onMouseDown,w=>{r?p.onItemFocus(f):w.preventDefault()}),onFocus:Yt(t.onFocus,()=>p.onItemFocus(f)),onKeyDown:Yt(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const j=OF(w,p.orientation,p.dir);if(j!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=x().filter(S=>S.focusable).map(S=>S.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const S=C.indexOf(w.currentTarget);C=p.loop?LF(C,S+1):C.slice(S+1)}setTimeout(()=>Uk(C))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:v!=null}):o})})});zk.displayName=qk;var TF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PF(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function OF(t,s,n){const r=PF(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return TF[r]}function Uk(t,s=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function LF(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var Vk=$k,Hk=zk;function IF(t){const s=MF(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(BF);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function MF(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=qF(a),d=$F(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var FF=Symbol("radix.slottable");function BF(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===FF}function $F(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function qF(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var zF=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},Bc=new WeakMap,fm=new WeakMap,pm={},Cg=0,Wk=function(t){return t&&(t.host||Wk(t.parentNode))},UF=function(t,s){return s.map(function(n){if(t.contains(n))return n;var r=Wk(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},VF=function(t,s,n,r){var a=UF(s,Array.isArray(t)?t:[t]);pm[n]||(pm[n]=new WeakMap);var i=pm[n],o=[],d=new Set,m=new Set(a),f=function(h){!h||d.has(h)||(d.add(h),f(h.parentNode))};a.forEach(f);var p=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(x){if(d.has(x))p(x);else try{var u=x.getAttribute(r),N=u!==null&&u!=="false",v=(Bc.get(x)||0)+1,w=(i.get(x)||0)+1;Bc.set(x,v),i.set(x,w),o.push(x),v===1&&N&&fm.set(x,!0),w===1&&x.setAttribute(n,"true"),N||x.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",x,j)}})};return p(s),d.clear(),Cg++,function(){o.forEach(function(h){var x=Bc.get(h)-1,u=i.get(h)-1;Bc.set(h,x),i.set(h,u),x||(fm.has(h)||h.removeAttribute(r),fm.delete(h)),u||h.removeAttribute(n)}),Cg--,Cg||(Bc=new WeakMap,Bc=new WeakMap,fm=new WeakMap,pm={})}},Kf=function(t,s,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=zF(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),VF(r,a,n,"aria-hidden")):function(){return null}},Di=function(){return Di=Object.assign||function(s){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Di.apply(this,arguments)};function Gk(t,s){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&s.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)s.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function HF(t,s,n){if(n||arguments.length===2)for(var r=0,a=s.length,i;r<a;r++)(i||!(r in s))&&(i||(i=Array.prototype.slice.call(s,0,r)),i[r]=s[r]);return t.concat(i||Array.prototype.slice.call(s))}var Fm="right-scroll-bar-position",Bm="width-before-scroll-bar",WF="with-scroll-bars-hidden",GF="--removed-body-scroll-bar-size";function Ag(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function KF(t,s){var n=g.useState(function(){return{value:t,callback:s,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=s,n.facade}var YF=typeof window<"u"?g.useLayoutEffect:g.useEffect,Q1=new WeakMap;function ZF(t,s){var n=KF(null,function(r){return t.forEach(function(a){return Ag(a,r)})});return YF(function(){var r=Q1.get(n);if(r){var a=new Set(r),i=new Set(t),o=n.current;a.forEach(function(d){i.has(d)||Ag(d,null)}),i.forEach(function(d){a.has(d)||Ag(d,o)})}Q1.set(n,t)},[t]),n}function QF(t){return t}function XF(t,s){s===void 0&&(s=QF);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=s(i,r);return n.push(o),function(){n=n.filter(function(d){return d!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(d){return i(d)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var d=n;n=[],d.forEach(i),o=n}var m=function(){var p=o;o=[],p.forEach(i)},f=function(){return Promise.resolve().then(m)};f(),n={push:function(p){o.push(p),f()},filter:function(p){return o=o.filter(p),n}}}};return a}function JF(t){t===void 0&&(t={});var s=XF(null);return s.options=Di({async:!0,ssr:!1},t),s}var Kk=function(t){var s=t.sideCar,n=Gk(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=s.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,Di({},n))};Kk.isSideCarExport=!0;function e6(t,s){return t.useMedium(s),Kk}var Yk=JF(),kg=function(){},Yf=g.forwardRef(function(t,s){var n=g.useRef(null),r=g.useState({onScrollCapture:kg,onWheelCapture:kg,onTouchMoveCapture:kg}),a=r[0],i=r[1],o=t.forwardProps,d=t.children,m=t.className,f=t.removeScrollBar,p=t.enabled,h=t.shards,x=t.sideCar,u=t.noRelative,N=t.noIsolation,v=t.inert,w=t.allowPinchZoom,j=t.as,b=j===void 0?"div":j,C=t.gapMode,S=Gk(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=x,_=ZF([n,s]),A=Di(Di({},S),a);return g.createElement(g.Fragment,null,p&&g.createElement(D,{sideCar:Yk,removeScrollBar:f,shards:h,noRelative:u,noIsolation:N,inert:v,setCallbacks:i,allowPinchZoom:!!w,lockRef:n,gapMode:C}),o?g.cloneElement(g.Children.only(d),Di(Di({},A),{ref:_})):g.createElement(b,Di({},A,{className:m,ref:_}),d))});Yf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Yf.classNames={fullWidth:Bm,zeroRight:Fm};var t6=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function s6(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=t6();return s&&t.setAttribute("nonce",s),t}function n6(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function r6(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var a6=function(){var t=0,s=null;return{add:function(n){t==0&&(s=s6())&&(n6(s,n),r6(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},i6=function(){var t=a6();return function(s,n){g.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&n])}},Zk=function(){var t=i6(),s=function(n){var r=n.styles,a=n.dynamic;return t(r,a),null};return s},l6={left:0,top:0,right:0,gap:0},Dg=function(t){return parseInt(t||"",10)||0},o6=function(t){var s=window.getComputedStyle(document.body),n=s[t==="padding"?"paddingLeft":"marginLeft"],r=s[t==="padding"?"paddingTop":"marginTop"],a=s[t==="padding"?"paddingRight":"marginRight"];return[Dg(n),Dg(r),Dg(a)]},c6=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return l6;var s=o6(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,r-n+s[2]-s[0])}},d6=Zk(),Jc="data-scroll-locked",u6=function(t,s,n,r){var a=t.left,i=t.top,o=t.right,d=t.gap;return n===void 0&&(n="margin"),`
|
||
.`.concat(WF,` {
|
||
overflow: hidden `).concat(r,`;
|
||
padding-right: `).concat(d,"px ").concat(r,`;
|
||
}
|
||
body[`).concat(Jc,`] {
|
||
overflow: hidden `).concat(r,`;
|
||
overscroll-behavior: contain;
|
||
`).concat([s&&"position: relative ".concat(r,";"),n==="margin"&&`
|
||
padding-left: `.concat(a,`px;
|
||
padding-top: `).concat(i,`px;
|
||
padding-right: `).concat(o,`px;
|
||
margin-left:0;
|
||
margin-top:0;
|
||
margin-right: `).concat(d,"px ").concat(r,`;
|
||
`),n==="padding"&&"padding-right: ".concat(d,"px ").concat(r,";")].filter(Boolean).join(""),`
|
||
}
|
||
|
||
.`).concat(Fm,` {
|
||
right: `).concat(d,"px ").concat(r,`;
|
||
}
|
||
|
||
.`).concat(Bm,` {
|
||
margin-right: `).concat(d,"px ").concat(r,`;
|
||
}
|
||
|
||
.`).concat(Fm," .").concat(Fm,` {
|
||
right: 0 `).concat(r,`;
|
||
}
|
||
|
||
.`).concat(Bm," .").concat(Bm,` {
|
||
margin-right: 0 `).concat(r,`;
|
||
}
|
||
|
||
body[`).concat(Jc,`] {
|
||
`).concat(GF,": ").concat(d,`px;
|
||
}
|
||
`)},X1=function(){var t=parseInt(document.body.getAttribute(Jc)||"0",10);return isFinite(t)?t:0},h6=function(){g.useEffect(function(){return document.body.setAttribute(Jc,(X1()+1).toString()),function(){var t=X1()-1;t<=0?document.body.removeAttribute(Jc):document.body.setAttribute(Jc,t.toString())}},[])},m6=function(t){var s=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;h6();var i=g.useMemo(function(){return c6(a)},[a]);return g.createElement(d6,{styles:u6(i,!s,a,n?"":"!important")})},hy=!1;if(typeof window<"u")try{var xm=Object.defineProperty({},"passive",{get:function(){return hy=!0,!0}});window.addEventListener("test",xm,xm),window.removeEventListener("test",xm,xm)}catch{hy=!1}var $c=hy?{passive:!1}:!1,f6=function(t){return t.tagName==="TEXTAREA"},Qk=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!f6(t)&&n[s]==="visible")},p6=function(t){return Qk(t,"overflowY")},x6=function(t){return Qk(t,"overflowX")},J1=function(t,s){var n=s.ownerDocument,r=s;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=Xk(t,r);if(a){var i=Jk(t,r),o=i[1],d=i[2];if(o>d)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},g6=function(t){var s=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[s,n,r]},v6=function(t){var s=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[s,n,r]},Xk=function(t,s){return t==="v"?p6(s):x6(s)},Jk=function(t,s){return t==="v"?g6(s):v6(s)},y6=function(t,s){return t==="h"&&s==="rtl"?-1:1},b6=function(t,s,n,r,a){var i=y6(t,window.getComputedStyle(s).direction),o=i*r,d=n.target,m=s.contains(d),f=!1,p=o>0,h=0,x=0;do{if(!d)break;var u=Jk(t,d),N=u[0],v=u[1],w=u[2],j=v-w-i*N;(N||j)&&Xk(t,d)&&(h+=j,x+=N);var b=d.parentNode;d=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!m&&d!==document.body||m&&(s.contains(d)||s===d));return(p&&Math.abs(h)<1||!p&&Math.abs(x)<1)&&(f=!0),f},gm=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},eS=function(t){return[t.deltaX,t.deltaY]},tS=function(t){return t&&"current"in t?t.current:t},j6=function(t,s){return t[0]===s[0]&&t[1]===s[1]},N6=function(t){return`
|
||
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
||
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
||
`)},w6=0,qc=[];function S6(t){var s=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(w6++)[0],i=g.useState(Zk)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var v=HF([t.lockRef.current],(t.shards||[]).map(tS),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var d=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var j=gm(v),b=n.current,C="deltaX"in v?v.deltaX:b[0]-j[0],S="deltaY"in v?v.deltaY:b[1]-j[1],D,_=v.target,A=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in v&&A==="h"&&_.type==="range")return!1;var E=window.getSelection(),q=E&&E.anchorNode,O=q?q===_||q.contains(_):!1;if(O)return!1;var R=J1(A,_);if(!R)return!0;if(R?D=A:(D=A==="v"?"h":"v",R=J1(A,_)),!R)return!1;if(!r.current&&"changedTouches"in v&&(C||S)&&(r.current=D),!D)return!0;var P=r.current||D;return b6(P,w,v,P==="h"?C:S)},[]),m=g.useCallback(function(v){var w=v;if(!(!qc.length||qc[qc.length-1]!==i)){var j="deltaY"in w?eS(w):gm(w),b=s.current.filter(function(D){return D.name===w.type&&(D.target===w.target||w.target===D.shadowParent)&&j6(D.delta,j)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var C=(o.current.shards||[]).map(tS).filter(Boolean).filter(function(D){return D.contains(w.target)}),S=C.length>0?d(w,C[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),f=g.useCallback(function(v,w,j,b){var C={name:v,delta:w,target:j,should:b,shadowParent:C6(j)};s.current.push(C),setTimeout(function(){s.current=s.current.filter(function(S){return S!==C})},1)},[]),p=g.useCallback(function(v){n.current=gm(v),r.current=void 0},[]),h=g.useCallback(function(v){f(v.type,eS(v),v.target,d(v,t.lockRef.current))},[]),x=g.useCallback(function(v){f(v.type,gm(v),v.target,d(v,t.lockRef.current))},[]);g.useEffect(function(){return qc.push(i),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:x}),document.addEventListener("wheel",m,$c),document.addEventListener("touchmove",m,$c),document.addEventListener("touchstart",p,$c),function(){qc=qc.filter(function(v){return v!==i}),document.removeEventListener("wheel",m,$c),document.removeEventListener("touchmove",m,$c),document.removeEventListener("touchstart",p,$c)}},[]);var u=t.removeScrollBar,N=t.inert;return g.createElement(g.Fragment,null,N?g.createElement(i,{styles:N6(a)}):null,u?g.createElement(m6,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function C6(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const A6=e6(Yk,S6);var Ju=g.forwardRef(function(t,s){return g.createElement(Yf,Di({},t,{ref:s,sideCar:A6}))});Ju.classNames=Yf.classNames;var my=["Enter"," "],k6=["ArrowDown","PageUp","Home"],eD=["ArrowUp","PageDown","End"],D6=[...k6,...eD],R6={ltr:[...my,"ArrowRight"],rtl:[...my,"ArrowLeft"]},E6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},eh="Menu",[Ru,_6,T6]=rb(eh),[uc,tD]=oa(eh,[T6,lo,Gf]),Zf=lo(),sD=Gf(),[P6,hc]=uc(eh),[O6,th]=uc(eh),nD=t=>{const{__scopeMenu:s,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=t,d=Zf(s),[m,f]=g.useState(null),p=g.useRef(!1),h=xr(i),x=Ku(a);return g.useEffect(()=>{const u=()=>{p.current=!0,document.addEventListener("pointerdown",N,{capture:!0,once:!0}),document.addEventListener("pointermove",N,{capture:!0,once:!0})},N=()=>p.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",N,{capture:!0}),document.removeEventListener("pointermove",N,{capture:!0})}},[]),e.jsx(Vf,{...d,children:e.jsx(P6,{scope:s,open:n,onOpenChange:h,content:m,onContentChange:f,children:e.jsx(O6,{scope:s,onClose:g.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:p,dir:x,modal:o,children:r})})})};nD.displayName=eh;var L6="MenuAnchor",mb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Zf(n);return e.jsx(Qu,{...a,...r,ref:s})});mb.displayName=L6;var fb="MenuPortal",[I6,rD]=uc(fb,{forceMount:void 0}),aD=t=>{const{__scopeMenu:s,forceMount:n,children:r,container:a}=t,i=hc(fb,s);return e.jsx(I6,{scope:s,forceMount:n,children:e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};aD.displayName=fb;var $a="MenuContent",[M6,pb]=uc($a),iD=g.forwardRef((t,s)=>{const n=rD($a,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,i=hc($a,t.__scopeMenu),o=th($a,t.__scopeMenu);return e.jsx(Ru.Provider,{scope:t.__scopeMenu,children:e.jsx(jr,{present:r||i.open,children:e.jsx(Ru.Slot,{scope:t.__scopeMenu,children:o.modal?e.jsx(F6,{...a,ref:s}):e.jsx(B6,{...a,ref:s})})})})}),F6=g.forwardRef((t,s)=>{const n=hc($a,t.__scopeMenu),r=g.useRef(null),a=Ys(s,r);return g.useEffect(()=>{const i=r.current;if(i)return Kf(i)},[]),e.jsx(xb,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Yt(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),B6=g.forwardRef((t,s)=>{const n=hc($a,t.__scopeMenu);return e.jsx(xb,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),$6=IF("MenuContent.ScrollLock"),xb=g.forwardRef((t,s)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEntryFocus:m,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:x,onDismiss:u,disableOutsideScroll:N,...v}=t,w=hc($a,n),j=th($a,n),b=Zf(n),C=sD(n),S=_6(n),[D,_]=g.useState(null),A=g.useRef(null),E=Ys(s,A,w.onContentChange),q=g.useRef(0),O=g.useRef(""),R=g.useRef(0),P=g.useRef(null),L=g.useRef("right"),$=g.useRef(0),Z=N?Ju:g.Fragment,Q=N?{as:$6,allowPinchZoom:!0}:void 0,W=M=>{var Y,re;const z=O.current+M,T=S().filter(ae=>!ae.disabled),F=document.activeElement,I=(Y=T.find(ae=>ae.ref.current===F))==null?void 0:Y.textValue,K=T.map(ae=>ae.textValue),G=X6(K,z,I),V=(re=T.find(ae=>ae.textValue===G))==null?void 0:re.ref.current;(function ae(ue){O.current=ue,window.clearTimeout(q.current),ue!==""&&(q.current=window.setTimeout(()=>ae(""),1e3))})(z),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(q.current),[]),Bf();const U=g.useCallback(M=>{var T,F;return L.current===((T=P.current)==null?void 0:T.side)&&e8(M,(F=P.current)==null?void 0:F.area)},[]);return e.jsx(M6,{scope:n,searchRef:O,onItemEnter:g.useCallback(M=>{U(M)&&M.preventDefault()},[U]),onItemLeave:g.useCallback(M=>{var z;U(M)||((z=A.current)==null||z.focus(),_(null))},[U]),onTriggerLeave:g.useCallback(M=>{U(M)&&M.preventDefault()},[U]),pointerGraceTimerRef:R,onPointerGraceIntentChange:g.useCallback(M=>{P.current=M},[]),children:e.jsx(Z,{...Q,children:e.jsx(Yu,{asChild:!0,trapped:a,onMountAutoFocus:Yt(i,M=>{var z;M.preventDefault(),(z=A.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:x,onDismiss:u,children:e.jsx(Vk,{asChild:!0,...C,dir:j.dir,orientation:"vertical",loop:r,currentTabStopId:D,onCurrentTabStopIdChange:_,onEntryFocus:Yt(m,M=>{j.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Hf,{role:"menu","aria-orientation":"vertical","data-state":ND(w.open),"data-radix-menu-content":"",dir:j.dir,...b,...v,ref:E,style:{outline:"none",...v.style},onKeyDown:Yt(v.onKeyDown,M=>{const T=M.target.closest("[data-radix-menu-content]")===M.currentTarget,F=M.ctrlKey||M.altKey||M.metaKey,I=M.key.length===1;T&&(M.key==="Tab"&&M.preventDefault(),!F&&I&&W(M.key));const K=A.current;if(M.target!==K||!D6.includes(M.key))return;M.preventDefault();const V=S().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);eD.includes(M.key)&&V.reverse(),Z6(V)}),onBlur:Yt(t.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(q.current),O.current="")}),onPointerMove:Yt(t.onPointerMove,Eu(M=>{const z=M.target,T=$.current!==M.clientX;if(M.currentTarget.contains(z)&&T){const F=M.clientX>$.current?"right":"left";L.current=F,$.current=M.clientX}}))})})})})})})});iD.displayName=$a;var q6="MenuGroup",gb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(Ss.div,{role:"group",...r,ref:s})});gb.displayName=q6;var z6="MenuLabel",lD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(Ss.div,{...r,ref:s})});lD.displayName=z6;var uf="MenuItem",sS="menu.itemSelect",Qf=g.forwardRef((t,s)=>{const{disabled:n=!1,onSelect:r,...a}=t,i=g.useRef(null),o=th(uf,t.__scopeMenu),d=pb(uf,t.__scopeMenu),m=Ys(s,i),f=g.useRef(!1),p=()=>{const h=i.current;if(!n&&h){const x=new CustomEvent(sS,{bubbles:!0,cancelable:!0});h.addEventListener(sS,u=>r==null?void 0:r(u),{once:!0}),KA(h,x),x.defaultPrevented?f.current=!1:o.onClose()}};return e.jsx(oD,{...a,ref:m,disabled:n,onClick:Yt(t.onClick,p),onPointerDown:h=>{var x;(x=t.onPointerDown)==null||x.call(t,h),f.current=!0},onPointerUp:Yt(t.onPointerUp,h=>{var x;f.current||(x=h.currentTarget)==null||x.click()}),onKeyDown:Yt(t.onKeyDown,h=>{const x=d.searchRef.current!=="";n||x&&h.key===" "||my.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Qf.displayName=uf;var oD=g.forwardRef((t,s)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=t,o=pb(uf,n),d=sD(n),m=g.useRef(null),f=Ys(s,m),[p,h]=g.useState(!1),[x,u]=g.useState("");return g.useEffect(()=>{const N=m.current;N&&u((N.textContent??"").trim())},[i.children]),e.jsx(Ru.ItemSlot,{scope:n,disabled:r,textValue:a??x,children:e.jsx(Hk,{asChild:!0,...d,focusable:!r,children:e.jsx(Ss.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:f,onPointerMove:Yt(t.onPointerMove,Eu(N=>{r?o.onItemLeave(N):(o.onItemEnter(N),N.defaultPrevented||N.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Yt(t.onPointerLeave,Eu(N=>o.onItemLeave(N))),onFocus:Yt(t.onFocus,()=>h(!0)),onBlur:Yt(t.onBlur,()=>h(!1))})})})}),U6="MenuCheckboxItem",cD=g.forwardRef((t,s)=>{const{checked:n=!1,onCheckedChange:r,...a}=t;return e.jsx(fD,{scope:t.__scopeMenu,checked:n,children:e.jsx(Qf,{role:"menuitemcheckbox","aria-checked":hf(n)?"mixed":n,...a,ref:s,"data-state":yb(n),onSelect:Yt(a.onSelect,()=>r==null?void 0:r(hf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cD.displayName=U6;var dD="MenuRadioGroup",[V6,H6]=uc(dD,{value:void 0,onValueChange:()=>{}}),uD=g.forwardRef((t,s)=>{const{value:n,onValueChange:r,...a}=t,i=xr(r);return e.jsx(V6,{scope:t.__scopeMenu,value:n,onValueChange:i,children:e.jsx(gb,{...a,ref:s})})});uD.displayName=dD;var hD="MenuRadioItem",mD=g.forwardRef((t,s)=>{const{value:n,...r}=t,a=H6(hD,t.__scopeMenu),i=n===a.value;return e.jsx(fD,{scope:t.__scopeMenu,checked:i,children:e.jsx(Qf,{role:"menuitemradio","aria-checked":i,...r,ref:s,"data-state":yb(i),onSelect:Yt(r.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,n)},{checkForDefaultPrevented:!1})})})});mD.displayName=hD;var vb="MenuItemIndicator",[fD,W6]=uc(vb,{checked:!1}),pD=g.forwardRef((t,s)=>{const{__scopeMenu:n,forceMount:r,...a}=t,i=W6(vb,n);return e.jsx(jr,{present:r||hf(i.checked)||i.checked===!0,children:e.jsx(Ss.span,{...a,ref:s,"data-state":yb(i.checked)})})});pD.displayName=vb;var G6="MenuSeparator",xD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(Ss.div,{role:"separator","aria-orientation":"horizontal",...r,ref:s})});xD.displayName=G6;var K6="MenuArrow",gD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Zf(n);return e.jsx(Wf,{...a,...r,ref:s})});gD.displayName=K6;var Y6="MenuSub",[SY,vD]=uc(Y6),mu="MenuSubTrigger",yD=g.forwardRef((t,s)=>{const n=hc(mu,t.__scopeMenu),r=th(mu,t.__scopeMenu),a=vD(mu,t.__scopeMenu),i=pb(mu,t.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:d,onPointerGraceIntentChange:m}=i,f={__scopeMenu:t.__scopeMenu},p=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>p,[p]),g.useEffect(()=>{const h=d.current;return()=>{window.clearTimeout(h),m(null)}},[d,m]),e.jsx(mb,{asChild:!0,...f,children:e.jsx(oD,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":ND(n.open),...t,ref:Hr(s,a.onTriggerChange),onClick:h=>{var x;(x=t.onClick)==null||x.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Yt(t.onPointerMove,Eu(h=>{i.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:Yt(t.onPointerLeave,Eu(h=>{var u,N;p();const x=(u=n.content)==null?void 0:u.getBoundingClientRect();if(x){const v=(N=n.content)==null?void 0:N.dataset.side,w=v==="right",j=w?-5:5,b=x[w?"left":"right"],C=x[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+j,y:h.clientY},{x:b,y:x.top},{x:C,y:x.top},{x:C,y:x.bottom},{x:b,y:x.bottom}],side:v}),window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Yt(t.onKeyDown,h=>{var u;const x=i.searchRef.current!=="";t.disabled||x&&h.key===" "||R6[r.dir].includes(h.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),h.preventDefault())})})})});yD.displayName=mu;var bD="MenuSubContent",jD=g.forwardRef((t,s)=>{const n=rD($a,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,i=hc($a,t.__scopeMenu),o=th($a,t.__scopeMenu),d=vD(bD,t.__scopeMenu),m=g.useRef(null),f=Ys(s,m);return e.jsx(Ru.Provider,{scope:t.__scopeMenu,children:e.jsx(jr,{present:r||i.open,children:e.jsx(Ru.Slot,{scope:t.__scopeMenu,children:e.jsx(xb,{id:d.contentId,"aria-labelledby":d.triggerId,...a,ref:f,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var h;o.isUsingKeyboardRef.current&&((h=m.current)==null||h.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Yt(t.onFocusOutside,p=>{p.target!==d.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Yt(t.onEscapeKeyDown,p=>{o.onClose(),p.preventDefault()}),onKeyDown:Yt(t.onKeyDown,p=>{var u;const h=p.currentTarget.contains(p.target),x=E6[o.dir].includes(p.key);h&&x&&(i.onOpenChange(!1),(u=d.trigger)==null||u.focus(),p.preventDefault())})})})})})});jD.displayName=bD;function ND(t){return t?"open":"closed"}function hf(t){return t==="indeterminate"}function yb(t){return hf(t)?"indeterminate":t?"checked":"unchecked"}function Z6(t){const s=document.activeElement;for(const n of t)if(n===s||(n.focus(),document.activeElement!==s))return}function Q6(t,s){return t.map((n,r)=>t[(s+r)%t.length])}function X6(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=Q6(t,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const m=o.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return m!==n?m:void 0}function J6(t,s){const{x:n,y:r}=t;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const d=s[i],m=s[o],f=d.x,p=d.y,h=m.x,x=m.y;p>r!=x>r&&n<(h-f)*(r-p)/(x-p)+f&&(a=!a)}return a}function e8(t,s){if(!s)return!1;const n={x:t.clientX,y:t.clientY};return J6(n,s)}function Eu(t){return s=>s.pointerType==="mouse"?t(s):void 0}var t8=nD,s8=mb,n8=aD,r8=iD,a8=gb,i8=lD,l8=Qf,o8=cD,c8=uD,d8=mD,u8=pD,h8=xD,m8=gD,f8=yD,p8=jD,Xf="DropdownMenu",[x8]=oa(Xf,[tD]),Kr=tD(),[g8,wD]=x8(Xf),SD=t=>{const{__scopeDropdownMenu:s,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:d=!0}=t,m=Kr(s),f=g.useRef(null),[p,h]=Li({prop:a,defaultProp:i??!1,onChange:o,caller:Xf});return e.jsx(g8,{scope:s,triggerId:yr(),triggerRef:f,contentId:yr(),open:p,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(x=>!x),[h]),modal:d,children:e.jsx(t8,{...m,open:p,onOpenChange:h,dir:r,modal:d,children:n})})};SD.displayName=Xf;var CD="DropdownMenuTrigger",AD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,i=wD(CD,n),o=Kr(n);return e.jsx(s8,{asChild:!0,...o,children:e.jsx(Ss.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Hr(s,i.triggerRef),onPointerDown:Yt(t.onPointerDown,d=>{!r&&d.button===0&&d.ctrlKey===!1&&(i.onOpenToggle(),i.open||d.preventDefault())}),onKeyDown:Yt(t.onKeyDown,d=>{r||(["Enter"," "].includes(d.key)&&i.onOpenToggle(),d.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})});AD.displayName=CD;var v8="DropdownMenuPortal",kD=t=>{const{__scopeDropdownMenu:s,...n}=t,r=Kr(s);return e.jsx(n8,{...r,...n})};kD.displayName=v8;var DD="DropdownMenuContent",RD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=wD(DD,n),i=Kr(n),o=g.useRef(!1);return e.jsx(r8,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:s,onCloseAutoFocus:Yt(t.onCloseAutoFocus,d=>{var m;o.current||(m=a.triggerRef.current)==null||m.focus(),o.current=!1,d.preventDefault()}),onInteractOutside:Yt(t.onInteractOutside,d=>{const m=d.detail.originalEvent,f=m.button===0&&m.ctrlKey===!0,p=m.button===2||f;(!a.modal||p)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});RD.displayName=DD;var y8="DropdownMenuGroup",b8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(a8,{...a,...r,ref:s})});b8.displayName=y8;var j8="DropdownMenuLabel",ED=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(i8,{...a,...r,ref:s})});ED.displayName=j8;var N8="DropdownMenuItem",_D=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(l8,{...a,...r,ref:s})});_D.displayName=N8;var w8="DropdownMenuCheckboxItem",TD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(o8,{...a,...r,ref:s})});TD.displayName=w8;var S8="DropdownMenuRadioGroup",C8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(c8,{...a,...r,ref:s})});C8.displayName=S8;var A8="DropdownMenuRadioItem",k8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(d8,{...a,...r,ref:s})});k8.displayName=A8;var D8="DropdownMenuItemIndicator",PD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(u8,{...a,...r,ref:s})});PD.displayName=D8;var R8="DropdownMenuSeparator",OD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(h8,{...a,...r,ref:s})});OD.displayName=R8;var E8="DropdownMenuArrow",_8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(m8,{...a,...r,ref:s})});_8.displayName=E8;var T8="DropdownMenuSubTrigger",P8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(f8,{...a,...r,ref:s})});P8.displayName=T8;var O8="DropdownMenuSubContent",L8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=Kr(n);return e.jsx(p8,{...a,...r,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});L8.displayName=O8;var I8=SD,M8=AD,F8=kD,B8=RD,$8=ED,q8=_D,z8=TD,U8=PD,V8=OD;function bb({...t}){return e.jsx(I8,{"data-slot":"dropdown-menu",...t})}function jb({...t}){return e.jsx(M8,{"data-slot":"dropdown-menu-trigger",...t})}function Nb({className:t,sideOffset:s=4,...n}){return e.jsx(F8,{children:e.jsx(B8,{"data-slot":"dropdown-menu-content",sideOffset:s,className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function LD({className:t,inset:s,variant:n="default",...r}){return e.jsx(q8,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":n,className:Nt("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function H8({className:t,children:s,checked:n,...r}){return e.jsxs(z8,{"data-slot":"dropdown-menu-checkbox-item",className:Nt("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:n,...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(U8,{children:e.jsx($n,{className:"size-4"})})}),s]})}function W8({className:t,inset:s,...n}){return e.jsx($8,{"data-slot":"dropdown-menu-label","data-inset":s,className:Nt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function G8({className:t,...s}){return e.jsx(V8,{"data-slot":"dropdown-menu-separator",className:Nt("bg-border -mx-1 my-1 h-px",t),...s})}const K8=Ky("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function we({className:t,variant:s,asChild:n=!1,...r}){const a=n?$A:"span";return e.jsx(a,{"data-slot":"badge",className:Nt(K8({variant:s}),t),...r})}const vm="/communication",Ko={getNotifications:async(t,s)=>{let n=`${vm}/notifications`;return t&&s&&(n+=`?page=${t}&limit=${s}`),(await Ie.get(n)).data},markAsRead:async t=>(await Ie.patch(`${vm}/notifications/${t}/read`)).data,markAllAsRead:async()=>(await Ie.patch(`${vm}/notifications/read-all`)).data,updatePushSubscription:async t=>(await Ie.post(`${vm}/notifications/subscribe`,{subscription:t})).data},Ii=Object.create(null);Ii.open="0";Ii.close="1";Ii.ping="2";Ii.pong="3";Ii.message="4";Ii.upgrade="5";Ii.noop="6";const $m=Object.create(null);Object.keys(Ii).forEach(t=>{$m[Ii[t]]=t});const fy={type:"error",data:"parser error"},ID=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",MD=typeof ArrayBuffer=="function",FD=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,wb=({type:t,data:s},n,r)=>ID&&s instanceof Blob?n?r(s):nS(s,r):MD&&(s instanceof ArrayBuffer||FD(s))?n?r(s):nS(new Blob([s]),r):r(Ii[t]+(s||"")),nS=(t,s)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];s("b"+(r||""))},n.readAsDataURL(t)};function rS(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let Rg;function Y8(t,s){if(ID&&t.data instanceof Blob)return t.data.arrayBuffer().then(rS).then(s);if(MD&&(t.data instanceof ArrayBuffer||FD(t.data)))return s(rS(t.data));wb(t,!1,n=>{Rg||(Rg=new TextEncoder),s(Rg.encode(n))})}const aS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fu=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<aS.length;t++)fu[aS.charCodeAt(t)]=t;const Z8=t=>{let s=t.length*.75,n=t.length,r,a=0,i,o,d,m;t[t.length-1]==="="&&(s--,t[t.length-2]==="="&&s--);const f=new ArrayBuffer(s),p=new Uint8Array(f);for(r=0;r<n;r+=4)i=fu[t.charCodeAt(r)],o=fu[t.charCodeAt(r+1)],d=fu[t.charCodeAt(r+2)],m=fu[t.charCodeAt(r+3)],p[a++]=i<<2|o>>4,p[a++]=(o&15)<<4|d>>2,p[a++]=(d&3)<<6|m&63;return f},Q8=typeof ArrayBuffer=="function",Sb=(t,s)=>{if(typeof t!="string")return{type:"message",data:BD(t,s)};const n=t.charAt(0);return n==="b"?{type:"message",data:X8(t.substring(1),s)}:$m[n]?t.length>1?{type:$m[n],data:t.substring(1)}:{type:$m[n]}:fy},X8=(t,s)=>{if(Q8){const n=Z8(t);return BD(n,s)}else return{base64:!0,data:t}},BD=(t,s)=>{switch(s){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},$D="",J8=(t,s)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((i,o)=>{wb(i,!1,d=>{r[o]=d,++a===n&&s(r.join($D))})})},eB=(t,s)=>{const n=t.split($D),r=[];for(let a=0;a<n.length;a++){const i=Sb(n[a],s);if(r.push(i),i.type==="error")break}return r};function tB(){return new TransformStream({transform(t,s){Y8(t,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),s.enqueue(a),s.enqueue(n)})}})}let Eg;function ym(t){return t.reduce((s,n)=>s+n.length,0)}function bm(t,s){if(t[0].length===s)return t.shift();const n=new Uint8Array(s);let r=0;for(let a=0;a<s;a++)n[a]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function sB(t,s){Eg||(Eg=new TextDecoder);const n=[];let r=0,a=-1,i=!1;return new TransformStream({transform(o,d){for(n.push(o);;){if(r===0){if(ym(n)<1)break;const m=bm(n,1);i=(m[0]&128)===128,a=m[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(ym(n)<2)break;const m=bm(n,2);a=new DataView(m.buffer,m.byteOffset,m.length).getUint16(0),r=3}else if(r===2){if(ym(n)<8)break;const m=bm(n,8),f=new DataView(m.buffer,m.byteOffset,m.length),p=f.getUint32(0);if(p>Math.pow(2,21)-1){d.enqueue(fy);break}a=p*Math.pow(2,32)+f.getUint32(4),r=3}else{if(ym(n)<a)break;const m=bm(n,a);d.enqueue(Sb(i?m:Eg.decode(m),s)),r=0}if(a===0||a>t){d.enqueue(fy);break}}}})}const qD=4;function Qn(t){if(t)return nB(t)}function nB(t){for(var s in Qn.prototype)t[s]=Qn.prototype[s];return t}Qn.prototype.on=Qn.prototype.addEventListener=function(t,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(s),this};Qn.prototype.once=function(t,s){function n(){this.off(t,n),s.apply(this,arguments)}return n.fn=s,this.on(t,n),this};Qn.prototype.off=Qn.prototype.removeListener=Qn.prototype.removeAllListeners=Qn.prototype.removeEventListener=function(t,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===s||r.fn===s){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+t],this};Qn.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)s[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,s)}return this};Qn.prototype.emitReserved=Qn.prototype.emit;Qn.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Qn.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Jf=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,n)=>n(s,0),Fa=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),rB="arraybuffer";function zD(t,...s){return s.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const aB=Fa.setTimeout,iB=Fa.clearTimeout;function ep(t,s){s.useNativeTimers?(t.setTimeoutFn=aB.bind(Fa),t.clearTimeoutFn=iB.bind(Fa)):(t.setTimeoutFn=Fa.setTimeout.bind(Fa),t.clearTimeoutFn=Fa.clearTimeout.bind(Fa))}const lB=1.33;function oB(t){return typeof t=="string"?cB(t):Math.ceil((t.byteLength||t.size)*lB)}function cB(t){let s=0,n=0;for(let r=0,a=t.length;r<a;r++)s=t.charCodeAt(r),s<128?n+=1:s<2048?n+=2:s<55296||s>=57344?n+=3:(r++,n+=4);return n}function UD(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dB(t){let s="";for(let n in t)t.hasOwnProperty(n)&&(s.length&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return s}function uB(t){let s={},n=t.split("&");for(let r=0,a=n.length;r<a;r++){let i=n[r].split("=");s[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return s}class hB extends Error{constructor(s,n,r){super(s),this.description=n,this.context=r,this.type="TransportError"}}class Cb extends Qn{constructor(s){super(),this.writable=!1,ep(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,n,r){return super.emitReserved("error",new hB(s,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const n=Sb(s,this.socket.binaryType);this.onPacket(n)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,n={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const n=dB(s);return n.length?"?"+n:""}}class mB extends Cb{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const n=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};eB(s,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,J8(s,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=UD()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(s,n)}}let VD=!1;try{VD=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const fB=VD;function pB(){}class xB extends mB{constructor(s){if(super(s),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||r!==s.port}}doWrite(s,n){const r=this.request({method:"POST",data:s});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=s}}class Oi extends Qn{constructor(s,n,r){super(),this.createRequest=s,ep(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var s;const n=zD(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=Oi.requestsCount++,Oi.requests[this._index]=this)}_onError(s){this.emitReserved("error",s,this._xhr),this._cleanup(!0)}_cleanup(s){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=pB,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Oi.requests[this._index],this._xhr=null}}_onLoad(){const s=this._xhr.responseText;s!==null&&(this.emitReserved("data",s),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Oi.requestsCount=0;Oi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",iS);else if(typeof addEventListener=="function"){const t="onpagehide"in Fa?"pagehide":"unload";addEventListener(t,iS,!1)}}function iS(){for(let t in Oi.requests)Oi.requests.hasOwnProperty(t)&&Oi.requests[t].abort()}const gB=(function(){const t=HD({xdomain:!1});return t&&t.responseType!==null})();class vB extends xB{constructor(s){super(s);const n=s&&s.forceBase64;this.supportsBinary=gB&&!n}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Oi(HD,this.uri(),s)}}function HD(t){const s=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||fB))return new XMLHttpRequest}catch{}if(!s)try{return new Fa[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const WD=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yB extends Cb{get name(){return"websocket"}doOpen(){const s=this.uri(),n=this.opts.protocols,r=WD?{}:zD(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(s,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let n=0;n<s.length;n++){const r=s[n],a=n===s.length-1;wb(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&Jf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const s=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=UD()),this.supportsBinary||(n.b64=1),this.createUri(s,n)}}const _g=Fa.WebSocket||Fa.MozWebSocket;class bB extends yB{createSocket(s,n,r){return WD?new _g(s,n,r):n?new _g(s,n):new _g(s)}doWrite(s,n){this.ws.send(n)}}class jB extends Cb{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const n=sB(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=s.readable.pipeThrough(n).getReader(),a=tB();a.readable.pipeTo(s.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:d,value:m})=>{d||(this.onPacket(m),i())}).catch(d=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let n=0;n<s.length;n++){const r=s[n],a=n===s.length-1;this._writer.write(r).then(()=>{a&&Jf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const NB={websocket:bB,webtransport:jB,polling:vB},wB=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,SB=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function py(t){if(t.length>8e3)throw"URI too long";const s=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let a=wB.exec(t||""),i={},o=14;for(;o--;)i[SB[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=s,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=CB(i,i.path),i.queryKey=AB(i,i.query),i}function CB(t,s){const n=/\/{2,9}/g,r=s.replace(n,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&r.splice(0,1),s.slice(-1)=="/"&&r.splice(r.length-1,1),r}function AB(t,s){const n={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const xy=typeof addEventListener=="function"&&typeof removeEventListener=="function",qm=[];xy&&addEventListener("offline",()=>{qm.forEach(t=>t())},!1);class Ql extends Qn{constructor(s,n){if(super(),this.binaryType=rB,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(n=s,s=null),s){const r=py(s);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=py(n.host).host);ep(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=uB(this.opts.query)),xy&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},qm.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const n=Object.assign({},this.opts.query);n.EIO=qD,n.transport=s,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&Ql.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(s);n.open(),this.setTransport(n)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ql.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=s.data,this._onError(n);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=oB(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,Jf(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,n,r){return this._sendPacket("message",s,n,r),this}send(s,n,r){return this._sendPacket("message",s,n,r),this}_sendPacket(s,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:s,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),s()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():s()}):this.upgrading?r():s()),this}_onError(s){if(Ql.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xy&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=qm.indexOf(this._offlineEventListener);r!==-1&&qm.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ql.protocol=qD;class kB extends Ql{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let n=this.createTransport(s),r=!1;Ql.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ql.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(p(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=n.name,this.emitReserved("upgradeError",x)}}))};function i(){r||(r=!0,p(),n.close(),n=null)}const o=h=>{const x=new Error("probe error: "+h);x.transport=n.name,i(),this.emitReserved("upgradeError",x)};function d(){o("transport closed")}function m(){o("socket closed")}function f(h){n&&h.name!==n.name&&i()}const p=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",d),this.off("close",m),this.off("upgrading",f)};n.once("open",a),n.once("error",o),n.once("close",d),this.once("close",m),this.once("upgrading",f),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const n=[];for(let r=0;r<s.length;r++)~this.transports.indexOf(s[r])&&n.push(s[r]);return n}}let DB=class extends kB{constructor(s,n={}){const r=typeof s=="object"?s:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>NB[a]).filter(a=>!!a)),super(s,r)}};function RB(t,s="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=py(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+s,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const EB=typeof ArrayBuffer=="function",_B=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,GD=Object.prototype.toString,TB=typeof Blob=="function"||typeof Blob<"u"&&GD.call(Blob)==="[object BlobConstructor]",PB=typeof File=="function"||typeof File<"u"&&GD.call(File)==="[object FileConstructor]";function Ab(t){return EB&&(t instanceof ArrayBuffer||_B(t))||TB&&t instanceof Blob||PB&&t instanceof File}function zm(t,s){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(zm(t[n]))return!0;return!1}if(Ab(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return zm(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&zm(t[n]))return!0;return!1}function OB(t){const s=[],n=t.data,r=t;return r.data=gy(n,s),r.attachments=s.length,{packet:r,buffers:s}}function gy(t,s){if(!t)return t;if(Ab(t)){const n={_placeholder:!0,num:s.length};return s.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=gy(t[r],s);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=gy(t[r],s));return n}return t}function LB(t,s){return t.data=vy(t.data,s),delete t.attachments,t}function vy(t,s){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<s.length)return s[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=vy(t[n],s);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=vy(t[n],s));return t}const IB=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var on;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(on||(on={}));class MB{constructor(s){this.replacer=s}encode(s){return(s.type===on.EVENT||s.type===on.ACK)&&zm(s)?this.encodeAsBinary({type:s.type===on.EVENT?on.BINARY_EVENT:on.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let n=""+s.type;return(s.type===on.BINARY_EVENT||s.type===on.BINARY_ACK)&&(n+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(n+=s.nsp+","),s.id!=null&&(n+=s.id),s.data!=null&&(n+=JSON.stringify(s.data,this.replacer)),n}encodeAsBinary(s){const n=OB(s),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class kb extends Qn{constructor(s){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof s=="function"?{reviver:s}:s)}add(s){let n;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(s);const r=n.type===on.BINARY_EVENT;r||n.type===on.BINARY_ACK?(n.type=r?on.EVENT:on.ACK,this.reconstructor=new FB(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Ab(s)||s.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(s),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let n=0;const r={type:Number(s.charAt(0))};if(on[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===on.BINARY_EVENT||r.type===on.BINARY_ACK){const i=n+1;for(;s.charAt(++n)!=="-"&&n!=s.length;);const o=s.substring(i,n);if(o!=Number(o)||s.charAt(n)!=="-")throw new Error("Illegal attachments");const d=Number(o);if(!BB(d)||d<0)throw new Error("Illegal attachments");if(d>this.opts.maxAttachments)throw new Error("too many attachments");r.attachments=d}if(s.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(s.charAt(n)===","||n===s.length););r.nsp=s.substring(i,n)}else r.nsp="/";const a=s.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=s.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===s.length)break}r.id=Number(s.substring(i,n+1))}if(s.charAt(++n)){const i=this.tryParse(s.substr(n));if(kb.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(s){try{return JSON.parse(s,this.opts.reviver)}catch{return!1}}static isPayloadValid(s,n){switch(s){case on.CONNECT:return lS(n);case on.DISCONNECT:return n===void 0;case on.CONNECT_ERROR:return typeof n=="string"||lS(n);case on.EVENT:case on.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&IB.indexOf(n[0])===-1);case on.ACK:case on.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class FB{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const n=LB(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const BB=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function lS(t){return Object.prototype.toString.call(t)==="[object Object]"}const $B=Object.freeze(Object.defineProperty({__proto__:null,Decoder:kb,Encoder:MB,get PacketType(){return on}},Symbol.toStringTag,{value:"Module"}));function ni(t,s,n){return t.on(s,n),function(){t.off(s,n)}}const qB=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class KD extends Qn{constructor(s,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=s,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const s=this.io;this.subs=[ni(s,"open",this.onopen.bind(this)),ni(s,"packet",this.onpacket.bind(this)),ni(s,"error",this.onerror.bind(this)),ni(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...n){var r,a,i;if(qB.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(n.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:on.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const p=this.ids++,h=n.pop();this._registerAckCallback(p,h),o.id=p}const d=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,m=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!d||(m?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(s,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[s]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let d=0;d<this.sendBuffer.length;d++)this.sendBuffer[d].id===s&&this.sendBuffer.splice(d,1);n.call(this,new Error("operation has timed out"))},a),o=(...d)=>{this.io.clearTimeoutFn(i),n.apply(this,d)};o.withError=!0,this.acks[s]=o}emitWithAck(s,...n){return new Promise((r,a)=>{const i=(o,d)=>o?a(o):r(d);i.withError=!0,n.push(i),this.emit(s,...n)})}_addToQueue(s){let n;typeof s[s.length-1]=="function"&&(n=s.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((a,...i)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!s||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:on.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(r=>String(r.id)===s)){const r=this.acks[s];delete this.acks[s],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case on.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case on.EVENT:case on.BINARY_EVENT:this.onevent(s);break;case on.ACK:case on.BINARY_ACK:this.onack(s);break;case on.DISCONNECT:this.ondisconnect();break;case on.CONNECT_ERROR:this.destroy();const r=new Error(s.data.message);r.data=s.data.data,this.emitReserved("connect_error",r);break}}onevent(s){const n=s.data||[];s.id!=null&&n.push(this.ack(s.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:on.ACK,id:s,data:a}))}}onack(s){const n=this.acks[s.id];typeof n=="function"&&(delete this.acks[s.id],n.withError&&s.data.unshift(null),n.apply(this,s.data))}onconnect(s,n){this.id=s,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:on.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(s===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(s===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,s.data)}}}function wd(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}wd.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),n=Math.floor(s*this.jitter*t);t=(Math.floor(s*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};wd.prototype.reset=function(){this.attempts=0};wd.prototype.setMin=function(t){this.ms=t};wd.prototype.setMax=function(t){this.max=t};wd.prototype.setJitter=function(t){this.jitter=t};class yy extends Qn{constructor(s,n){var r;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(n=s,s=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,ep(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new wd({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=s;const a=n.parser||$B;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var n;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(n=this.backoff)===null||n===void 0||n.setMin(s),this)}randomizationFactor(s){var n;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(n=this.backoff)===null||n===void 0||n.setJitter(s),this)}reconnectionDelayMax(s){var n;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(n=this.backoff)===null||n===void 0||n.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new DB(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=ni(n,"open",function(){r.onopen(),s&&s()}),i=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),s?s(d):this.maybeReconnectOnOpen()},o=ni(n,"error",i);if(this._timeout!==!1){const d=this._timeout,m=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},d);this.opts.autoUnref&&m.unref(),this.subs.push(()=>{this.clearTimeoutFn(m)})}return this.subs.push(a),this.subs.push(o),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(ni(s,"ping",this.onping.bind(this)),ni(s,"data",this.ondata.bind(this)),ni(s,"error",this.onerror.bind(this)),ni(s,"close",this.onclose.bind(this)),ni(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(n){this.onclose("parse error",n)}}ondecoded(s){Jf(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,n){let r=this.nsps[s];return r?this._autoConnect&&!r.active&&r.connect():(r=new KD(this,s,n),this.nsps[s]=r),r}_destroy(s){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(s){const n=this.encoder.encode(s);for(let r=0;r<n.length;r++)this.engine.write(n[r],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(a=>{a?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",a)):s.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const su={};function Um(t,s){typeof t=="object"&&(s=t,t=void 0),s=s||{};const n=RB(t,s.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=su[a]&&i in su[a].nsps,d=s.forceNew||s["force new connection"]||s.multiplex===!1||o;let m;return d?m=new yy(r,s):(su[a]||(su[a]=new yy(r,s)),m=su[a]),n.query&&!s.query&&(s.query=n.queryKey),m.socket(n.path,s)}Object.assign(Um,{Manager:yy,Socket:KD,io:Um,connect:Um});const YD=g.createContext({socket:null,isConnected:!1}),ZD=()=>g.useContext(YD),zB=({children:t})=>{const[s,n]=g.useState(null),[r,a]=g.useState(!1),{user:i}=Pn(o=>o.auth);return g.useEffect(()=>{let o="https://dealeronboarding-uat.royalenfield.com/api";o.endsWith("/api")&&(o=o.replace(/\/api$/,""));const d=Um(o,{withCredentials:!0});return d.on("connect",()=>{console.log("Socket connected:",d.id),a(!0)}),d.on("disconnect",()=>{console.log("Socket disconnected"),a(!1)}),n(d),()=>{d.close()}},[]),g.useEffect(()=>{if(s&&r&&(i!=null&&i.id))return s.emit("join_room",`user_${i.id}`),console.log(`Joined private notification room: user_${i.id}`),()=>{s.emit("leave_room",`user_${i.id}`)}},[s,r,i==null?void 0:i.id]),e.jsx(YD.Provider,{value:{socket:s,isConnected:r},children:t})};function Gs(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function la(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Ur(t,s){const n=Gs(t);return isNaN(s)?la(t,NaN):(s&&n.setDate(n.getDate()+s),n)}function di(t,s){const n=Gs(t);if(isNaN(s))return la(t,NaN);if(!s)return n;const r=n.getDate(),a=la(t,n.getTime());a.setMonth(n.getMonth()+s+1,0);const i=a.getDate();return r>=i?a:(n.setFullYear(a.getFullYear(),a.getMonth(),r),n)}const Db=6048e5,UB=864e5,jm=43200,oS=1440;let VB={};function Sd(){return VB}function Mi(t,s){var d,m,f,p;const n=Sd(),r=(s==null?void 0:s.weekStartsOn)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=Gs(t),i=a.getDay(),o=(i<r?7:0)+i-r;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function rc(t){return Mi(t,{weekStartsOn:1})}function QD(t){const s=Gs(t),n=s.getFullYear(),r=la(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=rc(r),i=la(t,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const o=rc(i);return s.getTime()>=a.getTime()?n+1:s.getTime()>=o.getTime()?n:n-1}function od(t){const s=Gs(t);return s.setHours(0,0,0,0),s}function cd(t){const s=Gs(t),n=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return n.setUTCFullYear(s.getFullYear()),+t-+n}function Ti(t,s){const n=od(t),r=od(s),a=+n-cd(n),i=+r-cd(r);return Math.round((a-i)/UB)}function HB(t){const s=QD(t),n=la(t,0);return n.setFullYear(s,0,4),n.setHours(0,0,0,0),rc(n)}function by(t,s){const n=s*7;return Ur(t,n)}function WB(t,s){return di(t,s*12)}function GB(t){let s;return t.forEach(function(n){const r=Gs(n);(s===void 0||s<r||isNaN(Number(r)))&&(s=r)}),s||new Date(NaN)}function KB(t){let s;return t.forEach(n=>{const r=Gs(n);(!s||s>r||isNaN(+r))&&(s=r)}),s||new Date(NaN)}function Vm(t,s){const n=Gs(t),r=Gs(s),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a}function YB(t){return la(t,Date.now())}function na(t,s){const n=od(t),r=od(s);return+n==+r}function Rb(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function ZB(t){if(!Rb(t)&&typeof t!="number")return!1;const s=Gs(t);return!isNaN(Number(s))}function dd(t,s){const n=Gs(t),r=Gs(s),a=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return a*12+i}function QB(t,s,n){const r=Mi(t,n),a=Mi(s,n),i=+r-cd(r),o=+a-cd(a);return Math.round((i-o)/Db)}function XB(t){return s=>{const r=(t?Math[t]:Math.trunc)(s);return r===0?0:r}}function JB(t,s){return+Gs(t)-+Gs(s)}function e9(t){const s=Gs(t);return s.setHours(23,59,59,999),s}function tp(t){const s=Gs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(23,59,59,999),s}function t9(t){const s=Gs(t);return+e9(s)==+tp(s)}function s9(t,s){const n=Gs(t),r=Gs(s),a=Vm(n,r),i=Math.abs(dd(n,r));let o;if(i<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*i);let d=Vm(n,r)===-a;t9(Gs(t))&&i===1&&Vm(t,r)===1&&(d=!1),o=a*(i-Number(d))}return o===0?0:o}function n9(t,s,n){const r=JB(t,s)/1e3;return XB(n==null?void 0:n.roundingMethod)(r)}function ia(t){const s=Gs(t);return s.setDate(1),s.setHours(0,0,0,0),s}function XD(t){const s=Gs(t),n=la(t,0);return n.setFullYear(s.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Eb(t,s){var d,m,f,p;const n=Sd(),r=(s==null?void 0:s.weekStartsOn)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=Gs(t),i=a.getDay(),o=(i<r?-7:0)+6-(i-r);return a.setDate(a.getDate()+o),a.setHours(23,59,59,999),a}function JD(t){return Eb(t,{weekStartsOn:1})}const r9={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},a9=(t,s,n)=>{let r;const a=r9[t];return typeof a=="string"?r=a:s===1?r=a.one:r=a.other.replace("{{count}}",s.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Tg(t){return(s={})=>{const n=s.width?String(s.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const i9={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},l9={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},o9={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},c9={date:Tg({formats:i9,defaultWidth:"full"}),time:Tg({formats:l9,defaultWidth:"full"}),dateTime:Tg({formats:o9,defaultWidth:"full"})},d9={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},u9=(t,s,n,r)=>d9[t];function nu(t){return(s,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,d=n!=null&&n.width?String(n.width):o;a=t.formattingValues[d]||t.formattingValues[o]}else{const o=t.defaultWidth,d=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[d]||t.values[o]}const i=t.argumentCallback?t.argumentCallback(s):s;return a[i]}}const h9={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},m9={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},f9={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},p9={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},x9={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},g9={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},v9=(t,s)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},y9={ordinalNumber:v9,era:nu({values:h9,defaultWidth:"wide"}),quarter:nu({values:m9,defaultWidth:"wide",argumentCallback:t=>t-1}),month:nu({values:f9,defaultWidth:"wide"}),day:nu({values:p9,defaultWidth:"wide"}),dayPeriod:nu({values:x9,defaultWidth:"wide",formattingValues:g9,defaultFormattingWidth:"wide"})};function ru(t){return(s,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],i=s.match(a);if(!i)return null;const o=i[0],d=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(d)?j9(d,h=>h.test(o)):b9(d,h=>h.test(o));let f;f=t.valueCallback?t.valueCallback(m):m,f=n.valueCallback?n.valueCallback(f):f;const p=s.slice(o.length);return{value:f,rest:p}}}function b9(t,s){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s(t[n]))return n}function j9(t,s){for(let n=0;n<t.length;n++)if(s(t[n]))return n}function N9(t){return(s,n={})=>{const r=s.match(t.matchPattern);if(!r)return null;const a=r[0],i=s.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const d=s.slice(a.length);return{value:o,rest:d}}}const w9=/^(\d+)(th|st|nd|rd)?/i,S9=/\d+/i,C9={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},A9={any:[/^b/i,/^(a|c)/i]},k9={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},D9={any:[/1/i,/2/i,/3/i,/4/i]},R9={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},E9={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},_9={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},T9={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},P9={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},O9={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},L9={ordinalNumber:N9({matchPattern:w9,parsePattern:S9,valueCallback:t=>parseInt(t,10)}),era:ru({matchPatterns:C9,defaultMatchWidth:"wide",parsePatterns:A9,defaultParseWidth:"any"}),quarter:ru({matchPatterns:k9,defaultMatchWidth:"wide",parsePatterns:D9,defaultParseWidth:"any",valueCallback:t=>t+1}),month:ru({matchPatterns:R9,defaultMatchWidth:"wide",parsePatterns:E9,defaultParseWidth:"any"}),day:ru({matchPatterns:_9,defaultMatchWidth:"wide",parsePatterns:T9,defaultParseWidth:"any"}),dayPeriod:ru({matchPatterns:P9,defaultMatchWidth:"any",parsePatterns:O9,defaultParseWidth:"any"})},_b={code:"en-US",formatDistance:a9,formatLong:c9,formatRelative:u9,localize:y9,match:L9,options:{weekStartsOn:0,firstWeekContainsDate:1}};function I9(t){const s=Gs(t);return Ti(s,XD(s))+1}function eR(t){const s=Gs(t),n=+rc(s)-+HB(s);return Math.round(n/Db)+1}function tR(t,s){var p,h,x,u;const n=Gs(t),r=n.getFullYear(),a=Sd(),i=(s==null?void 0:s.firstWeekContainsDate)??((h=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:h.firstWeekContainsDate)??a.firstWeekContainsDate??((u=(x=a.locale)==null?void 0:x.options)==null?void 0:u.firstWeekContainsDate)??1,o=la(t,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const d=Mi(o,s),m=la(t,0);m.setFullYear(r,0,i),m.setHours(0,0,0,0);const f=Mi(m,s);return n.getTime()>=d.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function M9(t,s){var d,m,f,p;const n=Sd(),r=(s==null?void 0:s.firstWeekContainsDate)??((m=(d=s==null?void 0:s.locale)==null?void 0:d.options)==null?void 0:m.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,a=tR(t,s),i=la(t,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),Mi(i,s)}function sR(t,s){const n=Gs(t),r=+Mi(n,s)-+M9(n,s);return Math.round(r/Db)+1}function Nn(t,s){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(s,"0");return n+r}const Wl={y(t,s){const n=t.getFullYear(),r=n>0?n:1-n;return Nn(s==="yy"?r%100:r,s.length)},M(t,s){const n=t.getMonth();return s==="M"?String(n+1):Nn(n+1,2)},d(t,s){return Nn(t.getDate(),s.length)},a(t,s){const n=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,s){return Nn(t.getHours()%12||12,s.length)},H(t,s){return Nn(t.getHours(),s.length)},m(t,s){return Nn(t.getMinutes(),s.length)},s(t,s){return Nn(t.getSeconds(),s.length)},S(t,s){const n=s.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return Nn(a,s.length)}},zc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},cS={G:function(t,s,n){const r=t.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,s,n){if(s==="yo"){const r=t.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return Wl.y(t,s)},Y:function(t,s,n,r){const a=tR(t,r),i=a>0?a:1-a;if(s==="YY"){const o=i%100;return Nn(o,2)}return s==="Yo"?n.ordinalNumber(i,{unit:"year"}):Nn(i,s.length)},R:function(t,s){const n=QD(t);return Nn(n,s.length)},u:function(t,s){const n=t.getFullYear();return Nn(n,s.length)},Q:function(t,s,n){const r=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(r);case"QQ":return Nn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,s,n){const r=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(r);case"qq":return Nn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,s,n){const r=t.getMonth();switch(s){case"M":case"MM":return Wl.M(t,s);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,s,n){const r=t.getMonth();switch(s){case"L":return String(r+1);case"LL":return Nn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,s,n,r){const a=sR(t,r);return s==="wo"?n.ordinalNumber(a,{unit:"week"}):Nn(a,s.length)},I:function(t,s,n){const r=eR(t);return s==="Io"?n.ordinalNumber(r,{unit:"week"}):Nn(r,s.length)},d:function(t,s,n){return s==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Wl.d(t,s)},D:function(t,s,n){const r=I9(t);return s==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Nn(r,s.length)},E:function(t,s,n){const r=t.getDay();switch(s){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,s,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(s){case"e":return String(i);case"ee":return Nn(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,n,r){const a=t.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(s){case"c":return String(i);case"cc":return Nn(i,s.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,n){const r=t.getDay(),a=r===0?7:r;switch(s){case"i":return String(a);case"ii":return Nn(a,s.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,s,n){const a=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,s,n){const r=t.getHours();let a;switch(r===12?a=zc.noon:r===0?a=zc.midnight:a=r/12>=1?"pm":"am",s){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,s,n){const r=t.getHours();let a;switch(r>=17?a=zc.evening:r>=12?a=zc.afternoon:r>=4?a=zc.morning:a=zc.night,s){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,s,n){if(s==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Wl.h(t,s)},H:function(t,s,n){return s==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Wl.H(t,s)},K:function(t,s,n){const r=t.getHours()%12;return s==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Nn(r,s.length)},k:function(t,s,n){let r=t.getHours();return r===0&&(r=24),s==="ko"?n.ordinalNumber(r,{unit:"hour"}):Nn(r,s.length)},m:function(t,s,n){return s==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Wl.m(t,s)},s:function(t,s,n){return s==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Wl.s(t,s)},S:function(t,s){return Wl.S(t,s)},X:function(t,s,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(s){case"X":return uS(r);case"XXXX":case"XX":return zo(r);case"XXXXX":case"XXX":default:return zo(r,":")}},x:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"x":return uS(r);case"xxxx":case"xx":return zo(r);case"xxxxx":case"xxx":default:return zo(r,":")}},O:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+dS(r,":");case"OOOO":default:return"GMT"+zo(r,":")}},z:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+dS(r,":");case"zzzz":default:return"GMT"+zo(r,":")}},t:function(t,s,n){const r=Math.trunc(t.getTime()/1e3);return Nn(r,s.length)},T:function(t,s,n){const r=t.getTime();return Nn(r,s.length)}};function dS(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+s+Nn(i,2)}function uS(t,s){return t%60===0?(t>0?"-":"+")+Nn(Math.abs(t)/60,2):zo(t,s)}function zo(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Nn(Math.trunc(r/60),2),i=Nn(r%60,2);return n+a+s+i}const hS=(t,s)=>{switch(t){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},nR=(t,s)=>{switch(t){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},F9=(t,s)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return hS(t,s);let i;switch(r){case"P":i=s.dateTime({width:"short"});break;case"PP":i=s.dateTime({width:"medium"});break;case"PPP":i=s.dateTime({width:"long"});break;case"PPPP":default:i=s.dateTime({width:"full"});break}return i.replace("{{date}}",hS(r,s)).replace("{{time}}",nR(a,s))},B9={p:nR,P:F9},$9=/^D+$/,q9=/^Y+$/,z9=["D","DD","YY","YYYY"];function U9(t){return $9.test(t)}function V9(t){return q9.test(t)}function H9(t,s,n){const r=W9(t,s,n);if(console.warn(r),z9.includes(t))throw new RangeError(r)}function W9(t,s,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const G9=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,K9=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Y9=/^'([^]*?)'?$/,Z9=/''/g,Q9=/[a-zA-Z]/;function za(t,s,n){var p,h,x,u,N,v,w,j;const r=Sd(),a=(n==null?void 0:n.locale)??r.locale??_b,i=(n==null?void 0:n.firstWeekContainsDate)??((h=(p=n==null?void 0:n.locale)==null?void 0:p.options)==null?void 0:h.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(x=r.locale)==null?void 0:x.options)==null?void 0:u.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((v=(N=n==null?void 0:n.locale)==null?void 0:N.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((j=(w=r.locale)==null?void 0:w.options)==null?void 0:j.weekStartsOn)??0,d=Gs(t);if(!ZB(d))throw new RangeError("Invalid time value");let m=s.match(K9).map(b=>{const C=b[0];if(C==="p"||C==="P"){const S=B9[C];return S(b,a.formatLong)}return b}).join("").match(G9).map(b=>{if(b==="''")return{isToken:!1,value:"'"};const C=b[0];if(C==="'")return{isToken:!1,value:X9(b)};if(cS[C])return{isToken:!0,value:b};if(C.match(Q9))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:b}});a.localize.preprocessor&&(m=a.localize.preprocessor(d,m));const f={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return m.map(b=>{if(!b.isToken)return b.value;const C=b.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&V9(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&U9(C))&&H9(C,s,String(t));const S=cS[C[0]];return S(d,C,a.localize,f)}).join("")}function X9(t){const s=t.match(Y9);return s?s[1].replace(Z9,"'"):t}function J9(t,s,n){const r=Sd(),a=(n==null?void 0:n.locale)??r.locale??_b,i=2520,o=Vm(t,s);if(isNaN(o))throw new RangeError("Invalid time value");const d=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o});let m,f;o>0?(m=Gs(s),f=Gs(t)):(m=Gs(t),f=Gs(s));const p=n9(f,m),h=(cd(f)-cd(m))/1e3,x=Math.round((p-h)/60);let u;if(x<2)return n!=null&&n.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,d):p<10?a.formatDistance("lessThanXSeconds",10,d):p<20?a.formatDistance("lessThanXSeconds",20,d):p<40?a.formatDistance("halfAMinute",0,d):p<60?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",1,d):x===0?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",x,d);if(x<45)return a.formatDistance("xMinutes",x,d);if(x<90)return a.formatDistance("aboutXHours",1,d);if(x<oS){const N=Math.round(x/60);return a.formatDistance("aboutXHours",N,d)}else{if(x<i)return a.formatDistance("xDays",1,d);if(x<jm){const N=Math.round(x/oS);return a.formatDistance("xDays",N,d)}else if(x<jm*2)return u=Math.round(x/jm),a.formatDistance("aboutXMonths",u,d)}if(u=s9(f,m),u<12){const N=Math.round(x/jm);return a.formatDistance("xMonths",N,d)}else{const N=u%12,v=Math.trunc(u/12);return N<3?a.formatDistance("aboutXYears",v,d):N<9?a.formatDistance("overXYears",v,d):a.formatDistance("almostXYears",v+1,d)}}function rR(t,s){return J9(t,YB(t),s)}function e7(t){const s=Gs(t),n=s.getFullYear(),r=s.getMonth(),a=la(t,0);return a.setFullYear(n,r+1,0),a.setHours(0,0,0,0),a.getDate()}function t7(t){return Math.trunc(+Gs(t)/1e3)}function s7(t){const s=Gs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(0,0,0,0),s}function n7(t,s){return QB(s7(t),ia(t),s)+1}function jy(t,s){const n=Gs(t),r=Gs(s);return n.getTime()>r.getTime()}function aR(t,s){const n=Gs(t),r=Gs(s);return+n<+r}function Tb(t,s){const n=Gs(t),r=Gs(s);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function r7(t,s){const n=Gs(t),r=Gs(s);return n.getFullYear()===r.getFullYear()}function Pg(t,s){return Ur(t,-s)}function Og(t,s){const n=Gs(t),r=n.getFullYear(),a=n.getDate(),i=la(t,0);i.setFullYear(r,s,15),i.setHours(0,0,0,0);const o=e7(i);return n.setMonth(s,Math.min(a,o)),n}function mS(t,s){const n=Gs(t);return isNaN(+n)?la(t,NaN):(n.setFullYear(s),n)}function a7({title:t,subtitle:s,onRefresh:n}){const{user:r}=Pn(h=>h.auth),{socket:a}=ZD(),[i,o]=g.useState([]),[d,m]=g.useState(0);g.useEffect(()=>{(async()=>{try{const x=await Ko.getNotifications(1,15);x.success&&(o(x.data),x.pagination&&x.pagination.unreadCount!==void 0?m(x.pagination.unreadCount):m(x.data.filter(u=>!u.isRead).length))}catch(x){console.error("Fetch notifications error:",x)}})()},[]),g.useEffect(()=>{if(a)return a.on("notification",h=>{o(x=>[h,...x].slice(0,15)),m(x=>x+1),J(h.title,{description:h.message,action:h.link?{label:"View",onClick:()=>window.location.href=h.link}:void 0})}),()=>{a.off("notification")}},[a]);const f=async h=>{try{h.isRead||(await Ko.markAsRead(h.id)).success&&(o(u=>u.map(N=>N.id===h.id?{...N,isRead:!0}:N)),m(u=>Math.max(0,u-1))),h.link&&(window.location.href=h.link)}catch(x){console.error("Notification click error:",x)}},p=async()=>{try{(await Ko.markAllAsRead()).success&&(o(x=>x.map(u=>({...u,isRead:!0}))),m(0))}catch(h){console.error("Mark all as read error:",h)}};return e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900",children:t}),e.jsx("p",{className:"text-slate-600 text-sm leading-snug max-w-3xl",children:s})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center",children:e.jsx(Rr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900",children:r.name}),e.jsx("p",{className:"text-slate-600",children:r.role})]})]}),n&&e.jsx(te,{variant:"outline",size:"icon",onClick:n,title:"Refresh",children:e.jsx(or,{className:"w-4 h-4"})}),e.jsx(te,{variant:"outline",size:"icon",title:"Help",children:e.jsx(ok,{className:"w-4 h-4"})}),e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(te,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(Au,{className:"w-4 h-4"}),d>0&&e.jsx(we,{variant:"destructive",className:"absolute -top-1 -right-1 w-5 h-5 p-0 flex items-center justify-center text-xs",children:d})]})}),e.jsxs(Nb,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[e.jsx("p",{className:"font-semibold text-slate-900",children:"Notifications"}),d>0&&e.jsx("button",{onClick:p,className:"text-xs text-blue-600 hover:underline",children:"Mark all read"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto custom-scrollbar",children:i.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500",children:"No notifications yet"}):i.map(h=>e.jsxs(LD,{className:`p-3 cursor-pointer flex items-start gap-3 ${h.isRead?"":"bg-blue-50/50"}`,onClick:()=>f(h),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:h.title}),e.jsx("p",{className:"text-slate-600 text-xs mt-1 leading-relaxed",children:h.message}),e.jsx("p",{className:"text-slate-400 text-[10px] mt-2",children:rR(new Date(h.createdAt),{addSuffix:!0})})]}),!h.isRead&&e.jsx("div",{className:"w-2 h-2 bg-blue-600 rounded-full mt-1.5 flex-shrink-0"})]},h.id))}),e.jsx("div",{className:"p-3 border-t text-center",children:e.jsx("button",{onClick:()=>window.location.href="/notifications",className:"text-xs font-medium text-blue-600 hover:text-blue-800 transition-colors",children:"View All Notifications"})})]})]})]})]})})}function _e({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:Nt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...s})}function Xe({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:Nt("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function st({className:t,...s}){return e.jsx("h4",{"data-slot":"card-title",className:Nt("leading-none",t),...s})}function es({className:t,...s}){return e.jsx("p",{"data-slot":"card-description",className:Nt("text-muted-foreground",t),...s})}function Oe({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:Nt("px-6 [&:last-child]:pb-6",t),...s})}function Ny(t,[s,n]){return Math.min(n,Math.max(s,t))}function i7(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var Pb="ScrollArea",[iR]=oa(Pb),[l7,Ua]=iR(Pb),lR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:i=600,...o}=t,[d,m]=g.useState(null),[f,p]=g.useState(null),[h,x]=g.useState(null),[u,N]=g.useState(null),[v,w]=g.useState(null),[j,b]=g.useState(0),[C,S]=g.useState(0),[D,_]=g.useState(!1),[A,E]=g.useState(!1),q=Ys(s,R=>m(R)),O=Ku(a);return e.jsx(l7,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:d,viewport:f,onViewportChange:p,content:h,onContentChange:x,scrollbarX:u,onScrollbarXChange:N,scrollbarXEnabled:D,onScrollbarXEnabledChange:_,scrollbarY:v,onScrollbarYChange:w,scrollbarYEnabled:A,onScrollbarYEnabledChange:E,onCornerWidthChange:b,onCornerHeightChange:S,children:e.jsx(Ss.div,{dir:O,...o,ref:q,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...t.style}})})});lR.displayName=Pb;var oR="ScrollAreaViewport",cR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,children:r,nonce:a,...i}=t,o=Ua(oR,n),d=g.useRef(null),m=Ys(s,d,o.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(Ss.div,{"data-radix-scroll-area-viewport":"",...i,ref:m,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});cR.displayName=oR;var Bi="ScrollAreaScrollbar",dR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ua(Bi,t.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,d=t.orientation==="horizontal";return g.useEffect(()=>(d?i(!0):o(!0),()=>{d?i(!1):o(!1)}),[d,i,o]),a.type==="hover"?e.jsx(o7,{...r,ref:s,forceMount:n}):a.type==="scroll"?e.jsx(c7,{...r,ref:s,forceMount:n}):a.type==="auto"?e.jsx(uR,{...r,ref:s,forceMount:n}):a.type==="always"?e.jsx(Ob,{...r,ref:s}):null});dR.displayName=Bi;var o7=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ua(Bi,t.__scopeScrollArea),[i,o]=g.useState(!1);return g.useEffect(()=>{const d=a.scrollArea;let m=0;if(d){const f=()=>{window.clearTimeout(m),o(!0)},p=()=>{m=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return d.addEventListener("pointerenter",f),d.addEventListener("pointerleave",p),()=>{window.clearTimeout(m),d.removeEventListener("pointerenter",f),d.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(jr,{present:n||i,children:e.jsx(uR,{"data-state":i?"visible":"hidden",...r,ref:s})})}),c7=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ua(Bi,t.__scopeScrollArea),i=t.orientation==="horizontal",o=np(()=>m("SCROLL_END"),100),[d,m]=i7("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return g.useEffect(()=>{if(d==="idle"){const f=window.setTimeout(()=>m("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(f)}},[d,a.scrollHideDelay,m]),g.useEffect(()=>{const f=a.viewport,p=i?"scrollLeft":"scrollTop";if(f){let h=f[p];const x=()=>{const u=f[p];h!==u&&(m("SCROLL"),o()),h=u};return f.addEventListener("scroll",x),()=>f.removeEventListener("scroll",x)}},[a.viewport,i,m,o]),e.jsx(jr,{present:n||d!=="hidden",children:e.jsx(Ob,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:s,onPointerEnter:Yt(t.onPointerEnter,()=>m("POINTER_ENTER")),onPointerLeave:Yt(t.onPointerLeave,()=>m("POINTER_LEAVE"))})})}),uR=g.forwardRef((t,s)=>{const n=Ua(Bi,t.__scopeScrollArea),{forceMount:r,...a}=t,[i,o]=g.useState(!1),d=t.orientation==="horizontal",m=np(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;o(d?f:p)}},10);return ud(n.viewport,m),ud(n.content,m),e.jsx(jr,{present:r||i,children:e.jsx(Ob,{"data-state":i?"visible":"hidden",...a,ref:s})})}),Ob=g.forwardRef((t,s)=>{const{orientation:n="vertical",...r}=t,a=Ua(Bi,t.__scopeScrollArea),i=g.useRef(null),o=g.useRef(0),[d,m]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=xR(d.viewport,d.content),p={...r,sizes:d,onSizesChange:m,hasThumb:f>0&&f<1,onThumbChange:x=>i.current=x,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:x=>o.current=x};function h(x,u){return p7(x,o.current,d,u)}return n==="horizontal"?e.jsx(d7,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const x=a.viewport.scrollLeft,u=fS(x,d,a.dir);i.current.style.transform=`translate3d(${u}px, 0, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollLeft=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollLeft=h(x,a.dir))}}):n==="vertical"?e.jsx(u7,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const x=a.viewport.scrollTop,u=fS(x,d);i.current.style.transform=`translate3d(0, ${u}px, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollTop=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollTop=h(x))}}):null}),d7=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,i=Ua(Bi,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Ys(s,m,i.onScrollbarXChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(mR,{"data-orientation":"horizontal",...a,ref:f,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":sp(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,h)=>{if(i.viewport){const x=i.viewport.scrollLeft+p.deltaX;t.onWheelScroll(x),vR(x,h)&&p.preventDefault()}},onResize:()=>{m.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:m.current.clientWidth,paddingStart:ff(o.paddingLeft),paddingEnd:ff(o.paddingRight)}})}})}),u7=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,i=Ua(Bi,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Ys(s,m,i.onScrollbarYChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(mR,{"data-orientation":"vertical",...a,ref:f,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":sp(n)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,h)=>{if(i.viewport){const x=i.viewport.scrollTop+p.deltaY;t.onWheelScroll(x),vR(x,h)&&p.preventDefault()}},onResize:()=>{m.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:m.current.clientHeight,paddingStart:ff(o.paddingTop),paddingEnd:ff(o.paddingBottom)}})}})}),[h7,hR]=iR(Bi),mR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:d,onThumbPositionChange:m,onDragScroll:f,onWheelScroll:p,onResize:h,...x}=t,u=Ua(Bi,n),[N,v]=g.useState(null),w=Ys(s,q=>v(q)),j=g.useRef(null),b=g.useRef(""),C=u.viewport,S=r.content-r.viewport,D=xr(p),_=xr(m),A=np(h,10);function E(q){if(j.current){const O=q.clientX-j.current.left,R=q.clientY-j.current.top;f({x:O,y:R})}}return g.useEffect(()=>{const q=O=>{const R=O.target;(N==null?void 0:N.contains(R))&&D(O,S)};return document.addEventListener("wheel",q,{passive:!1}),()=>document.removeEventListener("wheel",q,{passive:!1})},[C,N,S,D]),g.useEffect(_,[r,_]),ud(N,A),ud(u.content,A),e.jsx(h7,{scope:n,scrollbar:N,hasThumb:a,onThumbChange:xr(i),onThumbPointerUp:xr(o),onThumbPositionChange:_,onThumbPointerDown:xr(d),children:e.jsx(Ss.div,{...x,ref:w,style:{position:"absolute",...x.style},onPointerDown:Yt(t.onPointerDown,q=>{q.button===0&&(q.target.setPointerCapture(q.pointerId),j.current=N.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",u.viewport&&(u.viewport.style.scrollBehavior="auto"),E(q))}),onPointerMove:Yt(t.onPointerMove,E),onPointerUp:Yt(t.onPointerUp,q=>{const O=q.target;O.hasPointerCapture(q.pointerId)&&O.releasePointerCapture(q.pointerId),document.body.style.webkitUserSelect=b.current,u.viewport&&(u.viewport.style.scrollBehavior=""),j.current=null})})})}),mf="ScrollAreaThumb",fR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=hR(mf,t.__scopeScrollArea);return e.jsx(jr,{present:n||a.hasThumb,children:e.jsx(m7,{ref:s,...r})})}),m7=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,style:r,...a}=t,i=Ua(mf,n),o=hR(mf,n),{onThumbPositionChange:d}=o,m=Ys(s,h=>o.onThumbChange(h)),f=g.useRef(void 0),p=np(()=>{f.current&&(f.current(),f.current=void 0)},100);return g.useEffect(()=>{const h=i.viewport;if(h){const x=()=>{if(p(),!f.current){const u=x7(h,d);f.current=u,d()}};return d(),h.addEventListener("scroll",x),()=>h.removeEventListener("scroll",x)}},[i.viewport,p,d]),e.jsx(Ss.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:m,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Yt(t.onPointerDownCapture,h=>{const u=h.target.getBoundingClientRect(),N=h.clientX-u.left,v=h.clientY-u.top;o.onThumbPointerDown({x:N,y:v})}),onPointerUp:Yt(t.onPointerUp,o.onThumbPointerUp)})});fR.displayName=mf;var Lb="ScrollAreaCorner",pR=g.forwardRef((t,s)=>{const n=Ua(Lb,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?e.jsx(f7,{...t,ref:s}):null});pR.displayName=Lb;var f7=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,...r}=t,a=Ua(Lb,n),[i,o]=g.useState(0),[d,m]=g.useState(0),f=!!(i&&d);return ud(a.scrollbarX,()=>{var h;const p=((h=a.scrollbarX)==null?void 0:h.offsetHeight)||0;a.onCornerHeightChange(p),m(p)}),ud(a.scrollbarY,()=>{var h;const p=((h=a.scrollbarY)==null?void 0:h.offsetWidth)||0;a.onCornerWidthChange(p),o(p)}),f?e.jsx(Ss.div,{...r,ref:s,style:{width:i,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function ff(t){return t?parseInt(t,10):0}function xR(t,s){const n=t/s;return isNaN(n)?0:n}function sp(t){const s=xR(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*s;return Math.max(r,18)}function p7(t,s,n,r="ltr"){const a=sp(n),i=a/2,o=s||i,d=a-o,m=n.scrollbar.paddingStart+o,f=n.scrollbar.size-n.scrollbar.paddingEnd-d,p=n.content-n.viewport,h=r==="ltr"?[0,p]:[p*-1,0];return gR([m,f],h)(t)}function fS(t,s,n="ltr"){const r=sp(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,i=s.scrollbar.size-a,o=s.content-s.viewport,d=i-r,m=n==="ltr"?[0,o]:[o*-1,0],f=Ny(t,m);return gR([0,o],[0,d])(f)}function gR(t,s){return n=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const r=(s[1]-s[0])/(t[1]-t[0]);return s[0]+r*(n-t[0])}}function vR(t,s){return t>0&&t<s}var x7=(t,s=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return(function a(){const i={left:t.scrollLeft,top:t.scrollTop},o=n.left!==i.left,d=n.top!==i.top;(o||d)&&s(),n=i,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function np(t,s){const n=xr(t),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,s)},[n,s])}function ud(t,s){const n=xr(s);Jn(()=>{let r=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return a.observe(t),()=>{window.cancelAnimationFrame(r),a.unobserve(t)}}},[t,n])}var g7=lR,v7=cR,y7=pR;function Ib({className:t,children:s,...n}){return e.jsxs(g7,{"data-slot":"scroll-area",className:Nt("relative",t),...n,children:[e.jsx(v7,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:s}),e.jsx(b7,{}),e.jsx(y7,{})]})}function b7({className:t,orientation:s="vertical",...n}){return e.jsx(dR,{"data-slot":"scroll-area-scrollbar",orientation:s,className:Nt("flex touch-none p-px transition-colors select-none",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent",s==="horizontal"&&"h-1 flex-col border-t border-t-transparent",t),...n,children:e.jsx(fR,{"data-slot":"scroll-area-thumb",className:Nt("relative flex-1 rounded-full",s==="vertical"&&"bg-border",s==="horizontal"&&"bg-slate-200/70")})})}function j7({onNavigate:t}){const s=[{title:"Total Applications",value:Ci.totalApplications,icon:ks,color:"bg-blue-500",trend:{value:12,isPositive:!0},filter:"all"},{title:"LOA Issued",value:Ci.loaIssued,icon:ln,color:"bg-green-500",trend:{value:8,isPositive:!0},filter:"Approved"},{title:"Level 1 Pending",value:Ci.level1Pending,icon:dn,color:"bg-red-500",trend:{value:3,isPositive:!1},filter:"Level 1 Pending"},{title:"Level 2 Pending",value:Ci.level2Pending,icon:aM,color:"bg-purple-500",trend:{value:5,isPositive:!0},filter:"Level 2 Pending"},{title:"Level 3 Pending",value:Ci.level3Pending,icon:ak,color:"bg-indigo-500",trend:{value:2,isPositive:!1},filter:"Level 3 Pending"},{title:"EOR In Progress",value:Ci.eorInProgress,icon:sn,color:"bg-cyan-500",trend:{value:1,isPositive:!0},filter:"EOR In Progress"},{title:"Disqualified",value:Ci.disqualified,icon:ai,color:"bg-red-500",trend:{value:4,isPositive:!1},filter:"Disqualified"},{title:"Pending Reminders",value:Ci.pendingReminders,icon:Gr,color:"bg-orange-500",trend:{value:7,isPositive:!1},filter:"Questionnaire Pending"},{title:"Shortlisted Today",value:Ci.shortlistedToday,icon:ln,color:"bg-teal-500",trend:{value:5,isPositive:!0},filter:"Shortlisted"},{title:"Pending Shortlisting",value:Ci.pendingShortlisting,icon:zI,color:"bg-yellow-500",trend:{value:2,isPositive:!1},filter:"all",action:"opportunity-requests"}],n=[{status:"Pending",count:45,color:"#f59e0b"},{status:"In Progress",count:68,color:"#3b82f6"},{status:"Approved",count:25,color:"#10b981"},{status:"Rejected",count:12,color:"#ef4444"}],r=[{location:"Mumbai",count:23},{location:"Delhi",count:18},{location:"Bangalore",count:21},{location:"Chennai",count:15},{location:"Kolkata",count:12},{location:"Others",count:61}],a=Math.max(...r.map(i=>i.count));return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(i=>{const o=i.icon,d=i.trend.isPositive?ll:Go;return e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>t(i.action||"applications",i.filter),children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(st,{className:"text-slate-600",children:i.title}),e.jsx("div",{className:`${i.color} p-2 rounded-lg`,children:e.jsx(o,{className:"w-5 h-5 text-white"})})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-end justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:i.value}),e.jsxs("div",{className:`flex items-center gap-1 mt-1 ${i.trend.isPositive?"text-green-600":"text-red-600"}`,children:[e.jsx(d,{className:"w-3 h-3"}),e.jsxs("span",{children:[i.trend.value,"% from last month"]})]})]})})})]},i.title)})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Application Status Distribution"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:n.map(i=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i.color}}),e.jsx("span",{className:"text-slate-700",children:i.status})]}),e.jsx("span",{className:"text-slate-900",children:i.count})]}),e.jsx("div",{className:"w-full bg-slate-200 rounded-full h-2",children:e.jsx("div",{className:"h-2 rounded-full transition-all",style:{width:`${i.count/150*100}%`,backgroundColor:i.color}})})]},i.status))})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Applications by Location"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:r.map(i=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24 text-slate-700",children:i.location}),e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-8 relative overflow-hidden",children:e.jsx("div",{className:"bg-re-red h-full rounded-full transition-all flex items-center justify-end px-3",style:{width:`${i.count/a*100}%`},children:e.jsx("span",{className:"text-white",children:i.count})})})]},i.location))})})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Recent Activity"})}),e.jsx(Oe,{children:e.jsx(Ib,{className:"h-80",children:e.jsx("div",{className:"space-y-4",children:qM.map(i=>e.jsxs("div",{className:"flex items-start gap-4 p-3 hover:bg-slate-50 rounded-lg cursor-pointer transition-colors",onClick:()=>t("applications"),children:[e.jsxs("div",{className:"w-10 h-10 bg-red-50 rounded-full flex items-center justify-center flex-shrink-0",children:[i.action==="Approved"&&e.jsx(ln,{className:"w-5 h-5 text-green-600"}),i.action==="Interview Scheduled"&&e.jsx(dn,{className:"w-5 h-5 text-blue-600"}),i.action==="Document Uploaded"&&e.jsx(ks,{className:"w-5 h-5 text-purple-600"}),i.action==="Reminder Sent"&&e.jsx(Gr,{className:"w-5 h-5 text-orange-600"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(we,{variant:"outline",children:i.applicationId}),e.jsx("span",{className:"text-slate-700",children:i.action})]}),e.jsxs("p",{className:"text-slate-500 mt-1",children:["by ",i.user]})]}),e.jsx("div",{className:"text-slate-500 flex-shrink-0",children:i.timestamp})]},i.id))})})})]})]})}var rp="Tabs",[N7]=oa(rp,[Gf]),yR=Gf(),[w7,Mb]=N7(rp),bR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:d,activationMode:m="automatic",...f}=t,p=Ku(d),[h,x]=Li({prop:r,onChange:a,defaultProp:i??"",caller:rp});return e.jsx(w7,{scope:n,baseId:yr(),value:h,onValueChange:x,orientation:o,dir:p,activationMode:m,children:e.jsx(Ss.div,{dir:p,"data-orientation":o,...f,ref:s})})});bR.displayName=rp;var jR="TabsList",NR=g.forwardRef((t,s)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,i=Mb(jR,n),o=yR(n);return e.jsx(Vk,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(Ss.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:s})})});NR.displayName=jR;var wR="TabsTrigger",SR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=t,o=Mb(wR,n),d=yR(n),m=kR(o.baseId,r),f=DR(o.baseId,r),p=r===o.value;return e.jsx(Hk,{asChild:!0,...d,focusable:!a,active:p,children:e.jsx(Ss.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:m,...i,ref:s,onMouseDown:Yt(t.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?o.onValueChange(r):h.preventDefault()}),onKeyDown:Yt(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(r)}),onFocus:Yt(t.onFocus,()=>{const h=o.activationMode!=="manual";!p&&!a&&h&&o.onValueChange(r)})})})});SR.displayName=wR;var CR="TabsContent",AR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=t,d=Mb(CR,n),m=kR(d.baseId,r),f=DR(d.baseId,r),p=r===d.value,h=g.useRef(p);return g.useEffect(()=>{const x=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(x)},[]),e.jsx(jr,{present:a||p,children:({present:x})=>e.jsx(Ss.div,{"data-state":p?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":m,hidden:!x,id:f,tabIndex:0,...o,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:x&&i})})});AR.displayName=CR;function kR(t,s){return`${t}-trigger-${s}`}function DR(t,s){return`${t}-content-${s}`}var S7=bR,C7=NR,A7=SR,k7=AR;function In({className:t,...s}){return e.jsx(S7,{"data-slot":"tabs",className:Nt("flex flex-col gap-2",t),...s})}function Mn({className:t,...s}){return e.jsx(C7,{"data-slot":"tabs-list",className:Nt("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-xl p-[3px] flex",t),...s})}function Ht({className:t,...s}){return e.jsx(A7,{"data-slot":"tabs-trigger",className:Nt("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-xl border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function Vt({className:t,...s}){return e.jsx(k7,{"data-slot":"tabs-content",className:Nt("flex-1 outline-none",t),...s})}function D7(t){const s=R7(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(_7);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function R7(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=P7(a),d=T7(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var E7=Symbol("radix.slottable");function _7(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===E7}function T7(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function P7(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var ap="Dialog",[RR,ER]=oa(ap),[O7,pi]=RR(ap),_R=t=>{const{__scopeDialog:s,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,d=g.useRef(null),m=g.useRef(null),[f,p]=Li({prop:r,defaultProp:a??!1,onChange:i,caller:ap});return e.jsx(O7,{scope:s,triggerRef:d,contentRef:m,contentId:yr(),titleId:yr(),descriptionId:yr(),open:f,onOpenChange:p,onOpenToggle:g.useCallback(()=>p(h=>!h),[p]),modal:o,children:n})};_R.displayName=ap;var TR="DialogTrigger",PR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(TR,n),i=Ys(s,a.triggerRef);return e.jsx(Ss.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$b(a.open),...r,ref:i,onClick:Yt(t.onClick,a.onOpenToggle)})});PR.displayName=TR;var Fb="DialogPortal",[L7,OR]=RR(Fb,{forceMount:void 0}),LR=t=>{const{__scopeDialog:s,forceMount:n,children:r,container:a}=t,i=pi(Fb,s);return e.jsx(L7,{scope:s,forceMount:n,children:g.Children.map(r,o=>e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:o})}))})};LR.displayName=Fb;var pf="DialogOverlay",IR=g.forwardRef((t,s)=>{const n=OR(pf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=pi(pf,t.__scopeDialog);return i.modal?e.jsx(jr,{present:r||i.open,children:e.jsx(M7,{...a,ref:s})}):null});IR.displayName=pf;var I7=D7("DialogOverlay.RemoveScroll"),M7=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(pf,n);return e.jsx(Ju,{as:I7,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Ss.div,{"data-state":$b(a.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),ac="DialogContent",MR=g.forwardRef((t,s)=>{const n=OR(ac,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,i=pi(ac,t.__scopeDialog);return e.jsx(jr,{present:r||i.open,children:i.modal?e.jsx(F7,{...a,ref:s}):e.jsx(B7,{...a,ref:s})})});MR.displayName=ac;var F7=g.forwardRef((t,s)=>{const n=pi(ac,t.__scopeDialog),r=g.useRef(null),a=Ys(s,n.contentRef,r);return g.useEffect(()=>{const i=r.current;if(i)return Kf(i)},[]),e.jsx(FR,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yt(t.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Yt(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,d=o.button===0&&o.ctrlKey===!0;(o.button===2||d)&&i.preventDefault()}),onFocusOutside:Yt(t.onFocusOutside,i=>i.preventDefault())})}),B7=g.forwardRef((t,s)=>{const n=pi(ac,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(FR,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),FR=g.forwardRef((t,s)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,d=pi(ac,n),m=g.useRef(null),f=Ys(s,m);return Bf(),e.jsxs(e.Fragment,{children:[e.jsx(Yu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:e.jsx(yd,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":$b(d.open),...o,ref:f,onDismiss:()=>d.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(q7,{titleId:d.titleId}),e.jsx(U7,{contentRef:m,descriptionId:d.descriptionId})]})]})}),Bb="DialogTitle",BR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(Bb,n);return e.jsx(Ss.h2,{id:a.titleId,...r,ref:s})});BR.displayName=Bb;var $R="DialogDescription",qR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi($R,n);return e.jsx(Ss.p,{id:a.descriptionId,...r,ref:s})});qR.displayName=$R;var zR="DialogClose",UR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=pi(zR,n);return e.jsx(Ss.button,{type:"button",...r,ref:s,onClick:Yt(t.onClick,()=>a.onOpenChange(!1))})});UR.displayName=zR;function $b(t){return t?"open":"closed"}var VR="DialogTitleWarning",[$7,HR]=dI(VR,{contentName:ac,titleName:Bb,docsSlug:"dialog"}),q7=({titleId:t})=>{const s=HR(VR),n=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users.
|
||
|
||
If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component.
|
||
|
||
For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},z7="DialogDescriptionWarning",U7=({contentRef:t,descriptionId:s})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${HR(z7).contentName}}.`;return g.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(r))},[r,t,s]),null},qb=_R,WR=PR,zb=LR,ip=IR,lp=MR,GR=BR,KR=qR,Ub=UR;function ms({...t}){return e.jsx(qb,{"data-slot":"dialog",...t})}function oo({...t}){return e.jsx(WR,{"data-slot":"dialog-trigger",...t})}function V7({...t}){return e.jsx(zb,{"data-slot":"dialog-portal",...t})}const YR=g.forwardRef(({className:t,...s},n)=>e.jsx(ip,{ref:n,"data-slot":"dialog-overlay",className:Nt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...s}));YR.displayName=ip.displayName;const us=g.forwardRef(({className:t,children:s,...n},r)=>e.jsxs(V7,{"data-slot":"dialog-portal",children:[e.jsx(YR,{}),e.jsxs(lp,{ref:r,"data-slot":"dialog-content",className:Nt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...n,children:[s,e.jsxs(Ub,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e.jsx(id,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));us.displayName=lp.displayName;function ys({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-header",className:Nt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function mn({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-footer",className:Nt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function gs({className:t,...s}){return e.jsx(GR,{"data-slot":"dialog-title",className:Nt("text-lg leading-none font-semibold",t),...s})}function ws({className:t,...s}){return e.jsx(KR,{"data-slot":"dialog-description",className:Nt("text-muted-foreground text-sm",t),...s})}function H7(t){const s=W7(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(K7);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function W7(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=Z7(a),d=Y7(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var G7=Symbol("radix.slottable");function K7(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===G7}function Y7(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function Z7(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var ZR=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Q7="VisuallyHidden",QR=g.forwardRef((t,s)=>e.jsx(Ss.span,{...t,ref:s,style:{...ZR,...t.style}}));QR.displayName=Q7;var X7=QR,J7=[" ","Enter","ArrowUp","ArrowDown"],e$=[" ","Enter"],ic="Select",[op,cp,t$]=rb(ic),[Cd]=oa(ic,[t$,lo]),dp=lo(),[s$,co]=Cd(ic),[n$,r$]=Cd(ic),XR=t=>{const{__scopeSelect:s,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:d,onValueChange:m,dir:f,name:p,autoComplete:h,disabled:x,required:u,form:N}=t,v=dp(s),[w,j]=g.useState(null),[b,C]=g.useState(null),[S,D]=g.useState(!1),_=Ku(f),[A,E]=Li({prop:r,defaultProp:a??!1,onChange:i,caller:ic}),[q,O]=Li({prop:o,defaultProp:d,onChange:m,caller:ic}),R=g.useRef(null),P=w?N||!!w.closest("form"):!0,[L,$]=g.useState(new Set),Z=Array.from(L).map(Q=>Q.props.value).join(";");return e.jsx(Vf,{...v,children:e.jsxs(s$,{required:u,scope:s,trigger:w,onTriggerChange:j,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:D,contentId:yr(),value:q,onValueChange:O,open:A,onOpenChange:E,dir:_,triggerPointerDownPosRef:R,disabled:x,children:[e.jsx(op.Provider,{scope:s,children:e.jsx(n$,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(Q=>{$(W=>new Set(W).add(Q))},[]),onNativeOptionRemove:g.useCallback(Q=>{$(W=>{const U=new Set(W);return U.delete(Q),U})},[]),children:n})}),P?e.jsxs(NE,{"aria-hidden":!0,required:u,tabIndex:-1,name:p,autoComplete:h,value:q,onChange:Q=>O(Q.target.value),disabled:x,form:N,children:[q===void 0?e.jsx("option",{value:""}):null,Array.from(L)]},Z):null]})})};XR.displayName=ic;var JR="SelectTrigger",eE=g.forwardRef((t,s)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,i=dp(n),o=co(JR,n),d=o.disabled||r,m=Ys(s,o.onTriggerChange),f=cp(n),p=g.useRef("touch"),[h,x,u]=SE(v=>{const w=f().filter(C=>!C.disabled),j=w.find(C=>C.value===o.value),b=CE(w,v,j);b!==void 0&&o.onValueChange(b.value)}),N=v=>{d||(o.onOpenChange(!0),u()),v&&(o.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return e.jsx(Qu,{asChild:!0,...i,children:e.jsx(Ss.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":wE(o.value)?"":void 0,...a,ref:m,onClick:Yt(a.onClick,v=>{v.currentTarget.focus(),p.current!=="mouse"&&N(v)}),onPointerDown:Yt(a.onPointerDown,v=>{p.current=v.pointerType;const w=v.target;w.hasPointerCapture(v.pointerId)&&w.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(N(v),v.preventDefault())}),onKeyDown:Yt(a.onKeyDown,v=>{const w=h.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&x(v.key),!(w&&v.key===" ")&&J7.includes(v.key)&&(N(),v.preventDefault())})})})});eE.displayName=JR;var tE="SelectValue",sE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...d}=t,m=co(tE,n),{onValueNodeHasChildrenChange:f}=m,p=i!==void 0,h=Ys(s,m.onValueNodeChange);return Jn(()=>{f(p)},[f,p]),e.jsx(Ss.span,{...d,ref:h,style:{pointerEvents:"none"},children:wE(m.value)?e.jsx(e.Fragment,{children:o}):i})});sE.displayName=tE;var a$="SelectIcon",nE=g.forwardRef((t,s)=>{const{__scopeSelect:n,children:r,...a}=t;return e.jsx(Ss.span,{"aria-hidden":!0,...a,ref:s,children:r||"▼"})});nE.displayName=a$;var i$="SelectPortal",rE=t=>e.jsx(Nd,{asChild:!0,...t});rE.displayName=i$;var lc="SelectContent",aE=g.forwardRef((t,s)=>{const n=co(lc,t.__scopeSelect),[r,a]=g.useState();if(Jn(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?zu.createPortal(e.jsx(iE,{scope:t.__scopeSelect,children:e.jsx(op.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),i):null}return e.jsx(lE,{...t,ref:s})});aE.displayName=lc;var si=10,[iE,uo]=Cd(lc),l$="SelectContentImpl",o$=H7("SelectContent.RemoveScroll"),lE=g.forwardRef((t,s)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:d,sideOffset:m,align:f,alignOffset:p,arrowPadding:h,collisionBoundary:x,collisionPadding:u,sticky:N,hideWhenDetached:v,avoidCollisions:w,...j}=t,b=co(lc,n),[C,S]=g.useState(null),[D,_]=g.useState(null),A=Ys(s,Y=>S(Y)),[E,q]=g.useState(null),[O,R]=g.useState(null),P=cp(n),[L,$]=g.useState(!1),Z=g.useRef(!1);g.useEffect(()=>{if(C)return Kf(C)},[C]),Bf();const Q=g.useCallback(Y=>{const[re,...ae]=P().map(ce=>ce.ref.current),[ue]=ae.slice(-1),ye=document.activeElement;for(const ce of Y)if(ce===ye||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===re&&D&&(D.scrollTop=0),ce===ue&&D&&(D.scrollTop=D.scrollHeight),ce==null||ce.focus(),document.activeElement!==ye))return},[P,D]),W=g.useCallback(()=>Q([E,C]),[Q,E,C]);g.useEffect(()=>{L&&W()},[L,W]);const{onOpenChange:U,triggerPointerDownPosRef:M}=b;g.useEffect(()=>{if(C){let Y={x:0,y:0};const re=ue=>{var ye,ce;Y={x:Math.abs(Math.round(ue.pageX)-(((ye=M.current)==null?void 0:ye.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((ce=M.current)==null?void 0:ce.y)??0))}},ae=ue=>{Y.x<=10&&Y.y<=10?ue.preventDefault():C.contains(ue.target)||U(!1),document.removeEventListener("pointermove",re),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",ae,{capture:!0})}}},[C,U,M]),g.useEffect(()=>{const Y=()=>U(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[U]);const[z,T]=SE(Y=>{const re=P().filter(ye=>!ye.disabled),ae=re.find(ye=>ye.ref.current===document.activeElement),ue=CE(re,Y,ae);ue&&setTimeout(()=>ue.ref.current.focus())}),F=g.useCallback((Y,re,ae)=>{const ue=!Z.current&&!ae;(b.value!==void 0&&b.value===re||ue)&&(q(Y),ue&&(Z.current=!0))},[b.value]),I=g.useCallback(()=>C==null?void 0:C.focus(),[C]),K=g.useCallback((Y,re,ae)=>{const ue=!Z.current&&!ae;(b.value!==void 0&&b.value===re||ue)&&R(Y)},[b.value]),G=r==="popper"?wy:oE,V=G===wy?{side:d,sideOffset:m,align:f,alignOffset:p,arrowPadding:h,collisionBoundary:x,collisionPadding:u,sticky:N,hideWhenDetached:v,avoidCollisions:w}:{};return e.jsx(iE,{scope:n,content:C,viewport:D,onViewportChange:_,itemRefCallback:F,selectedItem:E,onItemLeave:I,itemTextRefCallback:K,focusSelectedItem:W,selectedItemText:O,position:r,isPositioned:L,searchRef:z,children:e.jsx(Ju,{as:o$,allowPinchZoom:!0,children:e.jsx(Yu,{asChild:!0,trapped:b.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:Yt(a,Y=>{var re;(re=b.trigger)==null||re.focus({preventScroll:!0}),Y.preventDefault()}),children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:e.jsx(G,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:Y=>Y.preventDefault(),...j,...V,onPlaced:()=>$(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Yt(j.onKeyDown,Y=>{const re=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!re&&Y.key.length===1&&T(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let ue=P().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const ye=Y.target,ce=ue.indexOf(ye);ue=ue.slice(ce+1)}setTimeout(()=>Q(ue)),Y.preventDefault()}})})})})})})});lE.displayName=l$;var c$="SelectItemAlignedPosition",oE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,i=co(lc,n),o=uo(lc,n),[d,m]=g.useState(null),[f,p]=g.useState(null),h=Ys(s,A=>p(A)),x=cp(n),u=g.useRef(!1),N=g.useRef(!0),{viewport:v,selectedItem:w,selectedItemText:j,focusSelectedItem:b}=o,C=g.useCallback(()=>{if(i.trigger&&i.valueNode&&d&&f&&v&&w&&j){const A=i.trigger.getBoundingClientRect(),E=f.getBoundingClientRect(),q=i.valueNode.getBoundingClientRect(),O=j.getBoundingClientRect();if(i.dir!=="rtl"){const ye=O.left-E.left,ce=q.left-ye,je=A.left-ce,Me=A.width+je,ut=Math.max(Me,E.width),jt=window.innerWidth-si,ft=Ny(ce,[si,Math.max(si,jt-ut)]);d.style.minWidth=Me+"px",d.style.left=ft+"px"}else{const ye=E.right-O.right,ce=window.innerWidth-q.right-ye,je=window.innerWidth-A.right-ce,Me=A.width+je,ut=Math.max(Me,E.width),jt=window.innerWidth-si,ft=Ny(ce,[si,Math.max(si,jt-ut)]);d.style.minWidth=Me+"px",d.style.right=ft+"px"}const R=x(),P=window.innerHeight-si*2,L=v.scrollHeight,$=window.getComputedStyle(f),Z=parseInt($.borderTopWidth,10),Q=parseInt($.paddingTop,10),W=parseInt($.borderBottomWidth,10),U=parseInt($.paddingBottom,10),M=Z+Q+L+U+W,z=Math.min(w.offsetHeight*5,M),T=window.getComputedStyle(v),F=parseInt(T.paddingTop,10),I=parseInt(T.paddingBottom,10),K=A.top+A.height/2-si,G=P-K,V=w.offsetHeight/2,Y=w.offsetTop+V,re=Z+Q+Y,ae=M-re;if(re<=K){const ye=R.length>0&&w===R[R.length-1].ref.current;d.style.bottom="0px";const ce=f.clientHeight-v.offsetTop-v.offsetHeight,je=Math.max(G,V+(ye?I:0)+ce+W),Me=re+je;d.style.height=Me+"px"}else{const ye=R.length>0&&w===R[0].ref.current;d.style.top="0px";const je=Math.max(K,Z+v.offsetTop+(ye?F:0)+V)+ae;d.style.height=je+"px",v.scrollTop=re-K+v.offsetTop}d.style.margin=`${si}px 0`,d.style.minHeight=z+"px",d.style.maxHeight=P+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[x,i.trigger,i.valueNode,d,f,v,w,j,i.dir,r]);Jn(()=>C(),[C]);const[S,D]=g.useState();Jn(()=>{f&&D(window.getComputedStyle(f).zIndex)},[f]);const _=g.useCallback(A=>{A&&N.current===!0&&(C(),b==null||b(),N.current=!1)},[C,b]);return e.jsx(u$,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:u,onScrollButtonChange:_,children:e.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:e.jsx(Ss.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});oE.displayName=c$;var d$="SelectPopperPosition",wy=g.forwardRef((t,s)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=si,...i}=t,o=dp(n);return e.jsx(Hf,{...o,...i,ref:s,align:r,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});wy.displayName=d$;var[u$,Vb]=Cd(lc,{}),Sy="SelectViewport",cE=g.forwardRef((t,s)=>{const{__scopeSelect:n,nonce:r,...a}=t,i=uo(Sy,n),o=Vb(Sy,n),d=Ys(s,i.onViewportChange),m=g.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),e.jsx(op.Slot,{scope:n,children:e.jsx(Ss.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Yt(a.onScroll,f=>{const p=f.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:x}=o;if(x!=null&&x.current&&h){const u=Math.abs(m.current-p.scrollTop);if(u>0){const N=window.innerHeight-si*2,v=parseFloat(h.style.minHeight),w=parseFloat(h.style.height),j=Math.max(v,w);if(j<N){const b=j+u,C=Math.min(N,b),S=b-C;h.style.height=C+"px",h.style.bottom==="0px"&&(p.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}m.current=p.scrollTop})})})]})});cE.displayName=Sy;var dE="SelectGroup",[h$,m$]=Cd(dE),uE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=yr();return e.jsx(h$,{scope:n,id:a,children:e.jsx(Ss.div,{role:"group","aria-labelledby":a,...r,ref:s})})});uE.displayName=dE;var hE="SelectLabel",mE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=m$(hE,n);return e.jsx(Ss.div,{id:a.id,...r,ref:s})});mE.displayName=hE;var xf="SelectItem",[f$,fE]=Cd(xf),pE=g.forwardRef((t,s)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=t,d=co(xf,n),m=uo(xf,n),f=d.value===r,[p,h]=g.useState(i??""),[x,u]=g.useState(!1),N=Ys(s,b=>{var C;return(C=m.itemRefCallback)==null?void 0:C.call(m,b,r,a)}),v=yr(),w=g.useRef("touch"),j=()=>{a||(d.onValueChange(r),d.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(f$,{scope:n,value:r,disabled:a,textId:v,isSelected:f,onItemTextChange:g.useCallback(b=>{h(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:e.jsx(op.ItemSlot,{scope:n,value:r,disabled:a,textValue:p,children:e.jsx(Ss.div,{role:"option","aria-labelledby":v,"data-highlighted":x?"":void 0,"aria-selected":f&&x,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:N,onFocus:Yt(o.onFocus,()=>u(!0)),onBlur:Yt(o.onBlur,()=>u(!1)),onClick:Yt(o.onClick,()=>{w.current!=="mouse"&&j()}),onPointerUp:Yt(o.onPointerUp,()=>{w.current==="mouse"&&j()}),onPointerDown:Yt(o.onPointerDown,b=>{w.current=b.pointerType}),onPointerMove:Yt(o.onPointerMove,b=>{var C;w.current=b.pointerType,a?(C=m.onItemLeave)==null||C.call(m):w.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Yt(o.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=m.onItemLeave)==null||C.call(m))}),onKeyDown:Yt(o.onKeyDown,b=>{var S;((S=m.searchRef)==null?void 0:S.current)!==""&&b.key===" "||(e$.includes(b.key)&&j(),b.key===" "&&b.preventDefault())})})})})});pE.displayName=xf;var pu="SelectItemText",xE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,...i}=t,o=co(pu,n),d=uo(pu,n),m=fE(pu,n),f=r$(pu,n),[p,h]=g.useState(null),x=Ys(s,j=>h(j),m.onItemTextChange,j=>{var b;return(b=d.itemTextRefCallback)==null?void 0:b.call(d,j,m.value,m.disabled)}),u=p==null?void 0:p.textContent,N=g.useMemo(()=>e.jsx("option",{value:m.value,disabled:m.disabled,children:u},m.value),[m.disabled,m.value,u]),{onNativeOptionAdd:v,onNativeOptionRemove:w}=f;return Jn(()=>(v(N),()=>w(N)),[v,w,N]),e.jsxs(e.Fragment,{children:[e.jsx(Ss.span,{id:m.textId,...i,ref:x}),m.isSelected&&o.valueNode&&!o.valueNodeHasChildren?zu.createPortal(i.children,o.valueNode):null]})});xE.displayName=pu;var gE="SelectItemIndicator",vE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return fE(gE,n).isSelected?e.jsx(Ss.span,{"aria-hidden":!0,...r,ref:s}):null});vE.displayName=gE;var Cy="SelectScrollUpButton",yE=g.forwardRef((t,s)=>{const n=uo(Cy,t.__scopeSelect),r=Vb(Cy,t.__scopeSelect),[a,i]=g.useState(!1),o=Ys(s,r.onScrollButtonChange);return Jn(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollTop>0;i(f)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(jE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop-m.offsetHeight)}}):null});yE.displayName=Cy;var Ay="SelectScrollDownButton",bE=g.forwardRef((t,s)=>{const n=uo(Ay,t.__scopeSelect),r=Vb(Ay,t.__scopeSelect),[a,i]=g.useState(!1),o=Ys(s,r.onScrollButtonChange);return Jn(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollHeight-m.clientHeight,p=Math.ceil(m.scrollTop)<f;i(p)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(jE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop+m.offsetHeight)}}):null});bE.displayName=Ay;var jE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,i=uo("SelectScrollButton",n),o=g.useRef(null),d=cp(n),m=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>m(),[m]),Jn(()=>{var p;const f=d().find(h=>h.ref.current===document.activeElement);(p=f==null?void 0:f.ref.current)==null||p.scrollIntoView({block:"nearest"})},[d]),e.jsx(Ss.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Yt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Yt(a.onPointerMove,()=>{var f;(f=i.onItemLeave)==null||f.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Yt(a.onPointerLeave,()=>{m()})})}),p$="SelectSeparator",x$=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return e.jsx(Ss.div,{"aria-hidden":!0,...r,ref:s})});x$.displayName=p$;var ky="SelectArrow",g$=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=dp(n),i=co(ky,n),o=uo(ky,n);return i.open&&o.position==="popper"?e.jsx(Wf,{...a,...r,ref:s}):null});g$.displayName=ky;var v$="SelectBubbleInput",NE=g.forwardRef(({__scopeSelect:t,value:s,...n},r)=>{const a=g.useRef(null),i=Ys(r,a),o=Zy(s);return g.useEffect(()=>{const d=a.current;if(!d)return;const m=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(m,"value").set;if(o!==s&&p){const h=new Event("change",{bubbles:!0});p.call(d,s),d.dispatchEvent(h)}},[o,s]),e.jsx(Ss.select,{...n,style:{...ZR,...n.style},ref:i,defaultValue:s})});NE.displayName=v$;function wE(t){return t===""||t===void 0}function SE(t){const s=xr(t),n=g.useRef(""),r=g.useRef(0),a=g.useCallback(o=>{const d=n.current+o;s(d),(function m(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>m(""),1e3))})(d)},[s]),i=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function CE(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=y$(t,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const m=o.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return m!==n?m:void 0}function y$(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var b$=XR,j$=eE,N$=sE,w$=nE,S$=rE,C$=aE,A$=cE,k$=uE,D$=mE,AE=pE,kE=xE,DE=vE,R$=yE,E$=bE;function Rt({...t}){return e.jsx(b$,{"data-slot":"select",...t})}function pS({...t}){return e.jsx(k$,{"data-slot":"select-group",...t})}function Et({...t}){return e.jsx(N$,{"data-slot":"select-value",...t})}function _t({className:t,size:s="default",children:n,...r}){return e.jsxs(j$,{"data-slot":"select-trigger","data-size":s,className:Nt("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-input-background px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,e.jsx(w$,{asChild:!0,children:e.jsx(va,{className:"size-4 opacity-50"})})]})}function Tt({className:t,children:s,position:n="popper",...r}){return e.jsx(S$,{children:e.jsxs(C$,{"data-slot":"select-content",className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...r,children:[e.jsx(T$,{}),e.jsx(A$,{className:Nt("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:s}),e.jsx(P$,{})]})})}function _$({className:t,...s}){return e.jsx(D$,{"data-slot":"select-label",className:Nt("text-muted-foreground px-2 py-1.5 text-xs",t),...s})}function Pe({className:t,children:s,...n}){return e.jsxs(AE,{"data-slot":"select-item",className:Nt("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(DE,{children:e.jsx($n,{className:"size-4"})})}),e.jsx(kE,{children:s})]})}function T$({className:t,...s}){return e.jsx(R$,{"data-slot":"select-scroll-up-button",className:Nt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(yu,{className:"size-4"})})}function P$({className:t,...s}){return e.jsx(E$,{"data-slot":"select-scroll-down-button",className:Nt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(va,{className:"size-4"})})}function Ms({className:t,...s}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto custom-scrollbar-x-slim",children:e.jsx("table",{"data-slot":"table",className:Nt("w-full caption-bottom text-sm",t),...s})})}function Fs({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:Nt("[&_tr]:border-b",t),...s})}function Bs({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:Nt("[&_tr:last-child]:border-0",t),...s})}function lt({className:t,...s}){return e.jsx("tr",{"data-slot":"table-row",className:Nt("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...s})}function me({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:Nt("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function oe({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:Nt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}const RE={getOnboardingPayments:async()=>{var s,n;const t=await Re.getOnboardingPayments();if(!t.ok)throw new Error(((s=t.data)==null?void 0:s.message)||"Failed to fetch onboarding payments");return((n=t.data)==null?void 0:n.payments)||[]},getFnFSettlements:async()=>{var s,n;const t=await Re.getFnFSettlements();if(!t.ok)throw new Error(((s=t.data)==null?void 0:s.message)||"Failed to fetch F&F settlements");return((n=t.data)==null?void 0:n.settlements)||[]},getFnFSettlementById:async t=>{var n,r;const s=await Re.getFnFSettlementById(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to fetch F&F details");return(r=s.data)==null?void 0:r.fnf},updatePayment:async(t,s)=>{var r;const n=await Re.updatePayment(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update payment");return n.data},calculateFnF:async t=>{var n;const s=await Re.calculateFnF(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to calculate F&F");return s.data},addLineItem:async(t,s)=>{var r;const n=await Re.addLineItem(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to add line item");return n.data},updateFnF:async(t,s)=>{var r;const n=await Re.updateFnF(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to update F&F settlement");return n.data}};function O$({onNavigate:t,onViewPaymentDetails:s,onViewAuditDetails:n,onViewFnFDetails:r}){var T,F,I,K;const[a,i]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[p,h]=g.useState(!0);g.useEffect(()=>{x()},[]);const x=async()=>{try{h(!0);const[G,V]=await Promise.all([RE.getFnFSettlements(),ps.getApplications()]),Y=V.data||[],re=[];Y.forEach(ue=>{const ye=ue.overallStatus||ue.status,ce=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(ye),je=ue.securityDeposits||[];je.length>0?je.forEach(Me=>{re.push({...Me,application:ue,paymentStatus:Me.status,paymentType:Me.depositType,amount:Me.amount,id:Me.id,applicationId:ue.applicationId||ue.id,createdAt:Me.createdAt,verificationDate:Me.verifiedAt})}):ce&&(["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(ye)?re.push({id:`virtual-${ue.id}-sd`,applicationId:ue.applicationId||ue.id,application:ue,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:ue.updatedAt,isVirtual:!0}):["LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(ye)&&re.push({id:`virtual-${ue.id}-ff`,applicationId:ue.applicationId||ue.id,application:ue,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:ue.updatedAt,isVirtual:!0}))}),i(re),d(G);const ae=Y.filter(ue=>ue.status==="FDD_VERIFICATION"||ue.overallStatus==="FDD Verification"||ue.currentStage==="FDD");f(ae)}catch(G){console.error("Fetch error:",G),J.error("Failed to load dashboard data")}finally{h(!1)}},[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(null),[C,S]=g.useState([]),[D,_]=g.useState({department:"",description:"",type:"receivable",amount:""}),[A,E]=g.useState(""),q=()=>{const G=C.filter(re=>re.type==="receivable").reduce((re,ae)=>re+ae.amount,0),V=C.filter(re=>re.type==="payable").reduce((re,ae)=>re+ae.amount,0),Y=V-G;return{totalReceivable:G,totalPayable:V,netAmount:Y}},O=async()=>{if(C.length===0){J.error("Please add at least one line item");return}if(!A){J.error("Please add final remarks");return}try{h(!0),J.success("Finance summary submitted successfully"),N(!1),b(null),S([]),E(""),x()}catch{J.error("Failed to submit summary")}finally{h(!1)}},R=G=>{const V=String(G||"").trim().toLowerCase();return V==="paid"||V==="verified"},P=a.filter(G=>!R(G.paymentStatus)),L=a.filter(G=>R(G.paymentStatus)),$=o.filter(G=>G.status==="Initiated"||G.status==="Calculated"),Z=o.filter(G=>G.status==="Completed"||G.status==="Cleared"),Q=()=>{if(!D.department||!D.description||!D.amount){J.error("Please fill in all line item fields");return}const G={id:Date.now().toString(),department:D.department,description:D.description,type:D.type,amount:parseFloat(D.amount)};S([...C,G]),_({department:"",description:"",type:"receivable",amount:""}),J.success("Line item added")},W=G=>{S(C.filter(V=>V.id!==G)),J.info("Line item removed")},{totalReceivable:U,totalPayable:M,netAmount:z}=q();return p?e.jsxs("div",{className:"flex items-center justify-center p-20 text-re-red",children:[e.jsx(dn,{className:"w-8 h-8 animate-spin mr-3"}),e.jsx("span",{children:"Loading Finance Data..."})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl mb-2",children:"Finance Dashboard"}),e.jsx("p",{className:"text-slate-600",children:"Verify payments and create financial settlement summaries"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-3",children:[e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-red-200 bg-red-50/20",onClick:()=>{m.length>0&&n?n(m[0].applicationId||m[0].id):t==null||t("finance-onboarding")},children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{className:"text-re-red font-bold",children:"Pending Audits"}),e.jsx(st,{className:"text-3xl text-re-red",children:m.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600 text-xs font-medium",children:"FDD Sign-offs"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2 text-xs",children:"Review Now →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-yellow-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Pending Verification"}),e.jsx(st,{className:"text-3xl text-yellow-600",children:P.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Onboarding Payments"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Verified"}),e.jsx(st,{className:"text-3xl text-green-600",children:L.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Total Validated"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-orange-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Pending F&F Summary"}),e.jsx(st,{className:"text-3xl text-orange-600",children:$.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Offboarding Cases"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"F&F Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:Z.length})]}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-slate-600",children:"Settlements Done"}),e.jsx(te,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]})]}),e.jsxs(In,{defaultValue:"onboarding",className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ht,{value:"onboarding",children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),"Onboarding"]}),e.jsxs(Ht,{value:"fnf",children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"F&F Settlement"]})]}),e.jsx(Vt,{value:"onboarding",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Payment Verification"}),e.jsx(es,{children:"Verify dealer advance payments for onboarding applications"})]}),e.jsx(Oe,{children:e.jsxs(In,{defaultValue:"pending",className:"w-full",children:[e.jsxs(Mn,{children:[e.jsxs(Ht,{value:"pending",children:["Pending (",P.length,")"]}),e.jsxs(Ht,{value:"verified",children:["Verified (",L.length,")"]})]}),e.jsx(Vt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[P.map(G=>{var V,Y;return e.jsx(_e,{className:"border-yellow-200 bg-yellow-50/30",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:((V=G.application)==null?void 0:V.applicationId)||"N/A"}),e.jsx(we,{className:"bg-yellow-100 text-yellow-700 border-yellow-300",children:G.paymentStatus})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Applicant Name"}),e.jsx("p",{className:"font-medium",children:(Y=G.application)==null?void 0:Y.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:G.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":G.paymentType==="FIRST_FILL"?"First Fill":G.paymentType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Amount"}),e.jsxs("p",{className:"text-re-red-hover font-bold",children:["₹",parseFloat(G.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Created On"}),e.jsx("p",{children:Qt(G.createdAt)})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{s&&s(G.applicationId||G.id)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(te,{size:"sm",className:"bg-green-600 hover:bg-green-700 font-bold",onClick:()=>{s&&s(G.applicationId||G.id)},children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Verify Payment"]})]})]})})},G.id)}),P.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ln,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No pending payment verifications"})]})]})}),e.jsx(Vt,{value:"verified",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:L.map(G=>{var V,Y;return e.jsx(_e,{className:"border-green-200 bg-green-50/30",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:((V=G.application)==null?void 0:V.applicationId)||"N/A"}),e.jsx(we,{className:"bg-green-100 text-green-700 border-green-300",children:G.paymentStatus})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Applicant Name"}),e.jsx("p",{className:"font-medium",children:(Y=G.application)==null?void 0:Y.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:G.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":G.paymentType==="FIRST_FILL"?"First Fill":G.paymentType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Amount"}),e.jsxs("p",{className:"text-green-700 font-bold",children:["₹",parseFloat(G.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Verified On"}),e.jsx("p",{children:G.verificationDate?Qt(G.verificationDate):"N/A"})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{s&&s(G.applicationId||G.id)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},G.id)})})})]})})]})}),e.jsx(Vt,{value:"fnf",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"F&F Financial Summary"}),e.jsx(es,{children:"Create financial settlement summaries for resignation and termination cases"})]}),e.jsx(Oe,{children:e.jsxs(In,{defaultValue:"pending",className:"w-full",children:[e.jsxs(Mn,{children:[e.jsxs(Ht,{value:"pending",children:["Pending Summary (",$.length,")"]}),e.jsxs(Ht,{value:"completed",children:["Completed (",Z.length,")"]})]}),e.jsx(Vt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[$.map(G=>{var V,Y,re,ae,ue,ye,ce;return e.jsx(_e,{className:"border-orange-200 bg-orange-50/30",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:((V=G.resignation)==null?void 0:V.resignationId)||G.id}),e.jsx(we,{variant:"outline",children:G.resignation?"Resignation":G.terminationRequest?"Termination":"General"}),e.jsx(we,{className:"bg-orange-100 text-orange-700 border-orange-300",children:G.status})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm mb-3",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm mb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Dealer Name"}),e.jsx("p",{className:"font-semibold text-slate-900",children:((re=(Y=G.outlet)==null?void 0:Y.dealer)==null?void 0:re.fullName)||((ae=G.outlet)==null?void 0:ae.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Dealer Code"}),e.jsx("p",{className:"font-mono text-xs font-bold text-blue-600",children:((ue=G.outlet)==null?void 0:ue.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 font-medium text-[10px] uppercase tracking-wider mb-1",children:"Location"}),e.jsxs("p",{className:"text-slate-900",children:[((ye=G.outlet)==null?void 0:ye.city)||"N/A",", ",((ce=G.outlet)==null?void 0:ce.state)||""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-white/50 p-2 rounded-lg border border-slate-100",children:[e.jsx(ln,{className:"w-4 h-4 text-emerald-500"}),e.jsxs("span",{className:"text-slate-600 font-medium",children:[e.jsx("span",{className:"text-emerald-600 font-bold",children:(G.clearances||[]).filter(je=>je.status==="NOC Submitted"||je.status==="Dues Pending").length}),"/16 Departments Cleared"]})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{b(G),w(!0)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(te,{size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:()=>{b(G),S([]),E(""),N(!0)},children:[e.jsx(rk,{className:"w-4 h-4 mr-2"}),"Create Summary"]})]})]})})},G.id)}),$.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ks,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No F&F cases pending financial summary"})]})]})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:Z.map(G=>e.jsx(_e,{className:"border-green-200 bg-green-50/30",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold",children:G.id}),e.jsx(we,{variant:"outline",children:G.type}),e.jsx(we,{className:"bg-green-100 text-green-700 border-green-300",children:G.status})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{className:"font-medium",children:G.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:G.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Net Settlement"}),e.jsxs("p",{className:G.netAmount&&G.netAmount>=0?"text-green-700":"text-red-700",children:["₹",G.netAmount?Math.abs(G.netAmount).toLocaleString("en-IN"):"0"]}),e.jsx("p",{className:"text-xs text-slate-500",children:G.netAmount&&G.netAmount>=0?"Payable to Dealer":"Receivable from Dealer"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Completed On"}),e.jsx("p",{children:G.completedOn})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>{r&&r(G.id)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},G.id))})})]})})]})})]}),e.jsx(ms,{open:u,onOpenChange:N,children:e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Create Financial Settlement Summary"}),e.jsxs(ws,{children:[((T=j==null?void 0:j.resignation)==null?void 0:T.resignationId)||(j==null?void 0:j.id)," - ",j==null?void 0:j.dealerName," (",j==null?void 0:j.dealerCode,")"]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border rounded-lg p-4 bg-slate-50",children:[e.jsx("h3",{className:"text-sm font-bold mb-4",children:"Add Financial Line Item"}),e.jsxs("div",{className:"grid grid-cols-12 gap-3",children:[e.jsxs("div",{className:"col-span-3",children:[e.jsx(le,{className:"text-xs",children:"Department"}),e.jsx(it,{placeholder:"e.g., Warranty",value:D.department,onChange:G=>_({...D,department:G.target.value})})]}),e.jsxs("div",{className:"col-span-4",children:[e.jsx(le,{className:"text-xs",children:"Description"}),e.jsx(it,{placeholder:"e.g., Pending warranty claims",value:D.description,onChange:G=>_({...D,description:G.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-xs",children:"Type"}),e.jsxs(Rt,{value:D.type,onValueChange:G=>_({...D,type:G}),children:[e.jsx(_t,{children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"receivable",children:"Receivable"}),e.jsx(Pe,{value:"payable",children:"Payable"})]})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-xs",children:"Amount (₹)"}),e.jsx(it,{type:"number",placeholder:"0",value:D.amount,onChange:G=>_({...D,amount:G.target.value})})]}),e.jsx("div",{className:"col-span-1 flex items-end",children:e.jsx(te,{size:"sm",onClick:Q,className:"w-full bg-re-red hover:bg-re-red-hover",children:e.jsx(bn,{className:"w-4 h-4"})})})]})]}),C.length>0&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-center",children:"Type"}),e.jsx(me,{className:"text-right",children:"Amount"}),e.jsx(me,{className:"w-16"})]})}),e.jsx(Bs,{children:C.map(G=>e.jsxs(lt,{children:[e.jsx(oe,{children:G.department}),e.jsx(oe,{children:G.description}),e.jsx(oe,{className:"text-center",children:e.jsx(we,{className:G.type==="receivable"?"bg-red-100 text-red-700 border-red-200":"bg-green-100 text-green-700 border-green-200",children:G.type==="receivable"?"Receivable":"Payable"})}),e.jsxs(oe,{className:`text-right font-medium ${G.type==="receivable"?"text-red-700":"text-green-700"}`,children:["₹",G.amount.toLocaleString("en-IN")]}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"ghost",onClick:()=>W(G.id),children:e.jsx(Zn,{className:"w-4 h-4 text-red-600"})})})]},G.id))})]})}),C.length>0&&e.jsxs("div",{className:"border rounded-lg p-4 bg-slate-900 text-white",children:[e.jsx("h3",{className:"text-sm font-bold mb-4",children:"Financial Settlement Summary"}),e.jsxs("div",{className:"grid grid-cols-3 gap-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Total Payable"}),e.jsxs("p",{className:"text-3xl font-bold text-green-400",children:["₹",M.toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Total receivable"}),e.jsxs("p",{className:"text-3xl font-bold text-red-400",children:["₹",U.toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider mb-1",children:"Net Settlement"}),e.jsxs("p",{className:`text-3xl font-bold ${z>=0?"text-green-400":"text-red-400"}`,children:["₹",Math.abs(z).toLocaleString("en-IN")]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1 italic",children:z>=0?"Payable to Dealer":"Receivable from Dealer"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"font-bold",children:["Summary Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{placeholder:"Add your final reconciliation remarks here...",rows:4,value:A,onChange:G=>E(G.target.value)})]})]}),e.jsxs(mn,{className:"border-t pt-4",children:[e.jsx(te,{variant:"outline",onClick:()=>N(!1),children:"Discard"}),e.jsxs(te,{className:"bg-green-600 hover:bg-green-700",onClick:O,disabled:C.length===0,children:[e.jsx(dl,{className:"w-4 h-4 mr-2"}),"Finalize & Submit Summary"]})]})]})}),e.jsx(ms,{open:v,onOpenChange:w,children:e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Full Settlement Details"}),e.jsxs(ws,{children:[((F=j==null?void 0:j.resignation)==null?void 0:F.resignationId)||(j==null?void 0:j.id)," - ",j==null?void 0:j.dealerName]})]}),j&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(_e,{className:"bg-slate-50 border-none",children:e.jsxs(Oe,{className:"pt-6 grid grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider mb-1",children:"Dealer Code"}),e.jsx("p",{className:"text-lg font-bold",children:((I=j.outlet)==null?void 0:I.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider mb-1",children:"Location"}),e.jsx("p",{className:"text-lg font-bold",children:((K=j.outlet)==null?void 0:K.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wider mb-1",children:"Current Status"}),e.jsx(we,{variant:"outline",className:"bg-red-50 text-re-red-hover border-red-200",children:j.status})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(_e,{className:"border-blue-100",children:[e.jsx(Xe,{className:"bg-blue-50/50 pb-2",children:e.jsxs(st,{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(ll,{className:"w-4 h-4 text-blue-600"}),"Receivables Check"]})}),e.jsxs(Oe,{className:"pt-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Security Deposit Credits"}),e.jsxs("span",{className:"font-bold text-slate-900",children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Other Payable Credits"}),e.jsx("span",{className:"font-bold text-slate-900",children:"₹0"})]}),e.jsxs("div",{className:"border-t pt-2 flex justify-between font-bold text-blue-700",children:[e.jsx("span",{children:"Total Payables"}),e.jsxs("span",{children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]})]})]}),e.jsxs(_e,{className:"border-red-100 shadow-sm",children:[e.jsx(Xe,{className:"bg-red-50/30 pb-2 border-b border-red-50",children:e.jsxs(st,{className:"text-sm font-bold flex items-center gap-2 text-red-700",children:[e.jsx(Go,{className:"w-4 h-4"}),"Receivables Check"]})}),e.jsxs(Oe,{className:"pt-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Departmental Dues (Recoverable)"}),e.jsxs("span",{className:"font-bold text-red-600",children:["₹",parseFloat(j.totalReceivables||0).toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"Outstanding Invoices"}),e.jsx("span",{className:"font-bold text-slate-900",children:"₹0"})]}),e.jsxs("div",{className:"border-t pt-2 flex justify-between font-bold text-red-700",children:[e.jsx("span",{children:"Total Recoveries"}),e.jsxs("span",{children:["₹",parseFloat(j.totalReceivables||0).toLocaleString("en-IN")]})]})]})]})]}),e.jsxs("div",{className:"p-5 bg-slate-900 text-white rounded-xl flex items-center justify-between shadow-lg",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-3 rounded-lg ${parseFloat(j.netAmount||0)>=0?"bg-emerald-500/20":"bg-rose-500/20"}`,children:e.jsx(ya,{className:`w-6 h-6 ${parseFloat(j.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-400 uppercase font-bold tracking-widest mb-1",children:"Final Net Financial Position"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("p",{className:`text-3xl font-bold tracking-tight ${parseFloat(j.netAmount||0)>=0?"text-emerald-400":"text-rose-400"}`,children:["₹",Math.abs(parseFloat(j.netAmount||0)).toLocaleString("en-IN")]}),e.jsxs("span",{className:"text-xs font-medium text-slate-400",children:["(",parseFloat(j.netAmount||0)>=0?"Payable to Dealer":"Recoverable from Dealer",")"]})]})]})]}),e.jsx(te,{className:"bg-blue-600 hover:bg-blue-500 px-6 font-bold shadow-md transition-all active:scale-95",children:"Generate PDF Summary"})]})]}),e.jsx(mn,{children:e.jsx(te,{onClick:()=>w(!1),children:"Close Overview"})})]})})]})}const Xl={getDashboardData:async()=>{var t;try{const s=await Re.getDealerDashboard();return((t=s.data)==null?void 0:t.data)||s.data}catch(s){throw console.error("Get dealer dashboard error:",s),s}},getConstitutionalChanges:async()=>{try{return(await Re.getConstitutionalChanges()).data}catch(t){throw console.error("Get constitutional changes error:",t),t}},submitConstitutionalChange:async t=>{try{return(await Re.createConstitutionalChange(t)).data}catch(s){throw console.error("Submit constitutional change error:",s),s}},getRelocationRequests:async()=>{try{return(await Re.getRelocationRequests()).data}catch(t){throw console.error("Get relocation requests error:",t),t}},submitRelocationRequest:async t=>{try{return(await Re.createRelocationRequest(t)).data}catch(s){throw console.error("Submit relocation request error:",s),s}}};function L$({currentUser:t,onNavigate:s}){var u,N;const[n,r]=g.useState(!0),[a,i]=g.useState(null);if(g.useEffect(()=>{(async()=>{try{const w=await Xl.getDashboardData();i(w)}catch(w){console.error("Failed to fetch dashboard:",w)}finally{r(!1)}})()},[]),n)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px]",children:[e.jsx(cs,{className:"w-10 h-10 text-re-red animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600",children:"Loading your dashboard..."})]});const o=a||{},d=o.profile||{},m=o.stats||{constitutional:0,relocation:0,total:0},f=o.recentRequests||[],p=((u=o.outlets)==null?void 0:u[0])||{},h=[{title:"Constitutional Changes",value:m.constitutional,icon:cl,color:"bg-blue-500",change:"Active Requests",onClick:()=>s("dealer-constitutional")},{title:"Relocation Requests",value:m.relocation,icon:Mr,color:"bg-re-red",change:"Active Requests",onClick:()=>s("dealer-relocation")},{title:"My Outlets",value:((N=o.outlets)==null?void 0:N.length)||0,icon:ZI,color:"bg-purple-500",change:"Registered",onClick:()=>{}},{title:"Total Requests",value:m.total,icon:ll,color:"bg-green-500",change:"All time",onClick:()=>{}}],x=[{title:"Constitutional Change",description:"Request change in business structure",icon:cl,color:"bg-blue-50 hover:bg-blue-100 border-blue-200",textColor:"text-blue-700",onClick:()=>s("dealer-constitutional")},{title:"Request Relocation",description:"Move dealership to new location",icon:Mr,color:"bg-red-50 hover:bg-red-100 border-red-200",textColor:"text-re-red",onClick:()=>s("dealer-relocation")}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg bg-gradient-to-r from-re-red to-re-red-hover p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-white mb-2",children:["Welcome back, ",d.name||(t==null?void 0:t.name),"!"]}),e.jsxs("p",{className:"text-white/90",children:["Dealer Code: ",d.dealerCode," • ",d.businessName]}),e.jsxs("p",{className:"text-white/90 text-sm mt-1",children:[p.name," • ",p.location]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-white",children:"Active Dealership"}),e.jsxs(we,{className:"bg-green-500 text-white border-0 mt-2",children:[e.jsx(ln,{className:"w-3 h-3 mr-1"}),"Operational"]})]})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map((v,w)=>{const j=v.icon;return e.jsxs(_e,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:v.onClick,children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(st,{className:"text-sm",children:v.title}),e.jsx("div",{className:`${v.color} p-2 rounded-lg`,children:e.jsx(j,{className:"h-4 w-4 text-white"})})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:v.value}),e.jsx("p",{className:"text-xs text-slate-600 mt-1",children:v.change})]})]},w)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Quick Actions"}),e.jsx(es,{children:"Submit new requests and manage your dealership"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:x.map((v,w)=>{const j=v.icon;return e.jsx("button",{onClick:v.onClick,className:`${v.color} border-2 rounded-lg p-4 text-left transition-all`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`${v.textColor} p-2 bg-white rounded-lg`,children:e.jsx(j,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:`${v.textColor} mb-1`,children:v.title}),e.jsx("p",{className:"text-slate-600 text-sm",children:v.description})]})]})},w)})})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"My Recent Requests"}),e.jsx(es,{children:"Track the status of your submitted requests"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:f.map(v=>e.jsxs("div",{className:"flex items-center justify-between p-4 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-slate-900",children:v.id}),e.jsx(we,{variant:"outline",className:"text-xs",children:v.type})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:v.title}),e.jsxs("p",{className:"text-slate-500 text-xs mt-1",children:["Submitted on ",v.date]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(we,{className:`border ${v.color}`,children:v.status}),e.jsx(te,{variant:"ghost",size:"sm",children:"View"})]})]},v.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"w-5 h-5 text-re-red"}),"Important Reminders"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"GST Filing Due"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Due by Jan 15, 2026"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"Inventory Audit Scheduled"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Jan 20, 2026"})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ln,{className:"w-4 h-4 text-green-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm",children:"Compliance Report Submitted"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Jan 2, 2026"})]})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-5 h-5 text-blue-600"}),"Support & Help"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm mb-1",children:"Regional Manager"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Rajesh Kumar - +91 98765 43210"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm mb-1",children:"Zonal Business Head"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"Priya Sharma - +91 98765 43211"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 text-sm mb-1",children:"Support Email"}),e.jsx("p",{className:"text-slate-600 text-xs",children:"dealer.support@royalenfield.com"})]}),e.jsx(te,{variant:"outline",className:"w-full mt-2",children:"Contact Support"})]})})]})]})]})}function I$({id:t,onBack:s}){const n=["PAN Card","GST Certificate","Aadhaar Card","Security Deposit Receipt","First Fill Receipt","Partnership Deed","LLP Agreement","Certificate of Incorporation","MOA","AOA","Firm Registration","Rental Agreement","Property Documents","Nodal Agreement","Cancelled Check","LOI Acknowledgement","Architecture Blueprint","Site Plan","Other"],[r,a]=g.useState(null),[i,o]=g.useState(!0),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState(null),[u,N]=g.useState(!1),[v,w]=g.useState(!1),j={panNumber:"",gstNumber:"",registeredAddress:"",bankName:"",accountNumber:"",ifscCode:"",branchName:"",accountHolderName:""},[b,C]=g.useState(j),[S,D]=g.useState(j),_=JSON.stringify(b)!==JSON.stringify(S),A=new Set(d.map(L=>String(L.documentType||"").trim().toLowerCase())),E=f?A.has(f.toLowerCase()):!1;g.useEffect(()=>{q()},[t]);const q=async()=>{var L,$;o(!0);try{const[Z,Q]=await Promise.all([Re.getApplicationById(t),Re.getDocuments(t)]);if((L=Z.data)!=null&&L.success){const W=Z.data.data,U={panNumber:W.panNumber||"",gstNumber:W.gstNumber||"",registeredAddress:W.registeredAddress||W.address||"",bankName:W.bankName||"",accountNumber:W.accountNumber||"",ifscCode:W.ifscCode||"",branchName:W.branchName||"",accountHolderName:W.accountHolderName||W.applicantName||""};a(W),C(U),D(U)}(($=Q.data)!=null&&$.success||Q.ok)&&m(Q.data.data||[])}catch(Z){console.error("Failed to fetch details:",Z),J.error("Failed to load application details")}finally{o(!1)}},O=async()=>{var L;w(!0);try{console.log("Saving business details for:",t,b);const $=await Re.updateApplication(t,b);if($.ok)J.success("Business details saved successfully"),await q();else{const Z=((L=$.data)==null?void 0:L.message)||"Failed to update business details";J.error(Z),console.error("Update failed:",$)}}catch($){console.error("Save details fatal error:",$),J.error($.message||"A network error occurred while saving")}finally{w(!1)}},R=L=>{L.target.files&&L.target.files[0]&&x(L.target.files[0])},P=async()=>{var $,Z,Q;if(!h||!f){J.error("Please select a document type and file");return}const L=new FormData;L.append("file",h),L.append("documentType",f),N(!0);try{const W=await Re.uploadDocument(t,L);if(($=W.data)!=null&&$.success||W.ok){J.success("Document uploaded successfully"),x(null),p("");const U=document.getElementById("file-upload");U&&(U.value="");const M=await Re.getDocuments(t);((Z=M.data)!=null&&Z.success||M.ok)&&m(M.data.data||[])}else J.error(((Q=W.data)==null?void 0:Q.message)||"Upload failed")}catch(W){console.error("Upload error:",W),J.error("Upload failed")}finally{N(!1)}};return i?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(or,{className:"w-8 h-8 animate-spin text-re-red"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:s,className:"mr-3 p-1.5 rounded-full hover:bg-slate-200 text-slate-600 transition-colors","data-testid":"onboarding-prospective-details-back-btn",children:e.jsx(io,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-2xl font-bold mb-1",children:"Application Details"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-slate-600 font-medium","data-testid":"onboarding-prospective-details-app-id",children:r.applicationId||"Loading..."}),r.districtId?e.jsx("span",{className:"text-[10px] bg-green-100 text-green-700 font-bold px-1.5 py-0.5 rounded uppercase tracking-wider","data-testid":"onboarding-prospective-details-type-badge",children:"Opportunity"}):e.jsx("span",{className:"text-[10px] bg-blue-100 text-blue-700 font-bold px-1.5 py-0.5 rounded uppercase tracking-wider","data-testid":"onboarding-prospective-details-type-badge",children:"Future Reference"})]})]})]})}),e.jsxs("div",{className:"animate-in fade-in duration-500 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm p-6","data-testid":"onboarding-prospective-details-summary-card",children:[e.jsx("div",{className:"mb-4 border-b pb-2",children:e.jsxs("h4",{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red"})," Application Summary"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-applicant-info",children:[e.jsx("div",{className:"p-2 bg-blue-50 rounded-lg",children:e.jsx(Rr,{className:"w-4 h-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Applicant"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900","data-testid":"onboarding-prospective-details-name",children:r.applicantName}),e.jsxs("p",{className:"text-xs text-slate-600",children:[r.email," | ",r.phone]})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-location-info",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(Mr,{className:"w-4 h-4 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Proposed Location"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:[r.city,", ",r.state]}),e.jsx("p",{className:"text-xs text-slate-600",children:r.preferredLocation||"Standard Area"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-concept-info",children:[e.jsx("div",{className:"p-2 bg-green-50 rounded-lg",children:e.jsx(ad,{className:"w-4 h-4 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Business Concept"}),e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:[r.businessType," - ",r.constitutionType]}),e.jsxs("p",{className:"text-xs text-slate-600",children:["Investment: ",r.investmentCapacity]})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"onboarding-prospective-details-date-info",children:[e.jsx("div",{className:"p-2 bg-slate-50 rounded-lg",children:e.jsx(dn,{className:"w-4 h-4 text-slate-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Applied On"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:r.createdAt?new Date(r.createdAt).toLocaleDateString("en-IN",{day:"numeric",month:"long",year:"numeric"}):"-"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:e.jsxs("div",{className:"lg:col-span-3 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden","data-testid":"onboarding-prospective-details-statutory-card",children:[e.jsxs("div",{className:"p-4 bg-slate-900 text-white flex justify-between items-center",children:[e.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-widest",children:[e.jsx(Wu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Details"]}),e.jsxs("button",{onClick:O,disabled:v,className:`text-xs text-white px-3 py-1 rounded font-bold transition-all flex items-center gap-1 disabled:opacity-50 ${_?"bg-emerald-600 hover:bg-emerald-700 ring-2 ring-emerald-300 animate-pulse":"bg-re-red hover:bg-re-red-hover"}`,"data-testid":"onboarding-prospective-details-save-statutory-btn",children:[v?e.jsx(or,{className:"w-3 h-3 animate-spin"}):e.jsx(Hn,{className:"w-3 h-3"}),"Save Business Info"]})]}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Registered Business Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.accountHolderName,onChange:L=>C({...b,accountHolderName:L.target.value}),placeholder:"As per legal documents","data-testid":"onboarding-prospective-details-input-biz-name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Permanent Account Number (PAN)"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.panNumber,onChange:L=>C({...b,panNumber:L.target.value.toUpperCase()}),placeholder:"ABCDE1234F",maxLength:10,"data-testid":"onboarding-prospective-details-input-pan"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"GST Identification Number (GSTIN)"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.gstNumber,onChange:L=>C({...b,gstNumber:L.target.value.toUpperCase()}),placeholder:"27ABCDE1234F1Z5",maxLength:15,"data-testid":"onboarding-prospective-details-input-gst"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Registered Office Address"}),e.jsx("textarea",{rows:1,className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.registeredAddress,onChange:L=>C({...b,registeredAddress:L.target.value}),placeholder:"Full legal address","data-testid":"onboarding-prospective-details-input-address"})]}),e.jsx("div",{className:"md:col-span-2 border-t pt-2 mt-2",children:e.jsxs("h5",{className:"text-xs font-black text-slate-900 uppercase flex items-center gap-2 mb-3",children:[e.jsx(ck,{className:"w-3.5 h-3.5 text-blue-600"})," Primary Bank Information"]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Bank Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.bankName,onChange:L=>C({...b,bankName:L.target.value}),placeholder:"e.g. HDFC Bank","data-testid":"onboarding-prospective-details-input-bank"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Account Number"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.accountNumber,onChange:L=>C({...b,accountNumber:L.target.value}),placeholder:"Bank account number","data-testid":"onboarding-prospective-details-input-acc-num"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"IFSC Code"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all uppercase",value:b.ifscCode,onChange:L=>C({...b,ifscCode:L.target.value.toUpperCase()}),placeholder:"HDFC0001234",maxLength:11,"data-testid":"onboarding-prospective-details-input-ifsc"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Branch Name"}),e.jsx("input",{type:"text",className:"w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-re-red outline-none transition-all",value:b.branchName,onChange:L=>C({...b,branchName:L.target.value}),placeholder:"e.g. South Mumbai","data-testid":"onboarding-prospective-details-input-branch"})]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden","data-testid":"onboarding-prospective-details-upload-card",children:[e.jsx("div",{className:"p-4 border-b border-slate-200 bg-slate-50 flex justify-between items-center",children:e.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-widest text-slate-900",children:[e.jsx(vr,{className:"w-4 h-4 text-re-red"})," Required Documents"]})}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg border border-slate-100",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Document Category"}),f&&e.jsx("span",{className:"rounded-full bg-red-50 px-2 py-0.5 text-[10px] font-bold text-re-red",children:E?"Already uploaded":"Pending upload"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Hn,{className:`pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 ${E?"text-green-600":"text-slate-300"}`}),e.jsxs(Rt,{value:f,onValueChange:p,disabled:u,children:[e.jsx(_t,{className:"h-12 rounded-xl border-slate-200 bg-gradient-to-r from-white to-slate-50 pl-10 pr-3 text-sm font-medium text-slate-700 shadow-sm focus:border-re-red/40 focus:ring-2 focus:ring-re-red","data-testid":"onboarding-prospective-details-doc-type-select",children:e.jsx(Et,{placeholder:"Choose document type"})}),e.jsx(Tt,{className:"rounded-xl border-slate-200 shadow-lg","data-testid":"onboarding-prospective-details-doc-type-content",children:n.map(L=>{const $=A.has(L.toLowerCase());return e.jsxs(AE,{value:L,textValue:L,className:Nt("relative flex w-full cursor-default select-none items-center gap-2 rounded-lg py-2 pl-2 pr-8 text-sm text-slate-700 outline-none","focus:bg-red-50 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"),"data-testid":`onboarding-prospective-details-doc-type-item-${L.replace(/\s+/g,"-").toLowerCase()}`,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(DE,{children:e.jsx($n,{className:"size-4"})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(Hn,{className:Nt("h-4 w-4 shrink-0",$?"text-green-600":"text-slate-300"),"aria-hidden":!0}),e.jsx(kE,{children:L})]})]},L)})})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Select File"}),e.jsx("input",{type:"file",id:"file-upload",className:"w-full text-xs text-slate-600 file:mr-4 file:py-1 file:px-4 file:rounded-full file:border-0 file:text-xs file:font-semibold file:bg-red-50 file:text-re-red hover:file:bg-red-100",onChange:R,disabled:u,"data-testid":"onboarding-prospective-details-file-input"})]}),e.jsx("div",{className:"md:col-span-2 flex justify-end",children:e.jsxs("button",{onClick:P,disabled:!h||!f||u,className:"bg-re-red text-white px-5 py-2 rounded-md hover:bg-re-red-hover disabled:opacity-50 text-xs font-bold transition-all shadow-sm flex items-center gap-2","data-testid":"onboarding-prospective-details-upload-btn",children:[u?e.jsx(or,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(vr,{className:"w-3.5 h-3.5"}),"Upload Document"]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-900 border-b pb-1",children:[e.jsx(rf,{className:"w-4 h-4 text-blue-600"}),e.jsxs("h3",{className:"text-xs font-black uppercase tracking-tighter",children:["Uploaded Library (",d.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3","data-testid":"onboarding-prospective-details-doc-library",children:d.length>0?d.map((L,$)=>e.jsxs("div",{className:"flex justify-between items-center p-3 border border-slate-100 rounded-xl bg-slate-50 group hover:border-red-200 transition-all","data-testid":`onboarding-prospective-details-doc-item-${$}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-white flex items-center justify-center border border-slate-200 group-hover:bg-blue-50",children:e.jsx(rf,{className:"w-4 h-4 text-slate-400 group-hover:text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold text-slate-900","data-testid":`onboarding-prospective-details-doc-type-${$}`,children:L.documentType}),e.jsx("p",{className:"text-[10px] text-slate-400 truncate w-32",children:L.fileName})]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 rounded-full font-black uppercase tracking-tighter ${L.status==="Approved"?"bg-green-100 text-green-700":"bg-red-50 text-re-red"}`,"data-testid":`onboarding-prospective-details-doc-status-${$}`,children:L.status||"Pending"})]},L.id)):e.jsxs("div",{className:"col-span-2 py-8 text-center bg-slate-50 rounded-xl border border-dashed border-slate-200","data-testid":"onboarding-prospective-details-doc-empty",children:[e.jsx(qa,{className:"w-6 h-6 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-slate-500 font-medium",children:"No documents in your library yet"})]})})]})]})]})]})})]})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 p-8 text-center",children:[e.jsx("p",{className:"text-slate-600 mb-4",children:"Application details not found."}),e.jsx("button",{onClick:s,className:"bg-re-red text-white px-4 py-2 rounded-md hover:bg-re-red-hover",children:"Go Back"})]})}function M$(){var f;const t=Lu(),s=tr(),n=xl(),{user:r}=Pn(p=>p.auth),[a,i]=g.useState(!1),[o,d]=g.useState("applicant"),m=()=>{t(SA()),J.info("Logged out successfully"),s("/")};return e.jsxs("div",{className:"flex h-screen bg-slate-50",children:[e.jsxs("div",{className:`bg-slate-900 text-white h-screen flex flex-col transition-all duration-300 ${a?"w-20":"w-64"}`,children:[e.jsx("div",{className:"p-4 border-b border-slate-800",children:a?e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-full",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"block h-auto w-full max-h-10 object-contain"})}),e.jsx("button",{onClick:()=>i(!1),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Expand sidebar",children:e.jsx(mi,{className:"w-5 h-5"})})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>i(!0),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Collapse sidebar",children:e.jsx(io,{className:"w-5 h-5"})})}),e.jsx("div",{className:"w-full",children:e.jsx("img",{src:"/assets/images/Re_Logo.png",alt:"Royal Enfield",className:"mx-auto block h-auto w-full max-h-14 object-contain"})}),e.jsx("p",{className:"text-center text-[10px] font-bold uppercase tracking-[0.2em] text-slate-400",children:"Applicant Portal"})]})}),e.jsx("nav",{className:"flex-1 p-4 space-y-2",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>{d("applicant"),s("/prospective-dashboard")},className:`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${o==="applicant"?"bg-re-red text-white hover:bg-re-red-hover":"text-slate-300 hover:bg-slate-800 hover:text-white"}`,children:[e.jsx(ks,{className:"w-5 h-5 flex-shrink-0"}),!a&&e.jsx("span",{className:"flex-1 text-left",children:"My Applications"})]})})}),e.jsxs("div",{className:"p-4 border-t border-slate-800 space-y-2",children:[!a&&e.jsx("div",{className:"px-4 py-2 bg-slate-800 rounded-lg mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-re-red rounded-full flex items-center justify-center text-white ring-2 ring-white/20",children:e.jsx("span",{className:"font-bold",children:((f=r==null?void 0:r.name)==null?void 0:f.charAt(0))||"A"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:(r==null?void 0:r.name)||"Applicant"}),e.jsx("p",{className:"text-slate-400 truncate text-xs",children:(r==null?void 0:r.role)||"Prospective"})]})]})}),e.jsxs("button",{onClick:m,className:`w-full flex items-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all h-9 px-4 py-2 text-slate-300 hover:bg-slate-800 hover:text-white ${a?"justify-center":"justify-start"}`,children:[e.jsx(uk,{className:"w-5 h-5 flex-shrink-0"}),!a&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-xl font-semibold",children:n.pathname.includes("/application/")?"Application details":"Applicant management"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-2xl leading-snug",children:n.pathname.includes("/application/")?"Review and update statutory information and required documents for this application. Progress is coordinated by Royal Enfield after you submit.":"Start or continue your dealership application, upload documents, and use links we email you (for example the questionnaire)."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-slate-100 rounded-lg",children:[e.jsx("div",{className:"w-8 h-8 bg-re-red rounded-full flex items-center justify-center ring-2 ring-re-red/20",children:e.jsx(Rr,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-slate-900 text-sm font-medium",children:(r==null?void 0:r.name)||"Applicant"}),e.jsx("p",{className:"text-slate-600 text-xs",children:(r==null?void 0:r.role)||"User"})]})]}),e.jsx("button",{className:"p-2 rounded-md hover:bg-slate-100",title:"Refresh",onClick:()=>window.location.reload(),children:e.jsx(or,{className:"w-4 h-4 text-slate-600"})})]})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs(Xv,{children:[e.jsx(Ps,{path:"/",element:e.jsx(F$,{})}),e.jsx(Ps,{path:"/application/:id",element:e.jsx(B$,{})})]})})]})]})}function F$(){const t=tr(),{user:s}=Pn(i=>i.auth),[n,r]=g.useState([]);g.useEffect(()=>{s!=null&&s.id&&a()},[s==null?void 0:s.id]);const a=async()=>{var i;try{const o=await Re.getApplications();(i=o.data)!=null&&i.success&&r(o.data.data)}catch(o){console.error("Failed to fetch applications",o)}};return e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 text-3xl font-bold mb-2",children:"My Applications"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Track and manage your dealership applications"})]})}),n.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 border-dashed p-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(ks,{className:"w-8 h-8 text-slate-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-1",children:"No applications found"}),e.jsx("p",{className:"text-slate-500 max-w-sm mx-auto mb-6",children:"You haven't submitted any dealership applications yet."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.map(i=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm hover:shadow-md hover:border-re-red cursor-pointer transition-all group",onClick:()=>t(`/prospective-dashboard/application/${i.id}`),children:[e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"w-12 h-12 bg-red-50 rounded-xl flex items-center justify-center group-hover:bg-re-red transition-colors",children:e.jsx(ks,{className:"w-6 h-6 text-re-red group-hover:text-white"})})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-1 truncate",children:i.applicationId}),e.jsxs("p",{className:"text-slate-500 text-sm mb-4 font-medium",children:[i.city,", ",i.state]}),e.jsx("div",{className:"space-y-4 pt-6 border-t border-slate-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-slate-500 font-medium",children:"Applied"}),e.jsx("span",{className:"text-xs font-bold text-slate-600",children:Qt(i.createdAt)})]})})]},i.id))})]})})}function B$(){const{id:t}=gd(),s=tr();return t?e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsx(I$,{id:t,onBack:()=>s("/prospective-dashboard")})}):null}function $$(){const t=tr(),[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState("");g.useEffect(()=>{d()},[]);const d=async()=>{var f;a(!0);try{const p=await Re.getApplications();(f=p.data)!=null&&f.success&&n(p.data.data)}catch(p){console.error("Failed to fetch FDD applications:",p),J.error("Failed to load assigned applications")}finally{a(!1)}},m=s.filter(f=>{var p;return f.applicationId.toLowerCase().includes(i.toLowerCase())||f.applicantName.toLowerCase().includes(i.toLowerCase())||((p=f.city)==null?void 0:p.toLowerCase().includes(i.toLowerCase()))});return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 tracking-tight",children:"FDD Dashboard"}),e.jsx("p",{className:"text-slate-500",children:"Manage financial due diligence for assigned dealer applications"})]}),e.jsxs("button",{onClick:d,className:"flex items-center gap-2 px-4 py-2 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors text-sm font-medium",children:[e.jsx(or,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx(_e,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Total Assigned"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:s.length})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(ks,{className:"w-5 h-5"})})]})})}),e.jsx(_e,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Pending Reports"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:s.filter(f=>f.currentStage==="FDD"||f.overallStatus==="Active").length})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(dn,{className:"w-5 h-5"})})]})})}),e.jsx(_e,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Completed Reports"}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900",children:"0"})]}),e.jsx("div",{className:"p-2 bg-slate-100 rounded-lg text-slate-600",children:e.jsx(Hn,{className:"w-5 h-5"})})]})})})]}),e.jsxs(_e,{className:"shadow-sm border-slate-200 overflow-hidden",children:[e.jsxs(Xe,{className:"bg-white border-b border-slate-100 px-6 py-4 flex flex-row items-center justify-between",children:[e.jsxs(st,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-blue-600"}),"My Assigned Cases"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search by ID or Name...",className:"pl-9 pr-4 py-2 bg-slate-50 border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 transition-all outline-none",value:i,onChange:f=>o(f.target.value)})]}),e.jsx("button",{className:"p-2 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors",children:e.jsx(eb,{className:"w-4 h-4 text-slate-600"})})]})]}),e.jsx(Oe,{className:"p-0",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6",children:[e.jsx(or,{className:"w-10 h-10 animate-spin text-blue-600 mb-4"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Synchronizing application data..."})]}):m.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mb-6",children:e.jsx(sn,{className:"w-10 h-10 text-slate-200"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-2",children:"No Applications Found"}),e.jsx("p",{className:"text-slate-500 max-w-md mx-auto",children:"You don't have any applications assigned for Financial Due Diligence at this time."})]}):e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Application Details"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Location"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Current Stage"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider text-right",children:"Action"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:m.map(f=>e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors cursor-pointer group",onClick:()=>t(`/fdd-details/${f.id}`),children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center font-bold",children:f.applicantName.charAt(0)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-900 group-hover:text-blue-600 transition-colors",children:f.applicationId}),e.jsx("p",{className:"text-xs text-slate-500",children:f.applicantName})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-slate-700",children:[f.city,", ",f.state]}),e.jsx("p",{className:"text-xs text-slate-400 capitalize",children:f.locationType||"New Market"})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(we,{className:`px-3 py-1 rounded-full text-[10px] uppercase font-bold tracking-wider ${f.overallStatus==="Completed"?"bg-green-100 text-green-700":"bg-red-50 text-re-red-hover"}`,children:f.overallStatus==="Active"?"FDD Pending":f.overallStatus})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"p-2 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-all",children:e.jsx(Wo,{className:"w-5 h-5"})})})]},f.id))})]})})})]})]})}const q$="modulepreload",z$=function(t){return"/"+t},xS={},Yo=function(s,n,r){let a=Promise.resolve();if(n&&n.length>0){let o=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=o(n.map(f=>{if(f=z$(f),f in xS)return;xS[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":q$,p||(x.as="script"),x.crossOrigin="",x.href=f,m&&x.setAttribute("nonce",m),document.head.appendChild(x),p)return new Promise((u,N)=>{x.addEventListener("load",u),x.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(o){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=o,window.dispatchEvent(d),!d.defaultPrevented)throw o}return a.then(o=>{for(const d of o||[])d.status==="rejected"&&i(d.reason);return s().catch(i)})};function U$(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o);d.displayName=i+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,V$(a,...s)]}function V$(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var H$=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Hb=H$.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Lg={exports:{}},Ig={};/**
|
||
* @license React
|
||
* use-sync-external-store-shim.production.js
|
||
*
|
||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var gS;function W$(){if(gS)return Ig;gS=1;var t=fd();function s(h,x){return h===x&&(h!==0||1/h===1/x)||h!==h&&x!==x}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,a=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function d(h,x){var u=x(),N=r({inst:{value:u,getSnapshot:x}}),v=N[0].inst,w=N[1];return i(function(){v.value=u,v.getSnapshot=x,m(v)&&w({inst:v})},[h,u,x]),a(function(){return m(v)&&w({inst:v}),h(function(){m(v)&&w({inst:v})})},[h]),o(u),u}function m(h){var x=h.getSnapshot;h=h.value;try{var u=x();return!n(h,u)}catch{return!0}}function f(h,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return Ig.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Ig}var vS;function G$(){return vS||(vS=1,Lg.exports=W$()),Lg.exports}var K$=G$();function Y$(){return K$.useSyncExternalStore(Z$,()=>!0,()=>!1)}function Z$(){return()=>{}}var Wb="Avatar",[Q$]=U$(Wb),[X$,EE]=Q$(Wb),_E=g.forwardRef((t,s)=>{const{__scopeAvatar:n,...r}=t,[a,i]=g.useState("idle");return e.jsx(X$,{scope:n,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:e.jsx(Hb.span,{...r,ref:s})})});_E.displayName=Wb;var TE="AvatarImage",J$=g.forwardRef((t,s)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:a=()=>{},...i}=t,o=EE(TE,n),d=eq(r,i),m=xr(f=>{a(f),o.onImageLoadingStatusChange(f)});return Jn(()=>{d!=="idle"&&m(d)},[d,m]),d==="loaded"?e.jsx(Hb.img,{...i,ref:s,src:r}):null});J$.displayName=TE;var PE="AvatarFallback",OE=g.forwardRef((t,s)=>{const{__scopeAvatar:n,delayMs:r,...a}=t,i=EE(PE,n),[o,d]=g.useState(r===void 0);return g.useEffect(()=>{if(r!==void 0){const m=window.setTimeout(()=>d(!0),r);return()=>window.clearTimeout(m)}},[r]),o&&i.imageLoadingStatus!=="loaded"?e.jsx(Hb.span,{...a,ref:s}):null});OE.displayName=PE;function yS(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function eq(t,{referrerPolicy:s,crossOrigin:n}){const r=Y$(),a=g.useRef(null),i=r?(a.current||(a.current=new window.Image),a.current):null,[o,d]=g.useState(()=>yS(i,t));return Jn(()=>{d(yS(i,t))},[i,t]),Jn(()=>{const m=h=>()=>{d(h)};if(!i)return;const f=m("loaded"),p=m("error");return i.addEventListener("load",f),i.addEventListener("error",p),s&&(i.referrerPolicy=s),typeof n=="string"&&(i.crossOrigin=n),()=>{i.removeEventListener("load",f),i.removeEventListener("error",p)}},[i,n,s]),o}var tq=_E,sq=OE;function Nm({className:t,...s}){return e.jsx(tq,{"data-slot":"avatar",className:Nt("relative flex size-10 shrink-0 overflow-hidden rounded-full",t),...s})}function wm({className:t,...s}){return e.jsx(sq,{"data-slot":"avatar-fallback",className:Nt("bg-muted flex size-full items-center justify-center rounded-full",t),...s})}const Sm="/collaboration",Cm={getWorknotes:async(t,s)=>(await Ie.get(`${Sm}/worknotes`,{requestId:t,requestType:s})).data,addWorknote:async t=>(await Ie.post(`${Sm}/worknotes`,t)).data,uploadAttachment:async(t,s,n)=>{const r=new FormData;return r.append("file",t),s&&r.append("requestId",s),n&&r.append("requestType",n),(await Ie.post(`${Sm}/upload`,r,{headers:{"Content-Type":"multipart/form-data"}})).data},revokeParticipant:async(t,s)=>(await Ie.delete(`${Sm}/participants/${t}`,{data:{reason:s}})).data},au=t=>[...t].sort((s,n)=>new Date(s.createdAt).getTime()-new Date(n.createdAt).getTime()),Mg=t=>{var s,n,r,a,i;return{name:((s=t==null?void 0:t.author)==null?void 0:s.name)||((n=t==null?void 0:t.author)==null?void 0:n.fullName)||"System",email:((r=t==null?void 0:t.author)==null?void 0:r.email)||"",role:String(((a=t==null?void 0:t.author)==null?void 0:a.role)||((i=t==null?void 0:t.author)==null?void 0:i.roleCode)||"")}},nq=new Set(["internal","workflow","system","audit","status"]),rq=t=>nq.has(String(t.noteType||"").toLowerCase()),aq=t=>{const s=String(t.noteType||"").toLowerCase();return s==="workflow"?"Workflow activity":s==="internal"?"Review / approval":s==="system"?"System":s==="audit"?"Audit":s==="status"?"Status update":"Activity"},iq=t=>{const s=String(t.noteType||"").toLowerCase();return s==="internal"?"APPROVAL":s==="workflow"?"WORKFLOW":s==="system"?"SYSTEM":s==="audit"?"AUDIT":s==="status"?"STATUS":"ACTIVITY"},bS=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"",Uc="https://dealeronboarding-uat.royalenfield.com/api".replace("/api","")||"http://localhost:5000";function LE(t){var Vs,Qs,Xs,ie,nt;const{user:s}=Pn(fe=>fe.auth),{id:n,type:r}=gd(),a=xl(),i=tr(),o=t.requestId||n||"",d=t.requestType||r||((Vs=a.state)==null?void 0:Vs.requestType)||"application",m=t.mode||((Qs=a.state)==null?void 0:Qs.mode)||"page",[f,p]=g.useState(t.applicationName||((Xs=a.state)==null?void 0:Xs.applicationName)||"Application"),[h,x]=g.useState(t.registrationNumber||((ie=a.state)==null?void 0:ie.registrationNumber)||""),u=t.onBack||(()=>i(-1)),N=t.participants||((nt=a.state)==null?void 0:nt.participants)||[],[v,w]=g.useState(N),[j,b]=g.useState([]),[C,S]=g.useState(""),[D,_]=g.useState(!1),[A,E]=g.useState(""),[q,O]=g.useState(0),[R,P]=g.useState(!0),[L,$]=g.useState(!1),[Z,Q]=g.useState([]),[W,U]=g.useState(!1),[M,z]=g.useState(!0),[T,F]=g.useState(""),[I,K]=g.useState(""),[G,V]=g.useState(null),[Y,re]=g.useState(""),[ae,ue]=g.useState(!1),{socket:ye}=ZD(),ce=g.useRef(null),je=g.useRef(null),[Me,ut]=g.useState(null),jt=(fe,Ae)=>fe.startsWith("image/")&&Ae?e.jsx("img",{src:`${Uc}/${Ae.replace(/\\/g,"/")}`,className:"w-full h-full object-cover rounded",alt:"Thumbnail"}):fe.startsWith("image/")?e.jsx(A1,{className:"w-5 h-5 text-blue-500"}):fe==="application/pdf"?e.jsx(ks,{className:"w-5 h-5 text-red-500"}):e.jsx(rf,{className:"w-5 h-5 text-slate-500"}),ft=["😊","😂","🤣","❤️","👍","🙏","🔥","✨","😍","🥰","😎","🤔","😅","🙌","👏","🎉","✅","❌","📌","📎","📍","💡","🔔","📢","⭐","🌟","💪","🚀","👀","💯","🌈","☀️","😢","😭","😞","😔","😟","😕","😠","😡","🤬","😤","😲","🙄","🤨","😓","😩","😫","🤐","😴","🤢","🤮","😱","🤡","💀","👻","🤝","👋","✌️","👌","✋","🍎","🍕","☕","💻","📱","⌚","📁","📄","📅","🔒","🔑","🛠️","⚙️","💬","💭","🌊","🍀","✈️","🏠"],X=fe=>fe.split(" ").map(Ae=>Ae[0]).join("").toUpperCase().substring(0,2),Ce=fe=>{const Ae=["bg-green-600","bg-blue-600","bg-purple-600","bg-re-red","bg-pink-600","bg-indigo-600","bg-teal-600"],Fe=fe.length%Ae.length;return Ae[Fe]},xe=[],We=new Set;v.forEach(fe=>{var Ke,Le,Ue,et,dt,ss,Wt;const Ae=((Ke=fe.user)==null?void 0:Ke.id)||fe.userId||"",Fe=fe.id;if(Ae&&!We.has(Ae)){We.add(Ae);const kt=((Le=fe.user)==null?void 0:Le.fullName)||((Ue=fe.user)==null?void 0:Ue.name)||fe.fullName||fe.name||"Unknown User",wt=((et=fe.user)==null?void 0:et.email)||fe.email||"",Os=((dt=fe.user)==null?void 0:dt.roleCode)||fe.roleCode||((ss=fe.user)==null?void 0:ss.role)||fe.role||"Participant";xe.push({id:Ae,recordId:Fe,name:kt,email:wt,initials:X(kt),color:Ce(kt),role:Os,isOnline:!1,revokedAt:(Wt=fe.metadata)==null?void 0:Wt.revokedAt})}});const Be=async()=>{try{P(!0);const fe=await Cm.getWorknotes(o,d);if(fe.success){const Ae=fe.data.map(Fe=>({id:Fe.id,noteText:Fe.noteText,noteType:Fe.noteType,createdAt:Fe.createdAt,userId:Fe.userId,author:Fe.author?Mg(Fe):{name:"System",email:"",role:"system"},attachments:Fe.attachments||[]}));b(au(Ae))}}catch(fe){console.error("Fetch notes error:",fe),J.error("Failed to load work notes")}finally{P(!1)}};g.useEffect(()=>{if(Be(),ye)return ye.emit("join_room",o),ye.on("new_worknote",fe=>{const Ae={id:fe.id,noteText:fe.noteText,noteType:fe.noteType,createdAt:fe.createdAt,userId:fe.userId,author:fe.author?Mg(fe):{name:"System",email:"",role:"system"},attachments:fe.attachments||[]};b(Fe=>{if(Fe.some(Ue=>Ue.id===Ae.id))return Fe;const Le=Fe.findIndex(Ue=>{var et,dt;return Ue.id.startsWith("temp-")&&Ue.noteText===Ae.noteText&&((et=Ue.author.email)==null?void 0:et.toLowerCase())===((dt=Ae.author.email)==null?void 0:dt.toLowerCase())});if(Le!==-1){const Ue=[...Fe];return Ue[Le]=Ae,au(Ue)}return au([...Fe,Ae])})}),()=>{ye.emit("leave_room",o),ye.off("new_worknote")}},[o,d,ye]),g.useEffect(()=>{if(!o||!d)return;(async()=>{var Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt;try{let wt=null;if(d==="application")wt=await ps.getApplicationById(o),wt&&(v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application")&&p(wt.companyName||"Application"),h||x(wt.registrationNumber||""));else if(d==="termination"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getTerminationById(o);(Ae=as.data)!=null&&Ae.success&&(wt=as.data.termination,v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application"||f==="Termination")&&p(((Fe=wt.dealer)==null?void 0:Fe.businessName)||"Termination"),h||x(wt.requestId||""))}else if(d==="constitutional"||d==="constitutional-change"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getConstitutionalChangeById(o);(Ke=as.data)!=null&&Ke.success&&(wt=as.data.request,v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application"||f==="Constitutional Change")&&p(((Le=wt.outlet)==null?void 0:Le.name)||"Constitutional Change"),h||x(wt.requestId||""))}else if(d==="resignation"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getResignationById(o);(Ue=as.data)!=null&&Ue.success&&(wt=as.data.resignation,v.length===0&&wt.participants&&w(wt.participants),(!f||f==="Application"||f==="Resignation")&&p(((et=wt.dealer)==null?void 0:et.businessName)||"Resignation"),h||x(wt.resignationId||""))}else if(d==="fnf"){const{API:Os}=await Yo(async()=>{const{API:Se}=await Promise.resolve().then(()=>cm);return{API:Se}},void 0),as=await Os.getFnFSettlementById(o);if((dt=as.data)!=null&&dt.success){wt=as.data.fnf,v.length===0&&wt.participants&&w(wt.participants||[]);const Se=((Wt=(ss=wt.outlet)==null?void 0:ss.dealer)==null?void 0:Wt.fullName)||((kt=wt.dealer)==null?void 0:kt.fullName)||"F&F Settlement";(!f||f==="Application"||f==="F&F Settlement")&&p(Se),h||x(wt.settlementId||"")}}}catch(wt){console.error(`Failed to fetch ${d} details:`,wt)}})()},[o,d,v.length,f,h]);const rt=g.useRef(null);g.useEffect(()=>{rt.current&&rt.current.scrollIntoView({behavior:"smooth"})},[j]);const ht=fe=>{const Ae=fe.target.value,Fe=fe.target.selectionStart||0;S(Ae),O(Fe);const Ke=Ae.substring(0,Fe),Le=Ke.lastIndexOf("@");if(Le!==-1&&Le===Ke.length-1)_(!0),E("");else if(Le!==-1){const Ue=Ke.substring(Le+1);Ue.includes(" ")?_(!1):(_(!0),E(Ue))}else _(!1)},ge=fe=>{var et;const Fe=C.substring(0,q).lastIndexOf("@"),Ke=C.substring(q),Le=`@${fe.name}`,Ue=C.substring(0,Fe)+Le+" "+Ke;S(Ue),_(!1),(et=ce.current)==null||et.focus()},Je=fe=>{var Ke,Le;const Ae=((Ke=ce.current)==null?void 0:Ke.selectionStart)||C.length,Fe=C.substring(0,Ae)+fe+C.substring(Ae);S(Fe),$(!1),(Le=ce.current)==null||Le.focus()},mt=async fe=>{const Ae=fe.target.files;if(!(!Ae||Ae.length===0)){U(!0);try{for(const Fe of Array.from(Ae)){const Ke=await Cm.uploadAttachment(Fe,o,d);Ke.success&&Q(Le=>[...Le,Ke.data])}}catch(Fe){console.error("File upload error:",Fe),J.error("Failed to upload attachment")}finally{U(!1),je.current&&(je.current.value="")}}},de=fe=>{Q(Ae=>Ae.filter(Fe=>Fe.id!==fe))},at=async()=>{if(!C.trim()&&Z.length===0)return;const fe=C,Ae=Z;S(""),Q([]);let Fe=fe;const Ke=[];xe.forEach(Le=>{if(Le.id&&Le.name){const Ue=Le.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),et=new RegExp(`@${Ue}\\b`,"gi");Fe.match(et)&&(Ke.push(Le.id),Fe=Fe.replace(et,`@[${Le.name}](user:${Le.id})`))}});try{const Le=`temp-${Date.now()}`,Ue={id:Le,noteText:Fe,noteType:"General",createdAt:new Date().toISOString(),userId:s==null?void 0:s.id,author:{name:(s==null?void 0:s.name)||"You",email:(s==null?void 0:s.email)||"",role:(s==null?void 0:s.role)||""},attachments:Ae};b(dt=>au([...dt,Ue]));const et=await Cm.addWorknote({requestId:o,requestType:d,noteText:Fe,noteType:"General",tags:Ke,attachmentDocIds:Ae.map(dt=>dt.id)});if(et.success&&et.data){const dt=et.data,ss={id:dt.id,noteText:dt.noteText,noteType:dt.noteType,createdAt:dt.createdAt,userId:dt.userId,author:dt.author?Mg(dt):{name:"System",email:"",role:"system"},attachments:dt.attachments||[]};b(Wt=>au(Wt.map(kt=>kt.id===Le?ss:kt)))}}catch(Le){console.error("Send message error:",Le),J.error("Failed to send message")}},ot=fe=>{if(!["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")){J.error("Only authorized roles can revoke participants");return}V(fe),re("")},ke=async()=>{if(G){ue(!0);try{const fe=await Cm.revokeParticipant(G.recordId,Y);fe.success&&(J.success(fe.message),V(null),w([]))}catch{J.error("Error revoking participant")}finally{ue(!1)}}},Zt=fe=>{fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),at())},Bt=fe=>{if(!fe)return"";const Ae=/(@\[[^\]]+\]\([^\)]+\))/g;return fe.split(Ae).map((Ke,Le)=>{const Ue=Ke.match(/@\[([^\]]+)\]\(([^\)]+)\)/);if(Ue){const et=Ue[1];return e.jsxs("span",{className:"text-blue-600 font-medium hover:underline cursor-pointer",children:["@",et]},Le)}return Ke})},_s=I.trim().toLowerCase(),Us=_s?j.filter(fe=>{var Ae;return(fe.noteText||"").toLowerCase().includes(_s)||(((Ae=fe.author)==null?void 0:Ae.name)||"").toLowerCase().includes(_s)||(fe.noteType||"").toLowerCase().includes(_s)}):j,fs=xe.filter(fe=>{const Ae=fe.name.toLowerCase().includes(A.toLowerCase()),Fe=fe.id&&(s==null?void 0:s.id)&&String(fe.id)===String(s.id)||fe.email&&(s==null?void 0:s.email)&&fe.email.toLowerCase()===s.email.toLowerCase();return Ae&&!Fe});return e.jsxs("div",{className:"h-full flex flex-col bg-slate-50 overflow-hidden",children:[e.jsx("div",{className:"bg-white border-b border-slate-200 px-6 py-4 z-10","data-testid":"onboarding-worknotes-header",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"ghost",size:"icon",onClick:u,className:"hover:bg-slate-100","data-testid":"onboarding-worknotes-back-btn",children:e.jsx(Wr,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-12 h-12 bg-purple-600 rounded-lg flex items-center justify-center",children:e.jsx(li,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900","data-testid":"onboarding-worknotes-title",children:"Work Notes"}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600","data-testid":"onboarding-worknotes-meta",children:[e.jsx("span",{"data-testid":"onboarding-worknotes-app-name",children:f}),e.jsx("span",{className:"text-slate-400",children:"|"}),e.jsx("span",{className:"text-slate-500","data-testid":"onboarding-worknotes-reg-num",children:h})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"hidden sm:flex items-center -space-x-2 mr-2","data-testid":"onboarding-worknotes-participant-avatars",children:[xe.slice(0,3).map((fe,Ae)=>e.jsx(Nm,{className:"w-8 h-8 border-2 border-white ring-1 ring-slate-100","data-testid":`onboarding-worknotes-avatar-${Ae}`,children:e.jsx(wm,{className:`${fe.color} text-white text-[10px]`,children:fe.initials})},Ae)),xe.length>3&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 border-2 border-white flex items-center justify-center ring-1 ring-slate-100","data-testid":"onboarding-worknotes-avatar-more",children:e.jsxs("span",{className:"text-slate-600 text-[10px] font-bold",children:["+",xe.length-3]})})]}),e.jsxs(te,{variant:"ghost",size:"sm",onClick:Be,className:"text-slate-500 hover:text-blue-600 flex items-center gap-1.5 px-2 h-9 rounded-lg hover:bg-slate-50 transition-colors",disabled:R,"data-testid":"onboarding-worknotes-sync-btn",children:[e.jsx(cl,{className:`w-4 h-4 ${R?"animate-spin":""}`}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Sync"})]}),e.jsxs(te,{variant:M?"secondary":"ghost",size:"sm",onClick:()=>z(!M),className:`flex items-center gap-1.5 px-2 h-9 rounded-lg transition-all ${M?"bg-blue-50 text-blue-600 hover:bg-blue-100":"text-slate-500 hover:bg-slate-50"}`,"data-testid":"onboarding-worknotes-toggle-sidebar-btn",children:[e.jsx(ja,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Participants"})]})]})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-white min-h-0 relative",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 custom-scrollbar bg-slate-50 relative z-0","data-testid":"onboarding-worknotes-chat-area",children:e.jsxs("div",{className:`max-w-4xl mx-auto flex flex-col py-4 gap-4 ${m==="modal"?"":"px-4"}`,children:[e.jsx("div",{className:"sticky top-0 z-[1] -mx-1 px-1 pb-1 bg-slate-50/95 backdrop-blur-sm",children:e.jsxs("div",{className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(it,{type:"search",value:I,onChange:fe=>K(fe.target.value),placeholder:"Search messages...",className:"pl-9 h-10 bg-white border-slate-200 rounded-xl text-sm shadow-sm","aria-label":"Search messages","data-testid":"onboarding-worknotes-search-input"})]})}),Us.map((fe,Ae)=>{var Ke,Le,Ue,et,dt,ss,Wt;if(rq(fe)){const kt=((Ke=fe.author)==null?void 0:Ke.name)||"System",wt=(Le=fe.author)!=null&&Le.role&&fe.author.role!=="0"&&fe.author.role!==""?fe.author.role:"";return e.jsx("div",{className:"flex w-full justify-center px-1 py-1 sm:px-2","data-testid":`onboarding-worknotes-activity-row-${Ae}`,children:e.jsxs("div",{role:"status",title:aq(fe),className:"flex w-full max-w-[min(100%,42rem)] items-start gap-2.5 rounded-xl border border-slate-200/90 bg-slate-100/80 px-3 py-2.5 shadow-sm",children:[e.jsx(rd,{className:"mt-0.5 h-4 w-4 shrink-0 text-purple-600",strokeWidth:2.5,"aria-hidden":!0}),e.jsx("span",{className:"shrink-0 pt-0.5 text-[10px] font-bold uppercase tracking-wide text-slate-600","data-testid":`onboarding-worknotes-activity-type-${Ae}`,children:iq(fe)}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:e.jsxs("p",{className:"text-sm leading-snug text-slate-800",children:[e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-worknotes-activity-who-${Ae}`,children:kt}),wt?e.jsxs("span",{className:"text-xs font-normal text-slate-500",children:[" · ",wt]}):null,e.jsx("span",{className:"font-normal text-slate-600",children:" — "}),e.jsx("span",{className:"font-normal text-slate-700","data-testid":`onboarding-worknotes-activity-text-${Ae}`,children:Bt(fe.noteText)})]})}),e.jsx("time",{className:"shrink-0 whitespace-nowrap pt-0.5 text-right text-[10px] leading-tight text-slate-400 tabular-nums sm:text-[11px]",dateTime:fe.createdAt,"data-testid":`onboarding-worknotes-activity-time-${Ae}`,children:bS(fe.createdAt)})]})},fe.id)}const Fe=((Ue=fe==null?void 0:fe.author)==null?void 0:Ue.email)&&(s==null?void 0:s.email)&&fe.author.email.toLowerCase()===s.email.toLowerCase()||(fe==null?void 0:fe.userId)&&(s==null?void 0:s.id)&&String(fe.userId)===String(s.id)||fe.id.startsWith("temp-");return e.jsx("div",{className:`flex w-full ${Fe?"justify-end":"justify-start"}`,"data-testid":`onboarding-worknotes-message-row-${Ae}`,children:e.jsxs("div",{className:`flex gap-3 max-w-[min(85%,36rem)] ${Fe?"flex-row-reverse":""}`,children:[e.jsx(Nm,{className:"w-10 h-10 flex-shrink-0 mt-1","data-testid":`onboarding-worknotes-message-avatar-${Ae}`,children:e.jsx(wm,{className:`${Ce(((et=fe==null?void 0:fe.author)==null?void 0:et.name)||"System")} text-white`,children:X(((dt=fe==null?void 0:fe.author)==null?void 0:dt.name)||"S")})}),e.jsxs("div",{className:`flex flex-col min-w-0 ${Fe?"items-end":"items-start"}`,children:[e.jsxs("div",{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 mb-1 px-1 ${Fe?"flex-row-reverse text-right":"text-left"}`,children:[e.jsx("span",{className:"text-slate-900 font-medium text-sm","data-testid":`onboarding-worknotes-message-author-${Ae}`,children:Fe?"You":((ss=fe==null?void 0:fe.author)==null?void 0:ss.name)||"Unknown"}),e.jsx("span",{className:"text-slate-400 text-[10px] uppercase tracking-wide",children:(Wt=fe==null?void 0:fe.author)!=null&&Wt.role&&fe.author.role!=="0"&&fe.author.role!==""?`(${fe.author.role})`:""}),e.jsx("span",{className:"text-slate-400 text-[10px] tabular-nums","data-testid":`onboarding-worknotes-message-time-${Ae}`,children:bS(fe.createdAt)})]}),e.jsxs("div",{className:`rounded-2xl border px-4 py-2.5 shadow-sm relative text-left ${Fe?"bg-blue-50 border-blue-100 text-slate-800 rounded-tr-none":"bg-white border-slate-200 text-slate-700 rounded-tl-none"}`,"data-testid":`onboarding-worknotes-message-bubble-${Ae}`,children:[e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words","data-testid":`onboarding-worknotes-message-text-${Ae}`,children:Bt(fe.noteText)}),fe.attachments&&fe.attachments.length>0&&e.jsx("div",{className:"mt-2 space-y-2 border-t border-slate-100 pt-2","data-testid":`onboarding-worknotes-message-attachments-${Ae}`,children:fe.attachments.map((kt,wt)=>{const Os=kt.mimeType.startsWith("image/");return e.jsx("div",{className:"flex items-center gap-2","data-testid":`onboarding-worknotes-message-attachment-${Ae}-${wt}`,children:Os?e.jsx("div",{className:"rounded-lg overflow-hidden border border-slate-100 max-w-[200px]",children:e.jsx("img",{src:`${Uc}/${kt.filePath.replace(/\\/g,"/")}`,alt:kt.fileName,className:"w-full h-auto cursor-pointer",onClick:()=>ut(kt),"data-testid":`onboarding-worknotes-message-attachment-img-${Ae}-${wt}`})}):kt.mimeType==="application/pdf"?e.jsxs("button",{type:"button",onClick:()=>ut(kt),className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-preview-${Ae}-${wt}`,children:[e.jsx(bu,{className:"w-3 h-3"}),kt.fileName," (Preview)"]}):e.jsxs("a",{href:`${Uc}/${kt.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-link-${Ae}-${wt}`,children:[e.jsx(bu,{className:"w-3 h-3"}),kt.fileName]})},kt.id)})})]})]})]})},fe.id)}),j.length===0&&!R&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"onboarding-worknotes-empty-state",children:[e.jsx(li,{className:"w-16 h-16 text-slate-300 mb-4"}),e.jsx("h3",{className:"text-slate-900 mb-2",children:"No messages yet"}),e.jsx("p",{className:"text-slate-600",children:"Start the conversation by sending a message below"})]}),j.length>0&&Us.length===0&&!R&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-slate-500 text-sm",children:['No messages match "',I.trim(),'". Clear the search box to see the full thread.']}),R&&e.jsx("div",{className:"flex justify-center items-center py-8",children:e.jsx("span",{className:"text-slate-500",children:"Loading notes..."})}),e.jsx("div",{ref:rt})]})}),e.jsx("div",{className:"bg-white border-t border-slate-100 px-6 py-4 shadow-[0_-4px_10px_-5px_rgba(0,0,0,0.05)]","data-testid":"onboarding-worknotes-composer",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-4",children:[Z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mb-3","data-testid":"onboarding-worknotes-attached-files",children:Z.map((fe,Ae)=>{const Fe=fe.mimeType.startsWith("image/")||fe.mimeType==="application/pdf";return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-white rounded-xl border border-slate-200 shadow-sm hover:border-blue-300 transition-all group max-w-[200px]","data-testid":`onboarding-worknotes-attached-file-${Ae}`,children:[e.jsx("div",{className:"w-10 h-10 bg-slate-50 rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden",children:jt(fe.mimeType,fe.filePath)}),e.jsxs("div",{className:"flex-1 min-w-0 pr-6 relative",children:[e.jsx("p",{className:`text-xs font-medium text-slate-700 truncate ${Fe?"hover:text-blue-600 cursor-pointer hover:underline":""}`,onClick:()=>Fe&&ut(fe),children:fe.fileName}),e.jsx("button",{onClick:()=>de(fe.id),className:"absolute -top-1 -right-1 p-1 bg-white rounded-full border border-slate-100 text-slate-400 hover:text-red-500 shadow-sm opacity-0 group-hover:opacity-100 transition-opacity","data-testid":`onboarding-worknotes-remove-attachment-${Ae}`,children:e.jsx(id,{className:"w-3 h-3"})})]})]},fe.id)})}),e.jsxs("div",{className:"flex items-end gap-3 bg-white p-2.5 rounded-2xl border border-slate-200 shadow-sm focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-100 transition-all relative",children:[D&&fs.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 mb-2 w-64 bg-white border border-slate-200 rounded-lg shadow-lg overflow-hidden max-h-48 overflow-y-auto z-50 custom-scrollbar","data-testid":"onboarding-worknotes-mention-suggestions",children:fs.map((fe,Ae)=>e.jsxs("button",{onClick:()=>ge(fe),className:"w-full flex items-center gap-3 px-4 py-2 hover:bg-slate-50 transition-colors text-left","data-testid":`onboarding-worknotes-mention-item-${Ae}`,children:[e.jsx(Nm,{className:"w-8 h-8",children:e.jsx(wm,{className:`${fe.color} text-white text-xs`,children:fe.initials})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-slate-900 text-sm font-medium",children:fe.name})})]},fe.id))}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("input",{type:"file",ref:je,className:"hidden",multiple:!0,onChange:mt}),e.jsx(te,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var fe;return(fe=je.current)==null?void 0:fe.click()},"data-testid":"onboarding-worknotes-attachment-btn",children:e.jsx(bu,{className:"w-5 h-5"})}),e.jsxs(te,{variant:"ghost",size:"icon",className:`w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl relative ${L?"bg-blue-50 text-blue-600":""}`,onClick:()=>$(!L),"data-testid":"onboarding-worknotes-emoji-btn",children:[e.jsx(JI,{className:"w-5 h-5"}),L&&e.jsxs("div",{className:"absolute bottom-12 left-0 z-50 bg-white border border-slate-200 rounded-xl shadow-2xl w-72 animate-in fade-in slide-in-from-bottom-2 overflow-hidden","data-testid":"onboarding-worknotes-emoji-picker",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-100 bg-slate-50 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Emojis"}),e.jsx("button",{onClick:()=>$(!1),className:"text-slate-400 hover:text-slate-600 text-lg leading-none",children:"×"})]}),e.jsx("div",{className:"p-2 grid grid-cols-8 gap-1 max-h-60 overflow-y-auto custom-scrollbar",children:ft.map((fe,Ae)=>e.jsx("button",{className:"w-8 h-8 flex items-center justify-center hover:bg-blue-50 hover:scale-110 rounded-lg transition-all text-lg",onClick:Fe=>{Fe.stopPropagation(),Je(fe)},"data-testid":`onboarding-worknotes-emoji-item-${Ae}`,children:fe},fe))})]})]}),e.jsx(te,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var fe;return(fe=je.current)==null?void 0:fe.click()},children:e.jsx(A1,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 relative",children:e.jsx(it,{ref:ce,type:"text",placeholder:"Type your message... Use @username to mention someone",value:C,onChange:ht,onKeyPress:Zt,className:"w-full pr-4 border-none focus-visible:ring-0 px-0"})}),e.jsx(te,{onClick:at,disabled:!C.trim()&&Z.length===0||W,className:"bg-blue-600 hover:bg-blue-700 text-white rounded-xl h-10 w-10 p-0",children:W?e.jsx("div",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):e.jsx(Gu,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-slate-400 text-[10px] px-1 flex items-center gap-1",children:[e.jsx(qa,{className:"w-3 h-3"}),e.jsxs("span",{children:["Press Enter to send • Use @ to mention • ",W?"Uploading files...":"Files attached appear above"]})]})]})})]}),M&&e.jsxs("div",{className:`w-[280px] lg:w-[320px] bg-slate-50 border-l border-slate-200 flex flex-col transition-all animate-in slide-in-from-right-full ${m==="modal"?"hidden lg:flex":"flex"}`,children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(ja,{className:"w-4 h-4 text-blue-600"}),"Participants",e.jsx(we,{variant:"secondary",className:"bg-slate-100 text-slate-600 ml-1",children:xe.length})]}),e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-600",onClick:()=>z(!1),children:e.jsx(id,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search people...",value:T,onChange:fe=>F(fe.target.value),className:"pl-9 bg-slate-50 border-slate-200 h-9 text-sm rounded-lg focus-visible:bg-white transition-all"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1 custom-scrollbar",children:[xe.filter(fe=>{var Ae;return fe.name.toLowerCase().includes(T.toLowerCase())||((Ae=fe.role)==null?void 0:Ae.toLowerCase().includes(T.toLowerCase()))}).map(fe=>{const Ae=!!fe.revokedAt,Fe=["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")&&!Ae&&fe.id!==(s==null?void 0:s.id);return e.jsxs("div",{className:Nt("group flex items-start gap-3 p-3 rounded-xl transition-all cursor-default border border-transparent",Ae?"opacity-50 bg-slate-100 grayscale-[0.5]":"hover:bg-white hover:shadow-sm hover:border-slate-100"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Nm,{className:Nt("w-10 h-10 ring-2 ring-transparent transition-all",!Ae&&"group-hover:ring-blue-100"),children:e.jsx(wm,{className:`${fe.color} text-white text-xs font-bold`,children:fe.initials})}),fe.isOnline&&!Ae&&e.jsx("span",{className:"absolute bottom-0 right-0 w-3 h-3 bg-green-500 border-2 border-slate-50 rounded-full shadow-sm"}),Ae&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-100 rounded-full p-0.5 border border-white",children:e.jsx(gg,{className:"w-2.5 h-2.5 text-red-600"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:Nt("text-sm font-semibold truncate",Ae?"text-slate-500 line-through":"text-slate-900"),children:fe.name}),Ae&&e.jsx(we,{variant:"outline",className:"text-[8px] h-3.5 px-1 bg-red-50 text-red-600 border-red-100",children:"Revoked"})]}),fe.id===(s==null?void 0:s.id)&&e.jsx(we,{variant:"outline",className:"text-[9px] h-4 px-1 border-blue-200 text-blue-600 bg-blue-50",children:"You"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 font-medium uppercase tracking-wider mb-1",children:fe.role}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate italic",children:fe.email})]}),Fe&&e.jsx(te,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-300 hover:text-red-600 hover:bg-red-50 opacity-0 group-hover:opacity-100 transition-all self-center",onClick:()=>ot(fe),children:e.jsx(gg,{className:"w-3.5 h-3.5"})}),!Fe&&!Ae&&e.jsx(mi,{className:"w-4 h-4 text-slate-300 group-hover:text-slate-400 opacity-0 group-hover:opacity-100 transition-all self-center"})]},fe.id)}),xe.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center opacity-50",children:[e.jsx(ja,{className:"w-8 h-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-xs text-slate-500",children:"No participants found"})]})]}),e.jsxs("div",{className:"p-4 bg-white border-t border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest",children:"Active Session"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-slate-50 border border-slate-100",children:[e.jsx(dn,{className:"w-4 h-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 font-medium uppercase",children:"Last Activity"}),e.jsx("p",{className:"text-xs text-slate-900 font-semibold",children:"Just now"})]})]})]})]})]}),e.jsx(ms,{open:!!Me,onOpenChange:fe=>!fe&&ut(null),children:e.jsxs(us,{className:"max-w-6xl h-[90vh] flex flex-col p-4",children:[e.jsx(ys,{children:e.jsxs(gs,{className:"flex items-center gap-2",children:[Me&&jt(Me.mimeType),e.jsx("span",{className:"truncate",children:Me==null?void 0:Me.fileName})]})}),e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg bg-slate-100 flex items-center justify-center p-4",children:Me!=null&&Me.mimeType.startsWith("image/")?e.jsx("img",{src:`${Uc}/${Me.filePath.replace(/\\/g,"/")}`,className:"max-w-full max-h-full object-contain",alt:"Preview"}):(Me==null?void 0:Me.mimeType)==="application/pdf"?e.jsx("iframe",{src:`${Uc}/${Me.filePath.replace(/\\/g,"/")}`,className:"w-full h-full border-none",title:"PDF Preview"}):e.jsxs("div",{className:"text-center",children:[e.jsx(rf,{className:"w-16 h-16 text-slate-300 mx-auto mb-4"}),e.jsx("p",{className:"text-slate-500",children:"Preview not available for this file type."}),e.jsx("a",{href:`${Uc}/${Me==null?void 0:Me.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline text-sm",children:"Open in new tab"})]})})]})}),e.jsx(ms,{open:!!G,onOpenChange:fe=>!fe&&V(null),children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl [&>button]:text-white [&>button]:opacity-100",children:[e.jsxs("div",{className:"bg-gradient-to-br from-red-600 to-red-700 p-6 text-white text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-white/20 rounded-full flex items-center justify-center mx-auto mb-4 border border-white/30 backdrop-blur-sm animate-pulse",children:e.jsx(gg,{className:"w-8 h-8 text-white"})}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"Revoke Participant Access?"}),e.jsxs("p",{className:"text-red-100 text-sm",children:["You are about to revoke access for ",e.jsx("span",{className:"font-bold text-white",children:G==null?void 0:G.name}),". They will no longer be able to view or interact with this request."]})]}),e.jsxs("div",{className:"p-6 bg-white space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest",children:"Reason for Revocation"}),e.jsx(it,{value:Y,onChange:fe=>re(fe.target.value),placeholder:"e.g. Roles changed, Case transferred...",className:"bg-slate-50 border-slate-200 focus:bg-white transition-all h-11"})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(te,{variant:"outline",className:"flex-1 h-11 border-slate-200 text-slate-600 hover:bg-slate-50",onClick:()=>V(null),children:"Cancel"}),e.jsxs(te,{className:"flex-1 h-11 bg-red-600 hover:bg-red-700 text-white font-bold shadow-lg shadow-red-200",onClick:ke,disabled:ae,children:[ae?e.jsx(cl,{className:"w-4 h-4 animate-spin mr-2"}):null,"Revoke Access"]})]})]})]})})]})}const Gb="!w-[80vw] !max-w-[80vw] sm:!max-w-[80vw]",ho=({isOpen:t,onClose:s,document:n})=>{var i;const a=n?`http://localhost:5000${n.filePath.startsWith("/")?"":"/"}${n.filePath}`:"";return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsx(us,{className:`${Gb} h-[85vh] flex flex-col p-0 overflow-hidden bg-white shadow-2xl border-none`,children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-red-50 flex items-center justify-center border border-red-200",children:e.jsx(un,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(gs,{className:"text-sm font-bold text-slate-900 leading-none mb-1",children:n.fileName}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium uppercase tracking-wider",children:n.documentType})]})]}),e.jsx("div",{className:"flex items-center gap-2 pr-10",children:e.jsxs(te,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:()=>window.open(a,"_blank"),children:[e.jsx(fi,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Download"})]})})]}),e.jsx("div",{className:"flex-1 bg-slate-100 relative overflow-hidden flex items-center justify-center p-4",children:(i=n.fileName)!=null&&i.toLowerCase().endsWith(".pdf")?e.jsx("iframe",{src:`${a}#toolbar=0`,className:"w-full h-full bg-white shadow-inner rounded-sm",title:"Preview"}):e.jsx("img",{src:a,className:"max-h-full max-w-full object-contain shadow-lg rounded-sm",alt:"Preview"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-slate-400",children:"Loading document..."})})})};function lq(){var W,U,M,z;const{id:t}=gd(),s=tr(),[n,r]=g.useState(null),[a,i]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState(!1),[p,h]=g.useState(""),[x,u]=g.useState("details"),[N,v]=g.useState(!1),[w,j]=g.useState(null),[b,C]=g.useState(!1),[S,D]=g.useState(!1),[_,A]=g.useState(""),E=Pn(T=>T.auth.user),q=(E==null?void 0:E.role)==="FDD";g.useEffect(()=>{t&&O()},[t]);const O=async()=>{var T,F,I,K;d(!0);try{const[G,V]=await Promise.all([Re.getApplicationById(t),Re.getFddAssignment(t)]);(T=G.data)!=null&&T.success&&r(G.data.data),(F=V.data)!=null&&F.success&&i(V.data.data)}catch(G){console.error("Error fetching application:",G);const V=((K=(I=G.response)==null?void 0:I.data)==null?void 0:K.message)||"Access Denied: Not authorized for FDD access";J.error(V),s("/fdd-dashboard")}finally{d(!1)}},R=async T=>{var K,G,V;const F=(K=T.target.files)==null?void 0:K[0];if(!F||!p){p||J.error("Please select a document type first");return}f(!0);const I=new FormData;I.append("file",F),I.append("documentType",p),I.append("stage","FDD"),I.append("applicationId",t),I.append("requestType","application");try{const Y=await Re.uploadDocument(t,I);if((G=Y.data)!=null&&G.success){if(p==="FDD Final Audit Report"){const re=((V=Y.data.data)==null?void 0:V.id)||Y.data.id;await Re.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:re,findings:"Final Audit Report submitted.",recommendation:"REVIEW_PENDING"})}J.success(`${p} uploaded successfully`),O(),h("")}}catch{J.error("Failed to upload document")}finally{f(!1)}},P=T=>{if(!T||!T.filePath){J.error("Document source file not found");return}j({fileName:T.originalName||T.fileName||"Document",filePath:T.filePath,documentType:T.documentType,createdAt:T.createdAt,mimeType:T.mimeType}),v(!0)};if(o)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-[70vh] bg-slate-50/50 rounded-2xl border border-slate-200 border-dashed",children:[e.jsx(cs,{className:"w-12 h-12 animate-spin text-blue-600 mb-4"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Authenticating and loading secure data..."})]});if(!n)return null;const L=n.currentStage==="FDD_VERIFICATION"||n.currentStage==="FDD",$=(a==null?void 0:a.status)==="Report Submitted",Z=!L&&(n.overallStatus!=="Active"||n.currentProgress>=75)||$,Q=!L&&n.currentProgress<70&&!$;return e.jsxs("div",{className:"flex flex-col gap-6 max-w-7xl mx-auto mb-10",children:[(n==null?void 0:n.statutoryStatus)==="Flagged"&&e.jsxs("div",{className:"bg-red-50 border border-red-200 p-4 rounded-xl flex items-center gap-4 animate-in fade-in slide-in-from-top-4 duration-500","data-testid":"onboarding-fdd-details-flag-banner",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-lg",children:e.jsx(Ba,{className:"w-5 h-5 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-red-900 leading-none",children:"APPLICATION FLAGGED BY YOU"}),e.jsx("p",{className:"text-red-700 text-[10px] font-bold uppercase tracking-wider mt-1 opacity-80",children:"Marked as non-responsive for follow-up by DD Team"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>s("/fdd-dashboard"),className:"flex items-center gap-2 text-slate-600 hover:text-slate-900 font-medium transition-all group","data-testid":"onboarding-fdd-details-back-btn",children:[e.jsx("div",{className:"p-2 rounded-full group-hover:bg-slate-100 transition-colors",children:e.jsx(Wr,{className:"w-5 h-5"})}),"Back to Dashboard"]}),e.jsx("div",{className:"flex items-center gap-3",children:Q?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-100 border border-slate-200 text-slate-500 font-bold text-[10px] uppercase tracking-[0.1em] rounded-lg","data-testid":"onboarding-fdd-details-awaiting-badge",children:[e.jsx(dn,{className:"w-4 h-4"}),"Awaiting Previous Stages"]}):Z?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-50 border border-green-200 text-green-700 font-bold text-[10px] uppercase tracking-[0.1em] rounded-lg shadow-inner","data-testid":"onboarding-fdd-details-submitted-badge",children:[e.jsx(Hn,{className:"w-4 h-4"}),"Final Audit Report Submitted"]}):e.jsx(e.Fragment,{children:q&&e.jsxs("button",{disabled:m,onClick:()=>D(!0),className:"px-4 py-2 bg-red-50 text-red-600 font-bold text-xs uppercase tracking-wider hover:bg-red-100 rounded-lg transition-all flex items-center gap-2 border border-red-100 shadow-sm","data-testid":"onboarding-fdd-details-flag-btn",children:[e.jsx(Ba,{className:"w-4 h-4"}),"Flag Non-Responsive"]})})})]}),e.jsx(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-header",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 bg-slate-900 text-white rounded-lg flex items-center justify-center font-bold text-xl","data-testid":"onboarding-fdd-details-avatar",children:n.applicantName.charAt(0)}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-900 tracking-tight","data-testid":"onboarding-fdd-details-name",children:n.applicantName}),e.jsx(we,{variant:"outline",className:"text-slate-500 font-medium px-2 py-0","data-testid":"onboarding-fdd-details-id-badge",children:n.applicationId})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-slate-500","data-testid":"onboarding-fdd-details-meta",children:[e.jsxs("span",{children:[n.city,", ",n.state]}),e.jsx("span",{className:"text-slate-300",children:"•"}),e.jsx("span",{children:n.businessType||"Dealership"})]})]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-right hidden md:block",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Status"}),e.jsx("p",{className:"text-sm font-bold text-slate-700",children:"Financial Due Diligence"})]})})]})})}),e.jsxs("div",{className:"flex items-center gap-8 border-b border-slate-200","data-testid":"onboarding-fdd-details-tabs",children:[e.jsxs("button",{onClick:()=>u("details"),className:`pb-3 text-sm font-semibold transition-all relative ${x==="details"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-workspace",children:["Workspace",x==="details"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]}),e.jsxs("button",{onClick:()=>u("worknotes"),className:`pb-3 text-sm font-semibold transition-all relative ${x==="worknotes"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-worknotes",children:[e.jsx("div",{className:"flex items-center gap-2",children:"Work Notes"}),x==="worknotes"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]})]}),x==="details"?e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsxs(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-workspace-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 py-4",children:e.jsxs(st,{className:"text-base font-bold flex items-center gap-2 text-slate-800",children:[e.jsx(vr,{className:"w-4 h-4 text-slate-500"}),Z?"Finalized Financial Reports":Q?"Audit Workspace":"Financial Report Submission"]})}),e.jsxs(Oe,{className:"p-6",children:[Q&&e.jsxs("div",{className:"mb-6 p-8 bg-slate-50 border border-dashed border-slate-200 rounded-xl flex flex-col items-center justify-center text-center","data-testid":"onboarding-fdd-details-not-active",children:[e.jsx("div",{className:"w-16 h-16 bg-white rounded-full flex items-center justify-center text-slate-300 mb-4 shadow-sm",children:e.jsx(dn,{className:"w-8 h-8"})}),e.jsx("h4",{className:"text-lg font-bold text-slate-900 mb-2",children:"Stage Not Yet Active"}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm mb-6",children:"This application is still being processed in previous documentation or interview stages. The FDD workspace will activate once the previous stages are approved."}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-slate-400 uppercase tracking-widest px-4 py-1.5 bg-white rounded-full border border-slate-200",children:["Status: ",n.status||"Pending Review"]})]}),Z&&e.jsxs("div",{className:"mb-6 p-4 bg-green-50/50 border border-green-100 rounded-xl flex items-center gap-4","data-testid":"onboarding-fdd-details-completed-alert",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-full flex items-center justify-center text-green-600 shrink-0",children:e.jsx(Hn,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-green-800",children:"Verification Stage Completed"}),e.jsx("p",{className:"text-[11px] text-green-600 font-medium",children:"The FDD report has been submitted and the case is now locked for further audits."})]})]}),!Z&&!Q&&e.jsxs("div",{className:"p-10 border-2 border-dashed border-slate-200 rounded-lg flex flex-col items-center justify-center text-center","data-testid":"onboarding-fdd-details-upload-section",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-50 text-slate-400 rounded-full flex items-center justify-center mb-4",children:e.jsx(ks,{className:"w-6 h-6"})}),e.jsx("p",{className:"text-slate-600 font-medium mb-1","data-testid":"onboarding-fdd-details-upload-title",children:q?"Select and upload the due diligence report":"View Authorized Documents"}),e.jsx("p",{className:"text-slate-400 text-xs mb-6","data-testid":"onboarding-fdd-details-upload-hint",children:q?"PDF or JPG formats accepted (Max 10MB)":"You are in View-Only mode for this Audit"}),q&&e.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[e.jsxs("select",{value:p,onChange:T=>h(T.target.value),className:"w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded text-sm font-medium text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 transition-all","data-testid":"onboarding-fdd-details-doc-type-select",children:[e.jsx("option",{value:"",children:"Select Document Category..."}),e.jsx("option",{value:"FDD Final Audit Report",children:"FDD Final Audit Report"}),e.jsx("option",{value:"Bank Statement",children:"Bank Statement"}),e.jsx("option",{value:"Income Tax Returns (ITR)",children:"Income Tax Returns (ITR)"}),e.jsx("option",{value:"CIBIL Report",children:"CIBIL Report"}),e.jsx("option",{value:"Business Valuation Report",children:"Business Valuation Report"}),e.jsx("option",{value:"Property Documents",children:"Property Documents"})]}),e.jsx("div",{className:"relative",children:m?e.jsxs("div",{className:"w-full py-2.5 bg-slate-100 rounded flex items-center justify-center gap-2","data-testid":"onboarding-fdd-details-uploading-state",children:[e.jsx(cs,{className:"w-4 h-4 animate-spin text-slate-400"}),e.jsx("span",{className:"text-slate-500 text-xs font-bold uppercase tracking-wider",children:"Uploading..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",className:"absolute inset-0 opacity-0 cursor-pointer",onChange:R,disabled:!p,"data-testid":"onboarding-fdd-details-file-input"}),e.jsx("div",{className:`w-full py-2.5 text-center font-bold uppercase tracking-wider text-xs rounded transition-all ${p?"bg-slate-900 text-white hover:bg-slate-800":"bg-slate-100 text-slate-300"}`,"data-testid":"onboarding-fdd-details-browse-btn",children:"Browse & Upload"})]})})]})]}),e.jsxs("div",{className:"mt-8 border-t border-slate-100 pt-8","data-testid":"onboarding-fdd-details-documents-section",children:[e.jsx("h3",{className:"text-sm font-bold text-slate-800 mb-4 px-1",children:"Submitted Documentation"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-testid":"onboarding-fdd-details-applicant-docs",children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500"}),"Applicant's KYC & Financials"]}),e.jsxs("div",{className:"space-y-2",children:[(W=n.uploadedDocuments)==null?void 0:W.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").map((T,F)=>{var I;return e.jsxs("div",{className:"p-3 border border-slate-100 rounded flex items-center justify-between hover:bg-slate-50 transition-all group","data-testid":`onboarding-fdd-details-applicant-doc-row-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-slate-100 flex items-center justify-center text-slate-400 group-hover:bg-white transition-colors",children:e.jsx(ks,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs font-bold text-slate-900","data-testid":`onboarding-fdd-details-applicant-doc-name-${F}`,children:T.originalName||T.fileName}),e.jsx("span",{className:"text-[8px] bg-slate-100 text-slate-500 px-1 py-0.5 rounded uppercase font-bold tracking-tighter",children:"APPLICANT"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-medium","data-testid":`onboarding-fdd-details-applicant-doc-meta-${F}`,children:[T.documentType," • ",Qt(T.createdAt),((I=T.uploader)==null?void 0:I.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>P(T),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-blue-600 transition-all","data-testid":`onboarding-fdd-details-applicant-doc-preview-${F}`,children:e.jsx(un,{className:"w-4 h-4"})})})]},F)}),((U=n.uploadedDocuments)==null?void 0:U.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").length)===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic px-1","data-testid":"onboarding-fdd-details-applicant-docs-empty",children:"No documents from applicant yet."})]})]}),e.jsxs("div",{"data-testid":"onboarding-fdd-details-my-submissions",children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"My Uploaded Reports"]}),e.jsxs("div",{className:"space-y-2",children:[(M=n.uploadedDocuments)==null?void 0:M.filter(T=>{var F;return((F=T.uploader)==null?void 0:F.roleCode)==="FDD"}).map((T,F)=>{var I;return e.jsxs("div",{className:"p-3 border border-red-100 bg-red-50/30 rounded flex items-center justify-between hover:bg-red-50 transition-all group","data-testid":`onboarding-fdd-details-my-report-row-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-red-50 flex items-center justify-center text-re-red",children:e.jsx(ks,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs font-bold text-slate-900","data-testid":`onboarding-fdd-details-my-report-name-${F}`,children:T.originalName||T.fileName}),e.jsx("span",{className:"text-[8px] bg-red-500 text-white px-1 py-0.5 rounded uppercase font-bold tracking-tighter",children:"YOUR AUDIT REPORT"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 font-medium","data-testid":`onboarding-fdd-details-my-report-meta-${F}`,children:[T.documentType," • ",Qt(T.createdAt),((I=T.uploader)==null?void 0:I.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>P(T),className:"p-1.5 hover:bg-white rounded text-slate-400 hover:text-re-red transition-all","data-testid":`onboarding-fdd-details-my-report-preview-${F}`,children:e.jsx(un,{className:"w-4 h-4"})})})]},F)}),((z=n.uploadedDocuments)==null?void 0:z.filter(T=>{var F;return((F=T.uploader)==null?void 0:F.roleCode)==="FDD"}).length)===0&&e.jsx("div",{className:"text-center py-4 bg-slate-50 border border-dashed border-slate-200 rounded-lg","data-testid":"onboarding-fdd-details-my-submissions-empty",children:e.jsx("p",{className:"text-slate-400 text-[10px]",children:"No audit reports uploaded yet."})})]})]})]})]})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-profile-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(st,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Applicant Profile"})}),e.jsxs(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-1 pb-3 border-b border-slate-50","data-testid":"onboarding-fdd-details-target-loc",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Target Location"}),e.jsxs("p",{className:"text-sm font-extrabold text-slate-900",children:[n.city,", ",n.state]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs","data-testid":"onboarding-fdd-details-profile-meta",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Education"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.education||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Experience"}),e.jsxs("p",{className:"font-bold text-slate-800",children:[n.experienceYears||"0"," Years"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Investment Cap"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.investmentCapacity||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Age"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.age||"N/A"})]})]}),e.jsxs("div",{className:"space-y-1 pt-3 border-t border-slate-50 text-xs","data-testid":"onboarding-fdd-details-communication",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Communication"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.email}),e.jsx("p",{className:"text-slate-500 font-medium",children:n.phone})]})]})]}),e.jsxs(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-statutory-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(st,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Statutory Details"})}),e.jsx(Oe,{className:"p-5 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2.5 text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Constitution Type"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.constitutionType||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"PAN Number"}),e.jsx("p",{className:"font-bold text-slate-800 uppercase tracking-tight",children:n.panNumber||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"GST Number"}),e.jsx("p",{className:"font-bold text-slate-800 uppercase tracking-tight",children:n.gstNumber||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Registered Address"}),e.jsx("p",{className:"font-medium text-slate-700 leading-relaxed text-[11px]",children:n.registeredAddress||"N/A"})]})]})})]}),e.jsxs(_e,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-bank-card",children:[e.jsx(Xe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(st,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Bank Details"})}),e.jsx(Oe,{className:"p-5 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2.5 text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Account Holder"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.accountHolderName||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Bank Name"}),e.jsx("p",{className:"font-bold text-slate-800",children:n.bankName||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"Account Number"}),e.jsx("p",{className:"font-bold text-slate-800 tabular-nums",children:n.accountNumber||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider",children:"IFSC Code & Branch"}),e.jsxs("p",{className:"font-bold text-slate-800 uppercase tracking-tight",children:[n.ifscCode||"N/A",n.branchName&&e.jsxs("span",{className:"text-slate-400 font-medium ml-2",children:["— ",n.branchName]})]})]})]})})]}),e.jsxs("div",{className:"p-6 bg-slate-900 rounded-lg text-white font-medium","data-testid":"onboarding-fdd-details-instructions",children:[e.jsx("h4",{className:"text-sm font-bold mb-2",children:"Instructions"}),e.jsxs("ul",{className:"text-xs text-slate-300 space-y-2 list-disc pl-4",children:[e.jsx("li",{children:"Bank statements must cover 12 months."}),e.jsx("li",{children:"GST discrepancies must be noted."}),e.jsx("li",{children:"Verify property papers with originals."})]})]})]})]}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 min-h-[600px] overflow-hidden",children:e.jsx(LE,{onBack:()=>u("details"),requestId:t,requestType:"application"})}),e.jsx(ho,{isOpen:N,onClose:()=>v(!1),document:w}),e.jsx(ms,{open:b,onOpenChange:C,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl","data-testid":"onboarding-fdd-details-finalize-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-6 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-re-red/20 to-transparent"}),e.jsx("div",{className:"w-16 h-16 bg-re-red/20 rounded-full flex items-center justify-center animate-pulse relative z-10",children:e.jsx(so,{className:"w-8 h-8 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-finalize-title",children:"Submit Audit Report"}),e.jsxs(ws,{className:"text-slate-500 text-center pt-2 leading-relaxed text-base","data-testid":"onboarding-fdd-details-finalize-desc",children:["You are about to submit your final findings. This action will ",e.jsx("span",{className:"font-bold text-slate-800 underline decoration-re-red decoration-2",children:"notify the Admin"})," for review and approval."]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-xl flex gap-3 border border-red-100 italic","data-testid":"onboarding-fdd-details-finalize-info",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-red-800 leading-normal",children:"Once submitted, you cannot edit the findings. Ensure all documents are uploaded."})]}),e.jsx("div",{className:"space-y-4 pt-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Detailed Audit Findings & Remarks"}),e.jsx(Ks,{placeholder:"Enter detailed financial observations...",className:"min-h-[120px] bg-slate-50 border-slate-200 rounded-xl focus:ring-re-red text-sm resize-none",value:_,onChange:T=>A(T.target.value),"data-testid":"onboarding-fdd-details-finalize-remarks"})]})}),e.jsxs(mn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(te,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>C(!1),disabled:m,"data-testid":"onboarding-fdd-details-finalize-cancel",children:"Cancel"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-2 border-re-red","data-testid":"onboarding-fdd-details-finalize-confirm",onClick:async()=>{var T,F;try{if(!_.trim()){J.error("Please provide findings.");return}f(!0);const I=(T=a==null?void 0:a.reports)==null?void 0:T[0];(F=(await Re.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:I==null?void 0:I.reportDocumentId,findings:_,recommendation:null})).data)!=null&&F.success&&(J.success("FDD Report submitted successfully."),C(!1),O())}catch{J.error("Failed to submit report")}finally{f(!1)}},disabled:m,children:m?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ms,{open:S,onOpenChange:D,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl","data-testid":"onboarding-fdd-details-flag-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-6 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-600/20 to-transparent"}),e.jsx("div",{className:"w-16 h-16 bg-red-600/20 rounded-full flex items-center justify-center relative z-10",children:e.jsx(Ba,{className:"w-8 h-8 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-flag-modal-title",children:"Flag Applicant"}),e.jsxs(ws,{className:"text-slate-500 text-center pt-2 leading-relaxed text-base","data-testid":"onboarding-fdd-details-flag-modal-desc",children:["Are you sure you want to flag this applicant as ",e.jsx("span",{className:"font-bold text-red-600",children:"Non-Responsive"}),"?"]})]}),e.jsx("div",{className:"bg-red-50 p-4 rounded-xl flex gap-3 border border-red-100 italic",children:e.jsx("p",{className:"text-xs text-red-800 leading-normal text-center w-full","data-testid":"onboarding-fdd-details-flag-modal-text",children:'"Applicant is non-responsive to FDD queries."'})}),e.jsxs(mn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(te,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>D(!1),disabled:m,"data-testid":"onboarding-fdd-details-flag-modal-cancel",children:"Go Back"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-2 border-red-600","data-testid":"onboarding-fdd-details-flag-modal-confirm",onClick:async()=>{try{f(!0),await Re.flagNonResponsive({applicationId:t,remarks:"Applicant is non-responsive to FDD queries."}),J.error("Application flagged for non-responsiveness."),D(!1),O()}catch{J.error("Action failed")}finally{f(!1)}},disabled:m,children:m?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Flag Applicant"})]})]})]})})]})}const Yl={getOperationsDashboard:async t=>(await Re.getSlaOperationsDashboard(t)).data,getBatchStatus:async t=>(await Re.postSlaBatchStatus({items:t})).data,exportOperationsCsv:async t=>{const s="https://dealeronboarding-uat.royalenfield.com/api",n=new URLSearchParams;t!=null&&t.module&&n.set("module",t.module),t!=null&&t.mineOnly&&n.set("mineOnly","true");const r=localStorage.getItem("token"),a=await fetch(`${s}/sla/operations/export?${n.toString()}`,{headers:r?{Authorization:`Bearer ${r}`}:{}});if(!a.ok)throw new Error("Export failed");const i=await a.blob(),o=URL.createObjectURL(i),d=document.createElement("a");d.href=o,d.download=`sla-queue-${Date.now()}.csv`,d.click(),URL.revokeObjectURL(o)},getQuestionnaireReminderSettings:async()=>(await Re.getQuestionnaireReminderSettings()).data,updateQuestionnaireReminderSettings:async t=>(await Re.updateQuestionnaireReminderSettings(t)).data},oq={healthy:"bg-emerald-100 text-emerald-800 border-emerald-200",warning:"bg-red-50 text-red-800 border-red-200",critical:"bg-orange-100 text-orange-800 border-orange-200",breached:"bg-red-100 text-red-800 border-red-200"},cq={healthy:"On track",warning:"Due soon",critical:"At risk",breached:"Breached"};function br({status:t,compact:s}){if(!t)return null;const n=t.isPaused?"warning":t.bucket,r=t.isPaused?"Paused":cq[t.bucket];return e.jsx(we,{variant:"outline",className:`text-[10px] font-semibold ${oq[n]} ${s?"px-1.5":""}`,title:`${t.stageName} · ${t.remainingLabel} (${t.percentUsed}% of TAT)`,children:s?r:`${r} · ${t.remainingLabel}`})}function dq(t,s=[]){let n=[];function r(i,o){const d=g.createContext(o);d.displayName=i+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:x,children:u,...N}=h,v=((j=x==null?void 0:x[t])==null?void 0:j[m])||d,w=g.useMemo(()=>N,Object.values(N));return e.jsx(v.Provider,{value:w,children:u})};f.displayName=i+"Provider";function p(h,x){var v;const u=((v=x==null?void 0:x[t])==null?void 0:v[m])||d,N=g.useContext(u);if(N)return N;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const a=()=>{const i=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||i;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,uq(a,...s)]}function uq(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(i)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var hq=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],IE=hq.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Kb="Progress",Yb=100,[mq]=dq(Kb),[fq,pq]=mq(Kb),ME=g.forwardRef((t,s)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=xq,...o}=t;(a||a===0)&&!jS(a)&&console.error(gq(`${a}`,"Progress"));const d=jS(a)?a:Yb;r!==null&&!NS(r,d)&&console.error(vq(`${r}`,"Progress"));const m=NS(r,d)?r:null,f=gf(m)?i(m,d):void 0;return e.jsx(fq,{scope:n,value:m,max:d,children:e.jsx(IE.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":gf(m)?m:void 0,"aria-valuetext":f,role:"progressbar","data-state":$E(m,d),"data-value":m??void 0,"data-max":d,...o,ref:s})})});ME.displayName=Kb;var FE="ProgressIndicator",BE=g.forwardRef((t,s)=>{const{__scopeProgress:n,...r}=t,a=pq(FE,n);return e.jsx(IE.div,{"data-state":$E(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:s})});BE.displayName=FE;function xq(t,s){return`${Math.round(t/s*100)}%`}function $E(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function gf(t){return typeof t=="number"}function jS(t){return gf(t)&&!isNaN(t)&&t>0}function NS(t,s){return gf(t)&&!isNaN(t)&&t<=s&&t>=0}function gq(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Yb}\`.`}function vq(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be:
|
||
- a positive number
|
||
- less than the value passed to \`max\` (or ${Yb} if no \`max\` prop is set)
|
||
- \`null\` or \`undefined\` if the progress is indeterminate.
|
||
|
||
Defaulting to \`null\`.`}var yq=ME,bq=BE;function oc({className:t,indicatorClassName:s,value:n,...r}){return e.jsx(yq,{"data-slot":"progress",className:Nt("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...r,children:e.jsx(bq,{"data-slot":"progress-indicator",className:Nt("bg-primary h-full w-full flex-1 transition-all",s),style:{transform:`translateX(-${100-(n||0)}%)`}})})}const jq=["Rejected","Revoked","Withdrawn"];function Ad(t,s){const n=String(t||""),r=String(s||"");return jq.some(a=>n.includes(a)||r===a)}function Zb(t,s){const n=String(t||""),r=String(s||"");return n==="Completed"||r==="Completed"||n==="Settled"||n==="Onboarded"||n==="Verified"||n==="Closed"}function Nq(t,s){return Zb(t,s)?"success":Ad(t,s)?"negative":"inProgress"}const lr={inProgress:{bar:"bg-status-progress",barBadge:"bg-status-progress hover:bg-status-progress-hover text-white border-transparent",badge:"bg-status-progress-soft text-status-progress-strong border-status-progress",badgeSolid:"bg-status-progress hover:bg-status-progress-hover text-white border-transparent",text:"text-status-progress-muted",textStrong:"text-status-progress-strong",icon:"text-status-progress",workflowIcon:"bg-status-workflow-icon",workflowPanel:"bg-status-workflow-panel -ml-4 pl-4 pr-4 py-3 rounded-lg border border-status-workflow-panel",workflowTitle:"text-status-progress-strong",workflowSubtitle:"text-status-progress-muted",workflowStageBadge:"bg-status-workflow-badge border",panel:"bg-status-workflow-panel -ml-4 pl-4 pr-4 py-3 rounded-lg border border-status-workflow-panel",title:"text-status-progress-strong",subtitle:"text-status-progress-muted",stageBadge:"bg-status-workflow-badge border",progress:"bg-status-progress",workflowActive:"bg-status-workflow-active"},success:{bar:"bg-green-600",barBadge:"bg-green-600 hover:bg-green-700 text-white border-transparent",badge:"bg-green-100 text-green-800 border-green-200",badgeSolid:"bg-green-600 hover:bg-green-700 text-white border-transparent",text:"text-green-700",textStrong:"text-green-900",icon:"text-green-600",workflowIcon:"bg-green-100 text-green-600",workflowPanel:"bg-green-50 border border-green-200",workflowTitle:"text-green-900",workflowSubtitle:"text-green-700",workflowStageBadge:"bg-green-100 text-green-700 border-green-300",panel:"bg-green-50 border border-green-200",title:"text-green-900",subtitle:"text-green-700",stageBadge:"bg-green-100 text-green-700 border-green-300",progress:"bg-green-600",workflowActive:"bg-green-600 border-green-600"},negative:{bar:"bg-re-red",barBadge:"bg-re-red hover:bg-re-red-hover text-white border-transparent",badge:"bg-red-50 text-re-red border-red-200",badgeSolid:"bg-re-red hover:bg-re-red-hover text-white border-transparent",text:"text-re-red-hover",textStrong:"text-red-900",icon:"text-re-red",workflowIcon:"bg-red-100 text-re-red",workflowPanel:"bg-red-50 border border-red-200",workflowTitle:"text-red-900",workflowSubtitle:"text-re-red-hover",workflowStageBadge:"bg-red-50 text-re-red border-red-200",panel:"bg-red-50 border border-red-200",title:"text-red-900",subtitle:"text-re-red-hover",stageBadge:"bg-red-50 text-re-red border-red-200",progress:"bg-re-red",workflowActive:"bg-re-red border-re-red"},neutral:{bar:"bg-slate-300",barBadge:"bg-slate-500 text-white border-transparent",badge:"bg-slate-100 text-slate-700 border-slate-200",badgeSolid:"bg-slate-600 hover:bg-slate-700 text-white border-transparent",text:"text-slate-600",textStrong:"text-slate-900",icon:"text-slate-500",workflowIcon:"bg-slate-100 text-slate-400",workflowPanel:"",workflowTitle:"text-slate-900",workflowSubtitle:"text-slate-600",workflowStageBadge:"bg-slate-100 text-slate-500 border-slate-300",panel:"",title:"text-slate-900",subtitle:"text-slate-600",stageBadge:"bg-slate-100 text-slate-500 border-slate-300",progress:"bg-slate-300",workflowActive:"bg-slate-400 border-slate-400"}};function qE(t,s){return lr[Nq(t,s)]}function fl(t,s){return qE(t,s).bar}function wq(t,s){return qE(t,s).barBadge}function Sq(t){return t>=100?lr.success.bar:lr.inProgress.bar}function Cq(t){return t>=100?lr.success.barBadge:lr.inProgress.barBadge}function zE(t){const s=String(t||""),n=s.toUpperCase();return s.includes("Rejected")||n.includes("DOCUMENT_REJECTED")?lr.negative.badge:s==="Verified"||s==="Completed"||n.includes("DOCUMENT_VERIFIED")?lr.success.badge:s.includes("Pending")||s.includes("Review")||s==="In Progress"?lr.inProgress.badge:lr.neutral.badge}function Qb(t,s){return Zb(t,s)?lr.success.badge:(Ad(t,s),lr.negative.badge)}function Xb(t,s){return Zb(t,s)?lr.success.badgeSolid:(Ad(t,s),lr.negative.badgeSolid)}function Jl(t,s){const n=String(t||""),r=String(s||"");return Ad(r,n)||/rejected|revoked/i.test(n)?lr.negative.badge:n==="Completed"||r==="Completed"||n==="Closed"?lr.success.badge:lr.negative.badge}function up({value:t,status:s,currentStage:n,barClassName:r="h-2 w-20 bg-status-progress-soft",showPercent:a=!1,percentClassName:i="text-slate-600 shrink-0","data-testid":o}){return e.jsxs("div",{className:Nt("flex items-center gap-2 min-w-0",a&&"w-full max-w-[8rem]"),"data-testid":o?`${o}-container`:void 0,children:[e.jsx(oc,{value:t,className:r,indicatorClassName:fl(s,n),"data-testid":o}),a&&e.jsxs("span",{className:i,"data-testid":o?`${o}-text`:void 0,children:[t,"%"]})]})}function mo({className:t,...s}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:Nt("mx-auto flex w-full justify-center",t),...s})}function fo({className:t,...s}){return e.jsx("ul",{"data-slot":"pagination-content",className:Nt("flex flex-row items-center gap-1",t),...s})}function pn({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function $i({className:t,isActive:s,size:n="icon",...r}){return e.jsx("a",{"aria-current":s?"page":void 0,"data-slot":"pagination-link","data-active":s,className:Nt(nd({variant:s?"outline":"ghost",size:n}),t),...r})}function po({className:t,...s}){return e.jsxs($i,{"aria-label":"Go to previous page",size:"default",className:Nt("gap-1 px-2.5 sm:pl-2.5",t),...s,children:[e.jsx(io,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function xo({className:t,...s}){return e.jsxs($i,{"aria-label":"Go to next page",size:"default",className:Nt("gap-1 px-2.5 sm:pr-2.5",t),...s,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(mi,{})]})}function go({className:t,...s}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:Nt("flex size-9 items-center justify-center",t),...s,children:[e.jsx(WI,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}function Aq({onViewDetails:t,initialFilter:s}){const{user:n}=Pn(z=>z.auth),[r,a]=g.useState(""),[i,o]=g.useState("all"),[d,m]=g.useState(s||"all"),[f,p]=g.useState([]),[h,x]=g.useState(!1),[u]=g.useState("date"),[N,v]=g.useState(!1),[w,j]=g.useState(!1),[b,C]=g.useState([]),[S,D]=g.useState({}),[_,A]=g.useState([]),[E,q]=g.useState(1),[O,R]=g.useState(null),P=10;g.useEffect(()=>{L()},[E,i,d,r]);const L=async()=>{try{const z=await ps.getApplications({page:E,limit:P,status:d!=="all"?d:void 0,location:i!=="all"?i:void 0,search:r||void 0,ddLeadShortlisted:"true",isShortlisted:"true",assignedTo:w?n==null?void 0:n.id:void 0}),T=z.data||[];R(z.meta);const F=T.map(I=>({id:I.id,registrationNumber:I.applicationId||"N/A",name:I.applicantName,email:I.email,phone:I.phone,age:I.age,education:I.education,residentialAddress:I.address||I.city||"",businessAddress:I.address||"",preferredLocation:I.preferredLocation,state:I.state,ownsBike:I.ownRoyalEnfield==="yes",pastExperience:I.experienceYears?`${I.experienceYears} years`:I.description||"",status:I.overallStatus,questionnaireMarks:0,rank:0,totalApplicantsAtLocation:0,submissionDate:I.createdAt,assignedUsers:[],assignedTo:I.assignedTo,progress:I.progressPercentage||0,isShortlisted:I.ddLeadShortlisted||I.isShortlisted||!1,companyName:I.companyName,source:I.source,existingDealer:I.existingDealer,royalEnfieldModel:I.royalEnfieldModel,description:I.description,pincode:I.pincode,locationType:I.locationType,ownRoyalEnfield:I.ownRoyalEnfield,address:I.address}));if(C(F),F.length>0?Yl.getBatchStatus(F.map(I=>({entityType:"application",entityId:I.id}))).then(I=>{if(I!=null&&I.success){const K={};F.forEach(G=>{K[G.id]=I.data[`application:${G.id}`]??null}),D(K)}}).catch(()=>D({})):D({}),_.length===0){const I=Array.from(new Set(F.map(K=>K.preferredLocation))).filter(Boolean);A(I)}}catch(z){console.error("Failed to fetch applications",z)}finally{}},$=b.sort((z,T)=>u==="date"?new Date(T.submissionDate).getTime()-new Date(z.submissionDate).getTime():0),Z=z=>{p(T=>T.includes(z)?T.filter(F=>F!==z):[...T,z])},Q=()=>{f.length===$.length?p([]):p($.map(z=>z.id))},W=async()=>{if(f.length!==0)try{x(!0);const z=await ps.sendBulkReminders(f);z.success&&(J.success(z.message||`Reminder emails sent to ${f.length} applicant(s)`),p([]))}catch(z){console.error("Failed to send reminders:",z),J.error(z.message||"Failed to send reminders")}finally{x(!1)}},U=()=>{alert("Exporting applications to CSV...")},M=z=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-red-500","Level 1 Approved":"bg-green-500","Level 2 Pending":"bg-purple-500","Level 2 Approved":"bg-green-600","Level 2 Recommended":"bg-teal-500","Level 3 Pending":"bg-indigo-500","FDD Verification":"bg-violet-500","Payment Pending":"bg-yellow-500","LOI Issued":"bg-lime-500","Dealer Code Generation":"bg-fuchsia-500","Architecture Team Assigned":"bg-blue-500","Architecture Document Upload":"bg-blue-500","Architecture Team Completion":"bg-blue-500","Statutory GST":"bg-emerald-500","Statutory PAN":"bg-emerald-500","Statutory Nodal":"bg-emerald-500","Statutory Check":"bg-emerald-500","Statutory Partnership":"bg-emerald-500","Statutory Firm Reg":"bg-emerald-500","Statutory Virtual Code":"bg-emerald-500","Statutory Domain":"bg-emerald-500","Statutory MSD":"bg-emerald-500","Statutory LOI Ack":"bg-emerald-500","EOR In Progress":"bg-sky-500","LOA Pending":"bg-emerald-500",Approved:"bg-green-700",Rejected:"bg-red-500",Disqualified:"bg-red-700"})[z]||"bg-slate-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name, ID, or email...",value:r,onChange:z=>a(z.target.value),className:"pl-10","data-testid":"onboarding-applications-search-input"})]}),e.jsxs(Rt,{value:i,onValueChange:o,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-applications-location-filter",children:e.jsx(Et,{placeholder:"All Locations"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),_.map(z=>e.jsx(Pe,{value:z,children:z},z))]})]}),e.jsxs(Rt,{value:d,onValueChange:m,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-applications-status-filter",children:e.jsx(Et,{placeholder:"All Statuses"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),e.jsx(Pe,{value:"Questionnaire Pending",children:"Questionnaire Pending"}),e.jsx(Pe,{value:"Shortlisted",children:"Shortlisted"}),e.jsx(Pe,{value:"Level 1 Pending",children:"Level 1 Pending"}),e.jsx(Pe,{value:"Level 2 Pending",children:"Level 2 Pending"}),e.jsx(Pe,{value:"Level 3 Pending",children:"Level 3 Pending"}),e.jsx(Pe,{value:"EOR In Progress",children:"EOR In Progress"}),e.jsx(Pe,{value:"Approved",children:"Approved"}),e.jsx(Pe,{value:"Rejected",children:"Rejected"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:"my-assignments",checked:w,onCheckedChange:z=>j(z),"data-testid":"onboarding-applications-assignments-checkbox"}),e.jsx(le,{htmlFor:"my-assignments","data-testid":"onboarding-applications-assignments-label",children:"My Assignments Only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-4",children:[e.jsxs(te,{variant:"outline",size:"sm",onClick:U,"data-testid":"onboarding-applications-export-button",children:[e.jsx(fi,{className:"w-4 h-4 mr-2"}),"Export"]}),f.length>0&&e.jsxs(te,{variant:"outline",size:"sm",onClick:W,disabled:h,"data-testid":"onboarding-applications-reminders-button",children:[h?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",f.length,")"]}),e.jsxs("div",{className:"ml-auto text-slate-600","data-testid":"onboarding-applications-count-text",children:[O?O.total:$.length," application",(O==null?void 0:O.total)!==1?"s":""]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200",children:[e.jsxs(Ms,{"data-testid":"onboarding-applications-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:f.length===$.length&&$.length>0,onCheckedChange:Q,"data-testid":"onboarding-applications-header-checkbox"})}),e.jsx(me,{children:"ID"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Preferred Location"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"SLA"}),e.jsx(me,{children:"Applicant Location"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Applied On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:$.map((z,T)=>e.jsxs(lt,{"data-testid":`onboarding-application-row-${T}`,children:[e.jsx(oe,{children:e.jsx(Tn,{checked:f.includes(z.id),onCheckedChange:()=>Z(z.id),"data-testid":`onboarding-application-checkbox-${T}`})}),e.jsx(oe,{"data-testid":`onboarding-application-id-${T}`,children:z.registrationNumber}),e.jsx(oe,{"data-testid":`onboarding-application-name-${T}`,children:z.name}),e.jsx(oe,{"data-testid":`onboarding-application-pref-location-${T}`,children:z.preferredLocation}),e.jsx(oe,{children:e.jsx(we,{className:M(z.status),"data-testid":`onboarding-application-status-${T}`,children:z.status})}),e.jsx(oe,{children:e.jsx(br,{status:S[z.id],compact:!0})}),e.jsx(oe,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-application-addr-${T}`,children:z.residentialAddress}),e.jsx(oe,{children:e.jsx(up,{value:z.progress,status:z.status,showPercent:!0,"data-testid":`onboarding-application-progress-bar-${T}`})}),e.jsx(oe,{"data-testid":`onboarding-application-date-${T}`,children:Qt(z.submissionDate)}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>t(z.id),"data-testid":`onboarding-application-view-btn-${T}`,children:"View"})})]},z.id))})]}),O&&O.totalPages>1&&e.jsx("div",{className:"py-4 border-t px-4 flex justify-center",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>q(z=>Math.max(1,z-1)),className:E===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(O.totalPages)].map((z,T)=>{const F=T+1;return F===1||F===O.totalPages||F>=E-1&&F<=E+1?e.jsx(pn,{children:e.jsx($i,{isActive:E===F,onClick:()=>q(F),className:"cursor-pointer",children:F})},F):F===2&&E>3||F===O.totalPages-1&&E<O.totalPages-2?e.jsx(pn,{children:e.jsx(go,{})},F):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>q(z=>Math.min(O.totalPages,z+1)),className:E===O.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ms,{open:N,onOpenChange:v,children:e.jsxs(us,{className:"max-w-2xl","data-testid":"onboarding-new-app-modal",children:[e.jsx(ys,{children:e.jsx(gs,{children:"Add New Application (Admin)"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-slate-600",children:"This form allows administrators to manually add applications to the system."}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Name"}),e.jsx(it,{placeholder:"Full Name","data-testid":"onboarding-new-app-name"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Email"}),e.jsx(it,{type:"email",placeholder:"email@example.com","data-testid":"onboarding-new-app-email"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Phone"}),e.jsx(it,{placeholder:"+91 XXXXX XXXXX","data-testid":"onboarding-new-app-phone"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Preferred Location"}),e.jsxs(Rt,{children:[e.jsx(_t,{"data-testid":"onboarding-new-app-location-select",children:e.jsx(Et,{placeholder:"Select location"})}),e.jsx(Tt,{children:_.map(z=>e.jsx(Pe,{value:z,children:z},z))})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(te,{variant:"outline",onClick:()=>v(!1),"data-testid":"onboarding-new-app-cancel",children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-new-app-submit",children:"Create Application"})]})]})]})})]})}function UE({application:t,onViewDetails:s}){var r;const n=a=>({Submitted:"bg-slate-500","Questionnaire Pending":"bg-orange-500","Questionnaire Completed":"bg-blue-500",Shortlisted:"bg-cyan-500","Level 1 Pending":"bg-red-500","Level 1 Approved":"bg-green-500","Level 2 Pending":"bg-purple-500","Level 2 Approved":"bg-green-600","Level 2 Recommended":"bg-teal-500","Level 3 Pending":"bg-indigo-500","FDD Verification":"bg-violet-500","Payment Pending":"bg-yellow-500","LOI Issued":"bg-lime-500","Dealer Code Generation":"bg-fuchsia-500","Architecture Team Assigned":"bg-blue-500","Architecture Document Upload":"bg-blue-500","Architecture Team Completion":"bg-blue-500","Statutory GST":"bg-emerald-500","Statutory PAN":"bg-emerald-500","Statutory Nodal":"bg-emerald-500","Statutory Check":"bg-emerald-500","Statutory Partnership":"bg-emerald-500","Statutory Firm Reg":"bg-emerald-500","Statutory Virtual Code":"bg-emerald-500","Statutory Domain":"bg-emerald-500","Statutory MSD":"bg-emerald-500","Statutory LOI Ack":"bg-emerald-500","EOR In Progress":"bg-sky-500","LOA Pending":"bg-emerald-500",Approved:"bg-green-700",Rejected:"bg-red-500",Disqualified:"bg-red-700"})[a]||"bg-slate-500";return e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-6 hover:shadow-lg transition-shadow","data-testid":`onboarding-application-card-${t.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-slate-900","data-testid":"onboarding-application-card-name",children:t.name}),(r=t.tags)==null?void 0:r.map(a=>e.jsx(we,{variant:"outline",className:a==="Approved"?"border-green-500 text-green-700":"border-teal-500 text-teal-700","data-testid":`onboarding-application-card-tag-${a}`,children:a},a))]}),e.jsx("p",{className:"text-slate-600","data-testid":"onboarding-application-card-registration",children:t.registrationNumber})]}),e.jsx(we,{className:n(t.status),"data-testid":"onboarding-application-card-status",children:t.status})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(Mr,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-location",children:t.preferredLocation}),t.rank&&t.totalApplicantsAtLocation&&e.jsxs(we,{variant:"outline","data-testid":"onboarding-application-card-rank",children:["Rank ",t.rank,"/",t.totalApplicantsAtLocation]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-slate-600",children:[e.jsx(ad,{className:"w-4 h-4 mt-0.5"}),e.jsx("span",{className:"text-sm","data-testid":"onboarding-application-card-address",children:t.businessAddress})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(Gr,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-email",children:t.email})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(tb,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-phone",children:t.phone})]}),t.questionnaireMarks!==void 0&&e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(nk,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-score",children:["Score: ",t.questionnaireMarks,"/100"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-submission-date",children:["Submitted: ",Qt(t.submissionDate)]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-600",children:"Progress"}),e.jsxs("span",{className:"text-slate-900","data-testid":"onboarding-application-card-progress-text",children:[t.progress,"%"]})]}),e.jsx(up,{value:t.progress,status:t.status,barClassName:"h-2 w-full bg-status-progress-soft","data-testid":"onboarding-application-card-progress-bar"})]}),t.deadline&&t.status==="Questionnaire Pending"&&e.jsx("div",{className:"mb-4 p-3 bg-orange-50 border border-orange-200 rounded-md","data-testid":"onboarding-application-card-deadline-warning",children:e.jsxs("p",{className:"text-orange-800",children:["Deadline: ",Qt(t.deadline)]})}),e.jsx(te,{onClick:()=>s(t.id),className:"w-full bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-application-card-view-button",children:"View Details"})]})}function kq({onViewDetails:t,initialFilter:s="all"}){const[n,r]=g.useState("grid"),[a,i]=g.useState(""),[o,d]=g.useState(s),[m,f]=g.useState("all"),[p,h]=g.useState("all"),[x,u]=g.useState([]),[N,v]=g.useState(!1),[w,j]=g.useState(""),[b,C]=g.useState([]),[S,D]=g.useState(!0),[_,A]=g.useState([]),[E,q]=g.useState([]),[O,R]=g.useState(1),[P,L]=g.useState(null);g.useEffect(()=>{Z()},[O,a,o,m,p]),g.useEffect(()=>{R(1)},[a,o,m,p]),g.useEffect(()=>{$()},[]);const $=async()=>{try{const I=await $s.getStates(),G=(Array.isArray(I)?I:(I==null?void 0:I.data)||(I==null?void 0:I.states)||[]).map(V=>typeof V=="string"?V:V.name||V.stateName).filter(Boolean);A(G)}catch(I){console.error("Failed to fetch states:",I)}},Z=async()=>{try{D(!0);const I=await ps.getApplications({page:O,limit:10,search:a,status:o==="all"?void 0:o,location:m!=="all"?m:void 0,state:p!=="all"?p:void 0,isShortlisted:void 0}),K=I.data||[];L(I.meta);const G=K.map(Y=>({id:Y.id,registrationNumber:Y.applicationId||"N/A",name:Y.applicantName,email:Y.email,phone:Y.phone,age:Y.age,education:Y.education,residentialAddress:Y.address||Y.city||"",businessAddress:Y.address||"",preferredLocation:Y.preferredLocation,state:Y.state,ownsBike:Y.ownRoyalEnfield==="yes",pastExperience:Y.experienceYears?`${Y.experienceYears} years`:Y.description||"",status:Y.overallStatus,questionnaireMarks:Y.score||Y.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:Y.createdAt,assignedUsers:[],progress:Y.progressPercentage||0,isShortlisted:Y.isShortlisted||Y.ddLeadShortlisted,companyName:Y.companyName,source:Y.source,existingDealer:Y.existingDealer,royalEnfieldModel:Y.royalEnfieldModel,description:Y.description,pincode:Y.pincode,locationType:Y.locationType,ownRoyalEnfield:Y.ownRoyalEnfield,address:Y.address}));C(G);const V=Array.from(new Set(G.map(Y=>Y.preferredLocation))).filter(Boolean);q(V)}catch(I){console.error("Failed to fetch applications:",I),J.error("Failed to load applications")}finally{D(!1)}},Q=b,W=I=>{u(I?Q.map(K=>K.id):[])},U=(I,K)=>{u(K?[...x,I]:x.filter(G=>G!==I))},M=()=>{if(x.length===0){J.error("Please select at least one application to shortlist");return}v(!0)},z=async()=>{try{J.success(`${x.length} application(s) shortlisted successfully!`),v(!1),Z()}catch{J.error("Failed to shortlist")}},T=["Submitted","Questionnaire Pending","Questionnaire Completed"],F=I=>({Submitted:"bg-blue-100 text-blue-800","Questionnaire Pending":"bg-yellow-100 text-yellow-800","Questionnaire Completed":"bg-cyan-100 text-cyan-800",Shortlisted:"bg-purple-100 text-purple-800","Level 1 Interview Pending":"bg-orange-100 text-orange-800","Level 1 Approved":"bg-green-100 text-green-800","Level 2 Interview Pending":"bg-orange-100 text-orange-800","Level 2 Approved":"bg-green-100 text-green-800","Level 2 Recommended":"bg-teal-100 text-teal-800","Level 3 Interview Pending":"bg-orange-100 text-orange-800","In Review":"bg-slate-100 text-slate-800","Level 3 Approved":"bg-green-100 text-green-800","FDD Verification":"bg-indigo-100 text-indigo-800","Payment Pending":"bg-red-50 text-red-800","LOI In Progress":"bg-sky-100 text-sky-800","LOI Issued":"bg-sky-100 text-sky-800","Dealer Code Generation":"bg-purple-100 text-purple-800","Architecture Team Assigned":"bg-blue-100 text-blue-800","Architecture Document Upload":"bg-blue-100 text-blue-800","Architecture Team Completion":"bg-blue-100 text-blue-800","Statutory GST":"bg-emerald-100 text-emerald-800","Statutory PAN":"bg-emerald-100 text-emerald-800","Statutory Nodal":"bg-emerald-100 text-emerald-800","Statutory Check":"bg-emerald-100 text-emerald-800","Statutory Partnership":"bg-emerald-100 text-emerald-800","Statutory Firm Reg":"bg-emerald-100 text-emerald-800","Statutory Rental":"bg-emerald-100 text-emerald-800","Statutory Virtual Code":"bg-emerald-100 text-emerald-800","Statutory Domain":"bg-emerald-100 text-emerald-800","Statutory MSD":"bg-emerald-100 text-emerald-800","Statutory LOI Ack":"bg-emerald-100 text-emerald-800","EOR In Progress":"bg-violet-100 text-violet-800","EOR Complete":"bg-violet-100 text-violet-800","LOA Pending":"bg-pink-100 text-pink-800",Inauguration:"bg-red-50 text-red-800",Approved:"bg-green-100 text-green-800",Rejected:"bg-red-100 text-red-800",Disqualified:"bg-gray-100 text-gray-800",Onboarded:"bg-emerald-100 text-emerald-800","LOI Approved":"bg-sky-100 text-sky-800","Security Deposit In Progress":"bg-red-50 text-red-800","Security Deposit Approved":"bg-green-100 text-green-800","Security Deposit":"bg-red-50 text-red-800","Security Details In Progress":"bg-red-50 text-red-800","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-red-50 text-red-800","LOA Issued":"bg-pink-100 text-pink-800"})[I]||"bg-gray-100 text-gray-800";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4","data-testid":"onboarding-all-apps-banner",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-red-900 mb-1",children:"DD Workflow - Initial Application Review"}),e.jsxs("p",{className:"text-red-800",children:["This page shows ",e.jsx("strong",{children:"only applications that haven't been shortlisted yet"}),". Review and select promising candidates using the ",e.jsx("strong",{children:"Shortlist"})," button. Once shortlisted, applications will be removed from here and moved to the ",e.jsx("strong",{children:"Dealership Requests"})," page for further processing."]})]})]})}),e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name or registration number...",value:a,onChange:I=>i(I.target.value),className:"pl-10","data-testid":"onboarding-all-apps-search-input"})]}),e.jsxs(Rt,{value:o,onValueChange:d,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-status-filter",children:e.jsx(Et,{placeholder:"Filter by status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),T.map(I=>e.jsx(Pe,{value:I,children:I},I))]})]}),e.jsxs(Rt,{value:p,onValueChange:h,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-state-filter",children:e.jsx(Et,{placeholder:"Filter by state"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),_.map(I=>e.jsx(Pe,{value:I,children:I},I))]})]}),e.jsxs(Rt,{value:m,onValueChange:f,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-location-filter",children:e.jsx(Et,{placeholder:"Filter by location"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),E.map(I=>e.jsx(Pe,{value:I,children:I},I))]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(te,{variant:n==="grid"?"default":"outline",size:"sm",onClick:()=>r("grid"),className:n==="grid"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-all-apps-grid-view-btn",children:[e.jsx(lk,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(te,{variant:n==="table"?"default":"outline",size:"sm",onClick:()=>r("table"),className:n==="table"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-all-apps-table-view-btn",children:[e.jsx(dk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(te,{variant:"outline",size:"sm","data-testid":"onboarding-all-apps-export-btn",children:[e.jsx(fi,{className:"w-4 h-4 mr-2"}),"Export"]}),x.length>0&&e.jsx(e.Fragment,{children:e.jsxs(te,{size:"sm",onClick:M,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-all-apps-shortlist-btn",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Shortlist (",x.length,")"]})}),e.jsx("div",{className:"ml-auto",children:e.jsxs(we,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-all-apps-pending-badge",children:[(P==null?void 0:P.total)||Q.length," pending shortlisting"]})})]})]})}),S?e.jsx("div",{className:"flex justify-center items-center h-96 bg-white rounded-lg border border-slate-200",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):n==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4","data-testid":"onboarding-all-apps-grid-container",children:Q.map((I,K)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-all-apps-grid-item-${K}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Tn,{checked:x.includes(I.id),onCheckedChange:G=>U(I.id,G),className:"bg-white","data-testid":`onboarding-all-apps-grid-checkbox-${K}`})}),I.isShortlisted&&e.jsx("div",{className:"absolute top-4 right-4 z-10",children:e.jsx(we,{className:"bg-green-600","data-testid":`onboarding-all-apps-grid-shortlisted-badge-${K}`,children:"Shortlisted"})}),e.jsx(UE,{application:I,onViewDetails:t})]},I.id))}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200",children:e.jsxs(Ms,{"data-testid":"onboarding-all-apps-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:x.length===Q.length&&Q.length>0,onCheckedChange:W,"data-testid":"onboarding-all-apps-header-checkbox"})}),e.jsx(me,{children:"Registration"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Location"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Shortlisted"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Submitted"})]})}),e.jsx(Bs,{children:Q.map((I,K)=>e.jsxs(lt,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(I.id),"data-testid":`onboarding-all-apps-row-${K}`,children:[e.jsx(oe,{onClick:G=>G.stopPropagation(),children:e.jsx(Tn,{checked:x.includes(I.id),onCheckedChange:G=>U(I.id,G),"data-testid":`onboarding-all-apps-checkbox-${K}`})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-reg-id-${K}`,children:I.registrationNumber})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-name-${K}`,children:I.name})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-location-${K}`,children:I.preferredLocation})}),e.jsx(oe,{children:e.jsx(we,{className:F(I.status),"data-testid":`onboarding-all-apps-status-${K}`,children:I.status})}),e.jsx(oe,{children:I.isShortlisted?e.jsx(we,{className:"bg-green-600","data-testid":`onboarding-all-apps-shortlisted-yes-${K}`,children:"Yes"}):e.jsx(we,{variant:"outline","data-testid":`onboarding-all-apps-shortlisted-no-${K}`,children:"No"})}),e.jsx(oe,{children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(up,{value:I.progress,status:I.status,showPercent:!0,"data-testid":`onboarding-all-apps-progress-bar-${K}`})})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-date-${K}`,children:Qt(I.submissionDate)})})]},I.id))})]})}),P&&P.totalPages>1&&e.jsx("div",{className:"py-6 border-t border-slate-200 bg-white rounded-b-lg",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>R(I=>Math.max(1,I-1)),className:O===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(P.totalPages)].map((I,K)=>{const G=K+1;return G===1||G===P.totalPages||G>=O-1&&G<=O+1?e.jsx(pn,{children:e.jsx($i,{isActive:O===G,onClick:()=>R(G),className:"cursor-pointer",children:G})},G):G===O-2||G===O+2?e.jsx(pn,{children:e.jsx(go,{})},G):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>R(I=>Math.min(P.totalPages,I+1)),className:O===P.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),e.jsx(ms,{open:N,onOpenChange:v,children:e.jsxs(us,{"data-testid":"onboarding-all-apps-shortlist-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{"data-testid":"onboarding-all-apps-shortlist-title",children:"Shortlist Applications"}),e.jsxs(ws,{"data-testid":"onboarding-all-apps-shortlist-desc",children:["You are about to shortlist ",x.length," application(s). These applications will be moved to the Dealership Requests page."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{htmlFor:"shortlist-remark",children:"Shortlisting Remark (Optional)"}),e.jsx(Ks,{id:"shortlist-remark",placeholder:"Enter reason for shortlisting these applications...",value:w,onChange:I=>j(I.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-all-apps-shortlist-remark"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>v(!1),"data-testid":"onboarding-all-apps-shortlist-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:z,"data-testid":"onboarding-all-apps-shortlist-confirm",children:"Confirm Shortlist"})]})]})]})})]})}function Dq(t){const s=Rq(t),n=g.forwardRef((r,a)=>{const{children:i,...o}=r,d=g.Children.toArray(i),m=d.find(_q);if(m){const f=m.props.children,p=d.map(h=>h===m?g.Children.count(f)>1?g.Children.only(null):g.isValidElement(f)?f.props.children:null:h);return e.jsx(s,{...o,ref:a,children:g.isValidElement(f)?g.cloneElement(f,void 0,p):null})}return e.jsx(s,{...o,ref:a,children:i})});return n.displayName=`${t}.Slot`,n}function Rq(t){const s=g.forwardRef((n,r)=>{const{children:a,...i}=n;if(g.isValidElement(a)){const o=Pq(a),d=Tq(i,a.props);return a.type!==g.Fragment&&(d.ref=r?Hr(r,o):o),g.cloneElement(a,d)}return g.Children.count(a)>1?g.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Eq=Symbol("radix.slottable");function _q(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Eq}function Tq(t,s){const n={...s};for(const r in s){const a=t[r],i=s[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...d)=>{const m=i(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...t,...n}}function Pq(t){var r,a;let s=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var hp="Popover",[VE]=oa(hp,[lo]),sh=lo(),[Oq,vo]=VE(hp),HE=t=>{const{__scopePopover:s,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=t,d=sh(s),m=g.useRef(null),[f,p]=g.useState(!1),[h,x]=Li({prop:r,defaultProp:a??!1,onChange:i,caller:hp});return e.jsx(Vf,{...d,children:e.jsx(Oq,{scope:s,contentId:yr(),triggerRef:m,open:h,onOpenChange:x,onOpenToggle:g.useCallback(()=>x(u=>!u),[x]),hasCustomAnchor:f,onCustomAnchorAdd:g.useCallback(()=>p(!0),[]),onCustomAnchorRemove:g.useCallback(()=>p(!1),[]),modal:o,children:n})})};HE.displayName=hp;var WE="PopoverAnchor",Lq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=vo(WE,n),i=sh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:d}=a;return g.useEffect(()=>(o(),()=>d()),[o,d]),e.jsx(Qu,{...i,...r,ref:s})});Lq.displayName=WE;var GE="PopoverTrigger",KE=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=vo(GE,n),i=sh(n),o=Ys(s,a.triggerRef),d=e.jsx(Ss.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":JE(a.open),...r,ref:o,onClick:Yt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?d:e.jsx(Qu,{asChild:!0,...i,children:d})});KE.displayName=GE;var Jb="PopoverPortal",[Iq,Mq]=VE(Jb,{forceMount:void 0}),YE=t=>{const{__scopePopover:s,forceMount:n,children:r,container:a}=t,i=vo(Jb,s);return e.jsx(Iq,{scope:s,forceMount:n,children:e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};YE.displayName=Jb;var hd="PopoverContent",ZE=g.forwardRef((t,s)=>{const n=Mq(hd,t.__scopePopover),{forceMount:r=n.forceMount,...a}=t,i=vo(hd,t.__scopePopover);return e.jsx(jr,{present:r||i.open,children:i.modal?e.jsx(Bq,{...a,ref:s}):e.jsx($q,{...a,ref:s})})});ZE.displayName=hd;var Fq=Dq("PopoverContent.RemoveScroll"),Bq=g.forwardRef((t,s)=>{const n=vo(hd,t.__scopePopover),r=g.useRef(null),a=Ys(s,r),i=g.useRef(!1);return g.useEffect(()=>{const o=r.current;if(o)return Kf(o)},[]),e.jsx(Ju,{as:Fq,allowPinchZoom:!0,children:e.jsx(QE,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yt(t.onCloseAutoFocus,o=>{var d;o.preventDefault(),i.current||(d=n.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Yt(t.onPointerDownOutside,o=>{const d=o.detail.originalEvent,m=d.button===0&&d.ctrlKey===!0,f=d.button===2||m;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Yt(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),$q=g.forwardRef((t,s)=>{const n=vo(hd,t.__scopePopover),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(QE,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,i),i.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),QE=g.forwardRef((t,s)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onInteractOutside:p,...h}=t,x=vo(hd,n),u=sh(n);return Bf(),e.jsx(Yu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:p,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onDismiss:()=>x.onOpenChange(!1),children:e.jsx(Hf,{"data-state":JE(x.open),role:"dialog",id:x.contentId,...u,...h,ref:s,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),XE="PopoverClose",qq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=vo(XE,n);return e.jsx(Ss.button,{type:"button",...r,ref:s,onClick:Yt(t.onClick,()=>a.onOpenChange(!1))})});qq.displayName=XE;var zq="PopoverArrow",Uq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=sh(n);return e.jsx(Wf,{...a,...r,ref:s})});Uq.displayName=zq;function JE(t){return t?"open":"closed"}var Vq=HE,Hq=KE,Wq=YE,Gq=ZE;function _u({...t}){return e.jsx(Vq,{"data-slot":"popover",...t})}function Tu({...t}){return e.jsx(Hq,{"data-slot":"popover-trigger",...t})}function Pu({className:t,align:s="center",sideOffset:n=4,...r}){return e.jsx(Wq,{children:e.jsx(Gq,{"data-slot":"popover-content",align:s,sideOffset:n,className:Nt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}var qs=function(){return qs=Object.assign||function(s){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},qs.apply(this,arguments)};function Kq(t,s){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&s.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)s.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function e_(t,s,n){for(var r=0,a=s.length,i;r<a;r++)(i||!(r in s))&&(i||(i=Array.prototype.slice.call(s,0,r)),i[r]=s[r]);return t.concat(i||Array.prototype.slice.call(s))}function nh(t){return t.mode==="multiple"}function rh(t){return t.mode==="range"}function mp(t){return t.mode==="single"}var Yq={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function Zq(t,s){return za(t,"LLLL y",s)}function Qq(t,s){return za(t,"d",s)}function Xq(t,s){return za(t,"LLLL",s)}function Jq(t){return"".concat(t)}function ez(t,s){return za(t,"cccccc",s)}function tz(t,s){return za(t,"yyyy",s)}var sz=Object.freeze({__proto__:null,formatCaption:Zq,formatDay:Qq,formatMonthCaption:Xq,formatWeekNumber:Jq,formatWeekdayName:ez,formatYearCaption:tz}),nz=function(t,s,n){return za(t,"do MMMM (EEEE)",n)},rz=function(){return"Month: "},az=function(){return"Go to next month"},iz=function(){return"Go to previous month"},lz=function(t,s){return za(t,"cccc",s)},oz=function(t){return"Week n. ".concat(t)},cz=function(){return"Year: "},dz=Object.freeze({__proto__:null,labelDay:nz,labelMonthDropdown:rz,labelNext:az,labelPrevious:iz,labelWeekNumber:oz,labelWeekday:lz,labelYearDropdown:cz});function uz(){var t="buttons",s=Yq,n=_b,r={},a={},i=1,o={},d=new Date;return{captionLayout:t,classNames:s,formatters:sz,labels:dz,locale:n,modifiersClassNames:r,modifiers:a,numberOfMonths:i,styles:o,today:d,mode:"default"}}function hz(t){var s=t.fromYear,n=t.toYear,r=t.fromMonth,a=t.toMonth,i=t.fromDate,o=t.toDate;return r?i=ia(r):s&&(i=new Date(s,0,1)),a?o=tp(a):n&&(o=new Date(n,11,31)),{fromDate:i?od(i):void 0,toDate:o?od(o):void 0}}var t_=g.createContext(void 0);function mz(t){var s,n=t.initialProps,r=uz(),a=hz(n),i=a.fromDate,o=a.toDate,d=(s=n.captionLayout)!==null&&s!==void 0?s:r.captionLayout;d!=="buttons"&&(!i||!o)&&(d="buttons");var m;(mp(n)||nh(n)||rh(n))&&(m=n.onSelect);var f=qs(qs(qs({},r),n),{captionLayout:d,classNames:qs(qs({},r.classNames),n.classNames),components:qs({},n.components),formatters:qs(qs({},r.formatters),n.formatters),fromDate:i,labels:qs(qs({},r.labels),n.labels),mode:n.mode||r.mode,modifiers:qs(qs({},r.modifiers),n.modifiers),modifiersClassNames:qs(qs({},r.modifiersClassNames),n.modifiersClassNames),onSelect:m,styles:qs(qs({},r.styles),n.styles),toDate:o});return e.jsx(t_.Provider,{value:f,children:t.children})}function An(){var t=g.useContext(t_);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function s_(t){var s=An(),n=s.locale,r=s.classNames,a=s.styles,i=s.formatters.formatCaption;return e.jsx("div",{className:r.caption_label,style:a.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:i(t.displayMonth,{locale:n})})}function fz(t){return e.jsx("svg",qs({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},t,{children:e.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function n_(t){var s,n,r=t.onChange,a=t.value,i=t.children,o=t.caption,d=t.className,m=t.style,f=An(),p=(n=(s=f.components)===null||s===void 0?void 0:s.IconDropdown)!==null&&n!==void 0?n:fz;return e.jsxs("div",{className:d,style:m,children:[e.jsx("span",{className:f.classNames.vhidden,children:t["aria-label"]}),e.jsx("select",{name:t.name,"aria-label":t["aria-label"],className:f.classNames.dropdown,style:f.styles.dropdown,value:a,onChange:r,children:i}),e.jsxs("div",{className:f.classNames.caption_label,style:f.styles.caption_label,"aria-hidden":"true",children:[o,e.jsx(p,{className:f.classNames.dropdown_icon,style:f.styles.dropdown_icon})]})]})}function pz(t){var s,n=An(),r=n.fromDate,a=n.toDate,i=n.styles,o=n.locale,d=n.formatters.formatMonthCaption,m=n.classNames,f=n.components,p=n.labels.labelMonthDropdown;if(!r)return e.jsx(e.Fragment,{});if(!a)return e.jsx(e.Fragment,{});var h=[];if(r7(r,a))for(var x=ia(r),u=r.getMonth();u<=a.getMonth();u++)h.push(Og(x,u));else for(var x=ia(new Date),u=0;u<=11;u++)h.push(Og(x,u));var N=function(w){var j=Number(w.target.value),b=Og(ia(t.displayMonth),j);t.onChange(b)},v=(s=f==null?void 0:f.Dropdown)!==null&&s!==void 0?s:n_;return e.jsx(v,{name:"months","aria-label":p(),className:m.dropdown_month,style:i.dropdown_month,onChange:N,value:t.displayMonth.getMonth(),caption:d(t.displayMonth,{locale:o}),children:h.map(function(w){return e.jsx("option",{value:w.getMonth(),children:d(w,{locale:o})},w.getMonth())})})}function xz(t){var s,n=t.displayMonth,r=An(),a=r.fromDate,i=r.toDate,o=r.locale,d=r.styles,m=r.classNames,f=r.components,p=r.formatters.formatYearCaption,h=r.labels.labelYearDropdown,x=[];if(!a)return e.jsx(e.Fragment,{});if(!i)return e.jsx(e.Fragment,{});for(var u=a.getFullYear(),N=i.getFullYear(),v=u;v<=N;v++)x.push(mS(XD(new Date),v));var w=function(b){var C=mS(ia(n),Number(b.target.value));t.onChange(C)},j=(s=f==null?void 0:f.Dropdown)!==null&&s!==void 0?s:n_;return e.jsx(j,{name:"years","aria-label":h(),className:m.dropdown_year,style:d.dropdown_year,onChange:w,value:n.getFullYear(),caption:p(n,{locale:o}),children:x.map(function(b){return e.jsx("option",{value:b.getFullYear(),children:p(b,{locale:o})},b.getFullYear())})})}function gz(t,s){var n=g.useState(t),r=n[0],a=n[1],i=s===void 0?r:s;return[i,a]}function vz(t){var s=t.month,n=t.defaultMonth,r=t.today,a=s||n||r||new Date,i=t.toDate,o=t.fromDate,d=t.numberOfMonths,m=d===void 0?1:d;if(i&&dd(i,a)<0){var f=-1*(m-1);a=di(i,f)}return o&&dd(a,o)<0&&(a=o),ia(a)}function yz(){var t=An(),s=vz(t),n=gz(s,t.month),r=n[0],a=n[1],i=function(o){var d;if(!t.disableNavigation){var m=ia(o);a(m),(d=t.onMonthChange)===null||d===void 0||d.call(t,m)}};return[r,i]}function bz(t,s){for(var n=s.reverseMonths,r=s.numberOfMonths,a=ia(t),i=ia(di(a,r)),o=dd(i,a),d=[],m=0;m<o;m++){var f=di(a,m);d.push(f)}return n&&(d=d.reverse()),d}function jz(t,s){if(!s.disableNavigation){var n=s.toDate,r=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=r?i:1,d=ia(t);if(!n)return di(d,o);var m=dd(n,t);if(!(m<i))return di(d,o)}}function Nz(t,s){if(!s.disableNavigation){var n=s.fromDate,r=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=r?i:1,d=ia(t);if(!n)return di(d,-o);var m=dd(d,n);if(!(m<=0))return di(d,-o)}}var r_=g.createContext(void 0);function wz(t){var s=An(),n=yz(),r=n[0],a=n[1],i=bz(r,s),o=jz(r,s),d=Nz(r,s),m=function(h){return i.some(function(x){return Tb(h,x)})},f=function(h,x){m(h)||(x&&aR(h,x)?a(di(h,1+s.numberOfMonths*-1)):a(h))},p={currentMonth:r,displayMonths:i,goToMonth:a,goToDate:f,previousMonth:d,nextMonth:o,isDateDisplayed:m};return e.jsx(r_.Provider,{value:p,children:t.children})}function ah(){var t=g.useContext(r_);if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function wS(t){var s,n=An(),r=n.classNames,a=n.styles,i=n.components,o=ah().goToMonth,d=function(p){o(di(p,t.displayIndex?-t.displayIndex:0))},m=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:s_,f=e.jsx(m,{id:t.id,displayMonth:t.displayMonth});return e.jsxs("div",{className:r.caption_dropdowns,style:a.caption_dropdowns,children:[e.jsx("div",{className:r.vhidden,children:f}),e.jsx(pz,{onChange:d,displayMonth:t.displayMonth}),e.jsx(xz,{onChange:d,displayMonth:t.displayMonth})]})}function Sz(t){return e.jsx("svg",qs({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:e.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Cz(t){return e.jsx("svg",qs({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:e.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var vf=g.forwardRef(function(t,s){var n=An(),r=n.classNames,a=n.styles,i=[r.button_reset,r.button];t.className&&i.push(t.className);var o=i.join(" "),d=qs(qs({},a.button_reset),a.button);return t.style&&Object.assign(d,t.style),e.jsx("button",qs({},t,{ref:s,type:"button",className:o,style:d}))});function Az(t){var s,n,r=An(),a=r.dir,i=r.locale,o=r.classNames,d=r.styles,m=r.labels,f=m.labelPrevious,p=m.labelNext,h=r.components;if(!t.nextMonth&&!t.previousMonth)return e.jsx(e.Fragment,{});var x=f(t.previousMonth,{locale:i}),u=[o.nav_button,o.nav_button_previous].join(" "),N=p(t.nextMonth,{locale:i}),v=[o.nav_button,o.nav_button_next].join(" "),w=(s=h==null?void 0:h.IconRight)!==null&&s!==void 0?s:Cz,j=(n=h==null?void 0:h.IconLeft)!==null&&n!==void 0?n:Sz;return e.jsxs("div",{className:o.nav,style:d.nav,children:[!t.hidePrevious&&e.jsx(vf,{name:"previous-month","aria-label":x,className:u,style:d.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:a==="rtl"?e.jsx(w,{className:o.nav_icon,style:d.nav_icon}):e.jsx(j,{className:o.nav_icon,style:d.nav_icon})}),!t.hideNext&&e.jsx(vf,{name:"next-month","aria-label":N,className:v,style:d.nav_button_next,disabled:!t.nextMonth,onClick:t.onNextClick,children:a==="rtl"?e.jsx(j,{className:o.nav_icon,style:d.nav_icon}):e.jsx(w,{className:o.nav_icon,style:d.nav_icon})})]})}function SS(t){var s=An().numberOfMonths,n=ah(),r=n.previousMonth,a=n.nextMonth,i=n.goToMonth,o=n.displayMonths,d=o.findIndex(function(N){return Tb(t.displayMonth,N)}),m=d===0,f=d===o.length-1,p=s>1&&(m||!f),h=s>1&&(f||!m),x=function(){r&&i(r)},u=function(){a&&i(a)};return e.jsx(Az,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:h,nextMonth:a,previousMonth:r,onPreviousClick:x,onNextClick:u})}function kz(t){var s,n=An(),r=n.classNames,a=n.disableNavigation,i=n.styles,o=n.captionLayout,d=n.components,m=(s=d==null?void 0:d.CaptionLabel)!==null&&s!==void 0?s:s_,f;return a?f=e.jsx(m,{id:t.id,displayMonth:t.displayMonth}):o==="dropdown"?f=e.jsx(wS,{displayMonth:t.displayMonth,id:t.id}):o==="dropdown-buttons"?f=e.jsxs(e.Fragment,{children:[e.jsx(wS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(SS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):f=e.jsxs(e.Fragment,{children:[e.jsx(m,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(SS,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:r.caption,style:i.caption,children:f})}function Dz(t){var s=An(),n=s.footer,r=s.styles,a=s.classNames.tfoot;return n?e.jsx("tfoot",{className:a,style:r.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:n})})}):e.jsx(e.Fragment,{})}function Rz(t,s,n){for(var r=n?rc(new Date):Mi(new Date,{locale:t,weekStartsOn:s}),a=[],i=0;i<7;i++){var o=Ur(r,i);a.push(o)}return a}function Ez(){var t=An(),s=t.classNames,n=t.styles,r=t.showWeekNumber,a=t.locale,i=t.weekStartsOn,o=t.ISOWeek,d=t.formatters.formatWeekdayName,m=t.labels.labelWeekday,f=Rz(a,i,o);return e.jsxs("tr",{style:n.head_row,className:s.head_row,children:[r&&e.jsx("td",{style:n.head_cell,className:s.head_cell}),f.map(function(p,h){return e.jsx("th",{scope:"col",className:s.head_cell,style:n.head_cell,"aria-label":m(p,{locale:a}),children:d(p,{locale:a})},h)})]})}function _z(){var t,s=An(),n=s.classNames,r=s.styles,a=s.components,i=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:Ez;return e.jsx("thead",{style:r.head,className:n.head,children:e.jsx(i,{})})}function Tz(t){var s=An(),n=s.locale,r=s.formatters.formatDay;return e.jsx(e.Fragment,{children:r(t.date,{locale:n})})}var ej=g.createContext(void 0);function Pz(t){if(!nh(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(ej.Provider,{value:s,children:t.children})}return e.jsx(Oz,{initialProps:t.initialProps,children:t.children})}function Oz(t){var s=t.initialProps,n=t.children,r=s.selected,a=s.min,i=s.max,o=function(f,p,h){var x,u;(x=s.onDayClick)===null||x===void 0||x.call(s,f,p,h);var N=!!(p.selected&&a&&(r==null?void 0:r.length)===a);if(!N){var v=!!(!p.selected&&i&&(r==null?void 0:r.length)===i);if(!v){var w=r?e_([],r):[];if(p.selected){var j=w.findIndex(function(b){return na(f,b)});w.splice(j,1)}else w.push(f);(u=s.onSelect)===null||u===void 0||u.call(s,w,f,p,h)}}},d={disabled:[]};r&&d.disabled.push(function(f){var p=i&&r.length>i-1,h=r.some(function(x){return na(x,f)});return!!(p&&!h)});var m={selected:r,onDayClick:o,modifiers:d};return e.jsx(ej.Provider,{value:m,children:n})}function tj(){var t=g.useContext(ej);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Lz(t,s){var n=s||{},r=n.from,a=n.to;return r&&a?na(a,t)&&na(r,t)?void 0:na(a,t)?{from:a,to:void 0}:na(r,t)?void 0:jy(r,t)?{from:t,to:a}:{from:r,to:t}:a?jy(t,a)?{from:a,to:t}:{from:t,to:a}:r?aR(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var sj=g.createContext(void 0);function Iz(t){if(!rh(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(sj.Provider,{value:s,children:t.children})}return e.jsx(Mz,{initialProps:t.initialProps,children:t.children})}function Mz(t){var s=t.initialProps,n=t.children,r=s.selected,a=r||{},i=a.from,o=a.to,d=s.min,m=s.max,f=function(u,N,v){var w,j;(w=s.onDayClick)===null||w===void 0||w.call(s,u,N,v);var b=Lz(u,r);(j=s.onSelect)===null||j===void 0||j.call(s,b,u,N,v)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(p.range_start=[i],o?(p.range_end=[o],na(i,o)||(p.range_middle=[{after:i,before:o}])):p.range_end=[i]):o&&(p.range_start=[o],p.range_end=[o]),d&&(i&&!o&&p.disabled.push({after:Pg(i,d-1),before:Ur(i,d-1)}),i&&o&&p.disabled.push({after:i,before:Ur(i,d-1)}),!i&&o&&p.disabled.push({after:Pg(o,d-1),before:Ur(o,d-1)})),m){if(i&&!o&&(p.disabled.push({before:Ur(i,-m+1)}),p.disabled.push({after:Ur(i,m-1)})),i&&o){var h=Ti(o,i)+1,x=m-h;p.disabled.push({before:Pg(i,x)}),p.disabled.push({after:Ur(o,x)})}!i&&o&&(p.disabled.push({before:Ur(o,-m+1)}),p.disabled.push({after:Ur(o,m-1)}))}return e.jsx(sj.Provider,{value:{selected:r,onDayClick:f,modifiers:p},children:n})}function nj(){var t=g.useContext(sj);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Hm(t){return Array.isArray(t)?e_([],t):t!==void 0?[t]:[]}function Fz(t){var s={};return Object.entries(t).forEach(function(n){var r=n[0],a=n[1];s[r]=Hm(a)}),s}var ui;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(ui||(ui={}));var Bz=ui.Selected,sl=ui.Disabled,$z=ui.Hidden,qz=ui.Today,Fg=ui.RangeEnd,Bg=ui.RangeMiddle,$g=ui.RangeStart,zz=ui.Outside;function Uz(t,s,n){var r,a=(r={},r[Bz]=Hm(t.selected),r[sl]=Hm(t.disabled),r[$z]=Hm(t.hidden),r[qz]=[t.today],r[Fg]=[],r[Bg]=[],r[$g]=[],r[zz]=[],r);return t.fromDate&&a[sl].push({before:t.fromDate}),t.toDate&&a[sl].push({after:t.toDate}),nh(t)?a[sl]=a[sl].concat(s.modifiers[sl]):rh(t)&&(a[sl]=a[sl].concat(n.modifiers[sl]),a[$g]=n.modifiers[$g],a[Bg]=n.modifiers[Bg],a[Fg]=n.modifiers[Fg]),a}var a_=g.createContext(void 0);function Vz(t){var s=An(),n=tj(),r=nj(),a=Uz(s,n,r),i=Fz(s.modifiers),o=qs(qs({},a),i);return e.jsx(a_.Provider,{value:o,children:t.children})}function i_(){var t=g.useContext(a_);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Hz(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function Wz(t){return!!(t&&typeof t=="object"&&"from"in t)}function Gz(t){return!!(t&&typeof t=="object"&&"after"in t)}function Kz(t){return!!(t&&typeof t=="object"&&"before"in t)}function Yz(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function Zz(t,s){var n,r=s.from,a=s.to;if(r&&a){var i=Ti(a,r)<0;i&&(n=[a,r],r=n[0],a=n[1]);var o=Ti(t,r)>=0&&Ti(a,t)>=0;return o}return a?na(a,t):r?na(r,t):!1}function Qz(t){return Rb(t)}function Xz(t){return Array.isArray(t)&&t.every(Rb)}function Jz(t,s){return s.some(function(n){if(typeof n=="boolean")return n;if(Qz(n))return na(t,n);if(Xz(n))return n.includes(t);if(Wz(n))return Zz(t,n);if(Yz(n))return n.dayOfWeek.includes(t.getDay());if(Hz(n)){var r=Ti(n.before,t),a=Ti(n.after,t),i=r>0,o=a<0,d=jy(n.before,n.after);return d?o&&i:i||o}return Gz(n)?Ti(t,n.after)>0:Kz(n)?Ti(n.before,t)>0:typeof n=="function"?n(t):!1})}function rj(t,s,n){var r=Object.keys(s).reduce(function(i,o){var d=s[o];return Jz(t,d)&&i.push(o),i},[]),a={};return r.forEach(function(i){return a[i]=!0}),n&&!Tb(t,n)&&(a.outside=!0),a}function eU(t,s){for(var n=ia(t[0]),r=tp(t[t.length-1]),a,i,o=n;o<=r;){var d=rj(o,s),m=!d.disabled&&!d.hidden;if(!m){o=Ur(o,1);continue}if(d.selected)return o;d.today&&!i&&(i=o),a||(a=o),o=Ur(o,1)}return i||a}var tU=365;function l_(t,s){var n=s.moveBy,r=s.direction,a=s.context,i=s.modifiers,o=s.retry,d=o===void 0?{count:0,lastFocused:t}:o,m=a.weekStartsOn,f=a.fromDate,p=a.toDate,h=a.locale,x={day:Ur,week:by,month:di,year:WB,startOfWeek:function(w){return a.ISOWeek?rc(w):Mi(w,{locale:h,weekStartsOn:m})},endOfWeek:function(w){return a.ISOWeek?JD(w):Eb(w,{locale:h,weekStartsOn:m})}},u=x[n](t,r==="after"?1:-1);r==="before"&&f?u=GB([f,u]):r==="after"&&p&&(u=KB([p,u]));var N=!0;if(i){var v=rj(u,i);N=!v.disabled&&!v.hidden}return N?u:d.count>tU?d.lastFocused:l_(u,{moveBy:n,direction:r,context:a,modifiers:i,retry:qs(qs({},d),{count:d.count+1})})}var o_=g.createContext(void 0);function sU(t){var s=ah(),n=i_(),r=g.useState(),a=r[0],i=r[1],o=g.useState(),d=o[0],m=o[1],f=eU(s.displayMonths,n),p=a??(d&&s.isDateDisplayed(d))?d:f,h=function(){m(a),i(void 0)},x=function(w){i(w)},u=An(),N=function(w,j){if(a){var b=l_(a,{moveBy:w,direction:j,context:u,modifiers:n});na(a,b)||(s.goToDate(b,a),x(b))}},v={focusedDay:a,focusTarget:p,blur:h,focus:x,focusDayAfter:function(){return N("day","after")},focusDayBefore:function(){return N("day","before")},focusWeekAfter:function(){return N("week","after")},focusWeekBefore:function(){return N("week","before")},focusMonthBefore:function(){return N("month","before")},focusMonthAfter:function(){return N("month","after")},focusYearBefore:function(){return N("year","before")},focusYearAfter:function(){return N("year","after")},focusStartOfWeek:function(){return N("startOfWeek","before")},focusEndOfWeek:function(){return N("endOfWeek","after")}};return e.jsx(o_.Provider,{value:v,children:t.children})}function aj(){var t=g.useContext(o_);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function nU(t,s){var n=i_(),r=rj(t,n,s);return r}var ij=g.createContext(void 0);function rU(t){if(!mp(t.initialProps)){var s={selected:void 0};return e.jsx(ij.Provider,{value:s,children:t.children})}return e.jsx(aU,{initialProps:t.initialProps,children:t.children})}function aU(t){var s=t.initialProps,n=t.children,r=function(i,o,d){var m,f,p;if((m=s.onDayClick)===null||m===void 0||m.call(s,i,o,d),o.selected&&!s.required){(f=s.onSelect)===null||f===void 0||f.call(s,void 0,i,o,d);return}(p=s.onSelect)===null||p===void 0||p.call(s,i,i,o,d)},a={selected:s.selected,onDayClick:r};return e.jsx(ij.Provider,{value:a,children:n})}function c_(){var t=g.useContext(ij);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function iU(t,s){var n=An(),r=c_(),a=tj(),i=nj(),o=aj(),d=o.focusDayAfter,m=o.focusDayBefore,f=o.focusWeekAfter,p=o.focusWeekBefore,h=o.blur,x=o.focus,u=o.focusMonthBefore,N=o.focusMonthAfter,v=o.focusYearBefore,w=o.focusYearAfter,j=o.focusStartOfWeek,b=o.focusEndOfWeek,C=function(W){var U,M,z,T;mp(n)?(U=r.onDayClick)===null||U===void 0||U.call(r,t,s,W):nh(n)?(M=a.onDayClick)===null||M===void 0||M.call(a,t,s,W):rh(n)?(z=i.onDayClick)===null||z===void 0||z.call(i,t,s,W):(T=n.onDayClick)===null||T===void 0||T.call(n,t,s,W)},S=function(W){var U;x(t),(U=n.onDayFocus)===null||U===void 0||U.call(n,t,s,W)},D=function(W){var U;h(),(U=n.onDayBlur)===null||U===void 0||U.call(n,t,s,W)},_=function(W){var U;(U=n.onDayMouseEnter)===null||U===void 0||U.call(n,t,s,W)},A=function(W){var U;(U=n.onDayMouseLeave)===null||U===void 0||U.call(n,t,s,W)},E=function(W){var U;(U=n.onDayPointerEnter)===null||U===void 0||U.call(n,t,s,W)},q=function(W){var U;(U=n.onDayPointerLeave)===null||U===void 0||U.call(n,t,s,W)},O=function(W){var U;(U=n.onDayTouchCancel)===null||U===void 0||U.call(n,t,s,W)},R=function(W){var U;(U=n.onDayTouchEnd)===null||U===void 0||U.call(n,t,s,W)},P=function(W){var U;(U=n.onDayTouchMove)===null||U===void 0||U.call(n,t,s,W)},L=function(W){var U;(U=n.onDayTouchStart)===null||U===void 0||U.call(n,t,s,W)},$=function(W){var U;(U=n.onDayKeyUp)===null||U===void 0||U.call(n,t,s,W)},Z=function(W){var U;switch(W.key){case"ArrowLeft":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?d():m();break;case"ArrowRight":W.preventDefault(),W.stopPropagation(),n.dir==="rtl"?m():d();break;case"ArrowDown":W.preventDefault(),W.stopPropagation(),f();break;case"ArrowUp":W.preventDefault(),W.stopPropagation(),p();break;case"PageUp":W.preventDefault(),W.stopPropagation(),W.shiftKey?v():u();break;case"PageDown":W.preventDefault(),W.stopPropagation(),W.shiftKey?w():N();break;case"Home":W.preventDefault(),W.stopPropagation(),j();break;case"End":W.preventDefault(),W.stopPropagation(),b();break}(U=n.onDayKeyDown)===null||U===void 0||U.call(n,t,s,W)},Q={onClick:C,onFocus:S,onBlur:D,onKeyDown:Z,onKeyUp:$,onMouseEnter:_,onMouseLeave:A,onPointerEnter:E,onPointerLeave:q,onTouchCancel:O,onTouchEnd:R,onTouchMove:P,onTouchStart:L};return Q}function lU(){var t=An(),s=c_(),n=tj(),r=nj(),a=mp(t)?s.selected:nh(t)?n.selected:rh(t)?r.selected:void 0;return a}function oU(t){return Object.values(ui).includes(t)}function cU(t,s){var n=[t.classNames.day];return Object.keys(s).forEach(function(r){var a=t.modifiersClassNames[r];if(a)n.push(a);else if(oU(r)){var i=t.classNames["day_".concat(r)];i&&n.push(i)}}),n}function dU(t,s){var n=qs({},t.styles.day);return Object.keys(s).forEach(function(r){var a;n=qs(qs({},n),(a=t.modifiersStyles)===null||a===void 0?void 0:a[r])}),n}function uU(t,s,n){var r,a,i,o=An(),d=aj(),m=nU(t,s),f=iU(t,m),p=lU(),h=!!(o.onDayClick||o.mode!=="default");g.useEffect(function(){var _;m.outside||d.focusedDay&&h&&na(d.focusedDay,t)&&((_=n.current)===null||_===void 0||_.focus())},[d.focusedDay,t,n,h,m.outside]);var x=cU(o,m).join(" "),u=dU(o,m),N=!!(m.outside&&!o.showOutsideDays||m.hidden),v=(i=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:Tz,w=e.jsx(v,{date:t,displayMonth:s,activeModifiers:m}),j={style:u,className:x,children:w,role:"gridcell"},b=d.focusTarget&&na(d.focusTarget,t)&&!m.outside,C=d.focusedDay&&na(d.focusedDay,t),S=qs(qs(qs({},j),(r={disabled:m.disabled,role:"gridcell"},r["aria-selected"]=m.selected,r.tabIndex=C||b?0:-1,r)),f),D={isButton:h,isHidden:N,activeModifiers:m,selectedDays:p,buttonProps:S,divProps:j};return D}function hU(t){var s=g.useRef(null),n=uU(t.date,t.displayMonth,s);return n.isHidden?e.jsx("div",{role:"gridcell"}):n.isButton?e.jsx(vf,qs({name:"day",ref:s},n.buttonProps)):e.jsx("div",qs({},n.divProps))}function mU(t){var s=t.number,n=t.dates,r=An(),a=r.onWeekNumberClick,i=r.styles,o=r.classNames,d=r.locale,m=r.labels.labelWeekNumber,f=r.formatters.formatWeekNumber,p=f(Number(s),{locale:d});if(!a)return e.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:p});var h=m(Number(s),{locale:d}),x=function(u){a(s,n,u)};return e.jsx(vf,{name:"week-number","aria-label":h,className:o.weeknumber,style:i.weeknumber,onClick:x,children:p})}function fU(t){var s,n,r=An(),a=r.styles,i=r.classNames,o=r.showWeekNumber,d=r.components,m=(s=d==null?void 0:d.Day)!==null&&s!==void 0?s:hU,f=(n=d==null?void 0:d.WeekNumber)!==null&&n!==void 0?n:mU,p;return o&&(p=e.jsx("td",{className:i.cell,style:a.cell,children:e.jsx(f,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:i.row,style:a.row,children:[p,t.dates.map(function(h){return e.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:e.jsx(m,{displayMonth:t.displayMonth,date:h})},t7(h))})]})}function CS(t,s,n){for(var r=n!=null&&n.ISOWeek?JD(s):Eb(s,n),a=n!=null&&n.ISOWeek?rc(t):Mi(t,n),i=Ti(r,a),o=[],d=0;d<=i;d++)o.push(Ur(a,d));var m=o.reduce(function(f,p){var h=n!=null&&n.ISOWeek?eR(p):sR(p,n),x=f.find(function(u){return u.weekNumber===h});return x?(x.dates.push(p),f):(f.push({weekNumber:h,dates:[p]}),f)},[]);return m}function pU(t,s){var n=CS(ia(t),tp(t),s);if(s!=null&&s.useFixedWeeks){var r=n7(t,s);if(r<6){var a=n[n.length-1],i=a.dates[a.dates.length-1],o=by(i,6-r),d=CS(by(i,1),o,s);n.push.apply(n,d)}}return n}function xU(t){var s,n,r,a=An(),i=a.locale,o=a.classNames,d=a.styles,m=a.hideHead,f=a.fixedWeeks,p=a.components,h=a.weekStartsOn,x=a.firstWeekContainsDate,u=a.ISOWeek,N=pU(t.displayMonth,{useFixedWeeks:!!f,ISOWeek:u,locale:i,weekStartsOn:h,firstWeekContainsDate:x}),v=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:_z,w=(n=p==null?void 0:p.Row)!==null&&n!==void 0?n:fU,j=(r=p==null?void 0:p.Footer)!==null&&r!==void 0?r:Dz;return e.jsxs("table",{id:t.id,className:o.table,style:d.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!m&&e.jsx(v,{}),e.jsx("tbody",{className:o.tbody,style:d.tbody,children:N.map(function(b){return e.jsx(w,{displayMonth:t.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),e.jsx(j,{displayMonth:t.displayMonth})]})}function gU(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var vU=gU()?g.useLayoutEffect:g.useEffect,qg=!1,yU=0;function AS(){return"react-day-picker-".concat(++yU)}function bU(t){var s,n=t??(qg?AS():null),r=g.useState(n),a=r[0],i=r[1];return vU(function(){a===null&&i(AS())},[]),g.useEffect(function(){qg===!1&&(qg=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function jU(t){var s,n,r=An(),a=r.dir,i=r.classNames,o=r.styles,d=r.components,m=ah().displayMonths,f=bU(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),p=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,h=[i.month],x=o.month,u=t.displayIndex===0,N=t.displayIndex===m.length-1,v=!u&&!N;a==="rtl"&&(s=[u,N],N=s[0],u=s[1]),u&&(h.push(i.caption_start),x=qs(qs({},x),o.caption_start)),N&&(h.push(i.caption_end),x=qs(qs({},x),o.caption_end)),v&&(h.push(i.caption_between),x=qs(qs({},x),o.caption_between));var w=(n=d==null?void 0:d.Caption)!==null&&n!==void 0?n:kz;return e.jsxs("div",{className:h.join(" "),style:x,children:[e.jsx(w,{id:f,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(xU,{id:p,"aria-labelledby":f,displayMonth:t.displayMonth})]},t.displayIndex)}function NU(t){var s=An(),n=s.classNames,r=s.styles;return e.jsx("div",{className:n.months,style:r.months,children:t.children})}function wU(t){var s,n,r=t.initialProps,a=An(),i=aj(),o=ah(),d=g.useState(!1),m=d[0],f=d[1];g.useEffect(function(){a.initialFocus&&i.focusTarget&&(m||(i.focus(i.focusTarget),f(!0)))},[a.initialFocus,m,i.focus,i.focusTarget,i]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var h=qs(qs({},a.styles.root),a.style),x=Object.keys(r).filter(function(N){return N.startsWith("data-")}).reduce(function(N,v){var w;return qs(qs({},N),(w={},w[v]=r[v],w))},{}),u=(n=(s=r.components)===null||s===void 0?void 0:s.Months)!==null&&n!==void 0?n:NU;return e.jsx("div",qs({className:p.join(" "),style:h,dir:a.dir,id:a.id,nonce:r.nonce,title:r.title,lang:r.lang},x,{children:e.jsx(u,{children:o.displayMonths.map(function(N,v){return e.jsx(jU,{displayIndex:v,displayMonth:N},v)})})}))}function SU(t){var s=t.children,n=Kq(t,["children"]);return e.jsx(mz,{initialProps:n,children:e.jsx(wz,{children:e.jsx(rU,{initialProps:n,children:e.jsx(Pz,{initialProps:n,children:e.jsx(Iz,{initialProps:n,children:e.jsx(Vz,{children:e.jsx(sU,{children:s})})})})})})})}function CU(t){return e.jsx(SU,qs({},t,{children:e.jsx(wU,{initialProps:t})}))}function yf({className:t,classNames:s,showOutsideDays:n=!0,...r}){return e.jsx(CU,{showOutsideDays:n,className:Nt("p-3",t),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:Nt(nd({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:Nt("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:Nt(nd({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({className:a,...i})=>e.jsx(io,{className:Nt("size-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(mi,{className:Nt("size-4",a),...i})},...r})}function AU({onViewDetails:t}){const[s,n]=g.useState("table"),[r,a]=g.useState(""),[i,o]=g.useState("all"),[d,m]=g.useState("all"),[f,p]=g.useState("all"),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState("date-desc"),[j,b]=g.useState(1),[C,S]=g.useState(null),[D,_]=g.useState([]),[A,E]=g.useState(!1),[q,O]=g.useState(!1),[R,P]=g.useState(""),[L,$]=g.useState([]),[Z,Q]=g.useState([]),[W,U]=g.useState([]),[M,z]=g.useState(!0);g.useEffect(()=>{F()},[h,u,i,r,j,d,f]),g.useEffect(()=>{b(1)},[h,u,i,r,d,f]),g.useEffect(()=>{T()},[]);const T=async()=>{try{const ce=await $s.getStates(),Me=(Array.isArray(ce)?ce:(ce==null?void 0:ce.data)||(ce==null?void 0:ce.states)||[]).map(ut=>typeof ut=="string"?ut:ut.name||ut.stateName).filter(Boolean);$(Me)}catch(ce){console.error("Failed to fetch states:",ce)}},F=async()=>{try{z(!0);const ce=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],je=await ps.getApplications({fromDate:h,toDate:u,status:i==="all"?ce.join(","):i,location:d!=="all"?d:void 0,state:f!=="all"?f:void 0,ddLeadShortlisted:"false",isShortlisted:"true",search:r,page:j,limit:10}),Me=je.data||[];S(je.meta);const ut=Me.map(X=>({id:X.id,registrationNumber:X.applicationId||"N/A",name:X.applicantName,email:X.email,phone:X.phone,age:X.age,education:X.education,residentialAddress:X.address||X.city||"",businessAddress:X.address||"",preferredLocation:X.preferredLocation,state:X.state,ownsBike:X.ownRoyalEnfield==="yes",pastExperience:X.experienceYears?`${X.experienceYears} years`:X.description||"",status:X.overallStatus,questionnaireMarks:X.score||X.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:X.createdAt,assignedUsers:[],progress:X.progressPercentage||0,isShortlisted:X.isShortlisted,ddLeadShortlisted:X.ddLeadShortlisted,companyName:X.companyName,source:X.source,existingDealer:X.existingDealer,royalEnfieldModel:X.royalEnfieldModel,description:X.description,pincode:X.pincode,locationType:X.locationType,ownRoyalEnfield:X.ownRoyalEnfield,address:X.address}));U(ut);const jt=Array.from(new Set(ut.map(X=>X.preferredLocation))).filter(Boolean);Q(X=>Array.from(new Set([...X,...jt])));const ft=Array.from(new Set(ut.map(X=>X.state))).filter(Boolean);$(X=>Array.from(new Set([...X,...ft])))}catch(ce){console.error("Failed to fetch applications:",ce),J.error("Failed to load opportunity requests")}finally{z(!1)}},I=W.sort((ce,je)=>v==="score-desc"?(je.questionnaireMarks||0)-(ce.questionnaireMarks||0):v==="score-asc"?(ce.questionnaireMarks||0)-(je.questionnaireMarks||0):v==="date-desc"?new Date(je.submissionDate).getTime()-new Date(ce.submissionDate).getTime():v==="date-asc"?new Date(ce.submissionDate).getTime()-new Date(je.submissionDate).getTime():0),K=ce=>{_(ce?I.map(je=>je.id):[])},G=(ce,je)=>{_(je?[...D,ce]:D.filter(Me=>Me!==ce))},V=()=>{if(D.length===0){J.error("Please select at least one application to shortlist");return}O(!0)},Y=async()=>{try{const ce=await ps.shortlistApplications(D,[],R);if(ce&&ce.success)await F(),_([]),O(!1),P(""),J.success(`${D.length} application(s) shortlisted successfully. Users will be assigned automatically.`);else throw new Error((ce==null?void 0:ce.message)||"Failed to process shortlisting")}catch(ce){console.error("Failed to shortlist applications:",ce),J.error(ce.message||"Failed to process shortlisting")}},re=async()=>{if(D.length===0){J.error("Please select at least one application");return}try{E(!0);const ce=await ps.sendBulkReminders(D);ce.success&&(J.success(ce.message||`Reminder emails sent to ${D.length} applicant(s)`),_([]))}catch(ce){console.error("Failed to send reminders:",ce),J.error(ce.message||"Failed to send reminders")}finally{E(!1)}},ae=async()=>{const ce=I.filter(ut=>ut.status!=="Questionnaire Pending"),je=ce.filter(ut=>D.includes(ut.id));let Me=[];if(D.length>0){if(je.length===0){J.error('Selected applications are in "Questionnaire Pending" status and cannot be exported.');return}Me=je.map(ut=>ut.id),je.length<D.length&&J.info(`Skipping ${D.length-je.length} applications with pending questionnaires.`)}else Me=ce.map(ut=>ut.id);if(Me.length===0){J.error("No applications with completed questionnaires available for export");return}try{const ut=J.loading("Preparing Excel export..."),jt=await ps.exportResponses(Me);if(J.dismiss(ut),!jt||jt.length===0){J.error("No response data found");return}const ft=Object.keys(jt[0]),Ce=[ft.join(","),...jt.map(rt=>ft.map(ht=>{const ge=rt[ht]??"";return`"${String(ge).replace(/"/g,'""')}"`}).join(","))].join(`
|
||
`),xe=new Blob([Ce],{type:"text/csv;charset=utf-8;"}),We=URL.createObjectURL(xe),Be=document.createElement("a");Be.setAttribute("href",We),Be.setAttribute("download",`onboarding_responses_${new Date().toISOString().split("T")[0]}.xlsx`),document.body.appendChild(Be),Be.click(),document.body.removeChild(Be),J.success(`Exported ${Me.length} records to Excel successfully`)}catch(ut){console.error("Export failed:",ut),J.error(ut.message||"Failed to export responses")}},ue=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],ye=ce=>({Submitted:"bg-blue-100 text-blue-800","Questionnaire Pending":"bg-yellow-100 text-yellow-800","Questionnaire Completed":"bg-cyan-100 text-cyan-800",Shortlisted:"bg-purple-100 text-purple-800","Level 1 Interview Pending":"bg-orange-100 text-orange-800","Level 1 Approved":"bg-green-100 text-green-800","Level 2 Interview Pending":"bg-orange-100 text-orange-800","Level 2 Approved":"bg-green-100 text-green-800","Level 2 Recommended":"bg-teal-100 text-teal-800","Level 3 Interview Pending":"bg-orange-100 text-orange-800","FDD Verification":"bg-indigo-100 text-indigo-800","Payment Pending":"bg-red-50 text-red-800","LOI Issued":"bg-sky-100 text-sky-800","Dealer Code Generation":"bg-purple-100 text-purple-800","Architecture Team Assigned":"bg-blue-100 text-blue-800","Architecture Document Upload":"bg-blue-100 text-blue-800","Architecture Team Completion":"bg-blue-100 text-blue-800","Statutory GST":"bg-emerald-100 text-emerald-800","Statutory PAN":"bg-emerald-100 text-emerald-800","Statutory Nodal":"bg-emerald-100 text-emerald-800","Statutory Check":"bg-emerald-100 text-emerald-800","Statutory Partnership":"bg-emerald-100 text-emerald-800","Statutory Firm Reg":"bg-emerald-100 text-emerald-800","Statutory Rental":"bg-emerald-100 text-emerald-800","Statutory Virtual Code":"bg-emerald-100 text-emerald-800","Statutory Domain":"bg-emerald-100 text-emerald-800","Statutory MSD":"bg-emerald-100 text-emerald-800","Statutory LOI Ack":"bg-emerald-100 text-emerald-800","EOR In Progress":"bg-violet-100 text-violet-800","LOA Pending":"bg-pink-100 text-pink-800",Inauguration:"bg-green-100 text-green-800",Approved:"bg-green-100 text-green-800",Rejected:"bg-red-100 text-red-800",Disqualified:"bg-gray-100 text-gray-800","In Review":"bg-slate-100 text-slate-800","Level 3 Approved":"bg-green-100 text-green-800","LOI In Progress":"bg-sky-50 text-sky-700","LOI Approved":"bg-green-100 text-green-800","Security Deposit In Progress":"bg-blue-50 text-blue-700","Security Deposit Approved":"bg-green-100 text-green-800","Security Deposit":"bg-blue-100 text-blue-800","Security Details In Progress":"bg-blue-50 text-blue-700","Security Details Approved":"bg-green-100 text-green-800","Security Details":"bg-blue-100 text-blue-800","LOI Issued In Progress":"bg-sky-50 text-sky-700","Statutory Work In Progress":"bg-emerald-50 text-emerald-700","Statutory Work Completed":"bg-green-100 text-green-800","Architecture Work In Progress":"bg-blue-50 text-blue-700","Architecture Work Completed":"bg-green-100 text-green-800","Dealer Code Generation In Progress":"bg-purple-50 text-purple-700","Dealer Code Generated":"bg-green-100 text-green-800","LOA Issued":"bg-pink-100 text-pink-800","EOR Complete":"bg-violet-100 text-violet-800",Onboarded:"bg-green-200 text-green-900"})[ce]||"bg-gray-100 text-gray-800";return M?e.jsx("div",{className:"flex justify-center items-center h-96",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name or registration number...",value:r,onChange:ce=>a(ce.target.value),className:"pl-10","data-testid":"onboarding-opp-requests-search-input"})]}),e.jsxs(Rt,{value:i,onValueChange:o,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-status-select",children:e.jsx(Et,{placeholder:"Filter by status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Statuses"}),ue.map(ce=>e.jsx(Pe,{value:ce,children:ce},ce))]})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-9",onClick:()=>{x(""),N(""),o("all"),m("all"),p("all"),a("")},"data-testid":"onboarding-opp-requests-clear-filters",children:"Clear Filters"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-state-select",children:e.jsx(Et,{placeholder:"Filter by state"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),L.map(ce=>e.jsx(Pe,{value:ce,children:ce},ce))]})]}),e.jsxs(Rt,{value:d,onValueChange:m,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-location-select",children:e.jsx(Et,{placeholder:"Filter by location"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),Z.map(ce=>e.jsx(Pe,{value:ce,children:ce},ce))]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-none",children:[e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-40 justify-start text-left font-normal h-9 px-3",!h&&"text-muted-foreground"),"data-testid":"onboarding-opp-requests-from-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),h?za(new Date(h),"PPP"):e.jsx("span",{className:"text-xs",children:"From Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:h?new Date(h):void 0,onSelect:ce=>x(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-40 justify-start text-left font-normal h-9 px-3",!u&&"text-muted-foreground"),"data-testid":"onboarding-opp-requests-to-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),u?za(new Date(u),"PPP"):e.jsx("span",{className:"text-xs",children:"To Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:u?new Date(u):void 0,onSelect:ce=>N(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(Rt,{value:v,onValueChange:w,children:[e.jsx(_t,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-sort-select",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_I,{className:"w-4 h-4 text-slate-400"}),e.jsx(Et,{placeholder:"Sort by"})]})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"date-desc",children:"Newest Applied"}),e.jsx(Pe,{value:"date-asc",children:"Oldest Applied"}),e.jsx(Pe,{value:"score-desc",children:"Highest Score"}),e.jsx(Pe,{value:"score-asc",children:"Lowest Score"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(te,{variant:s==="grid"?"default":"outline",size:"sm",onClick:()=>n("grid"),className:s==="grid"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-opp-requests-view-grid-btn",children:[e.jsx(lk,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(te,{variant:s==="table"?"default":"outline",size:"sm",onClick:()=>n("table"),className:s==="table"?"bg-re-red hover:bg-re-red-hover":"","data-testid":"onboarding-opp-requests-view-table-btn",children:[e.jsx(dk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(te,{variant:"outline",size:"sm",onClick:ae,"data-testid":"onboarding-opp-requests-export-btn",children:[e.jsx(fi,{className:"w-4 h-4 mr-2"}),"Export"]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{variant:"outline",size:"sm",onClick:re,disabled:A,"data-testid":"onboarding-opp-requests-bulk-reminder-btn",children:[A?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",D.length,")"]}),e.jsxs(te,{size:"sm",onClick:V,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-opp-requests-bulk-shortlist-btn",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Shortlist (",D.length,")"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(we,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-opp-requests-pending-count",children:[(C==null?void 0:C.total)||I.length," pending shortlisting"]})})]})]})}),s==="grid"?e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4","data-testid":"onboarding-opp-requests-grid",children:[I.map((ce,je)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-opp-requests-grid-item-${je}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Tn,{checked:D.includes(ce.id),onCheckedChange:Me=>G(ce.id,Me),className:"bg-white","data-testid":`onboarding-opp-requests-grid-checkbox-${je}`})}),e.jsx(UE,{application:ce,onViewDetails:t})]},ce.id)),I.length===0&&e.jsxs("div",{className:"col-span-full text-center py-12 text-slate-500 bg-white rounded-lg border border-slate-200","data-testid":"onboarding-opp-requests-grid-empty",children:[e.jsx(ln,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No opportunity requests found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})]}):e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200","data-testid":"onboarding-opp-requests-table-container",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:D.length===I.length&&I.length>0,onCheckedChange:K,"data-testid":"onboarding-opp-requests-table-select-all"})}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-reg",children:"Registration"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-name",children:"Name"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-pref-loc",children:"Preferred Location"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-status",children:"Status"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-score",children:"Score"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-app-loc",children:"Applicant Location"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-shortlisted",children:"Shortlisted"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-progress",children:"Progress"}),e.jsx(me,{"data-testid":"onboarding-opp-requests-th-date",children:"Applied On"})]})}),e.jsxs(Bs,{children:[I.map((ce,je)=>e.jsxs(lt,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(ce.id),"data-testid":`onboarding-opp-requests-row-${je}`,children:[e.jsx(oe,{onClick:Me=>Me.stopPropagation(),children:e.jsx(Tn,{checked:D.includes(ce.id),onCheckedChange:Me=>G(ce.id,Me),"data-testid":`onboarding-opp-requests-table-select-item-${ce.id}`})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-reg-${je}`,children:ce.registrationNumber})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-name-${je}`,children:ce.name})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-pref-loc-${je}`,children:ce.preferredLocation})}),e.jsx(oe,{children:e.jsx(we,{className:ye(ce.status),"data-testid":`onboarding-opp-requests-status-${je}`,children:ce.status})}),e.jsx(oe,{children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-opp-requests-score-${je}`,children:ce.questionnaireMarks})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-app-loc-${je}`,children:ce.businessAddress})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline","data-testid":`onboarding-opp-requests-shortlisted-badge-${je}`,children:"No"})}),e.jsx(oe,{children:e.jsx(up,{value:ce.progress,status:ce.status,showPercent:!0,"data-testid":`onboarding-opp-requests-progress-${je}`})}),e.jsx(oe,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-date-${je}`,children:Qt(ce.submissionDate)})})]},ce.id)),I.length===0&&e.jsx(lt,{children:e.jsxs(oe,{colSpan:9,className:"text-center py-12 text-slate-500","data-testid":"onboarding-opp-requests-table-empty",children:[e.jsx(ln,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No opportunity requests found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})})]})]}),C&&C.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>b(ce=>Math.max(1,ce-1)),className:j===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(C.totalPages)].map((ce,je)=>{const Me=je+1;return Me===1||Me===C.totalPages||Me>=j-1&&Me<=j+1?e.jsx(pn,{children:e.jsx($i,{isActive:j===Me,onClick:()=>b(Me),className:"cursor-pointer",children:Me})},Me):Me===j-2||Me===j+2?e.jsx(pn,{children:e.jsx(go,{})},Me):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>b(ce=>Math.min(C.totalPages,ce+1)),className:j===C.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ms,{open:q,onOpenChange:O,children:e.jsxs(us,{className:"overflow-visible","data-testid":"onboarding-opp-requests-shortlist-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{"data-testid":"onboarding-opp-requests-shortlist-modal-title",children:"Shortlist Applications"}),e.jsxs(ws,{children:["You are about to shortlist ",D.length," application(s). These applications will be moved to the Dealership Requests page and users will be assigned automatically based on the applied location."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Shortlisting Remark (Optional)"}),e.jsx(Ks,{placeholder:"Enter reason for shortlisting these applications...",value:R,onChange:ce=>P(ce.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-opp-requests-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>{O(!1),P("")},"data-testid":"onboarding-opp-requests-shortlist-cancel-btn",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:Y,"data-testid":"onboarding-opp-requests-shortlist-confirm-btn",children:"Confirm Shortlist"})]})]})]})})]})}function kU({onViewDetails:t}){var W,U;const[s,n]=g.useState(""),[r,a]=g.useState("all"),[i,o]=g.useState("all"),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(1),[u,N]=g.useState(null),[v,w]=g.useState([]),[j,b]=g.useState(!0),[C,S]=g.useState([]),[D,_]=g.useState([]),[A,E]=g.useState([]),[q,O]=g.useState(!1),R=async()=>{var M,z,T,F;if(A.length!==0)try{O(!0);const I=await ps.bulkConvertToOpportunity({ids:A});I!=null&&I.success&&((((M=I.data)==null?void 0:M.success)>0||!I.data)&&J.success(I.message||`Successfully converted ${((z=I.data)==null?void 0:z.success)||A.length} leads.`),((T=I.data)==null?void 0:T.failed)>0&&((F=I.data)!=null&&F.errors)&&I.data.errors.forEach(K=>{J.error(K,{duration:5e3})}),E([]),await Z())}catch(I){console.error("Bulk conversion error:",I),J.error(I.message||"Failed to perform bulk conversion")}finally{O(!1)}},P=()=>{A.length===Q.length?E([]):E(Q.map(M=>M.id))},L=M=>{E(z=>z.includes(M)?z.filter(T=>T!==M):[...z,M])};g.useEffect(()=>{Z()},[d,f,s,h,r,i]),g.useEffect(()=>{x(1)},[d,f,s,r,i]),g.useEffect(()=>{$()},[]);const $=async()=>{try{const M=await $s.getStates(),T=(Array.isArray(M)?M:(M==null?void 0:M.data)||(M==null?void 0:M.states)||[]).map(F=>typeof F=="string"?F:F.name||F.stateName).filter(Boolean);S(T)}catch(M){console.error("Failed to fetch states:",M)}},Z=async()=>{try{b(!0);const M=await ps.getApplications({fromDate:d,toDate:f,search:s,status:"Submitted",isShortlisted:"false",location:r!=="all"?r:void 0,state:i!=="all"?i:void 0,page:h,limit:10}),z=M.data||[];N(M.meta);const T=z.map(K=>({id:K.id,registrationNumber:K.applicationId||"N/A",name:K.applicantName,email:K.email,phone:K.phone,age:K.age,education:K.education,residentialAddress:K.address||K.city||"",businessAddress:K.address||"",preferredLocation:K.preferredLocation,state:K.state,ownsBike:K.ownRoyalEnfield==="yes",pastExperience:K.experienceYears?`${K.experienceYears} years`:K.description||"",status:K.overallStatus,questionnaireMarks:K.score||K.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:K.createdAt,assignedUsers:[],progress:K.progressPercentage||0,isShortlisted:K.isShortlisted,companyName:K.companyName,source:K.source,existingDealer:K.existingDealer,royalEnfieldModel:K.royalEnfieldModel,description:K.description,pincode:K.pincode,locationType:K.locationType,ownRoyalEnfield:K.ownRoyalEnfield,address:K.address}));w(T);const F=Array.from(new Set(T.map(K=>K.preferredLocation))).filter(Boolean);_(K=>Array.from(new Set([...K,...F])));const I=Array.from(new Set(T.map(K=>K.state))).filter(Boolean);S(K=>Array.from(new Set([...K,...I])))}catch(M){console.error("Failed to fetch applications:",M),J.error("Failed to load non-opportunity requests")}finally{b(!1)}},Q=v;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl mb-2",children:"Non-opportunities (Lead Generation)"}),e.jsx("p",{className:"text-slate-600",children:"Interest submissions from regions where dealerships are currently not being offered. These leads received non-opportunity notification and are stored for future reference."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-total",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Total Leads"}),e.jsx("p",{className:"text-2xl text-slate-900 mt-1",children:(u==null?void 0:u.total)||v.length})]}),e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(ty,{className:"w-6 h-6 text-blue-600"})})]})}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-locations",children:[e.jsx("p",{className:"text-slate-600",children:"Unique Locations"}),e.jsx("p",{className:"text-2xl text-slate-900 mt-1",children:((W=u==null?void 0:u.stats)==null?void 0:W.uniqueLocations)||0})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-4","data-testid":"onboarding-non-opps-stat-exp",children:[e.jsx("p",{className:"text-slate-600",children:"With Experience"}),e.jsx("p",{className:"text-2xl text-re-red mt-1",children:((U=u==null?void 0:u.stats)==null?void 0:U.withExperience)||0})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{type:"text",placeholder:"Search by name, email, phone, or registration number...",value:s,onChange:M=>n(M.target.value),className:"pl-10","data-testid":"onboarding-non-opps-search-input"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-36 justify-start text-left font-normal h-10 px-3",!d&&"text-muted-foreground"),"data-testid":"onboarding-non-opps-from-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),d?za(new Date(d),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"From Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:d?new Date(d):void 0,onSelect:M=>m(M?M.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(_u,{children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:Nt("w-full md:w-36 justify-start text-left font-normal h-10 px-3",!f&&"text-muted-foreground"),"data-testid":"onboarding-non-opps-to-date-trigger",children:[e.jsx(er,{className:"mr-2 h-4 w-4 text-slate-400"}),f?za(new Date(f),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"To Date"})]})}),e.jsx(Pu,{className:"w-auto p-0",align:"start",children:e.jsx(yf,{mode:"single",selected:f?new Date(f):void 0,onSelect:M=>p(M?M.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(Rt,{value:r,onValueChange:a,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-location-select",children:e.jsx(Et,{placeholder:"All Locations"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Locations"}),D.map(M=>e.jsx(Pe,{value:M,children:M},M))]})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-10 px-3",onClick:()=>{m(""),p(""),a("all"),o("all"),n("")},"data-testid":"onboarding-non-opps-clear-filters",children:"Clear Filters"}),e.jsxs(Rt,{value:i,onValueChange:o,children:[e.jsx(_t,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-state-select",children:e.jsx(Et,{placeholder:"All States"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),C.map(M=>e.jsx(Pe,{value:M,children:M},M))]})]}),e.jsx(te,{variant:"outline",size:"icon","data-testid":"onboarding-non-opps-export-btn",children:e.jsx(fi,{className:"w-4 h-4"})}),A.length>0&&e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover font-bold",onClick:R,disabled:q,children:[q?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(OI,{className:"w-4 h-4 mr-2"}),"Convert ",A.length," to Opportunity"]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 overflow-hidden","data-testid":"onboarding-non-opps-table-container",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-12",children:e.jsx(Tn,{checked:Q.length>0&&A.length===Q.length,onCheckedChange:P})}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-name",children:"Name"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-phone",children:"Phone"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-email",children:"Email"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-loc",children:"Preferred Location"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-address",children:"Main Address"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-age",children:"Age"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-exp",children:"Experience"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-edu",children:"Education"}),e.jsx(me,{"data-testid":"onboarding-non-opps-th-date",children:"Applied On"}),e.jsx(me,{className:"text-right","data-testid":"onboarding-non-opps-th-actions",children:"Actions"})]})}),e.jsx(Bs,{children:j?e.jsx(lt,{children:e.jsxs(oe,{colSpan:11,className:"text-center py-20",children:[e.jsx(cs,{className:"w-8 h-8 mx-auto animate-spin text-re-red mb-2"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading applications..."})]})}):Q.length===0?e.jsx(lt,{children:e.jsxs(oe,{colSpan:11,className:"text-center py-12 text-slate-500","data-testid":"onboarding-non-opps-empty-state",children:[e.jsx(ty,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{className:"text-lg mb-2",children:"No lead generation data found"}),e.jsx("p",{className:"text-sm",children:"Try adjusting your filters"})]})}):Q.map((M,z)=>e.jsxs(lt,{"data-testid":`onboarding-non-opps-row-${z}`,className:A.includes(M.id)?"bg-red-50/50":"",children:[e.jsx(oe,{children:e.jsx(Tn,{checked:A.includes(M.id),onCheckedChange:()=>L(M.id)})}),e.jsx(oe,{children:e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900","data-testid":`onboarding-non-opps-name-${z}`,children:M.name}),e.jsx("p",{className:"text-slate-500 text-sm","data-testid":`onboarding-non-opps-id-${z}`,children:M.registrationNumber})]})}),e.jsx(oe,{className:"text-slate-900","data-testid":`onboarding-non-opps-phone-${z}`,children:M.phone}),e.jsx(oe,{className:"text-slate-600","data-testid":`onboarding-non-opps-email-${z}`,children:M.email}),e.jsx(oe,{children:e.jsxs("div",{"data-testid":`onboarding-non-opps-pref-loc-${z}`,children:[e.jsx("p",{className:"text-slate-900",children:M.preferredLocation}),e.jsx("p",{className:"text-slate-500 text-sm",children:M.state})]})}),e.jsx(oe,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-non-opps-address-${z}`,children:M.residentialAddress}),e.jsx(oe,{className:"text-slate-900","data-testid":`onboarding-non-opps-age-${z}`,children:M.age}),e.jsx(oe,{className:"text-slate-600","data-testid":`onboarding-non-opps-experience-${z}`,children:M.pastExperience}),e.jsx(oe,{className:"text-slate-900","data-testid":`onboarding-non-opps-education-${z}`,children:M.education}),e.jsx(oe,{className:"text-slate-600","data-testid":`onboarding-non-opps-date-${z}`,children:Qt(M.submissionDate)}),e.jsx(oe,{className:"text-right",children:e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(te,{variant:"outline",size:"sm",onClick:()=>t(M.id),"data-testid":`onboarding-non-opps-view-btn-${z}`,children:"View"})})})]},M.id))})]}),u&&u.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>x(M=>Math.max(1,M-1)),className:h===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(u.totalPages)].map((M,z)=>{const T=z+1;return T===1||T===u.totalPages||T>=h-1&&T<=h+1?e.jsx(pn,{children:e.jsx($i,{isActive:h===T,onClick:()=>x(T),className:"cursor-pointer",children:T})},T):T===h-2||T===h+2?e.jsx(pn,{children:e.jsx(go,{})},T):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>x(M=>Math.min(u.totalPages,M+1)),className:h===u.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})}function DU({application:t,slaStatus:s,isNonResponsive:n,isAdmin:r,onBack:a,onOpenWorknotes:i}){return e.jsxs(e.Fragment,{children:[n&&e.jsxs("div",{className:"bg-red-50 border border-red-200 p-4 rounded-2xl flex items-center justify-between animate-in fade-in slide-in-from-top-4 duration-500","data-testid":"onboarding-details-non-responsive-banner",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-xl",children:e.jsx(mk,{className:"w-6 h-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black text-red-900 tracking-tight leading-none uppercase",children:"Applicant Flagged Non-Responsive"}),e.jsx("p",{className:"text-red-700 text-[11px] font-bold uppercase tracking-widest mt-1 opacity-80",children:"Audit process is currently on hold due to missing cooperation"})]})]}),r&&e.jsx(te,{variant:"outline",size:"sm",className:"bg-white border-red-200 text-red-600 hover:bg-red-50 font-black text-[10px] uppercase tracking-widest hidden sm:block h-9","data-testid":"onboarding-details-review-audit-button",onClick:()=>{const o=document.querySelector('[value="worknotes"]');o==null||o.click()},children:"Review Audit"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:a,className:"shrink-0","data-testid":"onboarding-details-back-button",children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{className:"truncate",children:[e.jsx("h1",{className:"text-slate-900 truncate leading-tight","data-testid":"onboarding-details-application-name",children:t.name}),e.jsx("p",{className:"text-slate-600 truncate text-sm","data-testid":"onboarding-details-registration-number",children:t.registrationNumber}),s&&e.jsx("div",{className:"mt-1",children:e.jsx(br,{status:s})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(te,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:i,"data-testid":"onboarding-details-view-work-notes",children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]})]})}var RU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],EU=RU.reduce((t,s)=>{const n=Hu(`Primitive.${s}`),r=g.forwardRef((a,i)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),_U="Separator",kS="horizontal",TU=["horizontal","vertical"],d_=g.forwardRef((t,s)=>{const{decorative:n,orientation:r=kS,...a}=t,i=PU(r)?r:kS,d=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return e.jsx(EU.div,{"data-orientation":i,...d,...a,ref:s})});d_.displayName=_U;function PU(t){return TU.includes(t)}var OU=d_;function Xo({className:t,orientation:s="horizontal",decorative:n=!0,...r}){return e.jsx(OU,{"data-slot":"separator-root",decorative:n,orientation:s,className:Nt("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}function LU({application:t,canEditStatutory:s,isEditingStatutory:n,isSavingStatutory:r,statutoryForm:a,onEditFirmType:i,onEditStatutory:o,onCancelEditStatutory:d,onSaveStatutory:m,onStatutoryFormChange:f}){return e.jsxs(_e,{"data-testid":"onboarding-applicant-info-card",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Applicant Information"})}),e.jsxs(Oe,{className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-x-6 gap-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Rr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Full Name"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-name",children:t.name})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Gr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Email"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-email",children:t.email})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(tb,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Phone"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-phone",children:t.phone})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Rr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Age"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-age",children:t.age?`${t.age} years`:"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(qI,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Education"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-education",children:t.education||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Mr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Preferred Location"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-preferred-location",children:t.preferredLocation||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Mr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location Type"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-location-type",children:t.locationType||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(to,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-slate-600 flex items-center justify-between group cursor-pointer",onClick:i,"data-testid":"onboarding-applicant-info-edit-firm-type",children:["Proposed Firm Type",e.jsx(ry,{className:"w-3 h-3 text-slate-300 group-hover:text-re-red transition-colors"})]}),e.jsx("p",{className:"text-slate-900 font-black text-re-red-hover tracking-tight leading-none mt-1","data-testid":"onboarding-applicant-info-firm-type",children:t.constitutionType||"Not Provided"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S1,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Owns Bike"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-owns-bike",children:t.ownRoyalEnfield==="yes"?"Yes":"No"})]})]}),t.ownRoyalEnfield==="yes"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S1,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Bike Model"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-bike-model",children:t.royalEnfieldModel||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Rr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Existing Dealer"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-existing-dealer",children:t.existingDealer==="yes"?"Yes":"No"})]})]}),t.existingDealer==="yes"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Rr,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Company Name"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-company-name",children:t.companyName||"N/A"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sc,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Source"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-source",children:t.source||"N/A"})]})]}),t.questionnaireMarks!==void 0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(nk,{className:"w-5 h-5 text-slate-400 mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Questionnaire Score"}),e.jsxs("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-score",children:[t.questionnaireMarks,"/100"]})]})]})]}),e.jsx(Xo,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Address"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-address",children:t.address||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Pincode"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-pincode",children:t.pincode||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Description"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-description",children:t.description||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 mb-2",children:"Past Experience"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-applicant-info-experience",children:t.pastExperience||"N/A"})]}),e.jsxs("div",{className:"pt-6 border-t mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-black text-slate-900 uppercase tracking-widest flex items-center gap-2",children:[e.jsx(Wu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Information"]}),s&&!n&&e.jsxs(te,{variant:"ghost",size:"sm",onClick:o,className:"h-8 text-re-red hover:text-re-red-hover hover:bg-red-50 gap-1.5","data-testid":"onboarding-applicant-info-edit-statutory",children:[e.jsx(ry,{className:"w-3.5 h-3.5"}),"Edit Details"]})]}),n?e.jsxs("div",{className:"bg-slate-50/50 p-6 rounded-xl border-2 border-red-100 space-y-4","data-testid":"onboarding-applicant-info-statutory-edit-form",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Legal Entity Name"}),e.jsx(it,{value:a.accountHolderName,onChange:p=>f({...a,accountHolderName:p.target.value}),placeholder:"Enter Legal Entity Name",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-legal-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"PAN Number"}),e.jsx(it,{value:a.panNumber,onChange:p=>f({...a,panNumber:p.target.value.toUpperCase()}),placeholder:"10-digit PAN",maxLength:10,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-pan"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"GST Number"}),e.jsx(it,{value:a.gstNumber,onChange:p=>f({...a,gstNumber:p.target.value.toUpperCase()}),placeholder:"15-digit GSTIN",maxLength:15,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-gst"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Registered Address"}),e.jsx(it,{value:a.registeredAddress,onChange:p=>f({...a,registeredAddress:p.target.value}),placeholder:"Enter Registered Office Address",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-registered-address"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Bank Name"}),e.jsx(it,{value:a.bankName,onChange:p=>f({...a,bankName:p.target.value}),placeholder:"Enter Bank Name",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-bank-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Account Number"}),e.jsx(it,{value:a.accountNumber,onChange:p=>f({...a,accountNumber:p.target.value}),placeholder:"Enter Account Number",className:"bg-white border-slate-200","data-testid":"onboarding-applicant-info-input-account-number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] uppercase font-bold text-slate-500",children:"IFSC Code"}),e.jsx(it,{value:a.ifscCode,onChange:p=>f({...a,ifscCode:p.target.value.toUpperCase()}),placeholder:"11-digit IFSC",maxLength:11,className:"bg-white border-slate-200 uppercase","data-testid":"onboarding-applicant-info-input-ifsc-code"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(te,{variant:"outline",size:"sm",onClick:d,disabled:r,"data-testid":"onboarding-applicant-info-statutory-cancel",children:"Cancel"}),e.jsx(te,{size:"sm",onClick:m,disabled:r,className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-applicant-info-statutory-save",children:r?e.jsx(cs,{className:"w-4 h-4 animate-spin"}):"Save Details"})]})]}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 bg-slate-50/50 p-4 rounded-xl border border-slate-100","data-testid":"onboarding-applicant-info-statutory-display",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"Legal Entity Name"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900","data-testid":"onboarding-applicant-info-display-legal-name",children:t.accountHolderName||"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"PAN Number"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900 uppercase","data-testid":"onboarding-applicant-info-display-pan",children:t.panNumber||"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"GST Number"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900 uppercase","data-testid":"onboarding-applicant-info-display-gst",children:t.gstNumber||"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"Registered Address"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900","data-testid":"onboarding-applicant-info-display-registered-address",children:t.registeredAddress||"Pending"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"onboarding-applicant-info-display-bank-info",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tight",children:"Bank Details"}),e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:t.bankName||"N/A"}),e.jsxs("p",{className:"text-[10px] text-slate-600",children:["A/C: ",t.accountNumber||"N/A"]}),e.jsxs("p",{className:"text-[10px] text-slate-600",children:["IFSC: ",t.ifscCode||"N/A"]})]})]})]})]})]})}const IU=({application:t})=>{if(!t.questionnaireResponses||t.questionnaireResponses.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-300","data-testid":"onboarding-questionnaire-empty",children:[e.jsx(sc,{className:"w-12 h-12 mb-3 text-slate-300"}),e.jsx("h3",{className:"text-lg font-medium text-slate-700",children:"Response is Pending"}),e.jsx("p",{className:"text-sm",children:"The applicant has not submitted the questionnaire yet."})]});const s=[...t.questionnaireResponses].sort((r,a)=>{var i,o;return(((i=r.question)==null?void 0:i.order)||0)-(((o=a.question)==null?void 0:o.order)||0)}),n=t.score||t.questionnaireMarks||0;return e.jsxs("div",{className:"space-y-6","data-testid":"onboarding-questionnaire-view",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(sc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900",children:"Questionnaire Responses"})]}),n!==void 0&&e.jsxs(we,{className:"bg-re-red","data-testid":"onboarding-questionnaire-total-score",children:["Score: ",n,"/100"]})]}),e.jsx("div",{className:"space-y-6",children:s.map((r,a)=>{const i=r.question,o=(i==null?void 0:i.questionText)||"Unknown Question",d=r.responseValue||"No Answer",m=(i==null?void 0:i.sectionName)||"General",f=(i==null?void 0:i.questionOptions)||[],p=f.find(v=>v.optionText===d),h=p?p.score:0,x=Math.max(...f.map(v=>v.score||0),0),u=typeof d=="string"&&d.startsWith("data:"),N=u&&d.startsWith("data:image");return e.jsxs("div",{className:"border border-slate-200 rounded-lg p-5 hover:border-red-300 transition-colors","data-testid":`onboarding-questionnaire-item-${a}`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-red-50 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-re-red",children:a+1})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(we,{variant:"outline",className:"text-slate-600 bg-slate-50","data-testid":`onboarding-questionnaire-item-section-${a}`,children:m}),f.length>0&&x>0&&e.jsxs(we,{className:h>0?"bg-green-600":"bg-slate-400","data-testid":`onboarding-questionnaire-item-score-${a}`,children:[h,"/",x]})]}),e.jsx("h4",{className:"text-slate-900 font-medium","data-testid":`onboarding-questionnaire-item-text-${a}`,children:o})]})]}),e.jsx("div",{className:"ml-11",children:N?e.jsx("div",{className:"mt-2","data-testid":`onboarding-questionnaire-item-image-${a}`,children:e.jsx("img",{src:d,alt:"Response Attachment",className:"max-w-full h-auto max-h-64 rounded border p-1 object-contain"})}):u?e.jsx("a",{href:d,download:`upload_${a}.pdf`,className:"text-blue-600 underline text-sm break-all","data-testid":`onboarding-questionnaire-item-download-${a}`,children:"Download Attachment"}):e.jsx("div",{className:"text-slate-600 leading-relaxed break-words whitespace-pre-wrap","data-testid":`onboarding-questionnaire-item-answer-${a}`,children:r.attachmentUrl?e.jsx("a",{href:r.attachmentUrl,target:"_blank",rel:"noreferrer",className:"text-blue-600 underline","data-testid":`onboarding-questionnaire-item-attachment-${a}`,children:"View Attachment"}):d})})]},r.id)})})]})},MU=Ky("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Ai({className:t,variant:s,...n}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:Nt(MU({variant:s}),t),...n})}function il({className:t,...s}){return e.jsx("div",{"data-slot":"alert-title",className:Nt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s})}function ki({className:t,...s}){return e.jsx("div",{"data-slot":"alert-description",className:Nt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s})}var FU={};function BU(t){const{application:s,activeTab:n,setActiveTab:r,processStages:a,documents:i,interviews:o,expandedBranches:d,setExpandedBranches:m,setSelectedStage:f,setShowDocumentsModal:p,setShowUploadForm:h,handleRetriggerEvaluators:x,handleRescheduleInterview:u,setSelectedEvaluationForView:N,setShowFeedbackDetailsModal:v,renderFddAuditContent:w,eorProgress:j,eorData:b,eorChecklist:C,setUploadDocType:S,isAdmin:D,fetchApplication:_,fetchEorData:A,deposits:E,getDeposit:q,paymentConfigs:O,setPreviewDoc:R,setShowPreviewModal:P,auditLoading:L,auditLogs:$,auditLogActionBadgeClass:Z}=t,Q=U=>String(U||"").trim().toLowerCase().replace(/[_\s-]+/g," "),W=(U,M)=>{var F,I,K;const z=[(F=U==null?void 0:U.user)==null?void 0:F.role,(I=U==null?void 0:U.user)==null?void 0:I.roleCode,(K=U==null?void 0:U.metadata)==null?void 0:K.role].map(Q),T=M.map(Q);return z.some(G=>T.includes(G))};return e.jsx(_e,{"data-testid":"onboarding-details-tabs-container",children:e.jsxs(In,{value:n,onValueChange:r,children:[e.jsx(Xe,{className:"pb-4 px-4 sm:px-6",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-4 px-4 sm:-mx-6 sm:px-6",children:e.jsxs(Mn,{className:"w-max min-w-full justify-start h-11 bg-slate-100/80 p-1","data-testid":"onboarding-tabs-list",children:[e.jsx(Ht,{value:"questionnaire",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-questionnaire",children:"Questionnaire"}),e.jsx(Ht,{value:"progress",className:"min-w-[80px]","data-testid":"onboarding-tab-trigger-progress",children:"Progress"}),e.jsx(Ht,{value:"documents",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-documents",children:"Documents"}),e.jsx(Ht,{value:"interviews",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-interviews",children:"Interviews"}),e.jsx(Ht,{value:"fdd",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-fdd",children:"FDD Audit"}),e.jsx(Ht,{value:"eor",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-eor",children:"EOR Checklist"}),e.jsx(Ht,{value:"payments",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-payments",children:"Payments"}),e.jsx(Ht,{value:"audit",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-audit",children:"Audit Trail"})]})})}),e.jsxs(Oe,{children:[e.jsx(Vt,{value:"questionnaire",className:"space-y-6","data-testid":"onboarding-tab-content-questionnaire",children:e.jsx(IU,{application:s})}),e.jsxs(Vt,{value:"progress",className:"space-y-6","data-testid":"onboarding-tab-content-progress",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-slate-900",children:"Application Journey"}),e.jsxs(we,{className:wq(s.status),"data-testid":"onboarding-progress-percentage-badge",children:[s.progress,"% Complete"]})]}),e.jsx(oc,{value:s.progress,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:fl(s.status),"data-testid":"onboarding-progress-bar"})]}),e.jsx("div",{className:"relative status-progress-ui","data-testid":"onboarding-progress-stages-container",children:(()=>{const U={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},M={LOI_APPROVAL:["DD Head","NBH"],LOA_APPROVAL:["DD Head","NBH"]},z=F=>(s.participants||[]).filter(K=>{var V,Y,re,ae,ue,ye,ce,je,Me,ut,jt,ft;return((V=K.metadata)==null?void 0:V.stageCode)===F||((re=(Y=K.metadata)==null?void 0:Y.allAssignments)==null?void 0:re.includes(F))||typeof F=="number"&&(((ae=K.metadata)==null?void 0:ae.interviewLevel)===F||((ue=K.metadata)==null?void 0:ue.interviewLevel)===String(F)||((ce=(ye=K.metadata)==null?void 0:ye.allAssignments)==null?void 0:ce.includes(F))||((Me=(je=K.metadata)==null?void 0:je.allAssignments)==null?void 0:Me.includes(String(F))))||typeof F=="string"&&!isNaN(Number(F))&&(((ut=K.metadata)==null?void 0:ut.interviewLevel)===Number(F)||((ft=(jt=K.metadata)==null?void 0:jt.allAssignments)==null?void 0:ft.includes(Number(F))))?!0:typeof F=="number"?W(K,U[F]||[]):W(K,M[F]||[])}).map(K=>{var Y,re,ae,ue,ye;const G=typeof F=="number"?`INTERVIEW_LEVEL_${F}`:F,V=(s.stageApprovals||[]).find(ce=>ce.stageCode===G&&String(ce.actorUserId)===String(K.userId));return{name:((Y=K.user)==null?void 0:Y.name)||((re=K.user)==null?void 0:re.fullName)||"Unknown",role:((ae=K.user)==null?void 0:ae.role)||((ue=K.user)==null?void 0:ue.roleCode)||((ye=K.metadata)==null?void 0:ye.role)||"Reviewer",status:V?V.decision==="Approved"?"approved":"rejected":"pending"}}),T=(F,I)=>{const G={"1st Level Interview":1,"2nd Level Interview":2,"3rd Level Interview":3,"LOI Approval":"LOI_APPROVAL",LOA:"LOA_APPROVAL"}[F];if(!G)return null;const V=z(G);return V.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2 mt-3","data-testid":`onboarding-stage-approvers-${I}`,children:V.map((Y,re)=>e.jsxs("div",{className:"group relative flex items-center gap-1.5 bg-slate-50 border border-slate-200 rounded-full pl-1 pr-2.5 py-0.5 transition-all hover:bg-white hover:shadow-sm","data-testid":`onboarding-stage-approver-${I}-${re}`,children:[e.jsx("div",{className:Nt("w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold text-white",Y.status==="approved"?"bg-green-500":Y.status==="rejected"?"bg-red-500":"bg-slate-300"),children:Y.name.split(" ").map(ae=>ae[0]).join("").substring(0,2).toUpperCase()}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-700 leading-none",children:Y.name}),e.jsx("span",{className:"text-[8px] text-slate-500 leading-none mt-0.5",children:Y.role})]}),e.jsx("div",{className:Nt("absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full border border-white",Y.status==="approved"?"bg-green-500":Y.status==="rejected"?"bg-red-500":"bg-status-progress"),"data-testid":`onboarding-stage-approver-status-dot-${I}-${re}`}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-slate-900 text-white text-[10px] rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-50",children:[Y.role,": ",Y.status.toUpperCase()]})]},re))})};return a.map((F,I)=>e.jsxs("div",{"data-testid":`onboarding-progress-stage-${I}`,children:[e.jsxs("div",{className:"flex gap-4 pb-8",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center border-2 z-10 relative ${F.status==="completed"?"bg-green-500 border-green-500 text-white shadow-md":F.status==="active"?F.isLocked?"bg-slate-400 border-slate-400 text-white":"bg-status-workflow-active border-status-workflow-active text-white animate-pulse-subtle":"bg-white border-slate-300 text-slate-400 shadow-none"}`,"data-testid":`onboarding-progress-stage-icon-${I}`,children:F.isParallel?e.jsx(sy,{className:"w-5 h-5"}):F.isLocked?e.jsxs("div",{className:"group relative",children:[e.jsx(ny,{className:"w-5 h-5 text-white cursor-help"}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-1.5 bg-slate-900 text-white text-[10px] rounded shadow-xl opacity-0 group-hover:opacity-100 pointer-events-none transition-all duration-200 whitespace-nowrap z-[100] border border-slate-700",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"font-bold text-status-progress flex items-center gap-1",children:[e.jsx(sn,{className:"w-3 h-3"})," Stage Locked"]}),e.jsx("span",{children:F.lockMessage})]}),e.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-slate-900"})]})]}):e.jsx(e.Fragment,{children:F.status==="completed"?e.jsx(Hn,{className:"w-6 h-6"}):F.status==="active"?e.jsx(dn,{className:"w-5 h-5 text-white"}):e.jsx("div",{className:"w-3 h-3 bg-slate-300 rounded-full"})})}),I<a.length-1&&!F.isParallel&&e.jsx("div",{className:`absolute top-10 left-1/2 -translate-x-1/2 w-0.5 h-full z-0 ${F.status==="completed"?"bg-green-500/30":"bg-slate-200"}`,"data-testid":`onboarding-progress-stage-connector-${I}`})]}),e.jsxs("div",{className:"flex-1 pt-1",children:[e.jsx("p",{className:Nt("font-bold transition-colors",F.status==="completed"?"text-green-700":F.status==="active"?"text-status-progress-muted":"text-slate-900"),"data-testid":`onboarding-progress-stage-name-${I}`,children:F.name}),F.description&&e.jsx("p",{className:"text-slate-600 text-sm mt-0.5 leading-relaxed","data-testid":`onboarding-progress-stage-desc-${I}`,children:F.description}),T(F.name,I),F.evaluators&&F.evaluators.length>0&&!["LOI Approval","LOA","1st Level Interview","2nd Level Interview","3rd Level Interview"].includes(F.name)&&e.jsxs("p",{className:"text-status-progress text-xs mt-1.5 flex items-center gap-1 bg-status-progress-soft w-fit px-2 py-0.5 rounded border border-status-progress","data-testid":`onboarding-progress-stage-evaluators-${I}`,children:[e.jsx(Rr,{className:"w-3 h-3"}),"Evaluators: ",F.evaluators.join(" + ")]}),(()=>{var ye;const K={3:2,4:2,5:2,6:2,8:2,12:2},G=Number(F.id),V=K[G],re={3:1,4:1,5:2,6:3,8:"LOI_APPROVAL",12:"LOA_APPROVAL"}[G],ae=re?z(re).length:((ye=F.evaluators)==null?void 0:ye.length)||0,ue=G===3?F.status==="completed":F.status!=="pending";return V&&ae<V&&s.status!=="Rejected"&&ue?e.jsx("div",{className:"mt-2","data-testid":`onboarding-progress-stage-warning-${I}`,children:e.jsxs(Ai,{variant:"destructive",className:"py-2 px-3 border-red-200 bg-red-50 text-red-800",children:[e.jsx(sn,{className:"h-4 w-4 text-re-red"}),e.jsx(il,{className:"text-xs font-semibold",children:"Missing Evaluators"}),e.jsxs(ki,{className:"text-xs",children:[ae===0?"Respective role users were not found for this location.":`Some roles (${ae}/${V}) are missing for this location.`,e.jsxs(te,{variant:"link",size:"sm",className:"h-auto p-0 ml-1 text-xs text-re-red-hover underline",onClick:x,"data-testid":`onboarding-progress-stage-retrigger-${I}`,children:[e.jsx(or,{className:"w-3 h-3 mr-1"}),"Re-trigger Assignment"]})]})]})}):null})(),(()=>{const K=i.filter(V=>{var Y;return V.stage===F.name||!V.stage&&((Y=V.documentType)==null?void 0:Y.toLowerCase().includes(F.name.toLowerCase().split(" ")[0]))}).length,G=F.status==="active"&&!F.isLocked;return K===0&&!G?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(F.name),p(!0),K===0&&G&&h(!0)},className:"text-xs font-semibold text-blue-600 hover:text-blue-800 flex items-center gap-1.5 px-3 py-1 rounded-full bg-blue-50 border border-blue-100 hover:bg-blue-100 transition-all shadow-sm","data-testid":`onboarding-progress-stage-docs-${I}`,children:[e.jsx(ks,{className:"w-3.5 h-3.5"}),K>0?`${K} Documents`:"Upload"]})})})(),e.jsxs("p",{className:"text-slate-500 mt-1 text-xs","data-testid":`onboarding-progress-stage-status-text-${I}`,children:[F.status==="completed"&&F.date&&`Completed: ${Qt(F.date)}`,F.status==="active"&&"In Progress",F.status==="pending"&&"Pending"]})]})]}),F.isParallel&&F.branches&&e.jsxs("div",{className:"ml-5 mb-8","data-testid":`onboarding-progress-parallel-branches-${I}`,children:[F.branches.map((K,G)=>{const V=K.name.toLowerCase().replace(/\s+/g,"-"),Y=d[V],re=K.color==="blue"?"blue":"green";return e.jsxs("div",{className:"mb-6 last:mb-0",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsxs("button",{onClick:()=>m(ae=>({...ae,[V]:!ae[V]})),className:`flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-all hover:shadow-md ${re==="blue"?"border-blue-300 bg-blue-50 hover:bg-blue-100":"border-green-300 bg-green-50 hover:bg-green-100"}`,"data-testid":`onboarding-progress-branch-trigger-${V}`,children:[Y?e.jsx(va,{className:`w-5 h-5 ${re==="blue"?"text-blue-600":"text-green-600"}`}):e.jsx(mi,{className:`w-5 h-5 ${re==="blue"?"text-blue-600":"text-green-600"}`}),e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${re==="blue"?"bg-blue-200":"bg-green-200"}`,children:e.jsx(sy,{className:`w-4 h-4 ${re==="blue"?"text-blue-700":"text-green-700"}`})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:`${re==="blue"?"text-blue-900":"text-green-900"} font-semibold tracking-tight`,children:K.name}),e.jsxs("p",{className:`text-[10px] uppercase font-bold tracking-wider ${re==="blue"?"text-blue-500":"text-green-500"}`,children:[K.stages.length," SUB-STEPS"]})]})]})}),Y&&e.jsx("div",{className:"mt-4 ml-8 border-l-2 border-slate-200 pl-6 space-y-6","data-testid":`onboarding-progress-branch-content-${V}`,children:K.stages.map((ae,ue)=>e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex gap-4 text-xs","data-testid":`onboarding-progress-branch-stage-${V}-${ue}`,children:(()=>{const ye=i.filter(je=>{var Me;return((Me=je.documentType)==null?void 0:Me.toLowerCase().includes(ae.name.toLowerCase().split(" ")[0]))||je.stage===ae.name}),ce=ae.status==="completed"||ye.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center border-2 ${ce?`${re==="blue"?"bg-blue-500 border-blue-500":"bg-green-500 border-green-500"}`:ae.status==="active"?"bg-status-workflow-active border-status-workflow-active text-white shadow-sm":"bg-white border-slate-300 text-slate-400"}`,"data-testid":`onboarding-progress-branch-stage-icon-${V}-${ue}`,children:ce?e.jsx($n,{className:"w-4 h-4 text-white",strokeWidth:3}):ae.status==="active"?e.jsx(dn,{className:"w-4 h-4 text-white"}):e.jsx("div",{className:"w-2 h-2 bg-slate-300 rounded-full"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold text-slate-800","data-testid":`onboarding-progress-branch-stage-name-${V}-${ue}`,children:ae.name}),ae.description&&e.jsx("p",{className:"text-slate-500 text-xs mt-0.5",children:ae.description}),(()=>{const je=ae.status==="active";return ye.length===0&&!je?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(ae.name),p(!0),ye.length===0&&je&&h(!0)},className:Nt("text-[10px] font-medium flex items-center gap-1 transition-colors",re==="blue"?"text-blue-600 hover:text-blue-800":"text-green-600 hover:text-green-800"),"data-testid":`onboarding-progress-branch-stage-docs-${V}-${ue}`,children:[e.jsx(ks,{className:"w-2.5 h-2.5"}),ye.length>0?`${ye.length} Docs`:"Upload"]})})})(),e.jsx("p",{className:"text-slate-400 text-[10px] mt-1","data-testid":`onboarding-progress-branch-stage-status-${V}-${ue}`,children:ce&&ae.date?`Done: ${Qt(ae.date)}`:ce&&ye.length>0?`Uploaded: ${Qt(ye[0].updatedAt||ye[0].createdAt)}`:"Pending"})]})]})})()})},ae.id))})]},G)}),e.jsx("div",{className:"h-8 w-0.5 bg-slate-300 ml-5 opacity-50"})]})]},F.id))})()})]}),e.jsxs(Vt,{value:"documents",className:"space-y-4","data-testid":"onboarding-tab-content-documents",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-slate-900",children:"Uploaded Documents"}),e.jsxs(te,{size:"sm",className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-documents-upload-tab-button",onClick:()=>{f(null),p(!0),h(!0)},children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ms,{"data-testid":"onboarding-documents-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"min-w-[200px]",children:"File Name"}),e.jsx(me,{className:"min-w-[120px]",children:"Type"}),e.jsx(me,{className:"min-w-[120px]",children:"Upload Date"}),e.jsx(me,{className:"min-w-[150px]",children:"Uploader"}),e.jsx(me,{className:"text-right min-w-[100px]",children:"Actions"})]})}),e.jsx(Bs,{children:i.length===0?e.jsx(lt,{"data-testid":"onboarding-documents-empty-row",children:e.jsx(oe,{colSpan:5,className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})}):i.map((U,M)=>{var z;return e.jsxs(lt,{"data-testid":`onboarding-document-row-${M}`,children:[e.jsxs(oe,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"truncate max-w-[150px] md:max-w-[300px]","data-testid":`onboarding-document-name-${M}`,children:U.fileName})]}),e.jsx(oe,{"data-testid":`onboarding-document-type-${M}`,children:U.documentType}),e.jsx(oe,{children:Qt(U.createdAt)}),e.jsx(oe,{"data-testid":`onboarding-document-uploader-${M}`,children:((z=U.uploader)==null?void 0:z.fullName)||(U.uploadedBy?"Unknown User":"Applicant")}),e.jsx(oe,{children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{size:"sm",variant:"outline","data-testid":`onboarding-document-preview-${M}`,onClick:()=>{R(U),P(!0)},children:e.jsx(un,{className:"w-3 h-3 text-slate-500"})}),e.jsx(te,{size:"sm",variant:"outline","data-testid":`onboarding-document-download-${M}`,onClick:()=>{const T=FU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${T}/${U.filePath}`,"_blank")},children:e.jsx(fi,{className:"w-3 h-3 text-slate-500"})})]})})]},U.id)})})]})})]}),e.jsxs(Vt,{value:"interviews",className:"space-y-6","data-testid":"onboarding-tab-content-interviews",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Scheduled Interviews"}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ms,{"data-testid":"onboarding-interviews-scheduled-table",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{className:"min-w-[100px]",children:"Level"}),e.jsx(me,{className:"min-w-[180px]",children:"Date & Time"}),e.jsx(me,{className:"min-w-[100px]",children:"Type"}),e.jsx(me,{className:"min-w-[200px]",children:"Location/Link"}),e.jsx(me,{className:"min-w-[120px]",children:"Status"}),e.jsx(me,{className:"min-w-[150px]",children:"Scheduled By"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:!o||o.length===0?e.jsx(lt,{"data-testid":"onboarding-interviews-empty-row",children:e.jsx(oe,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No interviews scheduled yet"})}):(Array.isArray(o)?o:[]).map((U,M)=>{var z,T;return e.jsxs(lt,{"data-testid":`onboarding-interview-row-${M}`,children:[e.jsxs(oe,{className:"font-medium",children:["Level ",U.level]}),e.jsx(oe,{children:U.scheduleDate?new Date(U.scheduleDate).toLocaleString():"N/A"}),e.jsx(oe,{className:"capitalize",children:U.interviewType}),e.jsx(oe,{children:(z=U.interviewType)!=null&&z.toLowerCase().includes("virtual")?e.jsx("a",{href:U.linkOrLocation,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline","data-testid":`onboarding-interview-link-${M}`,children:"Join Meeting"}):e.jsx("span",{"data-testid":`onboarding-interview-location-${M}`,children:U.linkOrLocation})}),e.jsx(oe,{children:e.jsx(we,{variant:U.status==="Completed"?"default":"secondary","data-testid":`onboarding-interview-status-${M}`,children:U.status})}),e.jsx(oe,{children:((T=U.scheduler)==null?void 0:T.fullName)||U.scheduledBy||"N/A"}),e.jsx(oe,{className:"text-right",children:(U.status==="Scheduled"||U.status==="scheduled")&&e.jsx(te,{variant:"ghost",size:"sm",className:"text-primary-600 hover:text-primary-700 hover:bg-primary-50 h-8 px-2","data-testid":`onboarding-interview-reschedule-${M}`,onClick:()=>u(U),children:"Reschedule"})})]},U.id)})})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Interview Feedback"}),!o||o.length===0?e.jsx("p",{className:"text-slate-500 italic","data-testid":"onboarding-interviews-no-feedback",children:"No interviews scheduled."}):(Array.isArray(o)?o:[]).map((U,M)=>e.jsxs("div",{className:"mb-6 border p-4 rounded-lg bg-slate-50/50","data-testid":`onboarding-interview-feedback-block-${M}`,children:[e.jsxs("h4",{className:"font-semibold text-slate-800 mb-2",children:["Level ",U.level," Interview",e.jsxs("span",{className:"font-normal text-slate-500 text-sm ml-2",children:["(",Qt(U.scheduleDate)," - ",U.interviewType,")"]})]}),U.evaluations&&U.evaluations.length>0?e.jsxs(Ms,{"data-testid":`onboarding-interview-evaluations-table-${M}`,children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Interviewer"}),e.jsx(me,{children:"Role"}),e.jsx(me,{children:U.level===1?"Score (KT Matrix)":"Overall Score"}),e.jsx(me,{children:"Remarks"}),e.jsx(me,{children:"Recommendation"})]})}),e.jsx(Bs,{children:U.evaluations.map((z,T)=>{var F,I,K;return e.jsxs(lt,{"data-testid":`onboarding-interview-evaluation-row-${M}-${T}`,children:[e.jsx(oe,{className:"font-medium",children:(F=z.evaluator)==null?void 0:F.fullName}),e.jsx(oe,{children:((K=(I=z.evaluator)==null?void 0:I.role)==null?void 0:K.roleName)||"N/A"}),e.jsx(oe,{children:z.ktMatrixScore?e.jsxs(we,{variant:U.level===1?Number(z.ktMatrixScore)>=50?"outline":"destructive":Number(z.ktMatrixScore)>=5?"outline":"destructive","data-testid":`onboarding-interview-evaluation-score-${M}-${T}`,children:[z.ktMatrixScore,"/",U.level===1?"100":"10"]}):"N/A"}),e.jsx(oe,{className:"max-w-xs truncate",title:z.remarks||z.qualitativeFeedback,children:z.remarks?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-slate-800",children:z.remarks}),z.feedbackDetails&&z.feedbackDetails.length>0&&e.jsx(te,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 text-xs w-fit","data-testid":`onboarding-interview-evaluation-details-btn-${M}-${T}`,onClick:()=>{N({...z,interview:U}),v(!0)},children:"View Detailed Feedback"})]}):z.feedbackDetails&&z.feedbackDetails.length>0?e.jsx(te,{variant:"link",className:"p-0 h-auto font-normal text-blue-600","data-testid":`onboarding-interview-evaluation-details-btn-${M}-${T}`,onClick:()=>{N({...z,interview:U}),v(!0)},children:"View Detailed Feedback"}):z.qualitativeFeedback||"-"}),e.jsx(oe,{"data-testid":`onboarding-interview-evaluation-rec-${M}-${T}`,children:z.recommendation||"-"})]},z.id)})})]}):e.jsx("p",{className:"text-sm text-slate-500 italic pl-2",children:"No feedback recorded yet."})]},U.id))]}),["Level 2 Approved","Level 3 Interview Pending","Approved","Onboarded"].includes(s.status)&&e.jsxs("div",{"data-testid":"onboarding-interviews-summary-l2",children:[e.jsx("h3",{className:"text-slate-900 mb-4",children:"Level 2 Interview Summary"}),e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[e.jsx("p",{className:"text-slate-600",children:"Decision: Approved by both ZBH and DD Lead"}),e.jsx("p",{className:"text-slate-600 mt-2",children:"Overall Assessment: Strong candidate with excellent business plan"})]})]})]}),e.jsx(Vt,{value:"fdd",className:"space-y-6","data-testid":"onboarding-tab-content-fdd",children:w()}),e.jsxs(Vt,{value:"eor",className:"space-y-4 status-progress-ui","data-testid":"onboarding-tab-content-eor",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-slate-900",children:"Essential Operating Requirements"}),e.jsxs(we,{className:Cq(j),"data-testid":"onboarding-eor-progress-badge",children:[Math.round(j),"% Complete"]})]}),e.jsx(oc,{value:j,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:Sq(j),"data-testid":"onboarding-eor-progress-bar"}),e.jsx("div",{className:"space-y-3","data-testid":"onboarding-eor-checklist",children:((b==null?void 0:b.items)||C).map((U,M)=>{const z=U.description||U.item,T=!!U.proofDocument;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-slate-50 rounded-xl transition-all border border-transparent hover:border-slate-200 group","data-testid":`onboarding-eor-item-${M}`,children:[e.jsx(Tn,{checked:U.isCompliant||U.completed,className:"pointer-events-none shrink-0","data-testid":`onboarding-eor-checkbox-${M}`}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0 cursor-pointer","data-testid":`onboarding-eor-clickable-${M}`,onClick:()=>{f(`EOR: ${z}`),S(z),p(!0),h(!T)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:U.isCompliant||U.completed?"text-slate-900 font-bold":"text-slate-600 font-medium",children:z}),T&&!U.isCompliant&&e.jsx(we,{variant:"outline",className:"text-[10px] h-4 px-1.5 bg-red-50 text-re-red border-red-200 uppercase tracking-wider font-bold",children:"Needs Verification"})]}),T&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-blue-600 font-semibold mt-1",children:[e.jsx(ks,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"truncate",children:U.proofDocument.fileName})]}),!T&&e.jsx("span",{className:"text-[10px] text-slate-400 mt-1 uppercase tracking-tighter",children:"Click to upload proof"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[T&&!U.isCompliant&&D&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(te,{size:"sm",className:"h-8 px-3 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg shadow-sm","data-testid":`onboarding-eor-verify-btn-${M}`,onClick:async()=>{await(await Yo(async()=>{const{eorService:F}=await Promise.resolve().then(()=>Ug);return{eorService:F}},void 0)).eorService.updateItem(b.id,{...U,isCompliant:!0}),A(),J.success(`${z} verified!`)},children:"Verify"}),e.jsx(te,{size:"sm",variant:"outline",className:"h-8 px-3 border-red-200 text-red-600 hover:bg-red-50 font-bold rounded-lg","data-testid":`onboarding-eor-reject-btn-${M}`,onClick:async()=>{await(await Yo(async()=>{const{eorService:F}=await Promise.resolve().then(()=>Ug);return{eorService:F}},void 0)).eorService.updateItem(b.id,{...U,isCompliant:!1,proofDocumentId:null}),A(),J.success(`${z} rejected.`)},children:"Reject"})]}),(U.isCompliant||U.completed)&&e.jsx("div",{className:"bg-green-100 p-1.5 rounded-full","data-testid":`onboarding-eor-done-icon-${M}`,children:e.jsx(ln,{className:"w-4 h-4 text-green-600"})}),!T&&e.jsx("div",{className:"p-2 text-slate-300 group-hover:text-re-red transition-colors","data-testid":`onboarding-eor-upload-hint-${M}`,children:e.jsx(vr,{className:"w-4 h-4"})})]})]},U.id)})}),j===100&&D&&(s.status==="EOR In Progress"||s.status==="LOA Pending")&&e.jsx("div",{className:"mt-8 p-6 bg-green-50 rounded-xl border-2 border-green-200 animate-in fade-in slide-in-from-bottom-4 duration-500","data-testid":"onboarding-eor-complete-banner",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-100 flex items-center justify-center shrink-0",children:e.jsx(so,{className:"w-7 h-7 text-green-600"})}),e.jsxs("div",{className:"flex-1 text-center sm:text-left",children:[e.jsx("h4",{className:"text-green-900 font-bold text-lg",children:"EOR Checklist Complete"}),e.jsx("p",{className:"text-green-700 text-sm",children:"All 12 mandatory requirements have been verified. You can now complete the audit and move to final inauguration."})]}),e.jsx(te,{className:"w-full sm:w-auto bg-green-600 hover:bg-green-700 text-white font-bold h-12 px-8 rounded-xl shadow-lg shadow-green-600/20 transition-all hover:scale-[1.02] active:scale-[0.98]","data-testid":"onboarding-eor-submit-audit",onClick:async()=>{try{const U=b==null?void 0:b.id;if(!U)throw new Error("Checklist ID not found");await(await Yo(async()=>{const{eorService:M}=await Promise.resolve().then(()=>Ug);return{eorService:M}},void 0)).eorService.submitAudit(U,{status:"Completed",overallComments:"EOR Checklist verified and audit completed."}),J.success("EOR Audit completed successfully!"),_(),A()}catch(U){J.error(U.message||"Failed to complete EOR audit")}},children:"Complete Audit & Proceed"})]})})]}),e.jsxs(Vt,{value:"payments",className:"space-y-6","data-testid":"onboarding-tab-content-payments",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Security Deposits"}),e.jsxs(we,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-payments-count-badge",children:[E.length," Payment Record(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(()=>{const U=q("SECURITY_DEPOSIT"),M=O.SECURITY_DEPOSIT,z=(M==null?void 0:M.amount)||5e5;return e.jsx(_e,{className:Nt("border-l-4",(U==null?void 0:U.status)==="Verified"?"border-l-green-500":(U==null?void 0:U.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-security",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-red-50 flex items-center justify-center text-re-red",children:e.jsx(sc,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"Security Deposit"})]}),e.jsx(we,{className:Nt((U==null?void 0:U.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(U==null?void 0:U.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-red-50 text-re-red-hover hover:bg-red-50"),"data-testid":"onboarding-payment-status-security",children:(U==null?void 0:U.status)||"Awaiting"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-xs text-slate-500 uppercase font-bold tracking-wider",children:"Amount Received"}),e.jsxs("span",{className:"text-lg font-bold text-slate-900","data-testid":"onboarding-payment-amount-security",children:["₹",Number((U==null?void 0:U.amount)||0).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-slate-100 pt-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Expected Total"}),e.jsxs("span",{className:"text-sm font-medium text-slate-600",children:["₹",z.toLocaleString()]})]}),(U==null?void 0:U.paymentReference)&&e.jsxs("div",{className:"bg-slate-50 p-2 rounded text-xs font-mono text-slate-600 flex justify-between items-center","data-testid":"onboarding-payment-ref-security",children:[e.jsxs("span",{children:["Ref: ",U.paymentReference]}),U.verifiedAt&&e.jsx("span",{children:Qt(U.verifiedAt)})]}),(U==null?void 0:U.remarks)&&e.jsxs("div",{className:"text-[11px] text-slate-500 bg-red-50/50 p-2 rounded border border-red-100 italic","data-testid":"onboarding-payment-remarks-security",children:['"',U.remarks,'"']}),e.jsxs("div",{className:"pt-4 mt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Verification Documents"}),e.jsxs("div",{className:"space-y-2",children:[i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("security"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("deposit"))}).map((T,F)=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-slate-50/50 border border-slate-100","data-testid":`onboarding-payment-doc-security-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(ks,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:T.fileName||T.name})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-re-red hover:text-re-red-hover hover:bg-red-50","data-testid":`onboarding-payment-doc-view-security-${F}`,onClick:()=>{R(T),P(!0)},children:"View"})]},F)),i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("security"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("deposit"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})(),(()=>{const U=q("FIRST_FILL"),M=O.FIRST_FILL,z=(M==null?void 0:M.amount)||15e5;return e.jsx(_e,{className:Nt("border-l-4",(U==null?void 0:U.status)==="Verified"?"border-l-green-500":(U==null?void 0:U.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-first-fill",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-blue-50 flex items-center justify-center text-blue-600",children:e.jsx(so,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"First Fill"})]}),e.jsx(we,{className:Nt((U==null?void 0:U.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(U==null?void 0:U.status)==="Rejected"?"bg-red-100 text-red-700 hover:bg-red-100":"bg-red-50 text-re-red-hover hover:bg-red-50"),"data-testid":"onboarding-payment-status-first-fill",children:(U==null?void 0:U.status)||"Awaiting"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-xs text-slate-500 uppercase font-bold tracking-wider",children:"Amount Received"}),e.jsxs("span",{className:"text-lg font-bold text-slate-900","data-testid":"onboarding-payment-amount-first-fill",children:["₹",Number((U==null?void 0:U.amount)||0).toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-baseline border-t border-slate-100 pt-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Expected Total"}),e.jsxs("span",{className:"text-sm font-medium text-slate-600",children:["₹",z.toLocaleString()]})]}),(U==null?void 0:U.paymentReference)&&e.jsxs("div",{className:"bg-slate-50 p-2 rounded text-xs font-mono text-slate-600 flex justify-between items-center","data-testid":"onboarding-payment-ref-first-fill",children:[e.jsxs("span",{children:["Ref: ",U.paymentReference]}),U.verifiedAt&&e.jsx("span",{children:Qt(U.verifiedAt)})]}),(U==null?void 0:U.remarks)&&e.jsxs("div",{className:"text-[11px] text-slate-500 bg-red-50/50 p-2 rounded border border-red-100 italic","data-testid":"onboarding-payment-remarks-first-fill",children:['"',U.remarks,'"']}),e.jsxs("div",{className:"pt-4 mt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Verification Documents"}),e.jsxs("div",{className:"space-y-2",children:[i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("first"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("fill"))}).map((T,F)=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-slate-50/50 border border-slate-100","data-testid":`onboarding-payment-doc-first-fill-${F}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(ks,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:T.fileName||T.name})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] text-blue-600 hover:text-blue-700 hover:bg-blue-50","data-testid":`onboarding-payment-doc-view-first-fill-${F}`,onClick:()=>{R(T),P(!0)},children:"View"})]},F)),i.filter(T=>{var F,I;return((F=T.documentType)==null?void 0:F.toLowerCase().includes("first"))&&((I=T.documentType)==null?void 0:I.toLowerCase().includes("fill"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})()]})]}),e.jsx(Vt,{value:"audit","data-testid":"onboarding-tab-content-audit",children:e.jsx(Ib,{className:"h-[30rem] rounded-md border border-slate-100 bg-slate-50/50",children:e.jsx("div",{className:"space-y-2.5 p-3 pr-4","data-testid":"onboarding-audit-logs-container",children:L?e.jsxs("div",{className:"flex items-center justify-center py-10","data-testid":"onboarding-audit-loading",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-re-red"}),e.jsx("span",{className:"ml-2 text-sm text-slate-500",children:"Loading audit trail…"})]}):$.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-slate-200 bg-white py-10 text-center text-sm text-slate-500","data-testid":"onboarding-audit-empty",children:"No audit logs recorded yet for this application."}):$.map((U,M)=>e.jsxs("div",{className:"rounded-lg border border-slate-200/90 bg-white p-3 text-sm shadow-sm","data-testid":`onboarding-audit-log-item-${M}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-3 gap-y-1.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(we,{variant:"outline",className:Nt("shrink-0 text-[10px] font-semibold uppercase tracking-wide",Z(U.action)),"data-testid":`onboarding-audit-log-action-${M}`,children:String(U.action||"EVENT").replace(/_/g," ")}),U.stage?e.jsx("span",{className:"max-w-[200px] truncate text-[11px] text-slate-500",title:U.stage,"data-testid":`onboarding-audit-log-stage-${M}`,children:U.stage}):null]}),e.jsx("time",{className:"shrink-0 text-xs tabular-nums text-slate-400",dateTime:U.timestamp,"data-testid":`onboarding-audit-log-time-${M}`,children:Qt(U.timestamp)})]}),e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-slate-800","data-testid":`onboarding-audit-log-desc-${M}`,children:U.description||"—"}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(Rr,{className:"h-3.5 w-3.5 shrink-0 text-slate-400","aria-hidden":!0}),e.jsxs("span",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-slate-600","data-testid":`onboarding-audit-log-user-${M}`,children:U.userName||"System"}),U.userEmail?e.jsxs("span",{className:"text-slate-400","data-testid":`onboarding-audit-log-email-${M}`,children:[" · ",U.userEmail]}):null]})]})]},U.id))})})})]})]})})}function $U(t){var I;const{application:s,permissions:n,getDeposit:r,isNonResponsive:a,isAdmin:i,currentUserStageAction:o,currentUserEvaluation:d,onOpenApproveModal:m,onOpenRejectModal:f,onOpenWorknote:p,onOpenScheduleModal:h,currentUser:x,handleGenerateDealerCodes:u,onOpenAssignArchitectureModal:N,onOpenAssignFdd:v,showAssignFddModal:w,setShowAssignFddModal:j,fddAgencies:b,selectedAgencyId:C,setSelectedAgencyId:S,isAssigningAgency:D,handleAssignAgency:_,activeInterviewForUser:A,hasSubmittedFeedback:E,setSelectedInterviewForFeedback:q,setShowKTMatrixModal:O,setShowLevel2FeedbackModal:R,setShowLevel3FeedbackModal:P,onGoToDashboard:L,showAssignModal:$,setShowAssignModal:Z,selectedUser:Q,setSelectedUser:W,users:U,participantType:M,setParticipantType:z,handleAddParticipant:T,isAssigningParticipant:F}=t;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_e,{"data-testid":"onboarding-details-summary-card",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Registration ID"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-reg-id",children:s.registrationNumber})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Status"}),e.jsx(we,{className:Nt("mt-1",Xb(s.status)),"data-testid":"onboarding-details-summary-status",children:s.status})]}),s.rank&&e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Rank"}),e.jsxs("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-rank",children:[s.rank," of ",s.totalApplicantsAtLocation,e.jsxs("span",{className:"text-slate-500",children:[" in ",s.preferredLocation]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(oc,{value:s.progress,className:"flex-1 bg-red-50",indicatorClassName:fl(s.status),"data-testid":"onboarding-details-summary-progress-bar"}),e.jsxs("span",{className:"text-slate-900","data-testid":"onboarding-details-summary-progress-text",children:[s.progress,"%"]})]})]}),s.deadline&&e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Questionnaire Deadline"}),e.jsx("p",{className:"text-slate-900","data-testid":"onboarding-details-summary-deadline",children:Qt(s.deadline)})]})]})]}),(s.isShortlisted!==!1||s.status==="Submitted")&&e.jsxs(_e,{"data-testid":"onboarding-details-actions-card",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[n.isLoaLocked&&e.jsxs(Ai,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-loa-locked-alert",children:[e.jsx(ny,{className:"w-4 h-4 text-re-red"}),e.jsx(il,{className:"text-red-900 font-semibold",children:"LOA approval locked"}),e.jsxs(ki,{className:"text-red-800",children:[e.jsx("span",{className:"font-medium",children:"First Fill"})," (later-stage payment) must be verified by Finance before LOA approval can proceed. This is separate from the initial Security Deposit before LOI Issued."]})]}),((I=r("FIRST_FILL"))==null?void 0:I.status)==="Verified"&&s.status!=="LOA Pending"&&!["LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded","Rejected"].includes(s.status)&&e.jsxs(Ai,{className:"mb-4 border-violet-200 bg-violet-50/90 text-violet-950","data-testid":"onboarding-details-first-fill-verified-alert",children:[e.jsx(qa,{className:"h-4 w-4 text-violet-700"}),e.jsx(il,{className:"font-semibold",children:"First Fill verified on file"}),e.jsxs(ki,{className:"text-sm text-violet-900/90 leading-relaxed",children:["Finance has verified the ",e.jsx("span",{className:"font-medium",children:"First Fill"})," payment. The application status was ",e.jsx("span",{className:"font-medium",children:"not"})," changed until you reach"," ",e.jsx("span",{className:"font-medium",children:"LOA Pending"}),". When you get there, LOA approval will not be blocked by payment (same pattern as recording the initial Security Deposit before the LOI security step)."]})]}),n.isSecurityDetailsLocked&&e.jsxs(Ai,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-security-locked-alert",children:[e.jsx(ny,{className:"w-4 h-4 text-re-red"}),e.jsx(il,{className:"text-red-900 font-semibold",children:"Security Deposit approval locked"}),e.jsxs(ki,{className:"text-red-800",children:["Finance must verify the ",e.jsx("span",{className:"font-medium",children:"Security Deposit"})," before this stage can be approved. You can still use ",e.jsx("span",{className:"font-medium",children:"Reject"})," if needed."]})]}),["Security Deposit","Security Details","Payment Pending"].includes(s.status)&&e.jsxs(Ai,{className:"mb-4 border-sky-200 bg-sky-50/90 text-sky-900","data-testid":"onboarding-details-security-review-alert",children:[e.jsx(qa,{className:"h-4 w-4 text-sky-700"}),e.jsx(il,{className:"text-sky-950 font-semibold",children:"Security Deposit review"}),e.jsxs(ki,{className:"text-sm text-sky-900/90 leading-relaxed",children:["Check the initial Security Deposit on the ",e.jsx("span",{className:"font-medium",children:"Payments"})," tab (Finance may have already marked it verified). When satisfied, use ",e.jsx("span",{className:"font-medium",children:"Approve"})," ","to move to ",e.jsx("span",{className:"font-medium",children:"LOI Issued"}),"."]})]}),a&&i&&e.jsxs(Ai,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-non-responsive-alert",children:[e.jsx(sn,{className:"w-4 h-4 text-red-600"}),e.jsx(il,{className:"text-red-900 font-black uppercase tracking-tighter",children:"⚠️ Non-Responsive Flag"}),e.jsx(ki,{className:"text-red-800 text-xs font-bold leading-tight",children:"FDD Audit has flagged this applicant. Review audit logs before approval."})]}),i&&(s.status==="Level 3 Approved"||s.status==="FDD Verification")&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(Ai,{className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-fdd-assignment-alert",children:[e.jsx(sn,{className:"w-4 h-4 text-re-red"}),e.jsx(il,{className:"text-red-900 font-bold",children:"FDD Assignment Required"}),e.jsx(ki,{className:"text-red-800 font-medium",children:"This application is pending financial due diligence. Please assign an FDD Agency to proceed with the audit."})]}),n.canApprove&&e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:m,"data-testid":"onboarding-details-approve-button",children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),["Inauguration","Approved"].includes(s.status)?"Onboard Dealer":"Approve"]}),n.canReject&&e.jsxs(te,{variant:"destructive",className:"w-full font-bold",onClick:f,"data-testid":"onboarding-details-reject-button",children:[e.jsx(ai,{className:"w-4 h-4 mr-2"}),"Reject"]}),n.showDecisionMessage&&e.jsxs("div",{className:`w-full p-2 text-center rounded border ${(o==null?void 0:o.decision)==="Approved"||(d==null?void 0:d.decision)==="Approved"||(d==null?void 0:d.recommendation)==="Approved"||(d==null?void 0:d.decision)==="Selected"?"bg-green-50 border-green-200 text-green-700":"bg-red-50 border-red-200 text-red-700"}`,"data-testid":"onboarding-details-decision-message",children:["You have ",(o==null?void 0:o.decision)==="Approved"||(d==null?void 0:d.decision)==="Approved"||(d==null?void 0:d.recommendation)==="Approved"||(d==null?void 0:d.decision)==="Selected"?"Approved":"Rejected"]}),e.jsx(Xo,{}),e.jsxs(te,{variant:"outline",className:"w-full",onClick:p,"data-testid":"onboarding-details-worknote-button",children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"Work Note"]}),n.canSchedule&&e.jsxs(te,{variant:"outline",className:"w-full",onClick:h,"data-testid":"onboarding-details-schedule-button",children:[e.jsx(er,{className:"w-4 h-4 mr-2"}),"Schedule Interview"]}),x&&["DD Admin","Super Admin"].includes(x.role)&&["Dealer Code Generation","LOA Pending","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion"].includes(s.status)&&e.jsxs(e.Fragment,{children:[!s.dealerCode&&e.jsxs(te,{className:"w-full bg-blue-600 hover:bg-blue-700",onClick:u,"data-testid":"onboarding-details-generate-dealer-codes",children:[e.jsx(D1,{className:"w-4 h-4 mr-2"}),"Generate Dealer Codes"]}),s.dealerCode&&!s.architectureAssignedTo&&e.jsxs(te,{variant:"outline",className:"w-full border-blue-200 hover:bg-blue-50 text-blue-700",onClick:N,"data-testid":"onboarding-details-assign-architecture",children:[e.jsx(sy,{className:"w-4 h-4 mr-2"}),"Assign Architecture Team"]})]}),i&&["Level 3 Approved","Level 3 Recommended","FDD Verification","FDD In Progress"].includes(s.status)&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(ms,{open:w,onOpenChange:j,children:[e.jsxs(te,{variant:"outline",className:"w-full border-purple-200 hover:bg-purple-50 text-purple-700",onClick:v,"data-testid":"onboarding-details-assign-fdd",children:[e.jsx(ak,{className:"w-4 h-4 mr-2"}),"Assign FDD"]}),e.jsxs(us,{"data-testid":"onboarding-details-assign-fdd-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Assign FDD Agency"}),e.jsx(ws,{children:"Select an FDD partner agency to perform the financial due diligence audit for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"FDD Agency"}),e.jsxs(Rt,{value:C,onValueChange:S,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-details-assign-fdd-select",children:e.jsx(Et,{placeholder:b!=null&&b.length?"Choose partner agency...":"No agencies available"})}),e.jsx(Tt,{children:(b||[]).map(K=>e.jsxs(Pe,{value:K.id,children:[K.fullName||K.name," (",K.email,")"]},K.id))})]})]}),e.jsx(te,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:_,disabled:D||!C,"data-testid":"onboarding-details-assign-fdd-submit",children:D?"Assigning...":"Assign Agency"})]})]})]}),A&&!E&&e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-feedback-dropdown-trigger",children:[e.jsx(eM,{className:"w-4 h-4 mr-2"}),"Interview Feedback",e.jsx(va,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(Nb,{className:"w-56","data-testid":"onboarding-details-feedback-dropdown-content",children:e.jsxs(LD,{"data-testid":`onboarding-details-feedback-item-${A.id}`,onClick:()=>{q(A),A.level===1?O(!0):A.level===2?R(!0):P(!0)},children:["Level ",A.level," - ",A.interviewType]},A.id)})]}),s.status==="Questionnaire Pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-send-reminder",children:[e.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Send Reminder"]}),e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-extend-deadline",children:[e.jsx(dn,{className:"w-4 h-4 mr-2"}),"Extend Deadline"]})]}),s.dealer&&e.jsxs("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg space-y-3","data-testid":"onboarding-details-dealer-active-banner",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-800 font-semibold",children:[e.jsx(ln,{className:"w-5 h-5 text-green-600"}),"Dealer Profile Active"]}),e.jsx("div",{className:"text-sm text-green-700",children:"This application has been successfully onboarded as a dealer. A user account has been created for the dealer."}),s.dealerCode&&e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono bg-white p-2 rounded border border-green-100","data-testid":"onboarding-details-active-dealer-code",children:[e.jsx("span",{className:"text-slate-500",children:"Dealer Code:"}),e.jsx("span",{className:"font-bold text-slate-900",children:s.dealerCode.code})]}),e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700 text-white",onClick:L,"data-testid":"onboarding-details-goto-dashboard",children:[e.jsx(D1,{className:"w-4 h-4 mr-2"}),"Go to Dealer Dashboard"]})]}),x&&["DD Admin","Super Admin"].includes(x.role)&&e.jsxs(ms,{open:$,onOpenChange:Z,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{variant:"outline",className:"w-full","data-testid":"onboarding-details-assign-user-trigger",children:[e.jsx(Rr,{className:"w-4 h-4 mr-2"}),"Assign User"]})}),e.jsxs(us,{"data-testid":"onboarding-details-assign-user-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Assign User to Application"}),e.jsx(ws,{children:"Select a user and their role for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Select User"}),e.jsxs(Rt,{value:Q,onValueChange:W,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-details-assign-user-select",children:e.jsx(Et,{placeholder:"Search users..."})}),e.jsx(Tt,{children:U.map(K=>e.jsxs(Pe,{value:K.id,children:[K.fullName," (",K.email,")"]},K.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Assignment Role"}),e.jsxs(Rt,{value:M,onValueChange:z,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-details-assign-role-select",children:e.jsx(Et,{placeholder:"Select role"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"owner",children:"Owner"}),e.jsx(Pe,{value:"contributor",children:"Contributor"}),e.jsx(Pe,{value:"reviewer",children:"Reviewer"})]})]})]}),e.jsx(te,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:T,disabled:F,"data-testid":"onboarding-details-assign-user-submit",children:F?"Assigning...":"Assign User"})]})]})]})]})]})]})}function qU(t){const{application:s,fetchApplication:n,showApproveModal:r,setShowApproveModal:a,approvalRemark:i,setApprovalRemark:o,setApprovalFile:d,isApproving:m,handleApprove:f,showOnboardModal:p,setShowOnboardModal:h,isOnboarding:x,setIsOnboarding:u,showRejectModal:N,setShowRejectModal:v,rejectionReason:w,setRejectionReason:j,isRejecting:b,handleReject:C,showScheduleModal:S,setShowScheduleModal:D,showCancelInterviewModal:_,setShowCancelInterviewModal:A,setInterviewIdToCancel:E,isCancellingInterview:q,handleConfirmCancelInterview:O,interviewToReschedule:R,setInterviewToReschedule:P,interviewType:L,setInterviewType:$,interviewMode:Z,setInterviewMode:Q,interviewDate:W,setInterviewDate:U,meetingLink:M,setMeetingLink:z,location:T,setLocation:F,isInterviewCompleted:I,isInterviewActive:K,users:G,selectedInterviewerId:V,setSelectedInterviewerId:Y,handleAddInterviewer:re,scheduledInterviewParticipants:ae,handleRemoveInterviewer:ue,isScheduling:ye,handleScheduleInterview:ce,showAssignArchitectureModal:je,setShowAssignArchitectureModal:Me,architectureLeadId:ut,setArchitectureLeadId:jt,isAssigningArchitecture:ft,handleAssignArchitecture:X,showArchitectureStatusModal:Ce,setShowArchitectureStatusModal:xe,architectureStatus:We,setArchitectureStatus:Be,architectureRemarks:rt,setArchitectureRemarks:ht,isUpdatingArchitecture:ge,handleUpdateArchitectureStatus:Je}=t,mt=de=>{var at,ot;return(de==null?void 0:de.__stageRole)||((at=de==null?void 0:de.role)==null?void 0:at.roleName)||((ot=de==null?void 0:de.role)==null?void 0:ot.roleCode)||(de==null?void 0:de.roleCode)||(de==null?void 0:de.role)||"Panelist"};return e.jsxs(e.Fragment,{children:[e.jsx(ms,{open:r,onOpenChange:a,children:e.jsxs(us,{"data-testid":"onboarding-approve-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Approve Application"}),e.jsx(ws,{children:"Provide approval remarks and optionally attach supporting documents."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Remark ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{placeholder:"Enter approval remarks...",value:i,onChange:de=>o(de.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-approve-remark-textarea"})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Attach File (Optional)"}),e.jsx(it,{type:"file",className:"mt-2",onChange:de=>d(de.target.files?de.target.files[0]:null),"data-testid":"onboarding-approve-file-input"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>a(!1),disabled:m,"data-testid":"onboarding-approve-cancel-button",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:f,disabled:m,"data-testid":"onboarding-approve-submit-button",children:m?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Approving..."]}):"Submit Approval"})]})]})]})}),e.jsx(ms,{open:p,onOpenChange:h,children:e.jsxs(us,{className:"max-w-md","data-testid":"onboarding-onboard-modal",children:[e.jsxs(ys,{children:[e.jsx("div",{className:"mx-auto w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(ln,{className:"w-8 h-8 text-green-600"})}),e.jsx(gs,{className:"text-center text-xl font-bold",children:"Finalize Onboarding"}),e.jsxs(ws,{className:"text-center pt-2",children:["You are about to officially onboard ",e.jsx("span",{className:"font-semibold text-slate-900",children:s.name})," as a Royal Enfield dealer."]})]}),e.jsxs("div",{className:"bg-slate-50 p-4 rounded-lg border border-slate-200 mt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-green-500 rounded-full p-0.5",children:e.jsx($n,{className:"w-3 h-3 text-white"})}),e.jsx("p",{className:"text-sm text-slate-600",children:"Official dealer profile will be created."})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-green-500 rounded-full p-0.5",children:e.jsx($n,{className:"w-3 h-3 text-white"})}),e.jsxs("p",{className:"text-sm text-slate-600",children:["User account will be activated with role ",e.jsx("span",{className:"font-medium text-slate-900",children:"Dealer"}),"."]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-green-500 rounded-full p-0.5",children:e.jsx($n,{className:"w-3 h-3 text-white"})}),e.jsx("p",{className:"text-sm text-slate-600",children:"Primary outlet will be registered in the system."})]})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3",children:[e.jsx(te,{className:"w-full bg-green-600 hover:bg-green-700 h-11 text-lg font-semibold shadow-lg shadow-green-100","data-testid":"onboarding-onboard-confirm-button",onClick:async()=>{u(!0);try{await ps.createDealer({applicationId:s.id}),J.success("Dealer profile and login account created successfully!"),h(!1),n()}catch{J.error("Failed to create dealer profile")}finally{u(!1)}},disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-5 h-5 mr-2 animate-spin"}),"Processing Onboarding..."]}):"Confirm & Onboard Dealer"}),e.jsx(te,{variant:"ghost",className:"w-full text-slate-500 hover:text-slate-700",onClick:()=>h(!1),disabled:x,"data-testid":"onboarding-onboard-cancel-button",children:"Cancel"})]})]})}),e.jsx(ms,{open:N,onOpenChange:v,children:e.jsxs(us,{"data-testid":"onboarding-reject-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Reject Application"}),e.jsx(ws,{children:"Please provide a clear reason for rejecting this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Reason for Rejection ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{placeholder:"Enter rejection reason...",value:w,onChange:de=>j(de.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-reject-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>v(!1),disabled:b,"data-testid":"onboarding-reject-cancel-button",children:"Cancel"}),e.jsx(te,{variant:"destructive",className:"flex-1",onClick:C,disabled:b,"data-testid":"onboarding-reject-submit-button",children:b?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Rejecting..."]}):"Confirm Rejection"})]})]})]})}),e.jsx(ms,{open:S,onOpenChange:de=>{D(de),de||P(null)},children:e.jsxs(us,{"data-testid":"onboarding-schedule-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:R?"Reschedule Interview":"Schedule Interview"}),e.jsx(ws,{children:"Set up an interview session with the applicant and relevant team members."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Interview Type"}),e.jsxs(Rt,{value:L,onValueChange:$,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-schedule-type-select",children:e.jsx(Et,{placeholder:"Select interview type"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"level1",disabled:I(1)||K(1),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 1"}),I(1)&&e.jsx(ln,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(1)&&e.jsx(dn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Pe,{value:"level2",disabled:!I(1)||I(2)||K(2),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 2"}),!I(1)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L1)"}),I(2)&&e.jsx(ln,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(2)&&e.jsx(dn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Pe,{value:"level3",disabled:!I(2)||I(3)||K(3),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 3"}),!I(2)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L2)"}),I(3)&&e.jsx(ln,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(3)&&e.jsx(dn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})})]})]})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interview Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:Z,onValueChange:Q,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-schedule-mode-select",children:e.jsx(Et,{placeholder:"Select interview mode"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"virtual",children:"Virtual"}),e.jsx(Pe,{value:"physical",children:"Physical"})]})]})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Date & Time ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"datetime-local",className:"mt-2",value:W,onChange:de=>U(de.target.value),"data-testid":"onboarding-schedule-date-input"})]}),Z==="virtual"&&e.jsxs("div",{children:[e.jsx(le,{children:"Meeting Link"}),e.jsx(it,{placeholder:"https://meet.google.com/...",className:"mt-2",value:M,onChange:de=>z(de.target.value),"data-testid":"onboarding-schedule-link-input"})]}),Z==="physical"&&e.jsxs("div",{children:[e.jsx(le,{children:"Location"}),e.jsx(it,{placeholder:"Enter interview location address",className:"mt-2",value:T,onChange:de=>F(de.target.value),"data-testid":"onboarding-schedule-location-input"})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interviewers ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Rt,{value:V,onValueChange:Y,children:[e.jsx(_t,{className:"flex-1","data-testid":"onboarding-schedule-interviewer-select",children:e.jsx(Et,{placeholder:"Select interviewer"})}),e.jsx(Tt,{children:G.map(de=>{var at;return e.jsxs(Pe,{value:de.id,children:[de.fullName||de.name," (",((at=de.role)==null?void 0:at.roleName)||de.roleCode,")"]},de.id)})})]}),e.jsx(te,{onClick:re,type:"button",variant:"secondary","data-testid":"onboarding-schedule-add-interviewer-button",children:"Add"})]}),ae.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(le,{className:"text-xs text-muted-foreground",children:"Selected Interviewers:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map(de=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-2 py-1 rounded text-sm","data-testid":`onboarding-schedule-participant-${de.id}`,children:[e.jsx("span",{children:de.fullName||de.name||"Unknown"}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",mt(de),")"]}),e.jsx("button",{onClick:()=>ue(de.id),className:"text-muted-foreground hover:text-destructive","data-testid":`onboarding-schedule-remove-participant-${de.id}`,children:"×"})]},de.id))})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>{D(!1),P(null)},disabled:ye,"data-testid":"onboarding-schedule-cancel-button",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-primary-600 hover:bg-primary-700",onClick:ce,disabled:ye,"data-testid":"onboarding-schedule-submit-button",children:ye?R?"Rescheduling...":"Scheduling...":R?"Reschedule":"Schedule"})]})]})]})}),e.jsx(ms,{open:_,onOpenChange:de=>{A(de),de||E("")},children:e.jsxs(us,{"data-testid":"onboarding-cancel-interview-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Cancel Interview"}),e.jsx(ws,{children:"Are you sure you want to cancel this interview?"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>{A(!1),E("")},disabled:q,"data-testid":"onboarding-cancel-interview-close",children:"No"}),e.jsx(te,{variant:"destructive",className:"flex-1",onClick:O,disabled:q,"data-testid":"onboarding-cancel-interview-confirm",children:q?"Cancelling...":"Yes, Cancel"})]})]})}),e.jsx(ms,{open:je,onOpenChange:Me,children:e.jsxs(us,{"data-testid":"onboarding-architecture-assign-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Assign Architecture Team"}),e.jsx(ws,{children:"Select an architecture team lead for site planning and blueprints."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Select Architecture Lead ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:ut,onValueChange:jt,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-architecture-lead-select",children:e.jsx(Et,{placeholder:"Search users..."})}),e.jsxs(Tt,{children:[G.filter(de=>{var at;return de.roleCode==="ARCHITECTURE"||((at=de.role)==null?void 0:at.roleCode)==="ARCHITECTURE"||de.role==="Architecture"||de.role==="Architecture Team"}).map(de=>e.jsxs(Pe,{value:de.id,children:[de.fullName," (",de.email,")"]},de.id)),G.filter(de=>{var at;return de.roleCode==="ARCHITECTURE"||((at=de.role)==null?void 0:at.roleCode)==="ARCHITECTURE"||de.role==="Architecture"||de.role==="Architecture Team"}).length===0&&G.map(de=>e.jsxs(Pe,{value:de.id,children:[de.fullName," (",de.roleCode||de.role,")"]},de.id))]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>Me(!1),disabled:ft,"data-testid":"onboarding-architecture-assign-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:X,disabled:ft,"data-testid":"onboarding-architecture-assign-submit",children:ft?"Assigning...":"Assign Team"})]})]})]})}),e.jsx(ms,{open:Ce,onOpenChange:xe,children:e.jsxs(us,{"data-testid":"onboarding-architecture-status-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Update Architecture Status"}),e.jsx(ws,{children:"Mark the architectural work as completed and optionally add remarks."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Status ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:We,onValueChange:Be,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-architecture-status-select",children:e.jsx(Et,{placeholder:"Select status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"COMPLETED",children:"Completed"}),e.jsx(Pe,{value:"REJECTED",children:"Rejected / Needs Revision"})]})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Remarks (Optional)"}),e.jsx(Ks,{placeholder:"Enter any planning or site-visit remarks...",value:rt,onChange:de=>ht(de.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-architecture-remarks-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>xe(!1),disabled:ge,"data-testid":"onboarding-architecture-status-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:Je,disabled:ge,"data-testid":"onboarding-architecture-status-submit",children:ge?"Updating...":"Update Status"})]})]})]})})]})}function zU(t){var Qs,Xs,ie,nt,fe,Ae,Fe,Ke;const{application:s,ktCriteria:n,l2Fields:r,l3Fields:a,showKTMatrixModal:i,setShowKTMatrixModal:o,ktMatrixSelectedValues:d,handleKTMatrixChange:m,ktMatrixRemarks:f,setKtMatrixRemarks:p,ktMatrixRecommendation:h,setKtMatrixRecommendation:x,calculateKTScore:u,handleSubmitKTMatrix:N,isSubmittingKT:v,showLevel2FeedbackModal:w,setShowLevel2FeedbackModal:j,level2Feedback:b,handleLevel2Change:C,level2Recommendation:S,setLevel2Recommendation:D,handleSubmitLevel2Feedback:_,isSubmittingLevel2:A,showFeedbackDetailsModal:E,setShowFeedbackDetailsModal:q,selectedEvaluationForView:O,selectedInterviewForFeedback:R,showLevel3FeedbackModal:P,setShowLevel3FeedbackModal:L,level3Feedback:$,handleLevel3Change:Z,level3Recommendation:Q,setLevel3Recommendation:W,handleSubmitLevel3Feedback:U,isSubmittingLevel3:M,showDocumentsModal:z,setShowDocumentsModal:T,showUploadForm:F,setShowUploadForm:I,selectedStage:K,getDocumentsForStage:G,setPreviewDoc:V,setShowPreviewModal:Y,uploadDocType:re,setUploadDocType:ae,setUploadFile:ue,isUploading:ye,handleUpload:ce,uploadFile:je,showPreviewModal:Me,previewDoc:ut,showFddFinalizeModal:jt,setShowFddFinalizeModal:ft,currentUser:X,fddAuditRecommendation:Ce,setFddAuditRecommendation:xe,fddAuditFindings:We,setFddAuditFindings:Be,isFinalizingFdd:rt,setIsFinalizingFdd:ht,fetchApplication:ge,showFddFlagModal:Je,setShowFddFlagModal:mt,isFddFlagging:de,setIsFddFlagging:at,showFirmTypeModal:ot,setShowFirmTypeModal:ke,tempFirmType:Zt,setTempFirmType:Bt,updatingFirmType:_s,handleUpdateFirmType:Us}=t,fs=R!=null&&R.scheduleDate?new Date(R.scheduleDate).toISOString().split("T")[0]:"",Vs=(X==null?void 0:X.fullName)||(X==null?void 0:X.name)||"";return e.jsxs(e.Fragment,{children:[e.jsx(ms,{open:i,onOpenChange:o,children:e.jsxs(us,{className:"flex min-h-0 max-h-[90vh] w-[calc(100%-2rem)] max-w-lg flex-col gap-0 overflow-hidden p-0 sm:max-w-lg","data-testid":"onboarding-kt-matrix-modal",children:[e.jsxs(ys,{className:"shrink-0 space-y-2 border-b px-5 py-4 text-left",children:[e.jsx(gs,{className:"text-base",children:"KT matrix"}),e.jsxs(ws,{className:"text-sm leading-relaxed",children:["Level 1 interview · ",s.name,e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[Object.keys(d).length," of ",n.length," criteria answered"]})]})]}),e.jsx("div",{className:"custom-scrollbar-slim min-h-0 flex-1 overflow-y-auto px-5 py-5",children:e.jsxs("div",{className:"space-y-6",children:[n.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"KT Matrix configuration is not available. Configure it in Master > Interview Configurations."}),n.map((Le,Ue)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{htmlFor:`kt-matrix-${Ue}`,className:"block text-sm font-medium leading-relaxed text-foreground",children:[e.jsxs("span",{className:"text-muted-foreground",children:[Ue+1,"."]})," ",Le.name," ",e.jsx("span",{className:"text-red-500",children:"*"})," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",Le.weight,"%)"]})]}),e.jsxs(Rt,{value:d[Le.name]??void 0,onValueChange:et=>{const dt=Le.options.find(ss=>ss.value===et);dt&&m(Le.name,dt.value,dt.score)},children:[e.jsx(_t,{id:`kt-matrix-${Ue}`,className:"h-10 w-full text-left text-sm font-normal","data-testid":`onboarding-kt-matrix-select-${Ue}`,children:e.jsx(Et,{placeholder:"Choose an option…"})}),e.jsx(Tt,{position:"popper",className:"max-h-72 w-[var(--radix-select-trigger-width)]",children:Le.options.map(et=>e.jsxs(Pe,{value:et.value,className:"py-2.5 text-sm leading-snug","data-testid":`onboarding-kt-matrix-option-${Ue}-${et.value}`,children:[et.label," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",et.score,")"]})]},et.value))})]})]},Le.name)),e.jsxs("div",{className:"space-y-2 border-t border-border pt-6",children:[e.jsxs(le,{htmlFor:"kt-matrix-remarks",className:"text-sm font-medium",children:["Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ks,{id:"kt-matrix-remarks",placeholder:"Enter remarks...",className:"min-h-[96px] resize-y text-sm leading-relaxed",value:f,onChange:Le=>p(Le.target.value),"data-testid":"onboarding-kt-matrix-remarks-textarea"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-sm font-medium",children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:h,onValueChange:x,children:[e.jsx(_t,{"data-testid":"onboarding-kt-matrix-recommendation-select",children:e.jsx(Et,{placeholder:"Select recommendation"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Approve",children:"Approve"}),e.jsx(Pe,{value:"Reject",children:"Reject"}),e.jsx(Pe,{value:"Hold",children:"Hold"})]})]})]})]})}),e.jsxs("div",{className:"flex shrink-0 flex-col gap-4 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Weighted total ",e.jsx("span",{className:"font-semibold tabular-nums text-foreground","data-testid":"onboarding-kt-matrix-total-score",children:u()}),e.jsx("span",{className:"text-muted-foreground",children:" / 100"})]}),e.jsxs("div",{className:"flex gap-2 sm:shrink-0",children:[e.jsx(te,{variant:"outline",onClick:()=>o(!1),"data-testid":"onboarding-kt-matrix-cancel",children:"Cancel"}),e.jsx(te,{onClick:N,disabled:v||n.length===0||Object.keys(d).length<n.length||!(f!=null&&f.trim()),"data-testid":"onboarding-kt-matrix-submit",children:v?"Saving…":"Submit"})]})]})]})}),e.jsx(ms,{open:w,onOpenChange:j,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level2-feedback-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Level 2 Interview Feedback"}),e.jsx(ws,{children:"Provide detailed feedback from the Level 2 interview (DD Lead + ZBH evaluation)."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"date",className:"mt-2",value:b.interviewDate||fs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{placeholder:"Enter your name",className:"mt-2",value:b.interviewerName||Vs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:b.overallScore,onValueChange:Le=>C("overallScore",Le),children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level2-overall-score-select",children:e.jsx(Et,{placeholder:"Select score"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Pe,{value:"8",children:"Excellent (7-8)"}),e.jsx(Pe,{value:"6",children:"Good (5-6)"}),e.jsx(Pe,{value:"4",children:"Average (3-4)"}),e.jsx(Pe,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsx(Xo,{}),r.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"Level 2 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(r||[]).map((Le,Ue)=>e.jsxs("div",{children:[e.jsxs(le,{children:[Le.label,Le.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),Le.type==="select"?e.jsxs(Rt,{value:b[Le.itemKey]||"",onValueChange:et=>C(Le.itemKey,et),children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{placeholder:`Select ${Le.label}...`})}),e.jsx(Tt,{children:(Le.options||[]).map((et,dt)=>e.jsx(Pe,{value:et.optionValue||et.value,children:et.optionLabel||et.label},dt))})]}):Le.type==="number"?e.jsx(it,{type:"number",className:"mt-2",value:b[Le.itemKey]||"",onChange:et=>C(Le.itemKey,et.target.value)}):e.jsx(Ks,{placeholder:`Enter ${Le.label.toLowerCase()}...`,className:"mt-2",rows:3,value:b[Le.itemKey]||"",onChange:et=>C(Le.itemKey,et.target.value)})]},Le.itemKey||Ue)),e.jsxs("div",{children:[e.jsxs(le,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:S,onValueChange:D,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level2-recommendation-select",children:e.jsx(Et,{placeholder:"Select recommendation"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Approve",children:"Approve"}),e.jsx(Pe,{value:"Reject",children:"Reject"}),e.jsx(Pe,{value:"Hold",children:"Hold"})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>j(!1),"data-testid":"onboarding-level2-feedback-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:_,disabled:A||r.length===0,"data-testid":"onboarding-level2-feedback-submit",children:A?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ms,{open:E,onOpenChange:q,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-feedback-details-modal",children:[e.jsx(ys,{children:e.jsx(gs,{children:"Interview Feedback Details"})}),O&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 bg-slate-50 p-4 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Interviewer"}),e.jsx("p",{className:"font-semibold","data-testid":"onboarding-feedback-details-interviewer",children:(Qs=O.evaluator)==null?void 0:Qs.fullName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Role"}),e.jsx("p",{"data-testid":"onboarding-feedback-details-role",children:((ie=(Xs=O.evaluator)==null?void 0:Xs.role)==null?void 0:ie.roleName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:((nt=O.interview)==null?void 0:nt.level)===1?"Score (KT Matrix)":"Overall Score"}),e.jsx("p",{className:"font-bold text-lg","data-testid":"onboarding-feedback-details-score",children:O.ktMatrixScore?`${O.ktMatrixScore}/${((fe=O.interview)==null?void 0:fe.level)===1?"100":"10"}`:"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Recommendation"}),e.jsx(we,{variant:(Ae=O.recommendation)!=null&&Ae.toLowerCase().includes("reject")?"destructive":(Fe=O.recommendation)!=null&&Fe.toLowerCase().includes("hold")?"secondary":"default","data-testid":"onboarding-feedback-details-recommendation",children:O.recommendation||"N/A"})]})]}),e.jsx(Xo,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Detailed Feedback"}),((Ke=O.feedbackDetails)==null?void 0:Ke.length)>0?e.jsx("div",{className:"space-y-4",children:O.feedbackDetails.map((Le,Ue)=>e.jsxs("div",{className:"border-b last:border-0 pb-3 last:pb-0","data-testid":`onboarding-feedback-detail-item-${Ue}`,children:[e.jsx("p",{className:"font-medium text-slate-900",children:Le.feedbackType}),e.jsx("p",{className:"text-slate-700 mt-1 whitespace-pre-wrap text-sm",children:Le.comments})]},Ue))}):e.jsx("p",{className:"text-slate-500 italic",children:"No detailed feedback available."})]})]})]})}),e.jsx(ms,{open:P,onOpenChange:L,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level3-feedback-modal",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Level 3 Interview Feedback"}),e.jsx(ws,{children:"Provide detailed feedback from the Level 3 interview (NBH + DD-Head evaluation)."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"date",className:"mt-2",value:$.interviewDate||fs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{placeholder:"Enter your name",className:"mt-2",value:$.interviewerName||Vs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:$.overallScore,onValueChange:Le=>Z("overallScore",Le),children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level3-overall-score-select",children:e.jsx(Et,{placeholder:"Select score"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Pe,{value:"8",children:"Excellent (7-8)"}),e.jsx(Pe,{value:"6",children:"Good (5-6)"}),e.jsx(Pe,{value:"4",children:"Average (3-4)"}),e.jsx(Pe,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsx(Xo,{}),a.length===0&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:"Level 3 feedback configuration is not available. Configure it in Master > Interview Configurations."}),(a||[]).map((Le,Ue)=>e.jsxs("div",{children:[e.jsxs(le,{children:[Le.label,Le.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),Le.type==="select"?e.jsxs(Rt,{value:$[Le.itemKey]||"",onValueChange:et=>Z(Le.itemKey,et),children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{placeholder:`Select ${Le.label}...`})}),e.jsx(Tt,{children:(Le.options||[]).map((et,dt)=>e.jsx(Pe,{value:et.optionValue||et.value,children:et.optionLabel||et.label},dt))})]}):Le.type==="number"?e.jsx(it,{type:"number",className:"mt-2",value:$[Le.itemKey]||"",onChange:et=>Z(Le.itemKey,et.target.value)}):e.jsx(Ks,{placeholder:`Enter ${Le.label.toLowerCase()}...`,className:"mt-2",rows:3,value:$[Le.itemKey]||"",onChange:et=>Z(Le.itemKey,et.target.value)})]},Le.itemKey||Ue)),e.jsxs("div",{children:[e.jsxs(le,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:Q,onValueChange:W,children:[e.jsx(_t,{className:"mt-2","data-testid":"onboarding-level3-recommendation-select",children:e.jsx(Et,{placeholder:"Select recommendation"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Approve",children:"Approve"}),e.jsx(Pe,{value:"Reject",children:"Reject"}),e.jsx(Pe,{value:"Hold",children:"Hold"})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>L(!1),"data-testid":"onboarding-level3-feedback-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:U,disabled:M||a.length===0,"data-testid":"onboarding-level3-feedback-submit",children:M?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ms,{open:z,onOpenChange:Le=>{T(Le),Le||I(!1)},children:e.jsxs(us,{className:"max-w-[95vw] sm:max-w-2xl md:max-w-3xl lg:max-w-4xl max-h-[90vh] overflow-hidden flex flex-col p-4 sm:p-6","data-testid":"onboarding-documents-modal",children:[e.jsxs(ys,{className:"pb-4",children:[e.jsxs(gs,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Documents - ",K||"General"]}),e.jsx(ws,{className:"text-slate-500",children:"View and manage documents uploaded for this stage."})]}),F?e.jsxs("div",{className:"space-y-6 py-4","data-testid":"onboarding-documents-upload-form",children:[e.jsx("div",{className:"bg-slate-50/50 p-4 sm:p-6 rounded-2xl border border-slate-200",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-slate-700 font-semibold px-1",children:["Document Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"text",placeholder:"Enter document name",value:re,onChange:Le=>ae(Le.target.value),className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-re-red shadow-sm","data-testid":"onboarding-documents-name-input"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-slate-700 font-semibold px-1",children:["Select File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{type:"file",className:"bg-white border-slate-200 h-12 rounded-xl focus:ring-re-red shadow-sm file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-red-50 file:text-re-red-hover hover:file:bg-red-50 cursor-pointer",onChange:Le=>{const Ue=Le.target.files?Le.target.files[0]:null;if(ue(Ue),Ue){const et=Ue.name.replace(/\.[^/.]+$/,"");ae(et)}},"data-testid":"onboarding-documents-file-input"})]})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-4",children:[e.jsx(te,{className:"flex-1 order-2 sm:order-1 py-3 sm:py-5 rounded-xl border-slate-200 font-semibold text-slate-600 hover:bg-slate-50",variant:"outline",onClick:()=>I(!1),disabled:ye,"data-testid":"onboarding-documents-upload-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 order-1 sm:order-2 bg-re-red hover:bg-re-red-hover text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-re-red/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:async()=>{await ce(),I(!1)},disabled:!je||!re||ye,"data-testid":"onboarding-documents-upload-submit",children:ye?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(vr,{className:"w-5 h-5"}),"Confirm Upload"]})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 space-y-4",children:[G(K||"").length>0?e.jsx("div",{className:"custom-scrollbar-x-slim flex-1 overflow-auto border rounded-lg border-slate-200","data-testid":"onboarding-documents-table-container",children:e.jsxs(Ms,{className:"w-full table-auto",children:[e.jsx(Fs,{className:"bg-slate-50/80 sticky top-0 z-10",children:e.jsxs(lt,{className:"hover:bg-transparent border-b",children:[e.jsx(me,{className:"w-[45%] min-w-[150px] font-semibold text-slate-900 py-3",children:"Document Name"}),e.jsx(me,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Type"}),e.jsx(me,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Upload Date"}),e.jsx(me,{className:"w-[15%] min-w-[140px] font-semibold text-slate-900 py-3",children:"Uploaded By"}),e.jsx(me,{className:"text-right w-[10%] min-w-[80px] font-semibold text-slate-900 py-3",children:"Actions"})]})}),e.jsx(Bs,{children:G(K||"").map((Le,Ue)=>{var et,dt;return e.jsxs(lt,{className:"hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-document-row-${Ue}`,children:[e.jsx(oe,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate font-medium text-slate-700",title:Le.fileName,"data-testid":`onboarding-document-name-${Ue}`,children:Le.fileName})]})}),e.jsx(oe,{className:"py-3",children:e.jsx(we,{variant:"outline",className:"capitalize whitespace-nowrap font-normal border-slate-200 bg-white","data-testid":`onboarding-document-type-${Ue}`,children:((et=Le.documentType)==null?void 0:et.toLowerCase())||"Other"})}),e.jsx(oe,{className:"py-3 whitespace-nowrap text-slate-600",children:Qt(Le.createdAt)}),e.jsx(oe,{className:"py-3 text-slate-600",children:((dt=Le.uploader)==null?void 0:dt.fullName)||(Le.uploadedBy?"System User":"Applicant")}),e.jsx(oe,{className:"text-right py-3",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-full",onClick:()=>{V(Le),Y(!0)},"data-testid":`onboarding-document-preview-${Ue}`,children:e.jsx(un,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50 rounded-full",onClick:()=>{window.open(`https://dealeronboarding-uat.royalenfield.com/api/${Le.filePath}`,"_blank")},"data-testid":`onboarding-document-download-${Ue}`,children:e.jsx(fi,{className:"w-4 h-4"})})]})})]},Le.id)})})]})}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-center border rounded-lg bg-slate-50/30","data-testid":"onboarding-documents-empty",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center mb-4",children:e.jsx(ks,{className:"w-8 h-8 text-slate-300"})}),e.jsx("h3",{className:"text-slate-900 font-semibold mb-2",children:"No Documents Found"}),e.jsx("p",{className:"text-slate-600 text-sm max-w-[250px]",children:"No documents have been uploaded for this stage yet."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2 mt-auto",children:[e.jsxs(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover text-white font-bold py-3 sm:py-5 rounded-xl shadow-lg shadow-re-red/15 transition-all hover:scale-[1.01] active:scale-[0.99]",onClick:()=>I(!0),"data-testid":"onboarding-documents-upload-button",children:[e.jsx(vr,{className:"w-5 h-5 mr-3"}),"Upload Document"]}),e.jsx(te,{variant:"outline",className:"flex-1 sm:flex-none py-3 sm:py-5 px-8 rounded-xl border-slate-200 font-semibold text-slate-600 hover:bg-slate-50",onClick:()=>T(!1),"data-testid":"onboarding-documents-close-button",children:"Close"})]})]})]})}),e.jsx(ho,{isOpen:Me,onClose:()=>Y(!1),document:ut}),e.jsx(ms,{open:jt,onOpenChange:ft,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl rounded-3xl","data-testid":"onboarding-fdd-finalize-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-8 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-re-red/20 to-transparent"}),e.jsx("div",{className:"w-20 h-20 bg-re-red/20 rounded-full flex items-center justify-center animate-pulse relative z-10 shadow-[0_0_40px_rgba(218,41,28,0.2)]",children:e.jsx(so,{className:"w-10 h-10 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-black text-slate-900 text-center tracking-tight",children:"Finalize FDD Audit"}),e.jsxs(ws,{className:"text-slate-500 text-center pt-2 leading-relaxed text-sm font-medium",children:["You are about to submit your final findings. This action will ",e.jsx("span",{className:"font-bold text-slate-900 underline decoration-re-red decoration-2",children:"lock the audit session"})," and trigger the LOI approval workflow."]})]}),e.jsxs("div",{className:"space-y-4",children:[(X==null?void 0:X.role)!=="FDD"&&(X==null?void 0:X.roleCode)!=="FDD"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:["Auditor Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-2",children:["Recommended","Qualified with Observations","Not Recommended"].map(Le=>e.jsx(te,{variant:Ce===Le?"default":"outline",className:Nt("flex-1 h-10 font-bold text-[9px] uppercase tracking-wider rounded-xl transition-all",Ce===Le&&Le==="Recommended"&&"bg-emerald-600 hover:bg-emerald-700",Ce===Le&&Le==="Qualified with Observations"&&"bg-red-500 hover:bg-re-red",Ce===Le&&Le==="Not Recommended"&&"bg-red-600 hover:bg-red-700"),onClick:()=>xe(Le),"data-testid":`onboarding-fdd-recommendation-${Le.replace(/\s+/g,"-").toLowerCase()}`,children:Le},Le))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Findings Summary"}),e.jsx(Ks,{placeholder:"Summarize key financial findings or discrepancies...",className:"min-h-[100px] rounded-xl border-slate-200 focus:ring-re-red text-sm",value:We,onChange:Le=>Be(Le.target.value),"data-testid":"onboarding-fdd-findings-textarea"})]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl flex gap-3 border border-red-100",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-800 font-medium italic",children:"Ensure the final PDF report is uploaded first. This satisfies the FDD statutory requirement."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2",children:[e.jsx(te,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-2xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>ft(!1),disabled:rt,"data-testid":"onboarding-fdd-finalize-cancel",children:"Cancel"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-2xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-4 border-re-red",disabled:rt||!We,"data-testid":"onboarding-fdd-finalize-submit",onClick:async()=>{try{ht(!0),await ps.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Approved",remarks:(X==null?void 0:X.role)==="FDD"||(X==null?void 0:X.roleCode)==="FDD"?`Findings: ${We}`:`[RECOMMENDATION: ${Ce}]
|
||
Findings: ${We}`,nextStatus:"LOI In Progress",nextProgress:65}),J.success("FDD Audit finalized and submitted."),ft(!1),ge()}catch{J.error("Submission failed")}finally{ht(!1)}},children:rt?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ms,{open:Je,onOpenChange:mt,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden border-none shadow-2xl rounded-3xl","data-testid":"onboarding-fdd-flag-modal",children:[e.jsxs("div",{className:"bg-slate-950 p-8 flex items-center justify-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-600/20 to-transparent"}),e.jsx("div",{className:"w-20 h-20 bg-red-600/20 rounded-full flex items-center justify-center relative z-10 shadow-[0_0_40px_rgba(220,38,38,0.2)]",children:e.jsx(mk,{className:"w-10 h-10 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white text-center",children:[e.jsxs(ys,{children:[e.jsx(gs,{className:"text-2xl font-black text-slate-900 tracking-tight",children:"Flag Non-Responsive"}),e.jsx(ws,{className:"text-slate-500 pt-2 leading-relaxed text-sm font-medium",children:"Are you sure you want to flag this applicant? This will notify the DD Admin that the audit cannot proceed due to applicant's non-cooperation."})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl flex gap-3 border border-red-100",children:[e.jsx(sn,{className:"w-5 h-5 text-red-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-800 text-left font-medium",children:'"Applicant is unresponsive to multiple queries and financial document requests."'})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-2",children:[e.jsx(te,{variant:"outline",className:"w-full sm:flex-1 h-12 rounded-2xl font-bold text-slate-600 hover:bg-slate-50 border-slate-200",onClick:()=>mt(!1),disabled:de,"data-testid":"onboarding-fdd-flag-cancel",children:"Go Back"}),e.jsx(te,{className:"w-full sm:flex-1 h-12 rounded-2xl font-bold bg-slate-950 hover:bg-slate-900 text-white shadow-lg shadow-slate-200 transition-all active:scale-95 border-b-4 border-red-600",disabled:de,"data-testid":"onboarding-fdd-flag-submit",onClick:async()=>{try{at(!0),await ps.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Rejected",remarks:"Applicant is non-responsive to FDD queries."}),J.error("Applicant flagged as non-responsive."),mt(!1),ge()}catch{J.error("Action failed")}finally{at(!1)}},children:de?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Confirm Flag"})]})]})]})}),e.jsx(ms,{open:ot,onOpenChange:ke,children:e.jsxs(us,{className:"max-w-md p-0 overflow-hidden rounded-3xl border-none shadow-2xl","data-testid":"onboarding-firm-type-modal",children:[e.jsxs("div",{className:"bg-re-red p-8 text-white",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center mb-6 backdrop-blur-sm border border-white/30 shadow-inner",children:e.jsx(to,{className:"w-8 h-8 text-white"})}),e.jsx("h3",{className:"text-2xl font-black tracking-tight mb-2",children:"Update Firm Type"}),e.jsx("p",{className:"text-red-100/80 text-sm font-medium leading-relaxed",children:"Select the proposed legal constitution for this dealership application."})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{className:"text-[10px] text-slate-400 uppercase tracking-widest font-black",children:["Proposed Legal Constitution ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:Zt,onValueChange:Bt,children:[e.jsx(_t,{className:"h-12 rounded-xl border-slate-200 focus:ring-re-red","data-testid":"onboarding-firm-type-select",children:e.jsx(Et,{placeholder:"Select Firm Type"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Proprietorship","data-testid":"onboarding-firm-type-proprietorship",children:"Proprietorship"}),e.jsx(Pe,{value:"Partnership","data-testid":"onboarding-firm-type-partnership",children:"Partnership"}),e.jsx(Pe,{value:"Limited Liability partnership","data-testid":"onboarding-firm-type-llp",children:"LLP (Limited Liability partnership)"}),e.jsx(Pe,{value:"Private Limited Company","data-testid":"onboarding-firm-type-pvt-ltd",children:"Private Limited Company"}),e.jsx(Pe,{value:"Public Limited Company","data-testid":"onboarding-firm-type-pub-ltd",children:"Public Limited Company"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(te,{variant:"outline",className:"flex-1 h-12 rounded-xl font-bold text-slate-600 border-slate-200",onClick:()=>ke(!1),disabled:_s,"data-testid":"onboarding-firm-type-cancel",children:"Cancel"}),e.jsx(te,{className:"flex-1 h-12 rounded-xl font-bold bg-re-red hover:bg-re-red-hover text-white shadow-lg shadow-red-200 transition-all active:scale-95",disabled:_s||!Zt,onClick:Us,"data-testid":"onboarding-firm-type-submit",children:_s?e.jsx(cs,{className:"w-5 h-5 animate-spin"}):"Update Type"})]})]})]})})]})}var UU={};function VU({application:t,documents:s,setPreviewDoc:n,setShowPreviewModal:r,setIsUploading:a,fetchApplication:i,refreshDocuments:o}){var N,v;const d=(t==null?void 0:t.fddAssignments)||[],m=((N=t==null?void 0:t.participants)==null?void 0:N.filter(w=>{var j,b,C,S;return((j=w.user)==null?void 0:j.role)==="FDD"||((b=w.user)==null?void 0:b.roleCode)==="FDD"||((S=(C=w.user)==null?void 0:C.allRoles)==null?void 0:S.includes("FDD"))}))||[],f=d.length>0||m.length>0,p=(v=m[0])==null?void 0:v.user,h=[{type:"Bank Statement",label:"Bank Statements"},{type:"Income Tax Returns (ITR)",label:"ITR (Last 3 Years)"},{type:"CIBIL Report",label:"CIBIL / Credit Reports"},{type:"Property Documents",label:"Property Documents"},{type:"Business Valuation Report",label:"Valuation Reports"},{type:"FDD Final Audit Report",label:"Final Audit Report"}],x=w=>{const j=w.toLowerCase();return(s||[]).find(b=>{const C=(b.documentType||"").toLowerCase(),S=(b.fileName||"").toLowerCase();return!!(C===j||j.includes("itr")&&(C.includes("itr")||S.includes("itr"))||j.includes("bank statement")&&(C.includes("bank")||S.includes("bank"))||j.includes("cibil")&&(C.includes("cibil")||S.includes("cibil")||C.includes("credit")))})},u=w=>{const j=(w.documentType||"").toLowerCase();return(w.stage||"").toLowerCase()==="fdd"||j.includes("report")||j.includes("itr")||j.includes("bank")||j.includes("cibil")||j.includes("valuation")};return!f&&!["FDD Verification","LOI In Progress","Payment Pending"].includes(t.status)?e.jsx("div",{className:"space-y-6","data-testid":"onboarding-fdd-no-assignment",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 bg-slate-50 rounded-2xl border-2 border-dashed border-slate-200",children:[e.jsx(so,{className:"w-12 h-12 text-slate-300 mb-4"}),e.jsx("h3",{className:"text-slate-900 font-semibold uppercase tracking-widest text-xs",children:"No FDD Assignment"}),e.jsx("p",{className:"text-slate-500 text-[10px] text-center max-w-xs mt-2 font-medium leading-relaxed uppercase tracking-tight",children:"The Financial Due Diligence process has not been initiated for this application yet."})]})}):e.jsxs("div",{className:"space-y-8","data-testid":"onboarding-fdd-audit-content",children:[f&&e.jsx("div",{className:"flex items-center justify-between p-4 bg-slate-50 border border-slate-200 rounded-xl mb-6","data-testid":"onboarding-fdd-assignment-banner",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(so,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900",children:"FDD Assignment Active"}),p&&e.jsxs("p",{className:"text-xs text-slate-500 font-medium","data-testid":"onboarding-fdd-assigned-user",children:["Assigned to: ",p.name]})]})]})}),e.jsxs(_e,{className:"border-slate-200 shadow-sm overflow-hidden rounded-2xl","data-testid":"onboarding-fdd-checklist-card",children:[e.jsx(Xe,{className:"bg-slate-50/50 border-b border-slate-100 py-4",children:e.jsxs(st,{className:"text-sm font-black uppercase tracking-widest text-slate-500 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sc,{className:"w-4 h-4"})," Financial Artefacts Checklist"]}),e.jsx(we,{variant:"outline",className:"text-[10px] bg-white",children:"Verify before sign-off"})]})}),e.jsx(Oe,{className:"p-0",children:e.jsx("div",{className:"divide-y divide-slate-100",children:h.map((w,j)=>{const b=x(w.type);return e.jsxs("div",{className:"flex items-center justify-between p-4 px-6 hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-fdd-checklist-item-${j}`,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:Nt("w-8 h-8 rounded-lg flex items-center justify-center",b?"bg-emerald-50 text-emerald-600":"bg-slate-50 text-slate-300"),children:b?e.jsx(ln,{className:"w-5 h-5"}):e.jsx(sn,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:w.label}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter","data-testid":`onboarding-fdd-checklist-status-${j}`,children:b?`Uploaded: ${Qt(b.createdAt)}`:"Missing in Documentation"})]})]}),b?e.jsxs(te,{variant:"ghost",size:"sm",className:"h-8 text-blue-600 font-black text-[10px] uppercase tracking-widest hover:bg-blue-50",onClick:()=>{n(b),r(!0)},"data-testid":`onboarding-fdd-checklist-preview-${j}`,children:[e.jsx(un,{className:"w-4 h-4 mr-1"})," Preview"]}):e.jsxs(te,{variant:"outline",size:"sm",className:"h-8 border-slate-200 text-slate-500 font-black text-[10px] uppercase tracking-widest hover:bg-slate-50 hover:text-blue-600","data-testid":`onboarding-fdd-checklist-upload-${j}`,onClick:()=>{const C=document.createElement("input");C.type="file",C.onchange=async S=>{var _;const D=S.target.files[0];if(D)try{a(!0);const A=new FormData;A.append("file",D),A.append("documentType",w.type),A.append("stage","FDD"),A.append("applicationId",t.id);const E=await ps.uploadDocument(t.id,A);w.type==="FDD Final Audit Report"&&(await ps.submitFddReport({applicationId:t.id,reportDocumentId:((_=E.data)==null?void 0:_.id)||E.id,findings:"Final Audit Report uploaded via checklist.",recommendation:"REVIEW_PENDING"}),i()),J.success(`${w.label} uploaded successfully`),o()}catch{J.error("Upload failed")}finally{a(!1)}},C.click()},children:[e.jsx(vr,{className:"w-4 h-4 mr-1 text-slate-300"})," Upload"]})]},w.type)})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Supporting Audit Documents"}),e.jsxs(we,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-fdd-support-docs-count",children:[(s||[]).filter(u).length," Document(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4","data-testid":"onboarding-fdd-support-docs-grid",children:[(s||[]).filter(u).map((w,j)=>e.jsxs("div",{className:"group bg-white border border-slate-200 rounded-xl p-4 flex items-center justify-between hover:border-red-300 transition-all hover:shadow-md","data-testid":`onboarding-fdd-support-doc-${j}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-slate-50 flex items-center justify-center",children:e.jsx(ks,{className:"w-5 h-5 text-slate-400"})}),e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("p",{className:"text-slate-900 font-bold text-sm truncate max-w-[150px]",title:w.fileName,"data-testid":`onboarding-fdd-support-doc-name-${j}`,children:w.fileName}),e.jsx("p",{className:"text-slate-500 text-[10px] font-medium uppercase",children:w.documentType})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{const b=UU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${b}/${w.filePath}`,"_blank")},"data-testid":`onboarding-fdd-support-doc-download-${j}`,children:e.jsx(fi,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{n(w),r(!0)},"data-testid":`onboarding-fdd-support-doc-preview-${j}`,children:e.jsx(un,{className:"w-4 h-4"})})]})]},w.id)),(s||[]).filter(u).length===0&&e.jsx("div",{className:"col-span-full p-8 text-center bg-slate-50 rounded-xl border border-dashed border-slate-200","data-testid":"onboarding-fdd-support-docs-empty",children:e.jsx("p",{className:"text-slate-400 text-sm",children:"No supporting audit documents uploaded yet."})})]})]})]})}function HU(t){const s=String(t||"").toUpperCase();return s.includes("REJECT")||s.includes("DELET")||s.includes("DISQUALIF")?"border-red-200 bg-red-50/90 text-red-800":s==="CREATED"||s.includes("APPROV")||s.includes("COMPLETE")?"border-emerald-200 bg-emerald-50/90 text-emerald-900":s.includes("DOCUMENT")||s.includes("UPLOAD")||s.includes("ATTACHMENT")?"border-sky-200 bg-sky-50/80 text-sky-900":s.includes("PAYMENT")||s.includes("SECURITY")||s.includes("DEPOSIT")?"border-violet-200 bg-violet-50/80 text-violet-900":s.includes("FDD")||s.includes("QUESTIONNAIRE")||s.includes("INTERVIEW")?"border-red-200 bg-red-50/80 text-red-900":"border-slate-200 bg-slate-50 text-slate-700"}function bf(t,s){return t==null||s==null?!1:String(t).trim()===String(s).trim()}function u_(t){return String(t??"").trim().toLowerCase().replace(/\s+/g," ")}function Am(t){const s=u_(t);return s?s==="scheduled"||s==="rescheduled"||s==="pending"||s==="in progress"||s==="inprogress":!1}function WU(t){return u_(t)==="completed"}function zg(t,s){var n;return!s||!((n=t==null?void 0:t.participants)!=null&&n.length)?!1:t.participants.some(r=>{var a;return bf(r.userId,s)||bf((a=r.user)==null?void 0:a.id,s)})}function GU(t){const s=String(t??"").trim();return{"Level 1 Interview Pending":1,"Level 1 Recommended":1,"Level 2 Interview Pending":2,"Level 2 Recommended":2,"Level 3 Interview Pending":3,"Level 3 Recommended":3}[s]}function DS(t){return String(t??"").trim().toLowerCase().replace(/[_\s-]+/g,"")}function KU(t,s){var d,m;if(!t)return!1;const n=["Super Admin","DD Admin"];if(n.includes(String(t.role??""))||n.includes(String(t.roleCode??"")))return!0;const a={1:["DD-ZM","DD ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]}[s];if(!(a!=null&&a.length))return!1;const i=a.map(DS),o=[t.role,t.roleCode,t.roleName,(d=t.role)==null?void 0:d.roleCode,(m=t.role)==null?void 0:m.roleName].filter(Boolean).map(DS);for(const f of o)if(f){for(const p of i)if(p&&(f===p||f.includes(p)||p.includes(f)))return!0}return!1}function YU({application:t,interviews:s,currentUser:n,getDeposit:r,eorProgress:a}){var C,S,D;const i=Array.isArray(s)?s:[],o=GU(t==null?void 0:t.status),d=(o!=null?i.find(_=>Am(_.status)&&zg(_,n==null?void 0:n.id)&&Number(_.level)===o):void 0)??i.find(_=>Am(_.status)&&zg(_,n==null?void 0:n.id)),m=o!=null&&n&&KU(n,o)?i.find(_=>Number(_.level)===o&&Am(_.status)):void 0,f=d??m,p=i.find(_=>zg(_,n==null?void 0:n.id)),h=((C=f==null?void 0:f.evaluations)==null?void 0:C.find(_=>bf(_.evaluatorId,n==null?void 0:n.id)))??((S=p==null?void 0:p.evaluations)==null?void 0:S.find(_=>bf(_.evaluatorId,n==null?void 0:n.id))),x=_=>i.some(A=>Number(A.level)===_&&WU(A.status)),u=_=>i.some(A=>Number(A.level)===_&&Am(A.status)),N=!!h,v={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"},w=v[t==null?void 0:t.status],j=(D=t==null?void 0:t.stageApprovals)==null?void 0:D.find(_=>_.stageCode===w&&String(_.actorUserId)===String(n==null?void 0:n.id));return{activeInterviewForUser:f,lastInterviewForUser:p,currentUserEvaluation:h,hasSubmittedFeedback:N,currentUserStageAction:j,isInterviewCompleted:x,isInterviewActive:u,permissions:(()=>{var U,M,z,T,F;if(!t||!n)return{canApprove:!1,canReject:!1,canSchedule:!1,canAssign:!1,isLoaLocked:!1,isSecurityDetailsLocked:!1,showDecisionMessage:!1};const _=["DD Admin","Super Admin","NBH","DD Lead","DD Head","Finance","Finance Admin","FDD","ZBH","RBM"].includes(n.role),A=["Level 3 Approved","FDD Verification","LOI In Progress","Security Deposit","Security Details","Payment Pending","LOI Issued","Statutory LOI Ack","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion","Statutory GST","Statutory PAN","Statutory Nodal","Statutory Check","Statutory Partnership","Statutory Firm Reg","Statutory Rental","Statutory Virtual Code","Statutory Domain","Statutory MSD","LOA Pending","EOR In Progress","EOR Complete","Inauguration","Approved"].includes(t.status),E=t.status==="LOA Pending"&&((U=r("FIRST_FILL"))==null?void 0:U.status)!=="Verified",q=["Security Deposit","Security Details","Payment Pending"].includes(t.status)&&((M=r("SECURITY_DEPOSIT"))==null?void 0:M.status)!=="Verified",O=t.status==="Onboarded"||t.status==="Rejected",R=(z=t.stageApprovals)==null?void 0:z.some(I=>I.stageCode==="LOI_APPROVAL"&&I.actorRole==="DD Head"&&I.decision==="Approved"),P=(T=t.stageApprovals)==null?void 0:T.some(I=>I.stageCode==="LOA_APPROVAL"&&I.actorRole==="DD Head"&&I.decision==="Approved");let L=!0;["Super Admin","DD Admin","DD Lead","DD Head"].includes(n.role)||((t.status==="FDD Verification"||t.status==="Level 3 Approved")&&(L=!1),t.status==="LOI In Progress"&&(L=n.role==="NBH"?!!R:n.role==="DD Head"),t.status==="LOA Pending"&&(L=n.role==="NBH"?!!P:n.role==="DD Head"));const $=!!((F=t.stageApprovals)!=null&&F.find(I=>v[t.status]===I.stageCode&&String(I.actorUserId)===String(n.id))),Z=["Approved","Rejected","Selected"].includes((h==null?void 0:h.decision)||(h==null?void 0:h.recommendation)||""),Q=(f?Z:!1)||$,W=!O&&!Q&&_&&A&&L&&(!["EOR In Progress","Inauguration","Approved"].includes(t.status)||a===100);return{canApprove:W&&!E&&!q,canReject:W&&!E,isLoaLocked:E,isSecurityDetailsLocked:q,showDecisionMessage:Q&&(!A||$),canSchedule:["DD Admin","Super Admin","DD AM","ASM"].includes(n.role)&&!O&&![1,2,3].every(I=>i.some(K=>K.level===I)),canAssign:["DD Admin","Super Admin","DD AM"].includes(n.role)}})()}}function ZU({initialTab:t="questionnaire"}){const[s,n]=g.useState(!1),[r,a]=g.useState(!1),[i,o]=g.useState(""),[d,m]=g.useState(t),[f,p]=g.useState(!1),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(""),[C,S]=g.useState([]),[D,_]=g.useState(!1),[A,E]=g.useState(!1),[q,O]=g.useState(""),[R,P]=g.useState(null),[L,$]=g.useState(!1),[Z,Q]=g.useState(!1),[W,U]=g.useState(!1),[M,z]=g.useState(!1),[T,F]=g.useState(!1),[I,K]=g.useState(null),[G,V]=g.useState("virtual"),[Y,re]=g.useState(""),[ae,ue]=g.useState({}),[ye,ce]=g.useState([]),[je,Me]=g.useState(""),[ut,jt]=g.useState("contributor"),[ft,X]=g.useState(""),[Ce,xe]=g.useState("level1"),[We,Be]=g.useState(""),[rt,ht]=g.useState(""),[ge,Je]=g.useState(!1),[mt,de]=g.useState(null),[at,ot]=g.useState(""),[ke,Zt]=g.useState(null),[Bt,_s]=g.useState(!1),[Us,fs]=g.useState(null),[Vs,Qs]=g.useState(!1),[Xs,ie]=g.useState(""),[nt,fe]=g.useState(!1),[Ae,Fe]=g.useState({}),[Ke,Le]=g.useState(!1),[Ue,et]=g.useState([]),[dt,ss]=g.useState(!1),[Wt,kt]=g.useState(!1),[wt,Os]=g.useState(!1),[as,Se]=g.useState(""),[be,pt]=g.useState(!1),[Ve,bt]=g.useState(!1),[gt,rs]=g.useState(""),[is,Ts]=g.useState(""),[Ws,nn]=g.useState(!1),[Ee,$t]=g.useState(!1),[Xt,Cs]=g.useState([]),[Mt,ze]=g.useState([]),[xt,yt]=g.useState(""),[Ot,Pt]=g.useState(!1),[Jt,bs]=g.useState(!1),[ns,Ds]=g.useState(!1),[ts,js]=g.useState(!1),[tn,vn]=g.useState({}),[jn,xn]=g.useState({}),[gn,Ye]=g.useState(""),[qt,Ze]=g.useState("Approve"),[Gt,St]=g.useState(!1),[qn,Er]=g.useState(null),[Fr,wn]=g.useState(!1),[Js,Sa]=g.useState(!1),[It,As]=g.useState("Recommended"),[_r,ca]=g.useState(""),[Ca,Yr]=g.useState(!1),[Nr,kn]=g.useState(!1),[Sn,sr]=g.useState({}),[wr,Sr]=g.useState("Approve"),[yn,Dn]=g.useState(!1),[Aa,ka]=g.useState({}),[qi,xi]=g.useState("Approve"),[gi,bl]=g.useState(!1),[jl,da]=g.useState(null),[Da,ua]=g.useState(!1);return{showFirmTypeModal:s,setShowFirmTypeModal:n,updatingFirmType:r,setUpdatingFirmType:a,tempFirmType:i,setTempFirmType:o,activeTab:d,setActiveTab:m,showApproveModal:f,setShowApproveModal:p,showOnboardModal:h,setShowOnboardModal:x,isOnboarding:u,setIsOnboarding:N,showRejectModal:v,setShowRejectModal:w,rejectionReason:j,setRejectionReason:b,scheduledInterviewParticipants:C,setScheduledInterviewParticipants:S,showScheduleModal:D,setShowScheduleModal:_,showCancelInterviewModal:A,setShowCancelInterviewModal:E,interviewIdToCancel:q,setInterviewIdToCancel:O,interviewToReschedule:R,setInterviewToReschedule:P,showKTMatrixModal:L,setShowKTMatrixModal:$,showLevel2FeedbackModal:Z,setShowLevel2FeedbackModal:Q,showLevel3FeedbackModal:W,setShowLevel3FeedbackModal:U,showDocumentsModal:M,setShowDocumentsModal:z,showAssignModal:T,setShowAssignModal:F,selectedStage:I,setSelectedStage:K,interviewMode:G,setInterviewMode:V,approvalRemark:Y,setApprovalRemark:re,expandedBranches:ae,setExpandedBranches:ue,users:ye,setUsers:ce,selectedUser:je,setSelectedUser:Me,participantType:ut,setParticipantType:jt,interviewDate:ft,setInterviewDate:X,interviewType:Ce,setInterviewType:xe,meetingLink:We,setMeetingLink:Be,location:rt,setLocation:ht,showUploadForm:ge,setShowUploadForm:Je,uploadFile:mt,setUploadFile:de,uploadDocType:at,setUploadDocType:ot,approvalFile:ke,setApprovalFile:Zt,isUploading:Bt,setIsUploading:_s,previewDoc:Us,setPreviewDoc:fs,showPreviewModal:Vs,setShowPreviewModal:Qs,selectedInterviewerId:Xs,setSelectedInterviewerId:ie,isEditingStatutory:nt,setIsEditingStatutory:fe,statutoryForm:Ae,setStatutoryForm:Fe,isSavingStatutory:Ke,setIsSavingStatutory:Le,interviews:Ue,setInterviews:et,isScheduling:dt,setIsScheduling:ss,isCancellingInterview:Wt,setIsCancellingInterview:kt,showAssignArchitectureModal:wt,setShowAssignArchitectureModal:Os,architectureLeadId:as,setArchitectureLeadId:Se,isAssigningArchitecture:be,setIsAssigningArchitecture:pt,showArchitectureStatusModal:Ve,setShowArchitectureStatusModal:bt,architectureStatus:gt,setArchitectureStatus:rs,architectureRemarks:is,setArchitectureRemarks:Ts,isUpdatingArchitecture:Ws,setIsUpdatingArchitecture:nn,isAssigningParticipant:Ee,setIsAssigningParticipant:$t,documentConfigs:Xt,setDocumentConfigs:Cs,fddAgencies:Mt,setFddAgencies:ze,selectedAgencyId:xt,setSelectedAgencyId:yt,isAssigningAgency:Ot,setIsAssigningAgency:Pt,showAssignFddModal:Jt,setShowAssignFddModal:bs,isApproving:ns,setIsApproving:Ds,isRejecting:ts,setIsRejecting:js,ktMatrixScores:tn,setKtMatrixScores:vn,ktMatrixSelectedValues:jn,setKtMatrixSelectedValues:xn,ktMatrixRemarks:gn,setKtMatrixRemarks:Ye,ktMatrixRecommendation:qt,setKtMatrixRecommendation:Ze,isSubmittingKT:Gt,setIsSubmittingKT:St,selectedInterviewForFeedback:qn,setSelectedInterviewForFeedback:Er,showFddFinalizeModal:Fr,setShowFddFinalizeModal:wn,showFddFlagModal:Js,setShowFddFlagModal:Sa,fddAuditRecommendation:It,setFddAuditRecommendation:As,fddAuditFindings:_r,setFddAuditFindings:ca,isFinalizingFdd:Ca,setIsFinalizingFdd:Yr,isFddFlagging:Nr,setIsFddFlagging:kn,level2Feedback:Sn,setLevel2Feedback:sr,level2Recommendation:wr,setLevel2Recommendation:Sr,isSubmittingLevel2:yn,setIsSubmittingLevel2:Dn,level3Feedback:Aa,setLevel3Feedback:ka,level3Recommendation:qi,setLevel3Recommendation:xi,isSubmittingLevel3:gi,setIsSubmittingLevel3:bl,selectedEvaluationForView:jl,setSelectedEvaluationForView:da,showFeedbackDetailsModal:Da,setShowFeedbackDetailsModal:ua}}const h_=()=>new Date().toISOString().split("T")[0],QU=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:h_()}),XU=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",brandAlignment:"",executiveSummary:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:h_()});function JU({ktMatrixScores:t,setKtMatrixScores:s,setKtMatrixSelectedValues:n,ktMatrixRemarks:r,setKtMatrixRemarks:a,ktMatrixRecommendation:i,setKtMatrixRecommendation:o,selectedInterviewForFeedback:d,interviews:m,setIsSubmittingKT:f,setShowKTMatrixModal:p,level2Feedback:h,setLevel2Feedback:x,level2Recommendation:u,setLevel2Recommendation:N,setIsSubmittingLevel2:v,setShowLevel2FeedbackModal:w,level3Feedback:j,setLevel3Feedback:b,level3Recommendation:C,setLevel3Recommendation:S,setIsSubmittingLevel3:D,setShowLevel3FeedbackModal:_,currentUser:A,fetchInterviews:E,fetchApplication:q,ktMatrixConfig:O,level2Config:R,level3Config:P}){const L=re=>re==="Approve"?"Recommended":re==="Reject"?"Not Recommended":"Hold",$=re=>re==="Approve"?"Approved":re==="Reject"?"Rejected":null,Z=()=>O!=null&&O.items&&O.items.length>0?O.items.map(re=>({name:re.label,weight:Number(re.weight)||0,maxScore:Number(re.maxScore)||10,options:(re.options||[]).map(ae=>({label:ae.optionLabel,value:ae.optionValue,score:Number(ae.score)||0}))})):[],Q=()=>R!=null&&R.items&&R.items.length>0?R.items:[],W=()=>P!=null&&P.items&&P.items.length>0?P.items:[],U=Z(),M=Q(),z=W();return{handleKTMatrixChange:(re,ae,ue)=>{s(ye=>({...ye,[re]:ue})),n(ye=>({...ye,[re]:ae}))},calculateKTScore:()=>{let re=0;return U.forEach(ae=>{const ue=t[ae.name||ae.label]||0,ye=ae.maxScore||10,ce=ae.weight||0;re+=ue/ye*ce}),re.toFixed(2)},handleSubmitKTMatrix:async()=>{var ae,ue;if(U.length===0){J.error("KT Matrix configuration is missing. Please configure it in Master > Interview Configurations.");return}if(Object.keys(t).length<U.length){J.warning("Please fill all fields in the KT Matrix");return}const re=(d==null?void 0:d.id)||((ae=m.find(ye=>ye.status!=="Completed"))==null?void 0:ae.id)||((ue=m[0])==null?void 0:ue.id);if(!re){J.error("No active interview found to link this KT Matrix to.");return}try{f(!0);const ye=U.map(je=>({criterionName:je.name||je.label,score:t[je.name||je.label]||0,maxScore:je.maxScore||10,weightage:je.weight||0}));await ps.submitKTMatrix({interviewId:re,criteriaScores:ye,feedback:r,recommendation:L(i)});const ce=$(i);ce&&await ps.updateInterviewDecision({interviewId:re,decision:ce,remarks:r||`Level 1 ${ce.toLowerCase()} via KT Matrix`}),J.success(ce?`KT Matrix submitted and interview ${ce.toLowerCase()}`:"KT Matrix submitted and interview kept on hold"),p(!1),s({}),n({}),a(""),o("Approve"),await E(),await q()}catch{J.error("Failed to submit KT Matrix")}finally{f(!1)}},handleLevel2Change:(re,ae)=>{x(ue=>({...ue,[re]:ae}))},handleSubmitLevel2Feedback:async()=>{var ae;if(M.length===0){J.error("Level 2 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!h.overallScore){J.warning("Please provide an overall score.");return}const re=(d==null?void 0:d.id)||((ae=m.find(ue=>ue.status!=="Completed"&&ue.level===2))==null?void 0:ae.id);if(!re){J.error("No active Level 2 interview found to link this feedback to.");return}try{v(!0);const ue=M.map(je=>({type:je.label,comments:h[je.itemKey]||""})).filter(je=>je.comments.trim()!=="");await ps.submitLevel2Feedback({interviewId:re,overallScore:Number(h.overallScore),feedbackItems:ue,recommendation:L(u)});const ye=$(u),ce=h.additionalComments||"Level 2 decision submitted via feedback modal";ye&&await ps.updateInterviewDecision({interviewId:re,decision:ye,remarks:ce}),J.success(ye?`Level 2 feedback submitted and interview ${ye.toLowerCase()}`:"Level 2 feedback submitted and interview kept on hold"),w(!1),x(QU(A)),N("Approve"),await E(),await q()}catch{J.error("Failed to submit Level 2 Feedback")}finally{v(!1)}},handleLevel3Change:(re,ae)=>{b(ue=>({...ue,[re]:ae}))},handleSubmitLevel3Feedback:async()=>{var ae;if(z.length===0){J.error("Level 3 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!j.overallScore){J.warning("Please provide an overall score.");return}const re=(d==null?void 0:d.id)||((ae=m.find(ue=>ue.status!=="Completed"&&ue.level===3))==null?void 0:ae.id);if(!re){J.error("No active Level 3 interview found to link this feedback to.");return}try{D(!0);const ue=z.map(je=>({type:je.label,comments:j[je.itemKey]||""})).filter(je=>je.comments.trim()!=="");await ps.submitLevel2Feedback({interviewId:re,overallScore:Number(j.overallScore),feedbackItems:ue,recommendation:L(C)});const ye=$(C),ce=j.executiveSummary||j.additionalComments||"Level 3 decision submitted via feedback modal";ye&&await ps.updateInterviewDecision({interviewId:re,decision:ye,remarks:ce}),J.success(ye?`Level 3 feedback submitted and interview ${ye.toLowerCase()}`:"Level 3 feedback submitted and interview kept on hold"),_(!1),b(XU(A)),S("Approve"),await E(),await q()}catch{J.error("Failed to submit Level 3 Feedback")}finally{D(!1)}},ktCriteria:U,l2Fields:M,l3Fields:z}}function eV(){const[t,s]=g.useState(null),[n,r]=g.useState(null),[a,i]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(null),p=g.useCallback(async x=>{var u,N;try{const v=await Re.getInterviewConfigByType(x);if((u=v.data)!=null&&u.success)return v.data.data}catch(v){((N=v==null?void 0:v.response)==null?void 0:N.status)!==404&&console.warn(`Failed to fetch ${x} config:`,v)}return null},[]),h=g.useCallback(async()=>{d(!0),f(null);try{const[x,u,N]=await Promise.all([p("KT_MATRIX"),p("LEVEL2_FEEDBACK"),p("LEVEL3_FEEDBACK")]);s(x),r(u),i(N)}catch{f("Failed to load interview configurations"),J.error("Failed to load interview configurations")}finally{d(!1)}},[p]);return g.useEffect(()=>{h()},[h]),{ktMatrixConfig:t,level2Config:n,level3Config:a,loading:o,error:m,refresh:h}}function tV(t){const{application:s,applicationId:n,currentUser:r,interviews:a,approvalFile:i,approvalRemark:o,rejectionReason:d,architectureLeadId:m,architectureStatus:f,architectureRemarks:p,selectedUser:h,participantType:x,users:u,interviewDate:N,setInterviewDate:v,interviewType:w,setInterviewType:j,interviewMode:b,setInterviewMode:C,meetingLink:S,setMeetingLink:D,location:_,setLocation:A,scheduledInterviewParticipants:E,uploadFile:q,uploadDocType:O,selectedStage:R,setIsApproving:P,setShowApproveModal:L,setApprovalRemark:$,setApprovalFile:Z,setIsRejecting:Q,setShowRejectModal:W,setRejectionReason:U,setIsAssigningArchitecture:M,setShowAssignArchitectureModal:z,setIsUpdatingArchitecture:T,setShowArchitectureStatusModal:F,setIsAssigningParticipant:I,setSelectedUser:K,setShowAssignModal:G,setLoading:V,setIsScheduling:Y,setShowScheduleModal:re,setShowCancelInterviewModal:ae,interviewIdToCancel:ue,setInterviewIdToCancel:ye,interviewToReschedule:ce,setInterviewToReschedule:je,setIsCancellingInterview:Me,setIsUploading:ut,setShowUploadForm:jt,setUploadFile:ft,setUploadDocType:X,setDocuments:Ce,selectedInterviewerId:xe,setSelectedInterviewerId:We,setScheduledInterviewParticipants:Be,setUsers:rt,showScheduleModal:ht,showAssignArchitectureModal:ge,showAssignModal:Je,fetchApplication:mt,fetchInterviews:de,fetchEorData:at}=t,ot=()=>{if(!xe)return;const et=(Array.isArray(u)?u:[]).find(dt=>dt.id===xe);et&&!E.find(dt=>dt.id===et.id)&&(Be([...E,et]),We(""))},ke=Ue=>{Be(E.filter(et=>et.id!==Ue))},Zt=g.useCallback(async Ue=>{if(!(!r||!["DD Admin","Super Admin","DD Lead","DD Head","NBH"].includes(r.role)))try{const et={};if(Ue){const kt={level1:["DD-ZM","RBM"],level2:["DD Lead","ZBH"],level3:["NBH","DD Head"]};kt[Ue]&&(et.preferredRoleCode=kt[Ue]),s&&(et.locationId=s.districtId||s.areaId||s.regionId||s.zoneId)}et.isExternal=!1;const dt=await ps.getUsers(et),Wt=(Array.isArray(dt)?dt:dt&&Array.isArray(dt.data)?dt.data:dt&&Array.isArray(dt.users)?dt.users:[]).filter(kt=>(kt.status||"").toLowerCase()!=="inactive");rt(Wt.sort((kt,wt)=>String(kt.fullName||kt.name||"").localeCompare(String(wt.fullName||wt.name||""))))}catch{rt([])}},[r,s,rt]),Bt=g.useCallback(()=>{if(!ht||!s||ce)return;const Ue=parseInt(w.replace("level",""))||1,et={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},dt=as=>String(as||"").trim().toLowerCase().replace(/[_\s-]+/g," "),ss=(et[Ue]||[]).map(dt),Wt=(as,Se)=>{var Ve,bt,gt;const be=[(Ve=as==null?void 0:as.metadata)==null?void 0:Ve.role,(bt=Se==null?void 0:Se.role)==null?void 0:bt.roleName,(gt=Se==null?void 0:Se.role)==null?void 0:gt.roleCode,Se==null?void 0:Se.roleCode,Se==null?void 0:Se.role].filter(Boolean),pt=be.find(rs=>ss.includes(dt(rs)));return String(pt||be[0]||"Panelist")},kt=((s==null?void 0:s.participants)||[]).filter(as=>{var Se,be,pt,Ve,bt,gt,rs,is,Ts;return((Se=as.metadata)==null?void 0:Se.interviewLevel)===Ue||((be=as.metadata)==null?void 0:be.interviewLevel)===String(Ue)||((Ve=(pt=as.metadata)==null?void 0:pt.allAssignments)==null?void 0:Ve.includes(Ue))||((gt=(bt=as.metadata)==null?void 0:bt.allAssignments)==null?void 0:gt.includes(String(Ue)))||ss.includes(dt((rs=as.user)==null?void 0:rs.role))||ss.includes(dt((is=as.user)==null?void 0:is.roleCode))||ss.includes(dt((Ts=as.metadata)==null?void 0:Ts.role))}).map(as=>{const Se=as.user||{};return{...Se,__stageRole:Wt(as,Se)}}).filter(as=>!!(as!=null&&as.id));if(kt.length===0){Be([]);return}const wt=[],Os=new Set;kt.forEach(as=>{as.id&&!Os.has(as.id)&&(Os.add(as.id),wt.push(as))}),Be(wt)},[ht,s,w,ce,Be]),_s=async()=>{if(!N){J.warning("Please select date and time");return}try{Y(!0);const Ue={applicationId:s==null?void 0:s.id,level:w,scheduledAt:N,type:b==="virtual"?"Virtual Interview":"Physical Interview",location:b==="virtual"?S:_,participants:E.map(et=>et.id)};ce?(await ps.updateInterview(ce.id,{...Ue,status:"Scheduled"}),J.success("Interview rescheduled successfully")):(await ps.scheduleInterview(Ue),J.success("Interview scheduled successfully")),re(!1),je(null),await de(),await mt()}catch{J.error(ce?"Failed to reschedule interview":"Failed to schedule interview")}finally{Y(!1)}},Us=async Ue=>{ye(Ue),ae(!0)},fs=async Ue=>{var dt,ss;je(Ue),j(`level${Ue.level}`),C((dt=Ue.interviewType)!=null&&dt.toLowerCase().includes("virtual")?"virtual":"physical"),v(Ue.scheduleDate?(()=>{const Wt=new Date(Ue.scheduleDate);return new Date(Wt.getTime()-Wt.getTimezoneOffset()*6e4).toISOString().slice(0,16)})():""),(ss=Ue.interviewType)!=null&&ss.toLowerCase().includes("virtual")?D(Ue.linkOrLocation||""):A(Ue.linkOrLocation||"");const et=(Ue.participants||[]).map(Wt=>Wt.user||Wt).filter(Boolean);Be(et),re(!0)},Vs=async()=>{if(ue)try{Me(!0),await ps.updateInterview(ue,{status:"Cancelled"}),J.success("Interview cancelled successfully"),ae(!1),ye(""),await de()}catch{J.error("Failed to cancel interview")}finally{Me(!1)}},Qs=async()=>{var Ue;if(!q||!O){J.warning("Please enter a document name and select a file");return}try{ut(!0);const et=new FormData,dt=((Ue=q.name.match(/\.[^/.]+$/))==null?void 0:Ue[0])||"",ss=O.trim(),Wt=ss.toLowerCase().endsWith(dt.toLowerCase())?ss:`${ss}${dt}`;et.append("file",q,Wt);const kt=R!=null&&R.startsWith("EOR: ")?R.replace(/^EOR:\s*/,""):null;et.append("documentType",kt||"Other"),R&&et.append("stage",R),await ps.uploadDocument(n,et),J.success("Document uploaded successfully"),jt(!1),ft(null),X("");const wt=await ps.getDocuments(n);Ce(wt||[]),await at()}catch{J.error("Failed to upload document")}finally{ut(!1)}},Xs=async()=>{var Ue;try{P(!0);const et=a.find(kt=>{var wt;return kt.status!=="Completed"&&kt.status!=="Cancelled"&&((wt=kt.participants)==null?void 0:wt.some(Os=>Os.userId===(r==null?void 0:r.id)))});if(i&&n)try{const kt=new FormData;kt.append("file",i),kt.append("documentType","Approval Attachment");let wt=null;et&&(et.level===1||et.level==="1"?wt="1st Level Interview":et.level===2||et.level==="2"?wt="2nd Level Interview":(et.level===3||et.level==="3")&&(wt="3rd Level Interview")),wt||(s.status==="Shortlisted"||s.status==="Level 1 Interview Pending"?wt="1st Level Interview":s.status==="Level 1 Approved"||s.status==="Level 2 Interview Pending"?wt="2nd Level Interview":(s.status==="Level 2 Approved"||s.status==="Level 3 Interview Pending")&&(wt="3rd Level Interview")),wt&&kt.append("stage",wt),await ps.uploadDocument(n,kt)}catch{J.error("Failed to upload document")}if(et)try{await ps.updateInterviewDecision({interviewId:et.id,decision:"Approved",remarks:o}),J.success("Interview approved successfully"),L(!1),$(""),Z(null),await de(),await mt();return}catch{J.error("Failed to approve interview");return}if(!o.trim()){J.warning("Please enter a remark");return}let dt=s.status;switch(s.status){case"Shortlisted":case"Level 1 Interview Pending":dt="Level 1 Approved";break;case"Level 1 Approved":case"Level 2 Interview Pending":dt="Level 2 Approved";break;case"Level 2 Approved":case"Level 3 Interview Pending":dt="Level 3 Approved";break;case"Level 3 Approved":dt="FDD Verification";break;case"FDD Verification":dt="LOI In Progress";break;case"LOI In Progress":dt="Security Deposit";break;case"Security Deposit":case"Security Details":case"Payment Pending":dt="LOI Issued";break;case"LOI Issued":dt="Dealer Code Generation";break;case"Dealer Code Generation":case"Architecture Team Assigned":case"Architecture Document Upload":case"Architecture Team Completion":case"Statutory GST":case"Statutory PAN":case"Statutory Nodal":case"Statutory Check":case"Statutory Partnership":case"Statutory Firm Reg":case"Statutory Rental":case"Statutory Virtual Code":case"Statutory Domain":case"Statutory MSD":case"Statutory LOI Ack":dt="LOA Pending";break;case"LOA Pending":dt="EOR In Progress";break;case"EOR In Progress":dt="EOR Complete";break;case"EOR Complete":dt="Inauguration";break;case"Inauguration":case"Approved":dt="Onboarded";break;default:dt="Onboarded"}const Wt={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"}[s.status];if(Wt){const kt=await ps.submitStageDecision({applicationId:s.id,stageCode:Wt,decision:"Approved",remarks:o,nextStatus:dt});(Ue=kt.data)!=null&&Ue.statusUpdated?J.success(kt.message||"Stage completed and moved to next step"):J.info(kt.message||"Approval recorded. Waiting for other mandatory approvers.")}else await ps.updateApplicationStatus(n,{status:dt,remarks:o});dt==="Onboarded"?(await ps.createDealer({applicationId:n}),J.success("Application finalized and Dealer profile created!")):J.success(`Application moved to ${dt}`),L(!1),$(""),Z(null),await mt()}catch(et){J.error(et.message||"Failed to process approval")}finally{P(!1)}},ie=async()=>{try{Q(!0);const Ue=a.find(ss=>{var Wt;return ss.status!=="Completed"&&ss.status!=="Cancelled"&&((Wt=ss.participants)==null?void 0:Wt.some(kt=>kt.userId===(r==null?void 0:r.id)))});if(Ue)try{await ps.updateInterviewDecision({interviewId:Ue.id,decision:"Rejected",remarks:d}),J.success("Interview rejected"),W(!1),U(""),await de(),await mt();return}catch{J.error("Failed to reject interview");return}if(!d.trim()){J.warning("Please enter a reason for rejection");return}const dt={"Level 1 Interview Pending":"INTERVIEW_LEVEL_1","Level 2 Interview Pending":"INTERVIEW_LEVEL_2","Level 2 Recommended":"INTERVIEW_LEVEL_2","Level 3 Interview Pending":"INTERVIEW_LEVEL_3","LOI In Progress":"LOI_APPROVAL","LOA Pending":"LOA_APPROVAL"}[s.status];dt?await ps.submitStageDecision({applicationId:s.id,stageCode:dt,decision:"Rejected",remarks:d,interviewId:Ue==null?void 0:Ue.id}):await ps.updateApplicationStatus(n,{status:"Rejected",remarks:d}),J.success("Application rejected"),W(!1),U(""),await mt()}catch(Ue){J.error(Ue.message||"Failed to process rejection")}finally{Q(!1)}},nt=async()=>{try{await ps.generateDealerCodes(n),J.success("Dealer codes generated successfully"),await mt()}catch(Ue){J.error(Ue.message||"Failed to generate dealer codes")}},fe=async()=>{if(!m){J.warning("Please select an architecture lead");return}try{M(!0),await ps.assignArchitectureTeam(n,m),J.success("Architecture team assigned successfully"),z(!1),await mt()}catch(Ue){J.error(Ue.message||"Failed to assign architecture team")}finally{M(!1)}},Ae=async()=>{try{T(!0),await ps.updateArchitectureStatus(n,f,p),J.success("Architecture status updated successfully"),F(!1),await mt()}catch{J.error("Failed to update architecture status")}finally{T(!1)}},Fe=async()=>{if(!h){J.warning("Please select a user");return}try{I(!0);const Ue=Array.isArray(u)?u.find(et=>et.id===h):null;Ue&&(Ue.role==="FDD"||Ue.roleCode==="FDD")&&(await ps.assignFddAgency({applicationId:n,assignedToAgency:h}),J.info(`${Ue.fullName||Ue.name} assigned as FDD Agency based on role.`)),await ps.addParticipant({requestId:n,requestType:"application",userId:h,participantType:x||"contributor"}),J.success("User assigned successfully!"),await mt(),K(""),G(!1)}catch{J.error("Failed to assign user")}finally{I(!1)}},Ke=async()=>{try{V(!0),await ps.retriggerEvaluators(n),J.success("Evaluators re-assigned successfully"),await mt()}catch{J.error("Failed to re-assign evaluators")}finally{V(!1)}},Le=g.useCallback(async()=>{if(ht&&s){await Zt(w),Bt();return}(ge||Je)&&s&&await Zt()},[ht,ge,Je,s,w,Zt,Bt]);return{handleAddInterviewer:ot,handleRemoveInterviewer:ke,fetchUsers:Zt,maybeFetchUsersForModal:Le,handleScheduleInterview:_s,handleRescheduleInterview:fs,handleCancelInterview:Us,handleConfirmCancelInterview:Vs,handleUpload:Qs,handleApprove:Xs,handleReject:ie,handleGenerateDealerCodes:nt,handleAssignArchitecture:fe,handleUpdateArchitectureStatus:Ae,handleAddParticipant:Fe,handleRetriggerEvaluators:Ke}}const m_={getChecklist:async(t,s)=>{const n=s?`/eor/relocation/${s}`:`/eor/application/${t}`;return(await Ie.get(n)).data},createChecklist:async t=>(await Ie.post("/eor",t)).data,updateItem:async(t,s)=>(await Ie.post(`/eor/item/${t}`,s)).data,submitAudit:async(t,s)=>(await Ie.post(`/eor/audit/${t}`,s)).data},Ug=Object.freeze(Object.defineProperty({__proto__:null,eorService:m_},Symbol.toStringTag,{value:"Module"})),sV={getAuditLogs:async(t,s,n=1,r=50)=>{var a;try{const i=await Re.getAuditLogs(t,s,n,r);return((a=i.data)==null?void 0:a.data)||i.data||[]}catch(i){throw console.error("Get audit logs error:",i),i}},getAuditSummary:async(t,s)=>{var n;try{const r=await Re.getAuditSummary(t,s);return((n=r.data)==null?void 0:n.data)||r.data}catch(r){throw console.error("Get audit summary error:",r),r}}},nV={getWorknotes:async(t,s)=>{var r,a;const n=await Re.getWorknotes(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to fetch worknotes");return((a=n.data)==null?void 0:a.data)||n.data},addWorknote:async t=>{var n,r;const s=await Re.addWorknote(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to add worknote");return((r=s.data)==null?void 0:r.data)||s.data},addParticipant:async t=>{var n;const s=await Re.addParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to add participant");return s.data},removeParticipant:async t=>{var n;const s=await Re.removeParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to remove participant");return s.data}};function rV({applicationId:t}){const[s,n]=g.useState(null),[r,a]=g.useState(!0),[i,o]=g.useState([]),[d,m]=g.useState(null),[f,p]=g.useState([]),[h,x]=g.useState(!1),[u,N]=g.useState([]),[v,w]=g.useState([]),[j,b]=g.useState({}),C=g.useCallback(async()=>{try{const A=await ps.getDocuments(t);o(A||[])}catch(A){console.error("Failed to refresh documents:",A)}},[t]),S=g.useCallback(async(A=!1)=>{try{A||a(!0);const E=await ps.getApplicationById(t),q=(R,P)=>{var $;const L=($=E.progressTracking)==null?void 0:$.find(Z=>Z.stageName===R);if(L!=null&&L.stageCompletedAt)return new Date(L.stageCompletedAt).toISOString();if(L!=null&&L.stageStartedAt)return new Date(L.stageStartedAt).toISOString();if(P){const Z=(E.statusHistory||[]).find(Q=>Q.newStatus===P);if(Z)return new Date(Z.createdAt).toISOString()}},O={id:E.id,registrationNumber:E.applicationId||"N/A",name:E.applicantName,email:E.email,phone:E.phone,age:E.age,education:E.education,residentialAddress:E.address||E.city||"",businessAddress:E.address||"",preferredLocation:E.preferredLocation,state:E.state,ownsBike:E.ownRoyalEnfield==="yes",pastExperience:E.experienceYears?`${E.experienceYears} years`:E.description||"",status:E.overallStatus,questionnaireMarks:E.score||E.questionnaireMarks||0,questionnaireResponses:E.questionnaireResponses||[],rank:0,totalApplicantsAtLocation:0,assignedUsers:[],progress:E.progressPercentage||0,isShortlisted:E.isShortlisted||!0,companyName:E.companyName,source:E.source,existingDealer:E.existingDealer,royalEnfieldModel:E.royalEnfieldModel,description:E.description,pincode:E.pincode,locationType:E.locationType,ownRoyalEnfield:E.ownRoyalEnfield,address:E.address,submissionDate:E.createdAt?new Date(E.createdAt).toISOString():"",questionnaireDate:q("Questionnaire","Questionnaire Completed")||q("Questionnaire","Questionnaire Pending"),shortlistDate:q("Shortlist","Shortlisted"),level1InterviewDate:q("1st Level Interview","Level 1 Approved"),level2InterviewDate:q("2nd Level Interview","Level 2 Approved"),level3InterviewDate:q("3rd Level Interview","Level 3 Approved"),fddDate:q("FDD","FDD Verification"),loiApprovalDate:q("LOI Approval","LOI In Progress"),securityDetailsDate:q("Security Deposit","Security Deposit")||q("Security Details","Security Details"),loiIssueDate:q("LOI Issue","LOI Issued"),dealerCodeDate:q("Dealer Code Generation","Dealer Code Generation"),architectureAssignedDate:q("Architecture Team Assigned","Architecture Team Assigned"),architectureDocumentDate:q("Architecture Document Upload","Architecture Document Upload"),architectureCompletionDate:q("Architecture Team Completion","Architecture Team Completion"),loaDate:q("LOA","LOA Pending"),eorCompleteDate:q("EOR Complete","EOR Complete"),inaugurationDate:q("Inauguration","Inauguration"),onboardedDate:E.overallStatus==="Onboarded"?E.updatedAt?new Date(E.updatedAt).toISOString():new Date().toISOString():void 0,progressTracking:E.progressTracking||[],participants:E.participants||[],dealerCode:E.dealerCode,zoneId:E.zoneId,regionId:E.regionId,areaId:E.areaId,districtId:E.districtId,stageApprovals:E.stageApprovals||[],fddAssignments:E.fddAssignments||[],constitutionType:E.constitutionType,architectureStatus:E.architectureStatus,statutoryStatus:E.statutoryStatus,panNumber:E.panNumber,gstNumber:E.gstNumber,bankName:E.bankName,accountNumber:E.accountNumber,ifscCode:E.ifscCode,branchName:E.branchName,accountHolderName:E.accountHolderName,registeredAddress:E.registeredAddress};n(O),E.uploadedDocuments&&o(E.uploadedDocuments||[])}catch(E){console.error("Failed to fetch application details",E)}finally{a(!1)}},[t]),D=g.useCallback(async()=>{if(t)try{const A=await m_.getChecklist(t);A.success&&A.data&&m(A.data)}catch{m(null)}},[t]),_=A=>v.find(E=>E.depositType===A);return g.useEffect(()=>{t&&(S(),C())},[t]),g.useEffect(()=>{t&&D()},[t,s==null?void 0:s.status]),g.useEffect(()=>{if(!(s!=null&&s.id))return;(async()=>{x(!0);try{const E=await sV.getAuditLogs("application",s.id,1,100);p(Array.isArray(E)?E:[])}catch{p([])}finally{x(!1)}try{const E=await nV.getWorknotes("application",s.id);N(E.data||[])}catch{N([])}})()},[s==null?void 0:s.id]),g.useEffect(()=>{if(!t)return;(async()=>{try{const[E,q]=await Promise.all([ps.getSecurityDeposit(t),ps.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);w(Array.isArray(E)?E:[E].filter(Boolean)),b(q||{})}catch(E){console.error("Failed to fetch payment data",E)}})()},[t]),{application:s,loading:r,setLoading:a,documents:i,setDocuments:o,eorData:d,auditLogs:f,auditLoading:h,worknotes:u,deposits:v,paymentConfigs:j,refreshDocuments:C,fetchApplication:S,fetchEorData:D,getDeposit:_}}function aV({application:t,applicationId:s,tempFirmType:n,setUpdatingFirmType:r,setShowFirmTypeModal:a,setStatutoryForm:i,setIsEditingStatutory:o,setIsSavingStatutory:d,statutoryForm:m,setFddAgencies:f,selectedAgencyId:p,setIsAssigningAgency:h,fetchApplication:x}){const u=async()=>{try{r(!0),await ps.updateApplication(s,{constitutionType:n}),J.success("Firm type updated successfully"),a(!1),await x()}catch{J.error("Failed to update firm type")}finally{r(!1)}},N=()=>{t&&(i({accountHolderName:t.accountHolderName||"",panNumber:t.panNumber||"",gstNumber:t.gstNumber||"",bankName:t.bankName||"",accountNumber:t.accountNumber||"",ifscCode:t.ifscCode||"",registeredAddress:t.registeredAddress||""}),o(!0))},v=async()=>{try{d(!0),await ps.updateApplication(s,m),J.success("Statutory & Bank details updated successfully"),o(!1),await x(!0)}catch{J.error("Failed to update details")}finally{d(!1)}},w=g.useCallback(async()=>{try{const b=await ps.getUsers({roleCode:"FDD"});f(Array.isArray(b)?b:[])}catch{f([])}},[f]);return{handleUpdateFirmType:u,handleEditStatutory:N,handleSaveStatutory:v,fetchFddAgencies:w,handleAssignAgency:async()=>{if(!p){J.warning("Please select an agency");return}try{h(!0),await ps.assignFddAgency({applicationId:(t==null?void 0:t.id)||s,assignedToAgency:p}),await ps.addParticipant({requestId:(t==null?void 0:t.id)||s,requestType:"application",userId:p,participantType:"contributor"}),J.success("FDD Agency assigned and added as participant"),await x()}catch{J.error("Failed to assign agency")}finally{h(!1)}}}}function iV({application:t,documents:s,interviews:n,eorData:r,getDeposit:a,documentConfigs:i=[]}){var w;const o=j=>String(j||"").trim().toLowerCase().replace(/[_\s-]+/g," "),d=(j,b)=>{var D,_,A;const C=[(D=j==null?void 0:j.user)==null?void 0:D.role,(_=j==null?void 0:j.user)==null?void 0:_.roleCode,(A=j==null?void 0:j.metadata)==null?void 0:A.role].map(o),S=b.map(o);return C.some(E=>S.includes(E))},m=j=>{var b,C,S,D,_;return`${((b=j==null?void 0:j.user)==null?void 0:b.fullName)||((C=j==null?void 0:j.user)==null?void 0:C.name)||"User"} (${((S=j==null?void 0:j.user)==null?void 0:S.role)||((D=j==null?void 0:j.user)==null?void 0:D.roleCode)||((_=j==null?void 0:j.metadata)==null?void 0:_.role)||(j==null?void 0:j.participantType)||"participant"})`},f=j=>(s||[]).some(b=>b.documentType===j),p=()=>{const j=t.progressTracking||[],b=j.find(C=>C.stageName==="Security Deposit")||j.find(C=>C.stageName==="Security Details");return b!=null&&b.status?b.status:"pending"},h=(j,b="pending")=>{const C=(t.progressTracking||[]).find(S=>S.stageName===j);return C!=null&&C.status?C.status:b},x=[{id:1,name:"Submitted",status:"completed",date:t.submissionDate,description:"Application submitted",documentsUploaded:3},{id:2,name:"Questionnaire",status:h("Questionnaire"),date:t.questionnaireDate,description:"Questionnaire completed",documentsUploaded:0},{id:3,name:"Shortlist",status:h("Shortlist"),date:t.shortlistDate,description:"Application shortlisted by DD",evaluators:Array.from(new Set((t.participants||[]).filter(j=>j.participantType==="assignee").map(j=>{var b,C,S;return`${((b=j.user)==null?void 0:b.fullName)||((C=j.user)==null?void 0:C.name)||"User"} (${((S=j.user)==null?void 0:S.roleCode)||j.participantType})`}))),documentsUploaded:2},{id:4,name:"1st Level Interview",status:h("1st Level Interview"),date:t.level1InterviewDate,description:"DD-ZM + RBM evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,D,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===1||((C=j.metadata)==null?void 0:C.interviewLevel)==="1"||((D=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:D.includes(1))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("1"))||d(j,["DD-ZM","RBM"])}).map(m))),documentsUploaded:1},{id:5,name:"2nd Level Interview",status:h("2nd Level Interview"),date:t.level2InterviewDate,description:"DD Lead + ZBH evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,D,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===2||((C=j.metadata)==null?void 0:C.interviewLevel)==="2"||((D=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:D.includes(2))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("2"))||d(j,["DD Lead","ZBH"])}).map(m))),documentsUploaded:1},{id:6,name:"3rd Level Interview",status:h("3rd Level Interview"),date:t.level3InterviewDate,description:"NBH + DD Head evaluation",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S,D,_,A;return((b=j.metadata)==null?void 0:b.interviewLevel)===3||((C=j.metadata)==null?void 0:C.interviewLevel)==="3"||((D=(S=j.metadata)==null?void 0:S.allAssignments)==null?void 0:D.includes(3))||((A=(_=j.metadata)==null?void 0:_.allAssignments)==null?void 0:A.includes("3"))||d(j,["NBH","DD Head"])}).map(m))),documentsUploaded:2},{id:7,name:"FDD",status:h("FDD"),date:t.fddDate,description:"Financial Due Diligence",documentsUploaded:5},{id:8,name:"LOI Approval",status:h("LOI Approval"),date:t.loiApprovalDate,description:"Letter of Intent approval",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S;return((b=j.metadata)==null?void 0:b.stageCode)==="LOI_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOI_APPROVAL"))}).map(m))),documentsUploaded:1},{id:9,name:"Security Deposit",status:p(),date:t.securityDetailsDate,description:"Security Deposit verification",documentsUploaded:3},{id:10,name:"LOI Issue",status:h("LOI Issue"),date:t.loiIssueDate,description:"Letter of Intent issued",isParallel:!0,branches:[{name:"LOI Documents",color:"green",stages:i.some(j=>j.stageCode==="LOI Issue")?i.filter(j=>j.stageCode==="LOI Issue").map((j,b)=>({id:`10a-${b}`,name:j.documentType,status:f(j.documentType)?"completed":"active",description:j.isMandatory?`Upload ${j.documentType} (Mandatory)`:`Upload ${j.documentType}`})):[{id:"10a-1",name:"Letter of Intent",status:f("Letter of Intent")||f("LOI")?"completed":"active",description:"Letter of Intent document"},{id:"10a-2",name:"Signed LOI",status:f("Signed LOI")||f("LOI Signed Copy")?"completed":"active",description:"Signed Letter of Intent"}]}]},{id:11,name:"Dealer Code Generation",status:h("Dealer Code Generation"),date:t.dealerCodeDate,description:"Dealer code generated and assigned",isParallel:!0,branches:[{name:"Architectural Work",color:"green",stages:[{id:"11a-1",name:"Architecture Assignment",status:t.architectureAssignedTo?"completed":t.status==="Architecture Team Assigned"?"active":"pending",description:"Assigned to architecture team"},{id:"11a-2",name:"Site Plan Blueprint",status:f("Architecture Blueprint")?"completed":t.architectureAssignedTo?"active":"pending",description:"Blueprints and site plans"},{id:"11a-3",name:"Architecture Work",status:t.architectureStatus==="COMPLETED"?"completed":t.architectureStatus==="IN_PROGRESS"||f("Architecture Blueprint")?"active":"pending",description:"Final architecture approval"}]},{name:"Statutory Documents",color:"green",stages:[{id:"11b-1",name:"GST",status:f("GST Certificate")||f("GST")?"completed":"active",description:"GST certificate"},{id:"11b-2",name:"PAN",status:f("PAN Card")||f("PAN")?"completed":"active",description:"PAN card"},{id:"11b-3",name:"Nodal Agreement",status:f("Nodal Agreement")?"completed":"active",description:"Nodal agreement document"},{id:"11b-4",name:"Cancelled Check",status:f("Cancelled Check")?"completed":"active",description:"Cancelled check copy"},{id:"11b-5",name:"Partnership Deed/LLP/MOA/AOA/COI",status:f("Partnership Deed/LLP/MOA/AOA/COI")||f("Partnership Deed")?"completed":"active",description:"Business entity documents"},{id:"11b-6",name:"Firm Registration Certificate",status:f("Firm Registration Certificate")||f("Firm Registration")?"completed":"active",description:"Firm registration certificate"},{id:"11b-7",name:"Rental agreement/ Lease agreement / Own/ Land agreement",status:f("Rental agreement/ Lease agreement / Own/ Land agreement")||f("Property Document")?"completed":"active",description:"Property agreement document"},{id:"11b-8",name:"Virtual Code",status:f("Virtual Code")||f("Virtual Code Confirmation")?"completed":"active",description:"Virtual code availability"},{id:"11b-9",name:"Domain ID",status:f("Domain ID")||f("Domain ID Setup")?"completed":"active",description:"Domain ID setup"},{id:"11b-10",name:"MSD Configuration",status:f("MSD Configuration")?"completed":"active",description:"Microsoft Dynamics configuration"},{id:"11b-11",name:"LOI Acknowledgement Copy",status:f("LOI Acknowledgement Copy")||f("LOI Acknowledgement")?"completed":"active",description:"LOI acknowledgement copy"}]}]},{id:12,name:"LOA",status:h("LOA"),isLocked:t.status==="LOA Pending"&&((w=a("FIRST_FILL"))==null?void 0:w.status)!=="Verified",lockMessage:"First Fill (₹15L) must be verified by Finance before LOA Approval.",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var b,C,S;return((b=j.metadata)==null?void 0:b.stageCode)==="LOA_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOA_APPROVAL"))}).map(m))),description:"Letter of Authorization"},{id:13,name:"EOR Complete",status:h("EOR Complete"),description:"Essential Operating Requirements"},{id:14,name:"Inauguration",status:h("Inauguration"),description:"Dealership inauguration"},{id:15,name:"Dealership Active",status:h("Onboarded"),description:"Dealer profile active"}],u=[{id:1,item:"Sales Standards",completed:!1},{id:2,item:"Service & Spares",completed:!1},{id:3,item:"DMS infra",completed:!1},{id:4,item:"Manpower Training",completed:!1},{id:5,item:"Trade certificate with test ride bikes registration",completed:!1},{id:6,item:"GST certificate including Accessories & Apparels billing",completed:!1},{id:7,item:"Inventory Funding",completed:!1},{id:8,item:"Virtual code availability",completed:!1},{id:9,item:"Vendor payments",completed:!1},{id:10,item:"Details for website submission",completed:!1},{id:11,item:"Infra Insurance both Showroom and Service center",completed:!1},{id:12,item:"Auto ordering",completed:!1}],N=x.reduce((j,b)=>(j.push({name:b.name}),b.branches&&b.branches.forEach(C=>C.stages.forEach(S=>j.push({name:S.name,parentBranch:C.name}))),(b.name==="EOR In Progress"||b.name==="EOR Complete")&&((r==null?void 0:r.items)||u).forEach(C=>j.push({name:`EOR: ${C.description||C.item}`,parentBranch:"EOR"})),j),[]);return{processStages:x,eorChecklist:u,flattenedStages:N,getDocumentsForStage:j=>s.filter(b=>{var C;return b.stage===j||!b.stage&&((C=b.documentType)==null?void 0:C.toLowerCase().includes(j.toLowerCase().split(" ")[0]))})}}const RS=()=>{var yc;const{id:t}=gd(),s=tr(),{user:n}=Pn(ur=>ur.auth),r=t||"",a=()=>s(-1),[i,o]=g.useState(null);g.useEffect(()=>{r&&Yl.getBatchStatus([{entityType:"application",entityId:r}]).then(ur=>{ur!=null&&ur.success&&o(ur.data[`application:${r}`]??null)}).catch(()=>o(null))},[r]);const{application:d,loading:m,setLoading:f,documents:p,setDocuments:h,eorData:x,auditLogs:u,auditLoading:N,worknotes:v,deposits:w,paymentConfigs:j,refreshDocuments:b,fetchApplication:C,fetchEorData:S,getDeposit:D}=rV({applicationId:r}),_=x!=null&&x.items?x.items.filter(ur=>ur.isCompliant).length/x.items.length*100:0,A=xl(),{showFirmTypeModal:E,setShowFirmTypeModal:q,updatingFirmType:O,setUpdatingFirmType:R,tempFirmType:P,setTempFirmType:L,activeTab:$,setActiveTab:Z,showApproveModal:Q,setShowApproveModal:W,showOnboardModal:U,setShowOnboardModal:M,isOnboarding:z,setIsOnboarding:T,showRejectModal:F,setShowRejectModal:I,rejectionReason:K,setRejectionReason:G,scheduledInterviewParticipants:V,setScheduledInterviewParticipants:Y,showScheduleModal:re,setShowScheduleModal:ae,showCancelInterviewModal:ue,setShowCancelInterviewModal:ye,interviewIdToCancel:ce,setInterviewIdToCancel:je,interviewToReschedule:Me,setInterviewToReschedule:ut,showKTMatrixModal:jt,setShowKTMatrixModal:ft,showLevel2FeedbackModal:X,setShowLevel2FeedbackModal:Ce,showLevel3FeedbackModal:xe,setShowLevel3FeedbackModal:We,showDocumentsModal:Be,setShowDocumentsModal:rt,showAssignModal:ht,setShowAssignModal:ge,selectedStage:Je,setSelectedStage:mt,interviewMode:de,setInterviewMode:at,approvalRemark:ot,setApprovalRemark:ke,expandedBranches:Zt,setExpandedBranches:Bt,users:_s,setUsers:Us,selectedUser:fs,setSelectedUser:Vs,participantType:Qs,setParticipantType:Xs,interviewDate:ie,setInterviewDate:nt,interviewType:fe,setInterviewType:Ae,meetingLink:Fe,setMeetingLink:Ke,location:Le,setLocation:Ue,showUploadForm:et,setShowUploadForm:dt,uploadFile:ss,setUploadFile:Wt,uploadDocType:kt,setUploadDocType:wt,approvalFile:Os,setApprovalFile:as,isUploading:Se,setIsUploading:be,previewDoc:pt,setPreviewDoc:Ve,showPreviewModal:bt,setShowPreviewModal:gt,selectedInterviewerId:rs,setSelectedInterviewerId:is,isEditingStatutory:Ts,setIsEditingStatutory:Ws,statutoryForm:nn,setStatutoryForm:Ee,isSavingStatutory:$t,setIsSavingStatutory:Xt,interviews:Cs,setInterviews:Mt,isScheduling:ze,setIsScheduling:xt,isCancellingInterview:yt,setIsCancellingInterview:Ot,showAssignArchitectureModal:Pt,setShowAssignArchitectureModal:Jt,architectureLeadId:bs,setArchitectureLeadId:ns,isAssigningArchitecture:Ds,setIsAssigningArchitecture:ts,showArchitectureStatusModal:js,setShowArchitectureStatusModal:tn,architectureStatus:vn,setArchitectureStatus:jn,architectureRemarks:xn,setArchitectureRemarks:gn,isUpdatingArchitecture:Ye,setIsUpdatingArchitecture:qt,isAssigningParticipant:Ze,setIsAssigningParticipant:Gt,documentConfigs:St,setDocumentConfigs:qn,fddAgencies:Er,setFddAgencies:Fr,selectedAgencyId:wn,setSelectedAgencyId:Js,isAssigningAgency:Sa,setIsAssigningAgency:It,showAssignFddModal:As,setShowAssignFddModal:_r,isApproving:ca,setIsApproving:Ca,isRejecting:Yr,setIsRejecting:Nr,ktMatrixScores:kn,setKtMatrixScores:Sn,ktMatrixSelectedValues:sr,setKtMatrixSelectedValues:wr,ktMatrixRemarks:Sr,setKtMatrixRemarks:yn,ktMatrixRecommendation:Dn,setKtMatrixRecommendation:Aa,isSubmittingKT:ka,setIsSubmittingKT:qi,selectedInterviewForFeedback:xi,setSelectedInterviewForFeedback:gi,showFddFinalizeModal:bl,setShowFddFinalizeModal:jl,showFddFlagModal:da,setShowFddFlagModal:Da,fddAuditRecommendation:ua,setFddAuditRecommendation:Va,fddAuditFindings:fc,setFddAuditFindings:Rd,isFinalizingFdd:vi,setIsFinalizingFdd:nr,isFddFlagging:yi,setIsFddFlagging:zi,level2Feedback:Br,setLevel2Feedback:yo,level2Recommendation:Ui,setLevel2Recommendation:bo,isSubmittingLevel2:bi,setIsSubmittingLevel2:Nl,level3Feedback:wl,setLevel3Feedback:rn,level3Recommendation:ee,setLevel3Recommendation:se,isSubmittingLevel3:he,setIsSubmittingLevel3:pe,showFeedbackDetailsModal:Ne,setShowFeedbackDetailsModal:$e,selectedEvaluationForView:qe,setSelectedEvaluationForView:ct}=ZU({initialTab:((yc=A.state)==null?void 0:yc.activeTab)||"questionnaire"}),ds=(v||[]).some(ur=>(ur.noteText||"").includes("FLAGGED:"))||(d==null?void 0:d.statutoryStatus)==="Flagged",{handleUpdateFirmType:Kt,handleEditStatutory:Ft,handleSaveStatutory:Rs,fetchFddAgencies:cn,handleAssignAgency:Kn}=aV({application:d,applicationId:r,tempFirmType:P,setUpdatingFirmType:R,setShowFirmTypeModal:q,setStatutoryForm:Ee,setIsEditingStatutory:Ws,setIsSavingStatutory:Xt,statutoryForm:nn,setFddAgencies:Fr,selectedAgencyId:wn,setIsAssigningAgency:It,fetchApplication:C}),zt=(n==null?void 0:n.roleCode)==="Super Admin"||(n==null?void 0:n.roleCode)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin"||(n==null?void 0:n.role)==="DD Admin",Es=(n==null?void 0:n.roleCode)==="Super Admin"||(n==null?void 0:n.roleCode)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin"||(n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="DD Head"||(n==null?void 0:n.roleCode)==="NBH"||(n==null?void 0:n.roleCode)==="DD_HEAD";g.useEffect(()=>{(async()=>{try{const Rl=await ps.getDocumentConfigs({limit:1e3}),hh=Rl.data||(Array.isArray(Rl)?Rl:[]);qn(hh)}catch(Rl){console.error("Failed to fetch document configs:",Rl)}})()},[qn]),g.useEffect(()=>{re&&d&&(d.status==="Shortlisted"||d.status==="Questionnaire Completed"?Ae("level1"):d.status==="Level 1 Approved"?Ae("level2"):(d.status==="Level 2 Approved"||d.status==="Level 2 Recommended")&&Ae("level3"))},[re,d==null?void 0:d.status,Ae]);const os=async()=>{if(r)try{const ur=await ps.getInterviews(r);Mt(ur||[])}catch(ur){console.error("Failed to fetch interviews",ur)}};g.useEffect(()=>{os()},[r]);const{ktMatrixConfig:On,level2Config:Cr,level3Config:zn}=eV(),{handleKTMatrixChange:cr,calculateKTScore:$r,handleSubmitKTMatrix:Ha,handleLevel2Change:dr,handleSubmitLevel2Feedback:jo,handleLevel3Change:Sl,handleSubmitLevel3Feedback:pc,ktCriteria:No,l2Fields:Cl,l3Fields:Vi}=JU({ktMatrixScores:kn,setKtMatrixScores:Sn,setKtMatrixSelectedValues:wr,ktMatrixRemarks:Sr,setKtMatrixRemarks:yn,ktMatrixRecommendation:Dn,setKtMatrixRecommendation:Aa,selectedInterviewForFeedback:xi,interviews:Cs,setIsSubmittingKT:qi,setShowKTMatrixModal:ft,level2Feedback:Br,setLevel2Feedback:yo,level2Recommendation:Ui,setLevel2Recommendation:bo,setIsSubmittingLevel2:Nl,setShowLevel2FeedbackModal:Ce,level3Feedback:wl,setLevel3Feedback:rn,level3Recommendation:ee,setLevel3Recommendation:se,setIsSubmittingLevel3:pe,setShowLevel3FeedbackModal:We,currentUser:n,fetchInterviews:os,fetchApplication:C,ktMatrixConfig:On,level2Config:Cr,level3Config:zn});g.useEffect(()=>{["documents","progress","fdd","eor"].includes($)&&r&&b(),$==="fdd"&&((n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin")&&cn()},[$,r,b,cn,n==null?void 0:n.role]);const{handleAddInterviewer:Wa,handleRemoveInterviewer:xc,maybeFetchUsersForModal:rr,handleScheduleInterview:gc,handleRescheduleInterview:Ra,handleConfirmCancelInterview:Al,handleUpload:Hi,handleApprove:Ea,handleReject:Ga,handleGenerateDealerCodes:kl,handleAssignArchitecture:Wi,handleUpdateArchitectureStatus:wo,handleAddParticipant:oh,handleRetriggerEvaluators:Dl}=tV({application:d,applicationId:r,currentUser:n,interviews:Cs,approvalFile:Os,approvalRemark:ot,rejectionReason:K,architectureLeadId:bs,architectureStatus:vn,architectureRemarks:xn,selectedUser:fs,participantType:Qs,users:_s,interviewDate:ie,setInterviewDate:nt,interviewType:fe,setInterviewType:Ae,interviewMode:de,setInterviewMode:at,meetingLink:Fe,setMeetingLink:Ke,location:Le,setLocation:Ue,scheduledInterviewParticipants:V,uploadFile:ss,uploadDocType:kt,selectedStage:Je,setIsApproving:Ca,setShowApproveModal:W,setApprovalRemark:ke,setApprovalFile:as,setIsRejecting:Nr,setShowRejectModal:I,setRejectionReason:G,setIsAssigningArchitecture:ts,setShowAssignArchitectureModal:Jt,setIsUpdatingArchitecture:qt,setShowArchitectureStatusModal:tn,setIsAssigningParticipant:Gt,setSelectedUser:Vs,setShowAssignModal:ge,setLoading:f,setIsScheduling:xt,setShowScheduleModal:ae,setShowCancelInterviewModal:ye,interviewIdToCancel:ce,setInterviewIdToCancel:je,interviewToReschedule:Me,setInterviewToReschedule:ut,setIsCancellingInterview:Ot,setIsUploading:be,setShowUploadForm:dt,setUploadFile:Wt,setUploadDocType:wt,setDocuments:h,selectedInterviewerId:rs,setSelectedInterviewerId:is,setScheduledInterviewParticipants:Y,setUsers:Us,showScheduleModal:re,showAssignArchitectureModal:Pt,showAssignModal:ht,fetchApplication:C,fetchInterviews:os,fetchEorData:S});if(g.useEffect(()=>{rr()},[re,Pt,ht,fe,d==null?void 0:d.id,rr]),m&&!d)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(cs,{className:"w-10 h-10 animate-spin text-re-red"})});if(!d)return e.jsx("div",{className:"flex justify-center items-center h-96",children:"Application not found"});const{processStages:Ap,eorChecklist:kp,flattenedStages:Dp,getDocumentsForStage:ch}=iV({application:d,documents:p,interviews:Cs,eorData:x,getDeposit:D,documentConfigs:St}),{activeInterviewForUser:dh,currentUserEvaluation:So,hasSubmittedFeedback:Co,currentUserStageAction:Rp,isInterviewCompleted:vc,isInterviewActive:Ep,permissions:uh}=YU({application:d,interviews:Cs,currentUser:n,getDeposit:D,eorProgress:_}),Ed=()=>e.jsx(VU,{application:d,documents:p,setPreviewDoc:Ve,setShowPreviewModal:gt,setIsUploading:be,fetchApplication:C,refreshDocuments:b});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(DU,{application:d,slaStatus:i,isNonResponsive:ds,isAdmin:Es,onBack:a,onOpenWorknotes:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(LU,{application:d,canEditStatutory:zt,isEditingStatutory:Ts,isSavingStatutory:$t,statutoryForm:nn,onEditFirmType:()=>{L(d.constitutionType||""),q(!0)},onEditStatutory:Ft,onCancelEditStatutory:()=>Ws(!1),onSaveStatutory:Rs,onStatutoryFormChange:Ee}),d.isShortlisted!==!1&&e.jsx(BU,{application:d,activeTab:$,setActiveTab:Z,processStages:Ap,documents:p,interviews:Cs,expandedBranches:Zt,setExpandedBranches:Bt,setSelectedStage:mt,setShowDocumentsModal:rt,setShowUploadForm:dt,handleRetriggerEvaluators:Dl,handleRescheduleInterview:Ra,setSelectedEvaluationForView:ct,setShowFeedbackDetailsModal:$e,renderFddAuditContent:Ed,eorProgress:_,eorData:x,eorChecklist:kp,setUploadDocType:wt,isAdmin:Es,fetchApplication:C,fetchEorData:S,deposits:w,getDeposit:D,paymentConfigs:j,setPreviewDoc:Ve,setShowPreviewModal:gt,auditLoading:N,auditLogs:u,auditLogActionBadgeClass:HU})]}),e.jsx($U,{application:d,permissions:uh,getDeposit:D,isNonResponsive:ds,isAdmin:Es,currentUserStageAction:Rp,currentUserEvaluation:So,onOpenApproveModal:()=>W(!0),onOpenRejectModal:()=>I(!0),onOpenWorknote:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}}),onOpenScheduleModal:()=>ae(!0),currentUser:n,handleGenerateDealerCodes:kl,onOpenAssignArchitectureModal:()=>Jt(!0),onOpenAssignFdd:()=>{Js(""),cn(),_r(!0)},showAssignFddModal:As,setShowAssignFddModal:_r,fddAgencies:Er,selectedAgencyId:wn,setSelectedAgencyId:Js,isAssigningAgency:Sa,handleAssignAgency:async()=>{await Kn(),_r(!1)},activeInterviewForUser:dh,hasSubmittedFeedback:Co,setSelectedInterviewForFeedback:gi,setShowKTMatrixModal:ft,setShowLevel2FeedbackModal:Ce,setShowLevel3FeedbackModal:We,onGoToDashboard:()=>s("/dashboard"),showAssignModal:ht,setShowAssignModal:ge,selectedUser:fs,setSelectedUser:Vs,users:_s,participantType:Qs,setParticipantType:Xs,handleAddParticipant:oh,isAssigningParticipant:Ze}),e.jsx(qU,{application:d,fetchApplication:C,showApproveModal:Q,setShowApproveModal:W,approvalRemark:ot,setApprovalRemark:ke,setApprovalFile:as,isApproving:ca,handleApprove:Ea,showOnboardModal:U,setShowOnboardModal:M,isOnboarding:z,setIsOnboarding:T,showRejectModal:F,setShowRejectModal:I,rejectionReason:K,setRejectionReason:G,isRejecting:Yr,handleReject:Ga,showScheduleModal:re,setShowScheduleModal:ae,showCancelInterviewModal:ue,setShowCancelInterviewModal:ye,setInterviewIdToCancel:je,isCancellingInterview:yt,handleConfirmCancelInterview:Al,interviewToReschedule:Me,setInterviewToReschedule:ut,interviewType:fe,setInterviewType:Ae,interviewMode:de,setInterviewMode:at,interviewDate:ie,setInterviewDate:nt,meetingLink:Fe,setMeetingLink:Ke,location:Le,setLocation:Ue,isInterviewCompleted:vc,isInterviewActive:Ep,users:_s,selectedInterviewerId:rs,setSelectedInterviewerId:is,handleAddInterviewer:Wa,scheduledInterviewParticipants:V,handleRemoveInterviewer:xc,isScheduling:ze,handleScheduleInterview:gc,showAssignArchitectureModal:Pt,setShowAssignArchitectureModal:Jt,architectureLeadId:bs,setArchitectureLeadId:ns,isAssigningArchitecture:Ds,handleAssignArchitecture:Wi,showArchitectureStatusModal:js,setShowArchitectureStatusModal:tn,architectureStatus:vn,setArchitectureStatus:jn,architectureRemarks:xn,setArchitectureRemarks:gn,isUpdatingArchitecture:Ye,handleUpdateArchitectureStatus:wo}),e.jsx(zU,{application:d,ktCriteria:No,l2Fields:Cl,l3Fields:Vi,showKTMatrixModal:jt,setShowKTMatrixModal:ft,ktMatrixSelectedValues:sr,handleKTMatrixChange:cr,ktMatrixRemarks:Sr,setKtMatrixRemarks:yn,ktMatrixRecommendation:Dn,setKtMatrixRecommendation:Aa,calculateKTScore:$r,handleSubmitKTMatrix:Ha,isSubmittingKT:ka,showLevel2FeedbackModal:X,setShowLevel2FeedbackModal:Ce,level2Feedback:Br,handleLevel2Change:dr,level2Recommendation:Ui,setLevel2Recommendation:bo,handleSubmitLevel2Feedback:jo,isSubmittingLevel2:bi,showFeedbackDetailsModal:Ne,setShowFeedbackDetailsModal:$e,selectedEvaluationForView:qe,selectedInterviewForFeedback:xi,showLevel3FeedbackModal:xe,setShowLevel3FeedbackModal:We,level3Feedback:wl,handleLevel3Change:Sl,level3Recommendation:ee,setLevel3Recommendation:se,handleSubmitLevel3Feedback:pc,isSubmittingLevel3:he,showDocumentsModal:Be,setShowDocumentsModal:rt,showUploadForm:et,setShowUploadForm:dt,selectedStage:Je,getDocumentsForStage:ch,setPreviewDoc:Ve,setShowPreviewModal:gt,flattenedStages:Dp,setSelectedStage:mt,uploadDocType:kt,setUploadDocType:wt,setUploadFile:Wt,isUploading:Se,handleUpload:Hi,uploadFile:ss,documentConfigs:St,showPreviewModal:bt,previewDoc:pt,showFddFinalizeModal:bl,setShowFddFinalizeModal:jl,currentUser:n,fddAuditRecommendation:ua,setFddAuditRecommendation:Va,fddAuditFindings:fc,setFddAuditFindings:Rd,isFinalizingFdd:vi,setIsFinalizingFdd:nr,fetchApplication:C,showFddFlagModal:da,setShowFddFlagModal:Da,isFddFlagging:yi,setIsFddFlagging:zi,showFirmTypeModal:E,setShowFirmTypeModal:q,tempFirmType:P,setTempFirmType:L,updatingFirmType:O,handleUpdateFirmType:Kt})]})]})};function mc(t,s=!0){const[n,r]=g.useState({});return g.useEffect(()=>{if(!s||t.length===0){r({});return}Yl.getBatchStatus(t).then(i=>{i!=null&&i.success&&r(i.data)}).catch(()=>r({}))},[s,JSON.stringify(t.map(i=>`${i.entityType}:${i.entityId}`).sort())]),{byKey:n,get:(i,o)=>n[`${i}:${o}`]??null}}const Vg=t=>t.includes("Approved")||t.includes("Completed")?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")?"bg-red-100 text-red-700 border-red-300":"bg-blue-100 text-blue-700 border-blue-300";function lV({onViewDetails:t}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState(1),[d,m]=g.useState("all"),[f,p]=g.useState(null),h=10,x=async()=>{var b;a(!0);try{const S=(await Re.getResignations({page:i,limit:h,status:d==="all"?void 0:d==="open"?"open":"Completed,Closed"})).data;S!=null&&S.success&&(n(S.requests||((b=S.resignations)==null?void 0:b.rows)||S.resignations||[]),p(S.meta))}catch(C){console.error("Error fetching resignations:",C),J.error("Failed to fetch resignation requests")}finally{a(!1)}};g.useEffect(()=>{x()},[i,d]);const u=b=>{m(b),o(1)},N=d==="open"?s:[],v=d==="completed"?s:[],w=s.map(b=>({entityType:"resignation",entityId:b.id})),{get:j}=mc(w,s.length>0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"All Requests"}),e.jsx(st,{className:"text-3xl",children:(f==null?void 0:f.total)||0})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Requests"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Open"}),e.jsx(st,{className:"text-3xl text-yellow-600",children:d==="open"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:d==="completed"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(st,{children:"Resignation Requests"}),e.jsxs(es,{children:["Track and manage dealer resignation requests",e.jsx("span",{className:"block mt-1 text-slate-500",children:"• Note: Resignation requests are initiated by the dealer or via ASM."})]})]})})}),e.jsx(Oe,{children:e.jsxs(In,{value:d,onValueChange:u,className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"all",children:"All Requests"}),e.jsx(Ht,{value:"open",children:"Open"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4 text-center py-1",children:r?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):s.length>0?e.jsxs(e.Fragment,{children:[s.map(b=>{var C,S,D,_,A,E,q,O,R,P,L;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-red-50 rounded-lg",children:e.jsx(ks,{className:"w-6 h-6 text-re-red"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(we,{className:Vg(b.status),children:b.status}),e.jsx(br,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=b.outlet)==null?void 0:D.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((E=(A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.dealerCode)==null?void 0:E.dealerCode)||((q=b.outlet)==null?void 0:q.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((R=(O=b.dealer)==null?void 0:O.dealerProfile)==null?void 0:R.registeredAddress)||((P=b.outlet)!=null&&P.city&&((L=b.outlet)!=null&&L.state)?`${b.outlet.city}, ${b.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:b.resignationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate max-w-[200px]",children:b.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(er,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:Qt(b.submittedOn)})]})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}),f&&f.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>o(b=>Math.max(1,b-1)),className:i===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(f.totalPages)].map((b,C)=>{const S=C+1;return S===1||S===f.totalPages||S>=i-1&&S<=i+1?e.jsx(pn,{children:e.jsx($i,{isActive:i===S,onClick:()=>o(S),className:"cursor-pointer",children:S})},S):S===2&&i>3||S===f.totalPages-1&&i<f.totalPages-2?e.jsx(pn,{children:e.jsx(go,{})},S):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>o(b=>Math.min(f.totalPages,b+1)),className:i===f.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No resignation requests found"})})})}),e.jsx(Vt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:N.length>0?N.map(b=>{var C,S,D,_,A,E,q;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-yellow-100 rounded-lg",children:e.jsx(ks,{className:"w-6 h-6 text-yellow-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(we,{className:Vg(b.status),children:b.status}),e.jsx(br,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=b.outlet)==null?void 0:D.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.registeredAddress)||((E=b.outlet)!=null&&E.city&&((q=b.outlet)!=null&&q.state)?`${b.outlet.city}, ${b.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(b.submittedOn)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ks,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:v.length>0?v.map(b=>{var C,S,D,_,A,E;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(ks,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:b.resignationId}),e.jsx(we,{className:Vg(b.status),children:b.status}),e.jsx(br,{status:j("resignation",b.id),compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((S=(C=b.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=b.outlet)==null?void 0:D.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((A=(_=b.dealer)==null?void 0:_.dealerProfile)==null?void 0:A.registeredAddress)||((E=b.outlet)==null?void 0:E.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Final Stage"}),e.jsx("p",{children:b.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(b.submittedOn)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(b.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},b.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ks,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed resignations to display"})]})})})]})})]})]})}const Ri="Last Working Day",ES="Proposed Last Working Day",Vc={AWAITING_FNF:"Awaiting F&F",AWAITING_FNF_LWD_PENDING:"Awaiting F&F (LWD Pending)"},Ei=lr.inProgress;function lj(t){if(!t)return"Pending";let s=t;return s=s.replace(/Personal Hearing/gi,"SCN Response Evaluation"),s=s.replace(/\(LWD Pending\)/gi,"(Last Working Day Pending)"),s=s.replace(/\bLWD\b/g,Ri),s}const oV=t=>{switch(t){case"Critical":return"bg-red-100 text-red-700 border-red-300";case"High":return"bg-orange-100 text-orange-700 border-orange-300";case"Medium":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Low":return"bg-blue-100 text-blue-700 border-blue-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},Hg=t=>t.includes("Approved")||t.includes("Terminated")?"bg-green-100 text-green-700 border-green-300":t.includes("Review")||t.includes("Pending")?"bg-yellow-100 text-yellow-700 border-yellow-300":t.includes("Rejected")?"bg-red-100 text-red-700 border-red-300":"bg-blue-100 text-blue-700 border-blue-300",iu=lj;function cV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState(!1),[a,i]=g.useState([]),[o,d]=g.useState(""),[m,f]=g.useState(!1),[p,h]=g.useState(""),[x,u]=g.useState(null),[N,v]=g.useState([]),[w,j]=g.useState({}),[b,C]=g.useState(!0),[S,D]=g.useState(1),[_,A]=g.useState(null),[E,q]=g.useState("all"),O=10,[R,P]=g.useState({terminationCategory:"",reason:"",proposedLwd:"",comments:"",document:null}),L=async()=>{C(!0);try{const K=(await Re.getTerminations({page:S,limit:O,status:E==="all"?void 0:E})).data;if(K!=null&&K.success){v(K.terminations),A(K.meta);const G=K.terminations||[];G.length?Yl.getBatchStatus(G.map(V=>({entityType:"termination",entityId:V.id}))).then(V=>{if(V!=null&&V.success){const Y={};G.forEach(re=>{Y[re.id]=V.data[`termination:${re.id}`]??null}),j(Y)}}).catch(()=>j({})):j({})}}catch(I){console.error("Error fetching terminations:",I),J.error("Failed to fetch termination requests")}finally{C(!1)}};g.useEffect(()=>{L()},[S,E]);const $=I=>{q(I),D(1)};g.useEffect(()=>{if(!n||!z)return;let I=!1;return(async()=>{try{f(!0);const G=(await Re.getDealers({onboarded:"true",activeOnly:"true"})).data;if(!I&&(G!=null&&G.success)){const V=(Array.isArray(G.data)?G.data:[]).filter(Y=>{var ue,ye;const re=String((Y==null?void 0:Y.status)||"").toLowerCase(),ae=String(((ue=Y==null?void 0:Y.user)==null?void 0:ue.status)||"").toLowerCase();return re==="active"&&((ye=Y==null?void 0:Y.user)==null?void 0:ye.isActive)&&ae==="active"});i(V)}}catch(K){I||(console.error("Error fetching dealers:",K),J.error("Failed to load dealer list"))}finally{I||f(!1)}})(),()=>{I=!0}},[n]);const Z=I=>{var K,G,V,Y,re,ae;return{id:I.id,dealerId:I.id,dealerCode:((K=I.dealerCode)==null?void 0:K.dealerCode)||"",legalName:I.legalName||"N/A",businessName:I.businessName||"N/A",gstNumber:I.gstNumber||"N/A",address:I.registeredAddress||((G=I.application)==null?void 0:G.preferredLocation)||"N/A",city:((V=I.application)==null?void 0:V.city)||"N/A",state:((Y=I.application)==null?void 0:Y.state)||"N/A",email:((re=I.user)==null?void 0:re.email)||"N/A",phoneNumber:((ae=I.user)==null?void 0:ae.mobileNumber)||"N/A"}},Q=I=>{d(I);const K=a.find(V=>String(V.id)===String(I));if(!K){h(""),u(null);return}const G=Z(K);h(G.dealerCode),u(G)},W=I=>{h(I);const K=I.trim().toLowerCase();if(!K){d(""),u(null);return}const G=a.find(V=>{var Y;return String(((Y=V.dealerCode)==null?void 0:Y.dealerCode)||"").toLowerCase()===K});if(!G){d(""),u(null);return}d(String(G.id)),u(Z(G))},U=async I=>{var K,G,V;if(I.preventDefault(),!x){J.error("Please select a dealer");return}try{const Y={dealerId:x.dealerId||x.id,category:R.terminationCategory,reason:R.reason,proposedLwd:R.proposedLwd,comments:R.comments};if(!Y.dealerId){J.error("Dealer record not found for the selected dealer");return}const ae=(await Re.createTermination(Y)).data;if(ae!=null&&ae.success){const ue=(K=ae.termination)==null?void 0:K.id;if(ue&&R.document){const ye=new FormData;ye.append("file",R.document),ye.append("documentType","Termination Recommendation"),ye.append("stage","Submitted");try{await Re.uploadTerminationDocument(ue,ye),J.success("Termination request and supporting document submitted")}catch(ce){console.error("Error uploading supporting document:",ce),J.warning("Termination created, but document upload failed. You can upload it from the details page.")}}else J.success("Termination request submitted successfully");r(!1),L(),d(""),h(""),i([]),u(null),P({terminationCategory:"",reason:"",proposedLwd:"",comments:"",document:null})}}catch(Y){console.error("Error submitting termination:",Y),J.error(((V=(G=Y.response)==null?void 0:G.data)==null?void 0:V.message)||"Failed to submit termination request")}},M=["DD Lead","ASM","DD Admin","DD AM","Super Admin"],z=(t==null?void 0:t.role)&&M.includes(t.role),T=E==="open"||E==="all"?N:[],F=E==="completed"||E==="all"?N:[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"All Cases"}),e.jsx(st,{className:"text-3xl",children:(_==null?void 0:_.total)||0})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Cases"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Open"}),e.jsx(st,{className:"text-3xl text-orange-600",children:E==="open"?(_==null?void 0:_.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:E==="completed"?(_==null?void 0:_.total)||0:"..."})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Termination Requests"}),e.jsx(es,{children:"Manage dealer termination proceedings and legal compliance"})]}),z&&e.jsxs(ms,{open:n,onOpenChange:r,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{className:"bg-red-600 hover:bg-red-700",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Create Termination Request"]})}),e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Create Termination Request"}),e.jsx(ws,{children:"Fill in the details to create a new termination request"})]}),e.jsxs("form",{onSubmit:U,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Select Dealer *"}),e.jsxs(Rt,{value:o,onValueChange:Q,disabled:m,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:m?"Loading dealers...":"Select dealer"})}),e.jsx(Tt,{children:a.map(I=>{var K;return e.jsxs(Pe,{value:String(I.id),children:[I.legalName||I.businessName||"Unnamed Dealer"," - ",((K=I.dealerCode)==null?void 0:K.dealerCode)||"No Code"]},I.id)})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"dealerCode",children:"Dealer Code *"}),e.jsx(it,{id:"dealerCode",value:p,onChange:I=>W(I.target.value),placeholder:"Type dealer code to auto-select",required:!0})]}),x&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name (Legal)"}),e.jsx("p",{children:x.legalName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Business Name"}),e.jsx("p",{children:x.businessName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:x.gstNumber||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:x.address})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"City/State"}),e.jsxs("p",{children:[x.city,", ",x.state]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:x.dealerCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Contact"}),e.jsxs("p",{children:[x.email," / ",x.phoneNumber]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Termination Category *"}),e.jsxs(Rt,{value:R.terminationCategory,onValueChange:I=>P({...R,terminationCategory:I}),children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select termination category"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Working Capital",children:"Working Capital"}),e.jsx(Pe,{value:"Performance Issues",children:"Performance Issues"}),e.jsx(Pe,{value:"Unethical Practice",children:"Unethical Practice"}),e.jsx(Pe,{value:"Unforeseen Circumstances",children:"Unforeseen Circumstances"}),e.jsx(Pe,{value:"Others",children:"Others"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(le,{children:[ES," *"]}),e.jsx(it,{type:"date",value:R.proposedLwd,onChange:I=>P({...R,proposedLwd:I.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Termination Reason *"}),e.jsx(it,{id:"reason",value:R.reason,onChange:I=>P({...R,reason:I.target.value}),placeholder:"Primary reason for termination",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"comments",children:"Additional Comments *"}),e.jsx(Ks,{id:"comments",value:R.comments,onChange:I=>P({...R,comments:I.target.value}),placeholder:"Detailed observations and justification",rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"document",children:"Upload Supporting Document"}),e.jsx(it,{id:"document",type:"file",onChange:I=>{var K;return P({...R,document:((K=I.target.files)==null?void 0:K[0])||null})}})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-red-600 hover:bg-red-700",children:"Submit Request"})]})]})]})]})]})}),e.jsxs(Oe,{children:[e.jsxs(In,{value:E,onValueChange:$,className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"all",children:"All Cases"}),e.jsx(Ht,{value:"open",children:"Open"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:b?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):N.length>0?N.map(I=>{var K,G,V,Y;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-red-100 rounded-lg",children:e.jsx(ai,{className:"w-6 h-6 text-red-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold",children:I.requestId||((G=(K=I.dealer)==null?void 0:K.dealerCode)==null?void 0:G.code)||"N/A"}),e.jsx(we,{className:oV(I.severity||"Medium"),children:I.severity||"Normal"}),e.jsx(we,{className:Hg(I.status),children:iu(I.status)}),e.jsx(br,{status:w[I.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((V=I.dealer)==null?void 0:V.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((Y=I.dealer)==null?void 0:Y.registeredAddress)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Category"}),e.jsx("p",{children:I.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:iu(I.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:ES}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(er,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:I.proposedLwd})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(I.createdAt)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(I.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},I.id)}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No termination requests found"})})})}),e.jsx(Vt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:T.length>0?T.map(I=>{var K,G,V;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-orange-100 rounded-lg",children:e.jsx(Ba,{className:"w-6 h-6 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold",children:I.requestId||((G=(K=I.dealer)==null?void 0:K.dealerCode)==null?void 0:G.code)||"N/A"}),e.jsx(we,{className:Hg(I.status),children:iu(I.status)}),e.jsx(br,{status:w[I.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(V=I.dealer)==null?void 0:V.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate",children:I.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:iu(I.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(I.createdAt)})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(I.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},I.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ai,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:F.length>0?F.map(I=>{var K,G,V;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(ai,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold",children:I.requestId||((G=(K=I.dealer)==null?void 0:K.dealerCode)==null?void 0:G.code)||"N/A"}),e.jsx(we,{className:Hg(I.status),children:iu(I.status)}),e.jsx(br,{status:w[I.id],compact:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:(V=I.dealer)==null?void 0:V.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Closed On"}),e.jsx("p",{children:Qt(I.updatedAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{children:I.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:Ri}),e.jsx("p",{children:I.proposedLwd})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(I.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},I.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ai,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed terminations to display"})]})})})]}),_&&_.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>D(I=>Math.max(1,I-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(_.totalPages)].map((I,K)=>{const G=K+1;return G===1||G===_.totalPages||G>=S-1&&G<=S+1?e.jsx(pn,{children:e.jsx($i,{isActive:S===G,onClick:()=>D(G),className:"cursor-pointer",children:G})},G):G===2&&S>3||G===_.totalPages-1&&S<_.totalPages-2?e.jsx(pn,{children:e.jsx(go,{})},G):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>D(I=>Math.min(_.totalPages,I+1)),className:S===_.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const lu=t=>{switch(t){case"Initiated":return"bg-blue-100 text-blue-700 border-blue-300";case"DD Clearance":case"Legal Clearance":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Finance Approval":case"Calculated":return"bg-orange-100 text-orange-700 border-orange-300";case"Completed":case"Settled":return"bg-green-100 text-green-700 border-green-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},ou=t=>t==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300";function dV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,i]=g.useState(!0);g.useEffect(()=>{o()},[]);const o=async()=>{try{i(!0);const N=(await Re.getFnFSettlements()).data;N.success&&r(N.settlements||[])}catch(u){console.error("Fetch settlements error:",u),J.error("Failed to fetch settlement cases")}finally{i(!1)}};if(a)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-blue-600"})});const d=u=>{var N,v,w,j,b,C,S,D,_,A,E,q,O,R,P,L;return{id:u.id,caseNumber:u.settlementId||((N=u.resignation)==null?void 0:N.resignationId)||((v=u.terminationRequest)==null?void 0:v.requestId)||u.id.substring(0,8).toUpperCase(),status:u.status,requestType:u.resignationId?"Resignation":"Termination",dealerName:((j=(w=u.outlet)==null?void 0:w.dealer)==null?void 0:j.fullName)||((b=u.dealer)==null?void 0:b.legalName)||((C=u.dealer)==null?void 0:C.businessName)||((S=u.dealer)==null?void 0:S.fullName)||"N/A",dealerCode:((D=u.outlet)==null?void 0:D.code)||((A=(_=u.dealer)==null?void 0:_.dealerCode)==null?void 0:A.dealerCode)||"N/A",dealershipName:((E=u.outlet)==null?void 0:E.name)||"N/A",location:((q=u.outlet)==null?void 0:q.city)||((O=u.outlet)==null?void 0:O.location)||"N/A",originalRequestId:((R=u.resignation)==null?void 0:R.resignationId)||((P=u.terminationRequest)==null?void 0:P.requestId)||((L=u.terminationRequest)==null?void 0:L.id)||"N/A",submittedOn:Qt(u.createdAt),financeReportStatus:u.status==="Calculated"||u.status==="Settled"?"Completed":"Pending",totalRecoveryAmount:parseFloat(u.totalReceivables)||0,totalPayableAmount:parseFloat(u.totalPayables)||0,completedOn:u.settlementDate?Qt(u.settlementDate):null,departmentResponses:u.lineItems||[]}},m=n.map(d),f=m.filter(u=>u.status==="Initiated"),p=m.filter(u=>u.status==="DD Clearance"||u.status==="Legal Clearance"),h=m.filter(u=>u.status==="Finance Approval"||u.status==="Calculated"),x=m.filter(u=>u.status==="Completed"||u.status==="Settled");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Initiated"}),e.jsx(st,{className:"text-3xl text-blue-600",children:f.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Newly created"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Clearance"}),e.jsx(st,{className:"text-3xl text-yellow-600",children:p.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Department / legal stage"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Finance Approval"}),e.jsx(st,{className:"text-3xl text-orange-600",children:h.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Ready for finance review"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"Completed"}),e.jsx(st,{className:"text-3xl text-green-600",children:m.filter(u=>u.status==="Completed"||u.status==="Settled").length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsx(es,{children:"All Cases"}),e.jsx(st,{className:"text-3xl",children:m.length})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-slate-600",children:"Total"})})]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Full & Final Settlement Cases"}),e.jsxs(es,{children:["Manage dealer exit dues clearance and settlement",t&&` • Current Role: ${t.role}`]})]}),e.jsx(Oe,{children:e.jsxs(In,{defaultValue:"all",className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"all",children:"All Cases"}),e.jsx(Ht,{value:"initiated",children:"Initiated"}),e.jsx(Ht,{value:"clearance",children:"Clearance"}),e.jsx(Ht,{value:"finance",children:"Finance Approval"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"initiated",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[f.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:e.jsx(hu,{className:"w-6 h-6 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:u.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:u.dealershipName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:u.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:u.originalRequestId})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(er,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:u.submittedOn})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Finance Report"}),e.jsx("p",{children:u.financeReportStatus})]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id)),f.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(hu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No initiated cases to display"})]})]})}),e.jsx(Vt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:m.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:`p-3 rounded-lg ${u.status==="Initiated"?"bg-blue-100":u.status==="DD Clearance"||u.status==="Legal Clearance"?"bg-yellow-100":u.status==="Finance Approval"||u.status==="Calculated"?"bg-orange-100":"bg-green-100"}`,children:e.jsx(ya,{className:`w-6 h-6 ${u.status==="Initiated"?"text-blue-600":u.status==="DD Clearance"||u.status==="Legal Clearance"?"text-yellow-600":u.status==="Finance Approval"||u.status==="Calculated"?"text-orange-600":"text-green-600"}`})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:u.dealershipName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:u.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4",children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id))})}),e.jsx(Vt,{value:"clearance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[p.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-yellow-100 rounded-lg",children:e.jsx(ya,{className:"w-6 h-6 text-yellow-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Departments Responded"}),e.jsxs("p",{children:[u.departmentResponses.filter(N=>N.status!=="Pending").length," / ",u.departmentResponses.length]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)),p.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ya,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No clearance-stage cases"})]})]})}),e.jsx(Vt,{value:"finance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[h.map(u=>{var N,v;return e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-orange-100 rounded-lg",children:e.jsx(ya,{className:"w-6 h-6 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Receivable amount"}),e.jsxs("p",{className:"text-red-600",children:["₹",(N=u.totalRecoveryAmount)==null?void 0:N.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Payable Amount"}),e.jsxs("p",{className:"text-green-600",children:["₹",(v=u.totalPayableAmount)==null?void 0:v.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Finance Status"}),e.jsx("p",{children:u.financeReportStatus})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)}),h.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(ya,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No finance-approval cases"})]})]})}),e.jsx(Vt,{value:"completed",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[x.map(u=>e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:e.jsx(hu,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:"text-lg",children:u.caseNumber}),e.jsx(we,{className:lu(u.status),children:u.status}),e.jsx(we,{className:ou(u.requestType),children:u.requestType})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:u.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Completed On"}),e.jsx("p",{children:u.completedOn||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:u.submittedOn})]})]})]})]}),e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(un,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},u.id)),x.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(hu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed cases"})]})]})})]})})]})]})}const Jo={getResignations:async()=>{try{return(await Re.getResignations()).data}catch(t){throw console.error("Get resignations error:",t),t}},createResignation:async t=>{try{return(await Re.createResignation(t)).data}catch(s){throw console.error("Create resignation error:",s),s}},getResignationById:async t=>{var s,n;try{const r=await Re.getResignationById(t);return((s=r.data)==null?void 0:s.resignation)||((n=r.data)==null?void 0:n.data)||r.data}catch(r){throw console.error("Get resignation error:",r),r}},updateClearance:async(t,s)=>{try{return(await Re.updateClearance(t,s)).data}catch(n){throw console.error("Update clearance error:",n),n}},uploadDocument:async(t,s)=>{try{return(await Re.uploadResignationDocument(t,s)).data}catch(n){throw console.error("Upload resignation document error:",n),n}},withdraw:async(t,s)=>{try{return(await Re.withdrawResignation(t,s)).data}catch(n){throw console.error("Withdraw resignation error:",n),n}}},Wg=["Resignation Letter","Dealer Undertaking","Approval Note","Resignation Acceptance Letter","Handover Document","Settlement Supporting Document","PPT Presentation","Other"],uV=["Request Submitted","ASM","RBM","ZBH","DD Lead","NBH","DD Admin","Legal","F&F Initiated"],Gg=["Termination Recommendation","Show Cause Notice","SCN Response","Hearing Record","Approval Note","Termination Letter","Settlement Supporting Document","Other"],hV=["Submitted","RBM + DD-ZM Review","ZBH Review","DD Lead Review","Legal Verification","NBH Evaluation","Show Cause Notice","Personal Hearing","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter"],mV={ASM:"ASM",RBM:"RBM",ZBH:"ZBH","DD Lead":"DD Lead",NBH:"NBH","DD Admin":"DD Admin",Legal:"Legal Admin"},_S=["REJECTED","Rejected","REVOKED","Revoked","WITHDRAWN","Withdrawn"],Kg={"Request Submitted":["Submission","Submitted","Initiation"],ASM:["ASM","ASM Review"],RBM:["RBM","RBM Review","Regional Review","RBM + DD-ZM Review"],ZBH:["ZBH","ZBH Review","ZM Review"],"DD Lead":["DD Lead","DD Lead Review","DDL Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],"Awaiting F&F":["Awaiting F&F","Awaiting F&F — manual initiation"],Legal:["Legal","Legal - Resignation Letter"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","FNF Initiated"],Completed:["Completed"]};function fV({resignationId:t,onBack:s,currentUser:n}){var Be,rt,ht,ge,Je,mt,de,at,ot,ke,Zt,Bt,_s,Us,fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se;const{get:r}=mc(t?[{entityType:"resignation",entityId:t}]:[],!!t),a=(be,pt)=>{const Ve=[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]],bt=[be,pt,...pt?Kg[pt]||[]:[],...Kg[be]||[]].filter(gt=>!!gt).map(gt=>gt.trim().toLowerCase());return Ve.filter(gt=>{if(!(gt!=null&>.stage))return!1;const rs=String(gt.stage).trim().toLowerCase();return bt.includes(rs)})},i=tr(),[o,d]=g.useState({open:!1,type:null}),[m,f]=g.useState(""),[p,h]=g.useState(""),[x,u]=g.useState(""),[N,v]=g.useState(""),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,D]=g.useState(!1),[_,A]=g.useState({open:!1,stageName:"",documents:[]}),[E,q]=g.useState(null),[O,R]=g.useState(!1),[P,L]=g.useState([]),[$,Z]=g.useState(!1),[Q,W]=g.useState(null),[U,M]=g.useState(!1),[z,T]=g.useState(null),[F,I]=g.useState(Wg[0]),[K,G]=g.useState(""),V=g.useMemo(()=>[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]].some(pt=>(pt.documentType||pt.type)==="PPT Presentation"),[E]),Y=async()=>{try{R(!0);const be=await Jo.getResignationById(t);q(be),re()}catch(be){console.error("Error fetching resignation:",be)}finally{R(!1)}},re=async()=>{try{const be=await Re.getAuditLogs("resignation",t);be.data&&be.data.success&&L(be.data.data||[])}catch(be){console.error("Error fetching audit logs:",be)}};g.useEffect(()=>{Y()},[t]);const ae=[{id:1,name:"Request Submitted",key:"Request Submitted",description:"Dealer submitted the resignation request"},{id:2,name:"ASM Review",key:"ASM",description:"Area Sales Manager review"},{id:3,name:"RBM + DD-ZM Review",key:"RBM",description:"Joint approval by Regional Business Manager and DD-ZM"},{id:4,name:"ZBH Review",key:"ZBH",description:"Zonal Business Head approval"},{id:5,name:"DD Lead Review",key:"DD Lead",description:"DD Lead final review"},{id:6,name:"NBH Approval",key:"NBH",description:"National Business Head approval"},{id:7,name:"Legal - Resignation Letter",key:"Legal",description:"Legal team issues resignation approval letter"},{id:8,name:"DD Admin Review",key:"DD Admin",description:"DD Admin verification and final closure"},{id:9,name:"Awaiting F&F",key:"Awaiting F&F",description:"Internal review complete — start Full & Final using Push to F&F when ready"},{id:10,name:"F&F Settlement",key:"F&F Initiated",description:"Full & Final settlement process"},{id:11,name:"Completed",key:"Completed",description:"Resignation process finalized"}],ue=["Request Submitted","ASM","RBM","ZBH","DD Lead","NBH","Legal","DD Admin","Awaiting F&F","F&F Initiated","Completed"],ye=E?["F&F Initiated","Completed","Settled","FNF_INITIATED"].includes(String(E.status||E.currentStage||""))?!0:(Array.isArray(E.timeline)?E.timeline:[]).some(Ve=>{const bt=String((Ve==null?void 0:Ve.stage)||"").trim().toLowerCase(),gt=String((Ve==null?void 0:Ve.targetStage)||"").trim().toLowerCase(),rs=String((Ve==null?void 0:Ve.action)||"").trim().toLowerCase(),is=bt==="legal"||bt==="legal - resignation letter",Ts=gt==="legal"||gt==="dd admin"||gt==="awaiting f&f"||gt==="f&f initiated"||gt==="fnf_initiated"||rs.includes("approved");return is&&Ts}):!1,je=(()=>{if(!E||!n)return{canApprove:!1,canWithdraw:!1,canSendBack:!1,canPushToFnF:!1,canAssign:!1};const be=E.currentStage,pt=E.status,Ve=n.role,bt=be==="RBM"||be==="RBM Review"||be==="RBM + DD-ZM Review",gt=String(n.roleCode||n.role||"").trim().toUpperCase(),rs=bt&&P.some(Ds=>{var ts,js,tn,vn;return Ds.action==="PARTIAL_APPROVE"&&(((ts=Ds.actor)==null?void 0:ts.id)===n.id||Ds.actorId===n.id||((js=Ds.actor)==null?void 0:js.email)===n.email||Ds.userEmail===n.email)&&(((tn=Ds.details)==null?void 0:tn.roleCode)===gt||((vn=Ds.details)==null?void 0:vn.roleCode)==="DD-ZM"&>==="DD ZM")}),is=["Completed","Rejected","Withdrawn","Revoked"].includes(pt),Ts=pt==="F&F Initiated"||be==="F&F Initiated"||pt==="Settled"||pt==="FNF_INITIATED",Ws=ue.indexOf(be),nn=ue.indexOf("NBH"),Ee=Ws!==-1&&nn!==-1&&Ws>=nn,$t=gt==="SUPER_ADMIN"||bt&&(gt==="RBM"||gt==="DD-ZM"||gt==="DD ZM")||Ve===mV[be],Xt=be==="DD Lead"||be==="DD Lead Review",Cs=gt==="DD_LEAD"||gt==="DD LEAD",Mt=(()=>{const Ds=new Date;Ds.setHours(0,0,0,0);const ts=E.lastOperationalDateServices||E.lastOperationalDateSales;if(!ts)return!0;const js=new Date(ts);return js.setHours(0,0,0,0),Ds>=js})(),ze=be==="Awaiting F&F",xt=(()=>{const Ds=String(be||"").trim();return ue.find(js=>js===Ds||(Kg[js]||[]).includes(Ds))||Ds})(),yt=xt==="NBH",Ot=xt==="Awaiting F&F",Pt=xt==="Legal",Jt=["DD Lead","DD Head","DD Admin","Super Admin"],bs=["DD Lead","DD Head","DD Admin","Super Admin"];return{canApprove:$t&&!is&&!Ts&&!rs&&!(be==="Legal"&&ye)&&!(Cs&&Xt&&!V)&&!(be==="DD Admin"&&!Mt)&&!ze,canSendBack:$t&&!is&&!Ts&&Ws>0&&Ve!=="Legal Admin"&>!=="LEGAL_ADMIN",canWithdraw:Ve==="Dealer"&&!Ee&&!is,canRevoke:(gt==="SUPER_ADMIN"||Ve==="DD Admin")&&!is&&!Ts,canPushToFnF:Jt.includes(Ve)&&!Ts&&!is&&!yt&&Mt&&(Ot||Pt&&bs.includes(Ve)),canAssign:Ve!=="Dealer"&&!is}})(),Me=["Super Admin","DD Lead","DD Head","NBH","DD Admin","Legal Admin","DD-ZM"].includes((n==null?void 0:n.role)||""),ut={ASM:["ASM","ASM Review","Request Initiated"],RBM:["RBM","RBM Review","RBM + DD-ZM Review"],ZBH:["ZBH","ZBH Review"],"DD Lead":["DD Lead","DD Lead Review","Lead Review"],NBH:["NBH","NBH Approval","NBH Review"],"DD Admin":["DD Admin","DD Admin Review"],"Awaiting F&F":["Awaiting F&F","Awaiting F&F — manual initiation"],Legal:["Legal","Legal - Resignation Letter","Legal Review"],"F&F Initiated":["F&F Initiated","FNF_INITIATED","F&F Settlement","Settled"],Completed:["Completed","Finalized"]},jt=be=>{if(!be)return"";const pt=String(be).trim();return ue.find(bt=>bt===pt||(ut[bt]||[]).includes(pt))||pt},ft=be=>{if(!E)return"pending";const pt=["Rejected","Revoked","Withdrawn"].includes(E.status);let Ve=E.currentStage;if(pt&&(!Ve||_S.includes(String(Ve)))){const is=[...E.timeline||[]].reverse().find(Ts=>(Ts==null?void 0:Ts.stage)&&!_S.includes(String(Ts.stage)));is!=null&&is.stage&&(Ve=is.stage)}const bt=ue.indexOf(jt(Ve)),gt=ue.indexOf(be);if((E.status==="Completed"||E.status==="Settled")&><=bt)return"completed";const rs=["Rejected","Revoked","Withdrawn"].includes(E.status);return be==="Legal"&&ye&&!rs?"completed":bt===-1?be==="ASM"?"completed":"pending":gt<bt?"completed":gt===bt?pt?"completed":"active":"pending"},X=be=>{d({open:!0,type:be})},Ce=(be,pt)=>{const Ve=a(be,pt).map((bt,gt)=>{var rs;return{id:bt.id||`${be}-${gt}`,name:bt.name||bt.fileName||"Document",type:bt.type||bt.documentType||"Document",uploadDate:bt.uploadDate||(bt.createdAt?Qt(bt.createdAt):"N/A"),uploader:typeof bt.uploader=="string"?bt.uploader:((rs=bt.uploader)==null?void 0:rs.fullName)||bt.uploadedBy||"System",filePath:bt.filePath||bt.path}});A({open:!0,stageName:be,documents:Ve})},xe=async()=>{var be,pt,Ve,bt,gt,rs,is,Ts;if(!m&&!["assign","pushfnf"].includes(o.type||"")){J.error("Please provide remarks (min 5 characters)");return}if(["sendBack","revoke"].includes(o.type||"")&&m.trim().length<5){J.error("Remarks are required for this action (min 5 characters).");return}if(o.type==="assign"&&!p){J.error("Please select a designation");return}try{Z(!0);const nn={action:o.type==="sendBack"?"sendBack":o.type,remarks:m,assignTo:N||p,force:S},Ee=await Re.updateResignationStatus(t,nn);if((be=Ee.data)!=null&&be.success)J.success(((pt=Ee.data)==null?void 0:pt.message)||"Action completed successfully"),d({open:!1,type:null}),f(""),h(""),v(""),j([]),D(!1),Y();else{const $t=((Ve=Ee.data)==null?void 0:Ve.message)||"Failed to submit action";J.error($t),(bt=Ee.data)!=null&&bt.canForce&&J.info(`${Ri} restriction: use "Push to F&F" and enable "Force Initiate F&F Settlement Immediately" if urgent.`)}}catch(Ws){console.error("Error submitting action:",Ws),J.error(((rs=(gt=Ws.response)==null?void 0:gt.data)==null?void 0:rs.message)||"Failed to submit action"),(Ts=(is=Ws==null?void 0:Ws.response)==null?void 0:is.data)!=null&&Ts.canForce&&J.info(`${Ri} restriction: use "Push to F&F" with the force option if business-approved.`)}finally{Z(!1)}},We=async()=>{var be,pt;if(!z){J.error("Please select a file to upload");return}try{Z(!0);const Ve=new FormData;Ve.append("file",z),Ve.append("documentType",F),K&&Ve.append("stage",K),await Jo.uploadDocument(t,Ve),J.success("Document uploaded successfully"),M(!1),T(null),I(Wg[0]),G(""),Y()}catch(Ve){J.error(((pt=(be=Ve==null?void 0:Ve.response)==null?void 0:be.data)==null?void 0:pt.message)||"Failed to upload document")}finally{Z(!1)}};return g.useEffect(()=>{(async()=>{if(o.type==="assign"&&(p||x)){const pt=setTimeout(async()=>{var Ve;try{C(!0);const bt={asm:"ASM",rbm:"RBM",zbh:"ZBH",nbh:"NBH",legal:"Legal Admin"},gt={limit:20,search:x};p&&(gt.roleCode=bt[p]||p);const rs=await Re.getUsers(gt);(Ve=rs.data)!=null&&Ve.success&&j(rs.data.data)}catch(bt){console.error("Error fetching users:",bt)}finally{C(!1)}},300);return()=>clearTimeout(pt)}})()},[p,x,o.type]),O&&!E?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:(E==null?void 0:E.resignationId)||t}),e.jsx("p",{className:"text-slate-600",children:(Be=E==null?void 0:E.outlet)==null?void 0:Be.name})]}),e.jsx(we,{className:(E==null?void 0:E.status)==="Completed"||(E==null?void 0:E.status)==="Settled"?"bg-green-100 text-green-700 border-green-300":(E==null?void 0:E.status)==="Rejected"||(E==null?void 0:E.status)==="Withdrawn"||(E==null?void 0:E.status)==="Revoked"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:(E==null?void 0:E.status)==="Settled"?"Completed":lj((E==null?void 0:E.status)||"Pending")}),e.jsx(br,{status:r("resignation",t)})]})}),e.jsxs(In,{defaultValue:"details",className:"w-full",children:[e.jsxs(Mn,{className:"bg-slate-100 p-1",children:[e.jsx(Ht,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(Ht,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(Ht,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(Ht,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"}),Me&&e.jsx(Ht,{value:"approvals",className:"data-[state=active]:bg-white",children:"Approval Summary"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Vt,{value:"details",className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Resignation Details"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Resignation Type"}),e.jsx("p",{children:E==null?void 0:E.resignationType})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Reason"}),e.jsx("p",{children:E==null?void 0:E.reason})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:E!=null&&E.lastOperationalDateSales?Qt(E.lastOperationalDateSales,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:E!=null&&E.lastOperationalDateServices?Qt(E.lastOperationalDateServices,"date"):"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Additional Info / Dealer Voice"}),e.jsx("p",{children:(E==null?void 0:E.additionalInfo)||"No additional info provided"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:E!=null&&E.submittedOn?Qt(E.submittedOn):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:E==null?void 0:E.currentStage})]})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Request Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((rt=E==null?void 0:E.dealer)==null?void 0:rt.fullName)||((ht=E==null?void 0:E.outlet)==null?void 0:ht.name)})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((Je=(ge=E==null?void 0:E.dealer)==null?void 0:ge.dealerProfile)==null?void 0:Je.gstNumber)||((mt=E==null?void 0:E.outlet)==null?void 0:mt.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((de=E==null?void 0:E.dealer)==null?void 0:de.email)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((ke=(ot=(at=E==null?void 0:E.dealer)==null?void 0:at.dealerProfile)==null?void 0:ot.dealerCode)==null?void 0:ke.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((_s=(Bt=(Zt=E==null?void 0:E.dealer)==null?void 0:Zt.dealerProfile)==null?void 0:Bt.dealerCode)==null?void 0:_s.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((Vs=(fs=(Us=E==null?void 0:E.dealer)==null?void 0:Us.dealerProfile)==null?void 0:fs.dealerCode)==null?void 0:Vs.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((ie=(Xs=(Qs=E==null?void 0:E.dealer)==null?void 0:Qs.dealerProfile)==null?void 0:Xs.dealerCode)==null?void 0:ie.gearCode)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((fe=(nt=E==null?void 0:E.dealer)==null?void 0:nt.dealerProfile)==null?void 0:fe.registeredAddress)||((Ae=E==null?void 0:E.outlet)==null?void 0:Ae.address)})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Operational Details"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(Ke=(Fe=E==null?void 0:E.dealer)==null?void 0:Fe.dealerProfile)!=null&&Ke.onboardedAt?Qt(E.dealer.dealerProfile.onboardedAt,"date"):(Le=E==null?void 0:E.outlet)!=null&&Le.inaugurationDate?Qt(E.outlet.inaugurationDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(et=(Ue=E==null?void 0:E.dealer)==null?void 0:Ue.dealerProfile)!=null&&et.loaDate?Qt(E.dealer.dealerProfile.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(ss=(dt=E==null?void 0:E.dealer)==null?void 0:dt.dealerProfile)!=null&&ss.loiDate?Qt(E.dealer.dealerProfile.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((wt=(kt=(Wt=E==null?void 0:E.dealer)==null?void 0:Wt.dealerProfile)==null?void 0:kt.application)==null?void 0:wt.businessType)||((Os=E==null?void 0:E.outlet)==null?void 0:Os.type)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"City Category"}),e.jsx("p",{children:((as=E==null?void 0:E.outlet)==null?void 0:as.cityCategory)||"N/A"})]})]})})]})]}),e.jsx(Vt,{value:"progress",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Progress Timeline"}),e.jsx(es,{children:"Track the resignation request approval process"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:ae.map((be,pt)=>{const Ve=ft(be.key),bt=a(be.name,be.key).length,gt=((E==null?void 0:E.timeline)||[]).filter(is=>is.stage===be.key||is.stage===be.name),rs=gt.length>0?gt[gt.length-1]:null;return e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${Ve==="completed"?"bg-green-100 text-green-600":Ve==="active"?"bg-blue-100 text-re-red":"bg-slate-100 text-slate-400"}`,children:Ve==="completed"?e.jsx($n,{className:"w-5 h-5"}):e.jsx("span",{children:be.id})}),pt<ae.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${Ve==="completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:Ve==="completed"?"text-green-600":Ve==="active"?"text-re-red":"text-slate-400",children:be.name}),bt>0&&e.jsxs("button",{onClick:()=>Ce(be.name,be.key),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-red-50 hover:bg-red-100 text-re-red-hover text-xs transition-colors cursor-pointer",children:[e.jsx(ks,{className:"w-3 h-3"}),e.jsxs("span",{children:[bt," ",bt===1?"doc":"docs"]})]})]}),rs&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-slate-600",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:Qt(rs.timestamp||rs.createdAt)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:be.description}),gt.length>0&&e.jsx("div",{className:"space-y-4 mt-3",children:gt.map((is,Ts)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:is.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:is.action}),e.jsx("span",{className:"text-[10px] text-slate-400 ml-auto",children:Qt(is.timestamp||is.createdAt)})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:is.comments||is.remarks||"No remarks provided."})]},Ts))})]})]},be.id)})})})]})}),e.jsx(Vt,{value:"documents",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Documents"}),e.jsx(es,{children:"View and manage resignation documents"})]}),e.jsxs(te,{size:"sm",onClick:()=>M(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:(()=>{var pt;const be=[...(E==null?void 0:E.documents)||[],...(E==null?void 0:E.uploadedDocuments)||[]];return E!=null&&E.departmentalClearances&&Object.entries(E.departmentalClearances).forEach(([Ve,bt])=>{bt.supportingDocument&&be.push({name:`${Ve} Clearance Proof`,type:"Clearance NOC",path:bt.supportingDocument,createdAt:bt.updatedAt,uploadedBy:bt.updatedBy||"Department Admin"})}),(pt=E==null?void 0:E.settlement)!=null&&pt.clearances&&E.settlement.clearances.forEach(Ve=>{Ve.supportingDocument&&be.push({name:`${Ve.department} Clearance NOC`,type:"Live NOC",path:Ve.supportingDocument,createdAt:Ve.clearedAt||Ve.updatedAt,uploadedBy:"Department Admin"})}),be.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):be.map((Ve,bt)=>{var gt;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Ve.name||Ve.fileName})]})}),e.jsx(oe,{children:Ve.documentType||Ve.type||"Document"}),e.jsx(oe,{children:Ve.createdAt?Qt(Ve.createdAt):"N/A"}),e.jsx(oe,{children:((gt=Ve.uploader)==null?void 0:gt.fullName)||Ve.uploadedBy||"Dealer"}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>{const rs=Ve.filePath||Ve.path,is=rs!=null&&rs.startsWith("/uploads/")&&!rs.startsWith("/uploads/documents/")?rs.replace("/uploads/","/uploads/documents/"):rs;W({fileName:Ve.fileName||Ve.name,filePath:is,documentType:Ve.documentType||Ve.type})},children:"View"})})]},bt)})})()})]})})]})}),e.jsx(Vt,{value:"audit",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Audit Trail"}),e.jsx(es,{children:"Complete history of actions on this resignation request"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:P.length>0?P.map((be,pt)=>{var Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt;return e.jsxs("div",{className:"flex gap-3 pb-6 border-b border-slate-100 last:border-0 relative",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-300 mt-2 z-10"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:`
|
||
${(be.description||be.action||((Ve=be.details)==null?void 0:Ve.action)||"").toLowerCase().includes("reject")||(be.description||be.action||((bt=be.details)==null?void 0:bt.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(be.description||be.action||((gt=be.details)==null?void 0:gt.action)||"").toLowerCase().includes("sent back")||(be.description||be.action||((rs=be.details)==null?void 0:rs.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(be.description||be.action||((is=be.details)==null?void 0:is.action)||"").toLowerCase().includes("approv")||(be.description||be.action||((Ts=be.details)==null?void 0:Ts.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
|
||
`,children:be.description||be.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Ws=be.actor)==null?void 0:Ws.name)||be.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Qt(be.timestamp||be.createdAt)})]}),(be.remarks||((nn=be.newData)==null?void 0:nn.remarks)||((Ee=be.details)==null?void 0:Ee.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:be.remarks||(($t=be.newData)==null?void 0:$t.remarks)||((Xt=be.details)==null?void 0:Xt.remarks)})]})]},pt)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})}),Me&&e.jsx(Vt,{value:"approvals",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Approval Summary"}),e.jsx(es,{children:"Comprehensive view of all approvals and remarks"})]}),je.canApprove&&e.jsxs(te,{onClick:()=>X("approve"),className:"bg-green-600 hover:bg-green-700",children:[e.jsx($n,{className:"w-4 h-4 mr-2"}),"Approve Request"]})]}),e.jsx(Oe,{children:e.jsxs(Ms,{className:"w-full border-collapse",children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50/50",children:[e.jsx(me,{className:"min-w-[120px]",children:"Stage"}),e.jsx(me,{className:"min-w-[120px]",children:"Approver"}),e.jsx(me,{className:"min-w-[200px]",children:"Action"}),e.jsx(me,{className:"w-full min-w-[300px]",children:"Remarks"}),e.jsx(me,{className:"min-w-[180px] text-right",children:"Date"})]})}),e.jsx(Bs,{children:((E==null?void 0:E.timeline)||[]).length>0?E.timeline.map((be,pt)=>e.jsxs(lt,{children:[e.jsx(oe,{className:"font-medium",children:be.stage}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:be.user||"System"})}),e.jsx(oe,{className:"whitespace-normal break-words",children:be.action}),e.jsx(oe,{className:"whitespace-normal break-words",children:be.remarks||be.comments||"-"}),e.jsx(oe,{className:"text-slate-500 whitespace-nowrap text-right",children:Qt(be.timestamp||be.createdAt)})]},pt)):e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-6 text-slate-500",children:"No approval records found"})})})]})})]})})]}),e.jsx("div",{className:"space-y-6",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[(()=>{const be=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").trim().toUpperCase(),pt=be==="DD LEAD"||be==="DD_LEAD",Ve=["DD Lead","DD Lead Review","DDL Review"].includes(E==null?void 0:E.currentStage);return pt&&Ve?e.jsxs(te,{variant:"outline",className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>{I("PPT Presentation"),G("DD Lead"),M(!0)},children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload PPT"]}):null})(),je.canApprove&&e.jsxs(te,{disabled:$,className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>X("approve"),children:[$&&o.type==="approve"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx($n,{className:"w-4 h-4 mr-2"}),"Approve"]}),je.canSendBack&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full font-bold",onClick:()=>X("sendBack"),children:[$&&o.type==="sendBack"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sb,{className:"w-4 h-4 mr-2"}),"Send Back"]}),je.canWithdraw&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full text-red-600 border-red-300 hover:bg-red-50 font-bold",onClick:()=>X("withdrawal"),children:[$&&o.type==="withdrawal"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(id,{className:"w-4 h-4 mr-2"}),"Withdrawal"]}),je.canRevoke&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full text-orange-600 border-orange-300 hover:bg-orange-50 font-bold",onClick:()=>X("revoke"),children:[$&&o.type==="revoke"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke"]}),je.canPushToFnF&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>X("pushfnf"),children:[$&&o.type==="pushfnf"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),je.canAssign&&e.jsxs(te,{variant:"outline",disabled:$,className:"w-full",onClick:()=>X("assign"),children:[$&&o.type==="assign"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(Xo,{}),e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>{var be;return i(`/worknotes/resignation/${t}`,{state:{applicationName:((be=E==null?void 0:E.outlet)==null?void 0:be.name)||"Resignation",registrationNumber:(E==null?void 0:E.resignationId)||"",participants:(E==null?void 0:E.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes",((Se=E==null?void 0:E.worknotes)==null?void 0:Se.length)>0&&e.jsx(we,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:E.worknotes.length})]})]})]})})]})]}),e.jsx(ms,{open:o.open,onOpenChange:be=>d({open:be,type:null}),children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[o.type==="approve"&&"Approve Resignation Request",o.type==="withdrawal"&&"Withdraw Resignation Request",o.type==="sendBack"&&"Send Back for Clarification",o.type==="revoke"&&"Revoke Resignation Request",o.type==="assign"&&"Assign to User",o.type==="pushfnf"&&"Push to Full & Final Settlement"]}),e.jsx(ws,{children:o.type==="assign"?"Select a user to assign this request to":o.type==="pushfnf"?"This will move the resignation request to F&F for dues clearance":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:o.type==="assign"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Designation Filter"}),e.jsxs(Rt,{value:p,onValueChange:be=>{h(be),v("")},children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"All Roles"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Roles"}),e.jsx(Pe,{value:"asm",children:"ASM"}),e.jsx(Pe,{value:"rbm",children:"RBM"}),e.jsx(Pe,{value:"zbh",children:"ZBH"}),e.jsx(Pe,{value:"nbh",children:"NBH"}),e.jsx(Pe,{value:"legal",children:"Legal"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Search Name/Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(it,{placeholder:"Search...",value:x,onChange:be=>u(be.target.value),className:"pr-8"}),b&&e.jsx(cs,{className:"w-4 h-4 animate-spin absolute right-2 top-2.5 text-slate-400"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Select Specific Person *"}),e.jsxs(Rt,{value:N,onValueChange:v,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:w.length>0?"Choose a user":"No users found"})}),e.jsx(Tt,{className:"max-h-60",children:w.map(be=>e.jsx(Pe,{value:be.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:be.fullName}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[be.roleCode," • ",be.email]})]})},be.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Assignment Remarks *"}),e.jsx(Ks,{value:m,onChange:be=>f(be.target.value),placeholder:"Why are you assigning this user?",rows:2})]})]}):o.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{className:"text-sm text-red-800",children:[e.jsx("p",{className:"font-bold",children:"Manual Trigger Notice"}),e.jsxs("p",{children:["Normally F&F is triggered after the ",Ri.toLowerCase(),". Use manual trigger only if urgent clearance is required."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"forceFnF",checked:S,onChange:be=>D(be.target.checked),className:"w-4 h-4 rounded border-slate-300"}),e.jsx(le,{htmlFor:"forceFnF",className:"font-medium text-slate-900 cursor-pointer",children:"Force Initiate F&F Settlement Immediately"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks (Optional)"}),e.jsx(Ks,{value:m,onChange:be=>f(be.target.value),placeholder:"Add any additional notes...",rows:3})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks *"}),e.jsx(Ks,{value:m,onChange:be=>f(be.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>d({open:!1,type:null}),disabled:$,children:"Cancel"}),e.jsx(te,{onClick:xe,disabled:$,className:o.type==="approve"?"bg-green-600 hover:bg-green-700":o.type==="withdrawal"?"bg-red-600 hover:bg-red-700":"bg-re-red hover:bg-re-red-hover",children:$?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:[o.type==="approve"&&"Approve",o.type==="withdrawal"&&"Withdraw",o.type==="sendBack"&&"Send Back",o.type==="revoke"&&"Revoke",o.type==="assign"&&"Assign",o.type==="pushfnf"&&"Push to F&F"]})})]})]})}),e.jsx(ms,{open:_.open,onOpenChange:be=>A({open:be,stageName:"",documents:[]}),children:e.jsxs(us,{className:Gb,children:[e.jsxs(ys,{children:[e.jsxs(gs,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Documents - ",_.stageName]}),e.jsxs(ws,{children:["Documents uploaded for this stage (",_.documents.length," ",_.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:_.documents.length>0?e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Action"})]})}),e.jsx(Bs,{children:_.documents.map(be=>e.jsxs(lt,{children:[e.jsx(oe,{children:be.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:be.type})}),e.jsx(oe,{children:be.uploadDate}),e.jsx(oe,{children:be.uploader}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",className:"text-re-red hover:text-blue-700",onClick:()=>{if(!be.filePath)return;const pt=be.filePath.startsWith("/uploads/")&&!be.filePath.startsWith("/uploads/documents/")?be.filePath.replace("/uploads/","/uploads/documents/"):be.filePath;W({fileName:be.name,filePath:pt,documentType:be.type})},children:[e.jsx(ks,{className:"w-4 h-4 mr-1"}),"View"]})})]},be.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(mn,{children:e.jsx(te,{variant:"outline",onClick:()=>A({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ms,{open:U,onOpenChange:M,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Upload Resignation Document"}),e.jsx(ws,{children:"Add a document and map it to a stage (optional)."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Document Type"}),e.jsxs(Rt,{value:F,onValueChange:I,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select document type"})}),e.jsx(Tt,{children:Wg.map(be=>e.jsx(Pe,{value:be,children:be},be))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Stage (Optional)"}),e.jsxs(Rt,{value:K||"none",onValueChange:be=>G(be==="none"?"":be),children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select stage"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"none",children:"No Stage Mapping"}),uV.map(be=>e.jsx(Pe,{value:be,children:be},be))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"File"}),e.jsx(it,{type:"file",onChange:be=>{var pt;return T(((pt=be.target.files)==null?void 0:pt[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>M(!1),disabled:$,children:"Cancel"}),e.jsx(te,{onClick:We,disabled:$,children:$?"Uploading...":"Upload"})]})]})}),e.jsx(ho,{isOpen:!!Q,onClose:()=>W(null),document:Q})]})}const Bo={getTerminationById:async t=>{const n=(await Re.getTerminationById(t)).data;return(n==null?void 0:n.termination)||(n==null?void 0:n.data)||n},updateTerminationStatus:async(t,s,n,r)=>(await Re.updateTerminationStatus(t,{action:s,remarks:n,...r!=null&&r.force?{force:!0}:{}})).data,issueSCN:async(t,s)=>(await Re.issueSCN(t,s)).data,uploadSCNResponse:async(t,s,n)=>{const r=new FormData;return r.append("file",s),n&&r.append("remarks",n),(await Re.uploadSCNResponse(t,r)).data},uploadDocument:async(t,s)=>(await Re.uploadTerminationDocument(t,s)).data,finalizeTermination:async(t,s,n)=>(await Re.finalizeTermination(t,{decision:s,remarks:n})).data},jf=t=>String(t||"").toLowerCase().replace(/\s+/g," ").trim(),pV="Evaluation of Dealer SCN Response",xV=t=>{const s=jf(t);return s?!!(s===jf(pV)||s.includes("evaluation")&&s.includes("scn")&&s.includes("response")||s.includes("personal hearing")):!1},gV=t=>{const s=jf(t);return s.includes("rbm")&&(s.includes("dd-zm")||s.includes("dd zm"))};function vV(t){const s=jf(t);return s.includes("sent back")||s.includes("send back")||s.includes("reconsider")||s.includes("reconsideration")}function TS(t,s){if(!Array.isArray(t)||t.length===0)return null;const n=s==="scn_response_eval"?xV:gV,r=t;for(let a=r.length-1;a>=0;a--){const i=r[a];if(!vV(i==null?void 0:i.action)||!n(i==null?void 0:i.targetStage))continue;const o=(i==null?void 0:i.timestamp)!=null?new Date(i.timestamp).getTime():NaN;if(!Number.isNaN(o))return o}return null}function yV(t){const s=t.createdAt??t.timestamp;if(s==null)return 0;const n=new Date(s).getTime();return Number.isNaN(n)?0:n}function bV(t,s){return s==null?!0:yV(t)>=s}function jV({terminationId:t,onBack:s,currentUser:n}){var Bt,_s,Us,fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn;const r=tr(),{get:a}=mc(t?[{entityType:"termination",entityId:t}]:[],!!t),[i,o]=g.useState({open:!1,type:null}),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(!1),[u,N]=g.useState({open:!1,stageName:"",documents:[]}),[v,w]=g.useState(!0),[j,b]=g.useState(null),[C,S]=g.useState([]),[D,_]=g.useState(!1),[A,E]=g.useState(null),[q,O]=g.useState(""),[R,P]=g.useState(!1),[L,$]=g.useState(!1),[Z,Q]=g.useState("Approve"),[W,U]=g.useState(""),[M,z]=g.useState(!1),[T,F]=g.useState(null),[I,K]=g.useState(Gg[0]),[G,V]=g.useState(""),[Y,re]=g.useState(null),ae=async()=>{try{w(!0);const Ee=await Bo.getTerminationById(t);b(Ee),ue()}catch(Ee){console.error("Error fetching termination:",Ee)}finally{w(!1)}},ue=async()=>{try{const Ee=await Re.getAuditLogs("termination",t);Ee.data&&Ee.data.success&&S(Ee.data.data||[])}catch(Ee){console.error("Error fetching audit logs:",Ee)}};if(g.useEffect(()=>{ae()},[t]),v)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading termination details..."})]});const ye=async()=>{try{P(!0),await Bo.issueSCN(t,{remarks:q}),J.success("SCN issued successfully"),_(!1),ae()}catch{J.error("Failed to issue SCN")}finally{P(!1)}},ce=async()=>{if(A)try{P(!0),await Bo.uploadSCNResponse(t,A,q),J.success("SCN response uploaded"),_(!1),ae()}catch{J.error("Failed to upload response")}finally{P(!1)}},je=async()=>{try{P(!0),await Bo.finalizeTermination(t,Z,W),J.success(`Termination ${Z.toLowerCase()}ed`),$(!1),ae()}catch{J.error("Failed to finalize termination")}finally{P(!1)}},Me=async()=>{if(!T){J.error("Please select a file to upload");return}try{P(!0);const Ee=new FormData;Ee.append("file",T),Ee.append("documentType",I),G&&Ee.append("stage",G),await Bo.uploadDocument(t,Ee),J.success("Document uploaded successfully"),z(!1),F(null),K(Gg[0]),V(""),ae()}catch{J.error("Failed to upload document")}finally{P(!1)}},ut=n&&["DD Lead","DD Head","DD_HEAD","NBH","DD Admin","Super Admin"].includes(n.role||n.roleCode),jt={Submitted:["Submitted"],"RBM + DD-ZM Review":["RBM + DD-ZM Review"],"ZBH Review":["ZBH Review"],"DD Lead Review":["DD Lead Review"],"Legal Verification":["Legal Verification"],"DD Head Review":["DD Head Review"],"NBH Evaluation":["NBH Evaluation"],"Show Cause Notice (SCN)":["Show Cause Notice","Show Cause Notice (SCN)","SCN"],"Evaluation of Dealer SCN Response":["Evaluation of Dealer SCN Response","Personal Hearing"],"NBH Final Approval":["NBH Final Approval"],"CCO Approval":["CCO Approval"],"CEO Final Approval":["CEO Final Approval"],"Legal - Termination Letter":["Legal - Termination Letter"],"Dealer Terminated":["Terminated","Dealer Terminated"]},ft=["Submitted","RBM + DD-ZM Review","ZBH Review","DD Lead Review","Legal Verification","DD Head Review","NBH Evaluation","Show Cause Notice (SCN)","Evaluation of Dealer SCN Response","NBH Final Approval","CCO Approval","CEO Final Approval","Legal - Termination Letter","Dealer Terminated"],Ce=(()=>{if(!j||!n)return{canApprove:!1,canWithdraw:!1,canIssueSCN:!1,canUploadSCNResponse:!1,canFinalize:!1,canPushToFnF:!1};const Ee=j.currentStage,$t=j.status,Xt=n.role||n.roleCode,Cs=["Show Cause Notice (SCN)","SCN"].includes(Ee),Mt=["Completed","Rejected","Withdrawn","Terminated"].includes($t)||Ee==="Terminated",ze=$t==="F&F Initiated"||Ee==="F&F Initiated"||$t==="Settled"||$t==="FNF_INITIATED",xt=(()=>{const ts=new Date;ts.setHours(0,0,0,0);const js=j.proposedLwd;if(!js)return!0;const tn=new Date(js);return tn.setHours(0,0,0,0),ts>=tn})(),yt=TS(j.timeline,"scn_response_eval"),Ot=TS(j.timeline,"rbm_review"),Pt=Ee==="Evaluation of Dealer SCN Response"||Ee==="Personal Hearing",Jt=Ee==="RBM + DD-ZM Review"?Ot:Pt?yt:null,bs=C.some(ts=>{var Ze,Gt,St;if(!bV(ts,Jt))return!1;const js=ts.userId||((Ze=ts.user)==null?void 0:Ze.id)||((Gt=ts.actor)==null?void 0:Gt.id)||ts.actorId,tn=String(js)===String(n.id),vn=(ts.action||ts.description||"").toUpperCase(),jn=vn.includes("PARTIAL_APPROVE")||vn.includes("PARTIAL APPROVED"),xn=((St=ts.details)==null?void 0:St.stage)||ts.stage||"",gn=xn==="RBM + DD-ZM Review"||(ts.remarks||"").includes("Partial approval by"),Ye=xn==="Evaluation of Dealer SCN Response"||xn==="Personal Hearing"||(ts.remarks||"").includes("SCN Response Review by");return tn&&jn&&(Ee==="RBM + DD-ZM Review"&&gn||Pt&&Ye)}),ns=ts=>(jt[ts]||[ts]).includes(Ee);return{canApprove:(Xt==="Super Admin"||Xt==="DD Admin"||ns("RBM + DD-ZM Review")&&(Xt==="RBM"||Xt==="DD-ZM")&&!bs||ns("ZBH Review")&&Xt==="ZBH"||ns("DD Lead Review")&&Xt==="DD Lead"||ns("Legal Verification")&&Xt==="Legal Admin"||ns("DD Head Review")&&(Xt==="DD Head"||Xt==="DD_HEAD")||ns("NBH Evaluation")&&Xt==="NBH"||ns("Evaluation of Dealer SCN Response")&&["DD Lead","ZBH","RBM","DD Head","DD_HEAD"].includes(Xt)&&!bs||ns("NBH Final Approval")&&Xt==="NBH"||ns("CCO Approval")&&Xt==="CCO"||ns("CEO Final Approval")&&Xt==="CEO"||ns("Legal - Termination Letter")&&Xt==="Legal Admin")&&!Mt&&!ze&&!["NBH Final Approval","CCO Approval","CEO Final Approval","Show Cause Notice (SCN)","SCN"].includes(Ee),canIssueSCN:Ee==="NBH Evaluation"&&(Xt==="NBH"||Xt==="Super Admin")&&!Mt,canUploadSCNResponse:Cs&&["Legal Admin","DD Admin","DD Lead","Super Admin"].includes(Xt)&&!Mt,canHold:(ns("NBH Evaluation")||ns("NBH Final Approval"))&&(Xt==="NBH"||Xt==="Super Admin")&&$t!=="On Hold"&&!Mt,canFinalize:(Ee==="NBH Final Approval"&&Xt==="NBH"||Ee==="CCO Approval"&&Xt==="CCO"||Ee==="CEO Final Approval"&&Xt==="CEO"||Xt==="Super Admin")&&["NBH Final Approval","CCO Approval","CEO Final Approval"].includes(Ee)&&!Mt,canPushToFnF:ut&&!ze&&!j.fnfSettlement&&(Ee==="Terminated"||$t===Vc.AWAITING_FNF||$t===Vc.AWAITING_FNF_LWD_PENDING)&&xt,isLwdReached:xt,canWithdraw:Xt==="ASM"&&Ee==="Request Initiated"&&!Mt,isFinalState:Mt,isSettlementPhase:ze}})(),xe=j||{},We=["Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(xe.currentStage),Be=Ee=>{if(!Ee)return"";const $t=String(Ee).trim();return ft.find(Cs=>(jt[Cs]||[Cs]).includes($t))||$t},rt=Ee=>{const $t=["Rejected","Revoked","Withdrawn"].includes(xe.status),Xt=["Completed","Terminated","Settled","F&F Initiated","FNF_INITIATED",Vc.AWAITING_FNF,Vc.AWAITING_FNF_LWD_PENDING].includes(xe.status)||xe.currentStage==="Terminated";let Cs=xe.currentStage||xe.status;if($t&&(xe.currentStage==="Rejected"||xe.currentStage==="Revoked"||!xe.currentStage)){const yt=[...xe.timeline||[]].reverse().find(Ot=>Ot.stage&&Ot.stage!=="Rejected"&&Ot.stage!=="Revoked");yt&&(Cs=yt.stage)}const Mt=Be(Cs),ze=ft.indexOf(Mt),xt=ft.indexOf(Ee);return Xt&&xt<=ze?"completed":xt===-1?"pending":ze===-1?Ee==="Submitted"?"completed":"pending":xt<ze?"completed":xt===ze?$t?"completed":"active":"pending"},ht=[...xe.documents||[],...xe.uploadedDocuments||[]],ge=Object.keys(jt).reduce((Ee,$t)=>{const Xt=jt[$t]||[$t],Cs=ht.filter(Mt=>!Mt.stage||Xt.includes(Mt.stage)).map(Mt=>{var ze;return{id:Mt.id||`${$t}-${Mt.fileName||Mt.name}`,name:Mt.fileName||Mt.name||"Document",type:Mt.documentType||Mt.type||"Document",uploadDate:Mt.uploadDate||Mt.createdAt?Qt(Mt.uploadDate||Mt.createdAt):"N/A",uploader:((ze=Mt.uploader)==null?void 0:ze.fullName)||Mt.uploader||"-",path:Mt.filePath||Mt.path||Mt.url}});return Ee[$t]=Cs,Ee},{}),Je=Ee=>{const $t=jt[Ee]||[Ee];return(xe.timeline||[]).filter(Cs=>$t.includes(Cs.stage)||Ee==="Submitted"&&(Cs.stage==="Submitted"||Cs.stage==="Request Initiated")).sort((Cs,Mt)=>new Date(Cs.timestamp).getTime()-new Date(Mt.timestamp).getTime())},mt=[{id:1,name:"Submitted",status:rt("Submitted"),description:"Termination request initiated",date:"",actionType:"",actionBy:"",remarks:"",feedback:""},{id:2,name:"RBM + DD-ZM Review",status:rt("RBM + DD-ZM Review"),description:"Joint review and approval by RBM and DD-ZM"},{id:3,name:"ZBH Review",status:rt("ZBH Review"),description:"Zonal Business Head evaluation"},{id:4,name:"DD Lead Review",status:rt("DD Lead Review"),description:"DD Lead validation"},{id:5,name:"Legal Verification",status:rt("Legal Verification"),description:"Legal team validates termination grounds"},{id:6,name:"DD Head Review",status:rt("DD Head Review"),description:"DD Head strategic review"},{id:7,name:"NBH Evaluation",status:rt("NBH Evaluation"),description:"National Business Head decision"},{id:8,name:"Show Cause Notice (SCN)",status:rt("Show Cause Notice (SCN)"),description:"SCN sent to dealer, awaiting response"},{id:9,name:"Evaluation of Dealer SCN Response",status:rt("Evaluation of Dealer SCN Response"),description:"Joint evaluation of SCN response by DD-Lead, ZBH, RBM, and DD-Head"},{id:10,name:"NBH Final Approval",status:rt("NBH Final Approval"),description:"NBH final termination decision"},{id:11,name:"CCO Approval",status:rt("CCO Approval"),description:"Chief Commercial Officer approval"},{id:12,name:"CEO Final Approval",status:rt("CEO Final Approval"),description:"CEO final authorization"},{id:13,name:"Legal - Termination Letter",status:rt("Legal - Termination Letter"),description:"Legal team issues final termination letter"},{id:14,name:"Dealer Terminated",status:rt("Dealer Terminated"),description:"Dealership termination effective",date:"",actionType:"",actionBy:"",remarks:"",feedback:""}],de=Ee=>{const $t=ge[Ee]||[];N({open:!0,stageName:Ee,documents:$t})},at=Ee=>{o({open:!0,type:Ee})},ot=async()=>{var Cs,Mt,ze,xt,yt,Ot;const Ee=i.type,$t=Ee==="sendBack"?"sendBack":Ee||"approve",Xt=d.trim();if(["sendBack","revoke"].includes(Ee||"")&&Xt.length<5){J.error("Please provide detailed remarks (minimum 5 characters required for Send Back / Revoke)");return}if(!Xt&&!["assign","pushfnf"].includes(Ee||"")){J.error("Please provide remarks/comments for this action");return}if(Ee==="assign"&&!f){J.error("Please select a user");return}P(!0);try{let Pt;if(Ee==="approve"||Ee==="sendBack"||Ee==="withdrawal"||Ee==="revoke"||Ee==="hold")Pt=await Bo.updateTerminationStatus(t,$t,d);else if(Ee==="pushfnf")Pt=await Bo.updateTerminationStatus(t,"pushfnf",d,{force:h});else{J.error("Action logic not fully implemented for this type"),P(!1);return}if(Pt&&(Pt.success===!1||Pt.ok===!1)){console.error("[TerminationDetails] Action failed:",Pt);const bs=Pt.message||((Cs=Pt.data)==null?void 0:Cs.message)||"Failed to perform action";J.error(bs),(Pt.canForce||(Mt=Pt.data)!=null&&Mt.canForce)&&J.info('Enable "Force initiate F&F" in the dialog if an exception is approved.'),P(!1);return}const Jt={approve:"Request approved and forwarded",withdrawal:"Request withdrawn successfully",sendBack:"Request sent back for clarification",assign:"Request assigned successfully",pushfnf:"Request pushed to F&F successfully",revoke:"Request revoked and withdrawn"};J.success(Jt[Ee]||(Pt==null?void 0:Pt.message)||"Action completed"),o({open:!1,type:null}),m(""),p(""),x(!1),ae()}catch(Pt){const Jt=((xt=(ze=Pt.response)==null?void 0:ze.data)==null?void 0:xt.message)||"Failed to perform action";J.error(Jt),(Ot=(yt=Pt==null?void 0:Pt.response)==null?void 0:yt.data)!=null&&Ot.canForce&&J.info('Enable "Force initiate F&F" in the dialog if an exception is approved.')}finally{P(!1)}},ke=Ee=>{switch(Ee){case"Critical":return"bg-red-100 text-red-700 border-red-300";case"High":return"bg-orange-100 text-orange-700 border-orange-300";case"Medium":return"bg-yellow-100 text-yellow-700 border-yellow-300";default:return"bg-blue-100 text-blue-700 border-blue-300"}},Zt=(xe.worknotes||[]).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:xe.requestId||t}),e.jsx("p",{className:"text-slate-600",children:((Bt=xe.dealer)==null?void 0:Bt.businessName)||((_s=xe.dealer)==null?void 0:_s.legalName)||"Termination"})]}),e.jsx(we,{className:ke(xe.severity),children:xe.severity}),e.jsx(we,{className:xe.status==="Completed"||xe.status==="Terminated"||xe.status==="Settled"?"bg-green-100 text-green-700 border-green-300":xe.status==="Rejected"||xe.status==="Withdrawn"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:xe.status==="Settled"?"Completed":lj(xe.status||"Pending")}),e.jsx(br,{status:a("termination",t)})]})}),e.jsxs(In,{defaultValue:"details",className:"w-full",children:[e.jsxs(Mn,{className:"bg-slate-100 p-1",children:[e.jsx(Ht,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(Ht,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(Ht,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(Ht,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Vt,{value:"details",className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Dealer Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((fs=(Us=xe.dealer)==null?void 0:Us.dealerCode)==null?void 0:fs.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((Vs=xe.dealer)==null?void 0:Vs.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((Qs=xe.dealer)==null?void 0:Qs.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((ie=(Xs=xe.dealer)==null?void 0:Xs.user)==null?void 0:ie.email)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((nt=xe.dealer)==null?void 0:nt.registeredAddress)||((Ae=(fe=xe.dealer)==null?void 0:fe.application)==null?void 0:Ae.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"City"}),e.jsx("p",{children:((Ke=(Fe=xe.dealer)==null?void 0:Fe.application)==null?void 0:Ke.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"District"}),e.jsx("p",{children:((et=(Ue=(Le=xe.dealer)==null?void 0:Le.application)==null?void 0:Ue.district)==null?void 0:et.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:((dt=xe.dealer)==null?void 0:dt.businessName)||xe.dealershipName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((Wt=(ss=xe.dealer)==null?void 0:ss.dealerCode)==null?void 0:Wt.salesCode)||xe.salesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((wt=(kt=xe.dealer)==null?void 0:kt.dealerCode)==null?void 0:wt.serviceCode)||xe.serviceCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((as=(Os=xe.dealer)==null?void 0:Os.dealerCode)==null?void 0:as.gmaCode)||xe.accessoriesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((be=(Se=xe.dealer)==null?void 0:Se.dealerCode)==null?void 0:be.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((Ve=(pt=xe.dealer)==null?void 0:pt.dealerCode)==null?void 0:Ve.gearCode)||"N/A"})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Operational Details"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(bt=xe.dealer)!=null&&bt.onboardedAt?Qt(xe.dealer.onboardedAt,"date"):xe.inauguration||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(gt=xe.dealer)!=null&>.loaDate?Qt(xe.dealer.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(rs=xe.dealer)!=null&&rs.loiDate?Qt(xe.dealer.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last 6 Months Sales"}),e.jsx("p",{children:xe.lastSixMonthsSales})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Number of Dealerships"}),e.jsx("p",{children:xe.numberOfDealerships})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Number of Studios"}),e.jsx("p",{children:xe.numberOfStudios})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Constitution"}),e.jsx("p",{children:((is=xe.dealer)==null?void 0:is.constitutionType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((Ws=(Ts=xe.dealer)==null?void 0:Ts.application)==null?void 0:Ws.businessType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:xe.typeOfClosure||"Complete"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Format Category"}),e.jsx("p",{children:xe.formatCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Score Card Band"}),e.jsx("p",{children:xe.dealerScoreCardBand||"N/A"})]})]})})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50/30",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-red-900 flex items-center gap-2",children:[e.jsx(Ba,{className:"w-5 h-5"}),"Termination Details"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{className:"text-red-900",children:xe.category})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sub Category"}),e.jsx("p",{children:xe.subCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Description"}),e.jsx("p",{children:xe.reason})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Severity"}),e.jsx("div",{className:"mt-1",children:e.jsx(we,{className:ke(xe.severity),children:xe.severity})})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted By"}),e.jsx("p",{children:((nn=xe.initiator)==null?void 0:nn.fullName)||"System"})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Qt(xe.createdAt)})]})]})]})})]})]}),e.jsx(Vt,{value:"progress",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Termination Progress Timeline"}),e.jsx(es,{children:"Track the termination request approval process"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:mt.map((Ee,$t)=>{var Mt,ze,xt;const Xt=((Mt=ge[Ee.name])==null?void 0:Mt.length)||0,Cs=Je(Ee.name);return e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${Ee.status==="completed"?"bg-green-100 text-green-600":Ee.status==="active"?"bg-red-50 text-re-red":"bg-slate-100 text-slate-400"}`,children:Ee.status==="completed"?e.jsx($n,{className:"w-5 h-5"}):Ee.status==="active"?e.jsx(Ba,{className:"w-5 h-5"}):e.jsx("span",{children:Ee.id})}),$t<mt.length-1&&e.jsx("div",{className:`w-0.5 ${Ee.remarks?"h-32":"h-16"} ${Ee.status==="completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:Ee.status==="completed"?"text-green-600":Ee.status==="active"?"text-re-red":"text-slate-400",children:Ee.name}),Xt>0&&e.jsxs("button",{onClick:()=>de(Ee.name),className:"flex items-center gap-1 px-2 py-1 rounded-full bg-red-50 hover:bg-red-100 text-re-red-hover text-xs transition-colors cursor-pointer",children:[e.jsx(ks,{className:"w-3 h-3"}),e.jsxs("span",{children:[Xt," ",Xt===1?"doc":"docs"]})]})]}),(((ze=Cs[0])==null?void 0:ze.timestamp)||Ee.date)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 bg-slate-50 px-2 py-0.5 rounded-full border border-slate-100",children:[e.jsx(er,{className:"w-3 h-3"}),e.jsx("span",{children:Qt(((xt=Cs[0])==null?void 0:xt.timestamp)||Ee.date)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:Ee.description}),Cs.length>0&&e.jsx("div",{className:"mt-3 space-y-3",children:Cs.map((yt,Ot)=>{var ns,Ds,ts;const Pt=yt.remarks||yt.comments||"",Jt=Pt==null?void 0:Pt.startsWith("Attachment:"),bs=Jt?Pt.replace("Attachment:","").trim():Pt;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(we,{className:`
|
||
text-[10px] h-4 px-1.5
|
||
${(ns=yt.action)!=null&&ns.toLowerCase().includes("rejected")||(Ds=yt.action)!=null&&Ds.toLowerCase().includes("revoked")?"bg-red-100 text-red-700":(ts=yt.action)!=null&&ts.toLowerCase().includes("approved")?"bg-emerald-100 text-emerald-700":"bg-blue-100 text-blue-700"}
|
||
`,children:yt.action||"Action"}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-medium",children:["by ",yt.user||"System",yt.role?` (${yt.role})`:""," • ",Qt(yt.timestamp)]})]}),e.jsx("div",{className:`
|
||
p-2.5 rounded-lg border text-sm
|
||
${Jt?"bg-red-50/50 border-red-100 text-red-900":"bg-slate-50 border-slate-100 text-slate-700"}
|
||
`,children:Jt?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-3.5 h-3.5 text-re-red"}),e.jsx("span",{className:"font-medium truncate",children:bs})]}):e.jsx("p",{className:"leading-relaxed",children:bs||"No remarks provided."})})]},Ot)})})]})]},Ee.id)})})})]})}),e.jsx(Vt,{value:"documents",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Documents"}),e.jsx(es,{children:"View and manage termination case documents"})]}),e.jsxs(te,{size:"sm",onClick:()=>z(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:(()=>{const Ee=[...xe.documents||[],...xe.uploadedDocuments||[]];return Ee.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):Ee.map(($t,Xt)=>{var Cs;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:$t.name||$t.fileName})]})}),e.jsx(oe,{children:$t.documentType||$t.type||"Document"}),e.jsx(oe,{children:Qt($t.uploadDate||$t.createdAt)}),e.jsx(oe,{children:((Cs=$t.uploader)==null?void 0:Cs.fullName)||$t.uploader||"-"}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>{const Mt=$t.filePath||$t.path||$t.url;if(!Mt)return;const ze=Mt.startsWith("/uploads/")&&!Mt.startsWith("/uploads/documents/")?Mt.replace("/uploads/","/uploads/documents/"):Mt;re({fileName:$t.name||$t.fileName||"Document",filePath:ze,documentType:$t.documentType||$t.type||"Document"})},children:"View"})})]},$t.id||Xt)})})()})]})})]})}),e.jsx(Vt,{value:"audit",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Audit Trail"}),e.jsx(es,{children:"Complete history of actions on this termination case"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:C.length>0?C.map((Ee,$t)=>{var Xt,Cs,Mt,ze,xt,yt,Ot,Pt,Jt,bs,ns;return e.jsxs("div",{className:"flex gap-3 pb-6 border-b border-slate-100 last:border-0 relative",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-300 mt-2 z-10"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:`
|
||
${(Ee.description||Ee.action||((Xt=Ee.details)==null?void 0:Xt.action)||"").toLowerCase().includes("reject")||(Ee.description||Ee.action||((Cs=Ee.details)==null?void 0:Cs.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Ee.description||Ee.action||((Mt=Ee.details)==null?void 0:Mt.action)||"").toLowerCase().includes("sent back")||(Ee.description||Ee.action||((ze=Ee.details)==null?void 0:ze.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(Ee.description||Ee.action||((xt=Ee.details)==null?void 0:xt.action)||"").toLowerCase().includes("approv")||(Ee.description||Ee.action||((yt=Ee.details)==null?void 0:yt.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
|
||
`,children:Ee.description||Ee.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Ot=Ee.actor)==null?void 0:Ot.name)||Ee.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Qt(Ee.timestamp||Ee.createdAt)})]}),(Ee.remarks||((Pt=Ee.newData)==null?void 0:Pt.remarks)||((Jt=Ee.details)==null?void 0:Jt.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:Ee.remarks||((bs=Ee.newData)==null?void 0:bs.remarks)||((ns=Ee.details)==null?void 0:ns.remarks)})]})]},$t)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})})]}),e.jsx("div",{className:"space-y-6",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[(xe.currentStage==="Evaluation of Dealer SCN Response"||xe.currentStage==="Personal Hearing")&&e.jsxs(Ai,{className:"mb-2 bg-blue-50 border-blue-200",children:[e.jsx(il,{className:"text-blue-800 text-sm font-semibold",children:"Joint Review Stage"}),e.jsxs(ki,{className:"text-blue-700 text-xs",children:["Joint evaluation by ",e.jsx("strong",{children:"DD-Lead, ZBH, RBM, and DD-Head"})," required before advancing to NBH Final Approval."]})]}),(n==null?void 0:n.role)!=="Dealer"&&e.jsxs(e.Fragment,{children:[!Ce.canFinalize&&e.jsxs(e.Fragment,{children:[Ce.canApprove&&e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>at("approve"),children:[e.jsx($n,{className:"w-4 h-4 mr-2"}),"Approve"]}),Ce.canIssueSCN&&e.jsxs(te,{className:"w-full bg-purple-600 hover:bg-purple-700",onClick:()=>_(!0),children:[e.jsx(Ba,{className:"w-4 h-4 mr-2"}),"Issue SCN"]}),Ce.canUploadSCNResponse&&e.jsxs(te,{className:"w-full bg-re-red hover:bg-re-red-hover",onClick:()=>{E(null),_(!0)},children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"Upload SCN Response"]}),Ce.canApprove&&e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>at("sendBack"),children:[e.jsx(sb,{className:"w-4 h-4 mr-2"}),"Send Back"]})]}),Ce.canHold&&e.jsxs(te,{variant:"outline",className:"w-full border-orange-200 text-orange-700 hover:bg-orange-50",onClick:()=>at("hold"),children:[e.jsx(GI,{className:"w-4 h-4 mr-2"}),"Hold Decision"]}),Ce.canFinalize&&e.jsxs(te,{className:"w-full bg-indigo-600 hover:bg-indigo-700",onClick:()=>$(!0),children:[e.jsx(so,{className:"w-4 h-4 mr-2"}),"Final Authorization"]})]}),Ce.canPushToFnF&&e.jsxs(te,{variant:"outline",className:"w-full text-blue-600 border-blue-300 hover:bg-blue-50",onClick:()=>at("pushfnf"),children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),ut&&!Ce.isSettlementPhase&&!Ce.canPushToFnF&&!xe.fnfSettlement&&(xe.currentStage==="Terminated"||xe.status===Vc.AWAITING_FNF||xe.status===Vc.AWAITING_FNF_LWD_PENDING)&&!Ce.isLwdReached&&e.jsxs(Ai,{className:"border-red-200 bg-red-50",children:[e.jsx(Ba,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(il,{className:"text-red-900",children:["Push to F&F locked until ",Ri]}),e.jsxs(ki,{className:"text-red-800 text-sm",children:[Ri," is"," ",xe.proposedLwd?new Date(xe.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"}):"not set",". Admins are notified by email when the ",Ri.toLowerCase()," is reached."]})]}),!Ce.isFinalState&&e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>at("assign"),children:[e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(Xo,{}),e.jsxs(te,{variant:"outline",className:"w-full",onClick:()=>{var Ee;return r(`/worknotes/termination/${t}`,{state:{applicationName:((Ee=xe==null?void 0:xe.dealer)==null?void 0:Ee.businessName)||"Termination",registrationNumber:t||"",participants:(xe==null?void 0:xe.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes",Zt>0&&e.jsx(we,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:Zt})]})]})]})})]})]}),e.jsx(ms,{open:i.open,onOpenChange:Ee=>o({open:Ee,type:null}),children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[i.type==="approve"&&"Approve Termination Request",i.type==="withdrawal"&&"Withdraw Termination Request",i.type==="sendBack"&&"Send Back for Clarification",i.type==="revoke"&&"Revoke Termination Request",i.type==="assign"&&"Assign to User",i.type==="pushfnf"&&"Push to Full & Final Settlement",i.type==="hold"&&"Hold Termination Case"]}),e.jsx(ws,{children:i.type==="assign"?"Select a user to assign this request to":i.type==="pushfnf"?"This creates the F&F settlement record and starts departmental clearance (manual step only).":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:i.type==="assign"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Select User"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Choose a user"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"rbm",children:"RBM - Regional Business Manager"}),e.jsx(Pe,{value:"zbh",children:"ZBH - Zonal Business Head"}),e.jsx(Pe,{value:"dd-lead",children:"DD Lead"}),e.jsx(Pe,{value:"legal",children:"Legal Team"}),e.jsx(Pe,{value:"nbh",children:"NBH - National Business Head"}),e.jsx(Pe,{value:"cco",children:"CCO - Chief Commercial Officer"}),e.jsx(Pe,{value:"ceo",children:"CEO"})]})]})]}):i.type==="pushfnf"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-slate-600",children:["F&F can be started on or after the ",Ri,xe.proposedLwd?` (${new Date(xe.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"})})`:"","."]}),e.jsx(le,{children:"Remarks (Optional)"}),e.jsx(Ks,{value:d,onChange:Ee=>m(Ee.target.value),placeholder:"Add any additional notes...",rows:3}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:h,onChange:Ee=>x(Ee.target.checked)}),e.jsxs("span",{children:["Force initiate F&F before ",Ri," (requires business approval; exception use only)"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks *"}),e.jsx(Ks,{value:d,onChange:Ee=>m(Ee.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>o({open:!1,type:null}),children:"Cancel"}),e.jsx(te,{onClick:ot,className:i.type==="approve"?"bg-green-600 hover:bg-green-700":i.type==="withdrawal"?"bg-red-600 hover:bg-red-700":i.type==="hold"?"bg-orange-600 hover:bg-orange-700":"bg-blue-600 hover:bg-blue-700",children:"Confirm"})]})]})}),e.jsx(ms,{open:u.open,onOpenChange:Ee=>N({open:Ee,stageName:"",documents:[]}),children:e.jsxs(us,{className:Gb,children:[e.jsxs(ys,{children:[e.jsxs(gs,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Documents - ",u.stageName]}),e.jsxs(ws,{children:["Documents uploaded for this stage (",u.documents.length," ",u.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.documents.length>0?e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Uploader"}),e.jsx(me,{children:"Action"})]})}),e.jsx(Bs,{children:u.documents.map(Ee=>e.jsxs(lt,{children:[e.jsx(oe,{children:Ee.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:Ee.type})}),e.jsx(oe,{children:Ee.uploadDate}),e.jsx(oe,{children:Ee.uploader}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",className:"text-re-red hover:text-re-red-hover",onClick:()=>{const $t=Ee.path;if(!$t)return;const Xt=$t.startsWith("/uploads/")&&!$t.startsWith("/uploads/documents/")?$t.replace("/uploads/","/uploads/documents/"):$t;re({fileName:Ee.name||"Document",filePath:Xt,documentType:Ee.type||"Document"})},children:[e.jsx(ks,{className:"w-4 h-4 mr-1"}),"View"]})})]},Ee.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(mn,{children:e.jsx(te,{variant:"outline",onClick:()=>N({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ms,{open:D,onOpenChange:_,children:e.jsxs(us,{className:"bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:We?"Upload SCN Response":"Issue Show Cause Notice (SCN)"}),e.jsx(ws,{children:We?"Upload the response received from the dealer regarding the SCN.":"Confirm the issuance of a formal Show Cause Notice to the dealer."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[We&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"SCN Response File"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"file",className:"hidden",id:"scn-file-upload",onChange:Ee=>{var $t;return E((($t=Ee.target.files)==null?void 0:$t[0])||null)}}),e.jsx(te,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ee;return(Ee=document.getElementById("scn-file-upload"))==null?void 0:Ee.click()},children:A?A.name:"Select PDF or Image"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Remarks/Details"}),e.jsx(Ks,{placeholder:"Add any internal remarks or justification...",value:q,onChange:Ee=>O(Ee.target.value),rows:4})]}),e.jsxs(mn,{className:"gap-2 sm:gap-0",children:[e.jsx(te,{variant:"outline",onClick:()=>_(!1),disabled:R,children:"Cancel"}),e.jsx(te,{className:We?"bg-re-red hover:bg-re-red-hover":"bg-purple-600 hover:bg-purple-700",onClick:We?ce:ye,disabled:R||We&&!A,children:R?"Processing...":We?"Upload Response":"Issue SCN"})]})]})]})}),e.jsx(ms,{open:L,onOpenChange:$,children:e.jsxs(us,{className:"bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Final Termination Authorization"}),e.jsx(ws,{children:"Provide your final decision on this termination case."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Final Decision"}),e.jsxs(Rt,{value:Z,onValueChange:Ee=>Q(Ee),children:[e.jsx(_t,{className:"mt-2 text-slate-900 border-slate-300",children:e.jsx(Et,{placeholder:"Select decision"})}),e.jsxs(Tt,{className:"bg-white border-slate-200 shadow-xl overflow-visible z-[9999]",children:[e.jsx(Pe,{value:"Approve",className:"text-re-red-hover focus:bg-red-50",children:"Confirm Termination"}),e.jsx(Pe,{value:"Reject",className:"text-slate-600 focus:bg-slate-50",children:"Reject Termination"}),e.jsx(Pe,{value:"Reconsider",className:"text-re-red focus:bg-red-50",children:"Reconsider / Give More Time"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Authorization Remarks"}),e.jsx(Ks,{placeholder:"Provide your rationale for this decision...",value:W,onChange:Ee=>U(Ee.target.value),rows:4})]}),e.jsxs(mn,{className:"gap-2 sm:gap-0",children:[e.jsx(te,{variant:"outline",onClick:()=>$(!1),disabled:R,children:"Cancel"}),e.jsx(te,{className:"bg-indigo-600 hover:bg-indigo-700",onClick:je,disabled:R||!W,children:R?"Authorizing...":"Submit Decision"})]})]})]})}),e.jsx(ms,{open:M,onOpenChange:z,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Upload Termination Document"}),e.jsx(ws,{children:"Add a document and map it to a stage (optional)."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Document Type"}),e.jsxs(Rt,{value:I,onValueChange:K,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select document type"})}),e.jsx(Tt,{children:Gg.map(Ee=>e.jsx(Pe,{value:Ee,children:Ee},Ee))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Stage (Optional)"}),e.jsxs(Rt,{value:G||"none",onValueChange:Ee=>V(Ee==="none"?"":Ee),children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select stage"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"none",children:"No Stage Mapping"}),hV.map(Ee=>e.jsx(Pe,{value:Ee,children:Ee},Ee))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"File"}),e.jsx("input",{type:"file",onChange:Ee=>{var $t;return F((($t=Ee.target.files)==null?void 0:$t[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>z(!1),disabled:R,children:"Cancel"}),e.jsx(te,{onClick:Me,disabled:R,children:R?"Uploading...":"Upload"})]})]})}),e.jsx(ho,{isOpen:!!Y,onClose:()=>re(null),document:Y})]})}const xa=t=>{if(!t)return"-";try{const s=new Date(t);return isNaN(s.getTime())?"-":s.toLocaleString("en-IN",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0})}catch{return"-"}},PS=t=>{if(!t)return"-";try{const s=new Date(t);return isNaN(s.getTime())?"-":s.toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"})}catch{return"-"}},f_=({isOpen:t,onClose:s,onSubmit:n,editingBank:r,isSubmitting:a})=>e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"sm:max-w-[500px]",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:r?"Edit Bank Details":"Add Bank Account"}),e.jsx(ws,{children:"Enter the dealer's bank information for settlement transfers."})]}),e.jsxs("form",{onSubmit:n,"data-testid":"onboarding-bank-details-form",children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"bankName",className:"text-right text-xs",children:"Bank Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{id:"bankName",name:"bankName",defaultValue:r==null?void 0:r.bankName,required:!0,placeholder:"e.g. HDFC Bank, ICICI Bank",className:"h-9","data-testid":"onboarding-bank-name-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"accountHolderName",className:"text-right text-xs",children:"Holder Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{id:"accountHolderName",name:"accountHolderName",defaultValue:r==null?void 0:r.accountHolderName,required:!0,placeholder:"Full name as per bank records",className:"h-9","data-testid":"onboarding-account-holder-name-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"accountNumber",className:"text-right text-xs",children:"A/C Number"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{id:"accountNumber",name:"accountNumber",defaultValue:r==null?void 0:r.accountNumber,required:!0,placeholder:"Enter account number",className:"h-9","data-testid":"onboarding-account-number-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"ifscCode",className:"text-right text-xs",children:"IFSC Code"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{id:"ifscCode",name:"ifscCode",defaultValue:r==null?void 0:r.ifscCode,required:!0,placeholder:"11-character code",className:"h-9","data-testid":"onboarding-ifsc-code-input"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"branchName",className:"text-right text-xs",children:"Branch"}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{id:"branchName",name:"branchName",defaultValue:r==null?void 0:r.branchName,required:!0,placeholder:"Branch location",className:"h-9","data-testid":"onboarding-branch-name-input"})})]}),e.jsx("div",{className:"grid grid-cols-4 items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2 col-start-2 col-span-3",children:[e.jsx("input",{type:"checkbox",id:"isPrimaryModal",name:"isPrimary",defaultChecked:r==null?void 0:r.isPrimary,className:"w-4 h-4 rounded border-slate-300 text-re-red focus:ring-re-red","data-testid":"onboarding-is-primary-checkbox"}),e.jsx(le,{htmlFor:"isPrimaryModal",className:"text-xs font-medium cursor-pointer",children:"Set as primary account"})]})})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:s,"data-testid":"onboarding-bank-details-cancel",children:"Cancel"}),e.jsxs(te,{type:"submit",disabled:a,size:"sm",className:"bg-re-red","data-testid":"onboarding-bank-details-submit",children:[a?e.jsx(cs,{className:"w-4 h-4 animate-spin mr-2"}):null,r?"Update Account":"Save Bank Details"]})]})]})]})}),OS=["Warranty Department","Accessories Department","Sales Department","RTO Department","Service Department","Parts Department","Finance Department","Insurance Department","Inventory Department","Marketing Department","HR Department","IT Department","Legal Department","Quality Department","Logistics Department","Customer Relations Department"],NV="[DEPARTMENT_CLAIM]",wV="[FINANCE_VALIDATED]";function SV({fnfId:t,onBack:s,currentUser:n}){var xe,We,Be,rt,ht;const r=tr(),[a,i]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState("details"),[p,h]=g.useState(!1),[x,u]=g.useState(null),[N,v]=g.useState([]),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,D]=g.useState(null),[_,A]=g.useState(!1),[E,q]=g.useState(!1),[O,R]=g.useState(null),[P,L]=g.useState(!1),[$,Z]=g.useState({remarks:"",amount:0,type:"Receivable"}),[Q,W]=g.useState(null);g.useEffect(()=>{I(),K()},[t]);const U=ge=>{if(!ge)return ge;let Je=ge.trim();const mt=OS.find(ot=>ot.toLowerCase()===Je.toLowerCase());if(mt)return mt;const at={sales:"Sales Department",service:"Service Department",spares:"Parts Department",parts:"Parts Department","spares / parts":"Parts Department",finance:"Finance Department",accounts:"Finance Department",warranty:"Warranty Department",marketing:"Marketing Department",hr:"HR Department",it:"IT Department",legal:"Legal Department",logistics:"Logistics Department",quality:"Quality Department",fdd:"Finance Department",apparel:"Accessories Department",accessories:"Accessories Department",dms:"IT Department",rto:"Admin Department",admin:"Admin Department","admin / dd-admin":"Admin Department"}[Je.toLowerCase().replace(" department","")];return at||ge},M=(ge,Je)=>Je==="DepartmentClaim"||typeof ge=="string"&&(ge.startsWith(NV)||ge.includes("Clearance:")),z=ge=>(ge==null?void 0:ge.sourceType)==="FinanceValidated"&&typeof(ge==null?void 0:ge.description)=="string"&&ge.description.includes("Auto-seeded from department claim"),T=(ge,Je)=>Je==="FinanceValidated"||typeof ge=="string"&&ge.startsWith(wV),F=ge=>ge?{ADD_LINE_ITEM:"Line Item Added",UPDATE_LINE_ITEM:"Line Item Updated",REMOVE_LINE_ITEM:"Line Item Removed",UPDATE_CLEARANCE:"Clearance Status Updated",SETTLE_CASE:"Settlement Finalized",FNF_UPDATED:"F&F Case Updated"}[ge]||ge.split("_").map(mt=>mt.charAt(0).toUpperCase()+mt.slice(1).toLowerCase()).join(" "):"Action",I=async(ge=!0)=>{var Je,mt,de,at,ot,ke,Zt,Bt,_s,Us,fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt,Cs,Mt,ze,xt,yt,Ot,Pt,Jt,bs,ns,Ds,ts,js,tn,vn,jn,xn,gn,Ye,qt;try{ge&&d(!0);const Gt=(await Re.getFnFSettlementById(t)).data;if(Gt.success){const St=Gt.fnf,qn=(St.lineItems||[]).filter(It=>It.isActive!==!1),Fr=qn.some(It=>T(It.description,It.sourceType))?qn.filter(It=>T(It.description,It.sourceType)):qn.filter(It=>!M(It.description,It.sourceType)),wn={id:St.id,caseNumber:St.settlementId||((Je=St.resignation)==null?void 0:Je.resignationId)||((mt=St.terminationRequest)==null?void 0:mt.requestId)||St.id.substring(0,8),status:St.status,requestType:St.resignationId?"Resignation":"Termination",dealerName:((at=(de=St.outlet)==null?void 0:de.dealer)==null?void 0:at.fullName)||((ot=St.dealer)==null?void 0:ot.fullName)||"N/A",dealerCode:((ke=St.outlet)==null?void 0:ke.code)||((Bt=(Zt=St.dealer)==null?void 0:Zt.dealerCode)==null?void 0:Bt.dealerCode)||"N/A",dealershipName:((_s=St.outlet)==null?void 0:_s.name)||((Us=St.dealer)==null?void 0:Us.businessName)||"N/A",location:((fs=St.outlet)==null?void 0:fs.city)||((Vs=St.outlet)==null?void 0:Vs.location)||"N/A",originalRequestId:((Qs=St.resignation)==null?void 0:Qs.resignationId)||((Xs=St.terminationRequest)==null?void 0:Xs.requestId)||((ie=St.terminationRequest)==null?void 0:ie.id)||"N/A",submittedOn:xa(St.createdAt),lastOperationalDateSales:(nt=St.resignation)!=null&&nt.lastOperationalDateSales||(fe=St.terminationRequest)!=null&&fe.proposedLwd?PS(((Ae=St.resignation)==null?void 0:Ae.lastOperationalDateSales)||((Fe=St.terminationRequest)==null?void 0:Fe.proposedLwd)):"N/A",lastOperationalDateServices:(Ke=St.resignation)!=null&&Ke.lastOperationalDateServices||(Le=St.terminationRequest)!=null&&Le.proposedLwd?PS(((Ue=St.resignation)==null?void 0:Ue.lastOperationalDateServices)||((et=St.terminationRequest)==null?void 0:et.proposedLwd)):"N/A",typeOfClosure:St.resignationId?"Voluntary":"Involuntary",gst:((Wt=(ss=(dt=St.outlet)==null?void 0:dt.dealer)==null?void 0:ss.dealerProfile)==null?void 0:Wt.gstNumber)||((kt=St.dealer)==null?void 0:kt.gstNumber)||"N/A",pan:((as=(Os=(wt=St.outlet)==null?void 0:wt.dealer)==null?void 0:Os.dealerProfile)==null?void 0:as.panNumber)||((Se=St.dealer)==null?void 0:Se.panNumber)||"N/A",salesCode:((pt=(be=St.dealer)==null?void 0:be.dealerCode)==null?void 0:pt.salesCode)||((rs=(gt=(bt=(Ve=St.outlet)==null?void 0:Ve.dealer)==null?void 0:bt.dealerProfile)==null?void 0:gt.dealerCode)==null?void 0:rs.salesCode)||"N/A",serviceCode:((Ts=(is=St.dealer)==null?void 0:is.dealerCode)==null?void 0:Ts.serviceCode)||(($t=(Ee=(nn=(Ws=St.outlet)==null?void 0:Ws.dealer)==null?void 0:nn.dealerProfile)==null?void 0:Ee.dealerCode)==null?void 0:$t.serviceCode)||"N/A",gearCode:((Cs=(Xt=St.dealer)==null?void 0:Xt.dealerCode)==null?void 0:Cs.gearCode)||((yt=(xt=(ze=(Mt=St.outlet)==null?void 0:Mt.dealer)==null?void 0:ze.dealerProfile)==null?void 0:xt.dealerCode)==null?void 0:yt.gearCode)||"N/A",gmaCode:((Pt=(Ot=St.dealer)==null?void 0:Ot.dealerCode)==null?void 0:Pt.gmaCode)||((Ds=(ns=(bs=(Jt=St.outlet)==null?void 0:Jt.dealer)==null?void 0:bs.dealerProfile)==null?void 0:ns.dealerCode)==null?void 0:Ds.gmaCode)||"N/A",financeReportStatus:St.status==="Finance Approval"?"In Progress":St.status==="Completed"?"Completed":"Pending",totalPayableAmount:Fr.filter(It=>It.itemType==="Payable").reduce((It,As)=>It+(parseFloat(As.amount)||0),0),totalRecoveryAmount:Fr.filter(It=>It.itemType==="Receivable"||It.itemType==="Recovery").reduce((It,As)=>It+(parseFloat(As.amount)||0),0),totalDeductions:Fr.filter(It=>It.itemType==="Deduction").reduce((It,As)=>It+(parseFloat(As.amount)||0),0),allLineItems:qn,netAmount:0,departmentResponses:[]};wn.netAmount=wn.totalPayableAmount-wn.totalRecoveryAmount-wn.totalDeductions,wn.departmentResponses=["Warranty Department","Accessories Department","Sales Department","RTO Department","Service Department","Parts Department","Finance Department","Insurance Department","Inventory Department","Marketing Department","HR Department","IT Department","Legal Department","Quality Department","Logistics Department","Customer Relations Department"].map(It=>{const As=(St.clearances||[]).find(yn=>U(yn.department)===It),_r=qn.filter(yn=>U(yn.department)===It&&M(yn.description,yn.sourceType)),ca=qn.filter(yn=>U(yn.department)===It&&z(yn)),Ca=_r.length>0?_r:ca;let Yr=0,Nr=0;Ca.forEach(yn=>{const Dn=Math.abs(parseFloat(yn.amount)||0);yn.itemType==="Payable"?Yr+=Dn:Nr+=Dn});const kn=Yr-Nr,Sn=Math.abs(kn)>0,sr=(As==null?void 0:As.status)||"Pending",wr=Sn?"Dues Pending":sr==="Cleared"?"NOC Submitted":sr,Sr=kn>0?"payable":kn<0?"recovery":null;return{id:(As==null?void 0:As.id)||`dept-${It}`,clearanceId:(As==null?void 0:As.id)||null,departmentName:It,status:wr,duesFlow:Sr,amountType:kn>0?"Payable to dealer":kn<0?"Receivable from dealer":null,amount:Math.abs(kn),submittedDate:As!=null&&As.clearedAt?xa(As.clearedAt):"-",remarks:(As==null?void 0:As.remarks)||"-",supportingDocument:(As==null?void 0:As.supportingDocument)||null}});const Js={...wn,documents:[...(((ts=St.resignation)==null?void 0:ts.uploadedDocuments)||[]).map(It=>({id:`res-${It.id}`,name:It.fileName,type:"Resignation",uploadDate:xa(It.createdAt),status:"Verified",url:It.filePath})),...(St.clearances||[]).filter(It=>It.supportingDocument).map(It=>({id:`clr-${It.id}`,name:It.supportingDocument.split("/").pop(),type:`${It.department} Proof`,uploadDate:xa(It.clearedAt),status:"Attached",url:It.supportingDocument})),...(St.settlementDocs||[]).map(It=>({id:`set-${It.id}`,name:It.fileName,type:"Settlement Proof",uploadDate:xa(It.createdAt),status:"Finance",url:It.filePath}))],participants:St.participants||[]};i(Js);const Sa=St.bankDetails||((js=St.dealer)==null?void 0:js.bankDetails)||((jn=(vn=(tn=St.outlet)==null?void 0:tn.dealer)==null?void 0:vn.dealerProfile)==null?void 0:jn.bankDetails);Sa&&Sa.length>0?j(Sa):((gn=(xn=St.outlet)==null?void 0:xn.dealer)!=null&&gn.id||St.dealerId)&&G(((qt=(Ye=St.outlet)==null?void 0:Ye.dealer)==null?void 0:qt.id)||St.dealerId)}}catch(Ze){console.error("Fetch F&F details error:",Ze),J.error("Failed to fetch settlement details")}finally{ge&&d(!1)}},K=async()=>{try{const Je=(await Re.getAuditLogs("fnf",t)).data;Je.success&&v(Je.data||[])}catch(ge){console.error("Fetch audit logs error:",ge)}},G=async ge=>{try{const mt=(await Re.getDealerBankDetails(ge)).data;mt.success&&j(mt.bankDetails||[])}catch(Je){console.error("Fetch bank details error:",Je)}},V=async ge=>{var de,at;ge.preventDefault();const Je=new FormData(ge.currentTarget),mt=Object.fromEntries(Je.entries());try{A(!0);const ot=((at=(de=a==null?void 0:a.outlet)==null?void 0:de.dealer)==null?void 0:at.id)||(a==null?void 0:a.dealerId);if(!ot){J.error("Dealer information missing");return}(await Re.saveBankDetail(ot,{...mt,id:S==null?void 0:S.id,isPrimary:Je.get("isPrimary")==="on"})).data.success&&(J.success("Bank details saved successfully"),G(ot),C(!1),D(null))}catch{J.error("Failed to save bank details")}finally{A(!1)}},Y=async ge=>{var Je,mt;if(confirm("Are you sure you want to delete this bank account?"))try{if((await Re.deleteBankDetail(ge)).data.success){J.success("Bank detail deleted");const at=((mt=(Je=a==null?void 0:a.outlet)==null?void 0:Je.dealer)==null?void 0:mt.id)||(a==null?void 0:a.dealerId);at&&G(at)}}catch{J.error("Failed to delete bank detail")}};if(o)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})});if(!a)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-slate-600",children:"Case not found"}),e.jsx(te,{onClick:s,className:"mt-4",children:"Go Back"})]});const ae=(ge=>{const Je=new Date(ge),de=Math.abs(new Date().getTime()-Je.getTime());return Math.ceil(de/(1e3*60*60*24))})(a.submittedOn),ue=ge=>{if(!a||!ge)return!1;const Je=String((n==null?void 0:n.role)||"").toLowerCase();if(!Je||ge.status!=="Pending")return!1;const de=["Finance Approval","Completed"].includes(a.status),at=Je.includes("super admin")||Je.includes("finance")||Je.includes("dd admin");if(de&&!at)return!1;if(at)return!0;const ot=ge.departmentName.replace(" Department","").toLowerCase();return Je.includes(ot)},ye=((a==null?void 0:a.departmentResponses)||[]).some(ge=>ue(ge)),ce=async()=>{var ge;if(!(O!=null&&O.clearanceId)||!t){J.error("Clearance record not available for this department");return}try{L(!0);const Je=new FormData,mt=Number($.amount)>0?"Dues Pending":"NOC Submitted";Je.append("status",mt),Je.append("remarks",$.remarks),Je.append("amount",String($.amount)),Je.append("type",$.type),Q&&Je.append("file",Q);const de=await Re.updateFnFClearance(t,O.clearanceId,Je);if(!de.ok){J.error(((ge=de.data)==null?void 0:ge.message)||"Failed to update department clearance"),L(!1);return}J.success(`Clearance updated for ${O.departmentName}`),q(!1),W(null),f("departments"),I(!1)}catch(Je){console.error("Update clearance error:",Je),J.error("Failed to update department clearance")}finally{L(!1)}},je=()=>{J.success("Notifications sent to all 16 departments"),h(!1)},Me=ge=>{switch(ge){case"New":return"bg-red-50 text-blue-700 border-blue-300";case"In Progress":return"bg-yellow-100 text-yellow-700 border-yellow-300";case"Under Review":return"bg-orange-100 text-orange-700 border-orange-300";case"Completed":return"bg-green-100 text-green-700 border-green-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},ut=ge=>{switch(ge){case"NOC Submitted":return"bg-green-100 text-green-700 border-green-300";case"Dues Pending":return"bg-red-100 text-red-700 border-red-300";case"Pending":return"bg-slate-100 text-slate-700 border-slate-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},jt=a.departmentResponses.filter(ge=>ge.status!=="Pending").length,ft=a.departmentResponses.length,X=jt/ft*100,Ce=OS.map(ge=>{const Je=(a.departmentResponses||[]).find(fs=>fs.departmentName===ge),mt=Number(Je==null?void 0:Je.amount)||0,de=(Je==null?void 0:Je.amountType)||"-",at=(a.allLineItems||[]).filter(fs=>U(fs.department)===ge),ot=at.filter(fs=>fs.sourceType==="FinanceValidated"&&fs.itemType==="Payable").reduce((fs,Vs)=>fs+Math.abs(parseFloat(Vs.amount)||0),0),ke=at.filter(fs=>fs.sourceType==="FinanceValidated"&&(fs.itemType==="Receivable"||fs.itemType==="Recovery")).reduce((fs,Vs)=>fs+Math.abs(parseFloat(Vs.amount)||0),0),Zt=at.filter(fs=>fs.sourceType==="FinanceValidated"&&fs.itemType==="Deduction").reduce((fs,Vs)=>fs+Math.abs(parseFloat(Vs.amount)||0),0),Bt=ot-ke-Zt,_s=Math.abs(Bt),Us=Bt>0?"Payable":Bt<0?"Receivable":"-";return{department:ge,claimAmount:mt,claimType:de,validatedAmount:_s,validatedType:Us,variance:_s-mt}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(_e,{className:`border-none shadow-md bg-gradient-to-r ${(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"from-red-600 to-red-500":"from-green-600 to-green-500"} text-white`,children:e.jsxs(Oe,{className:"p-6 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-white/20 rounded-full",children:e.jsx(ck,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white/80 text-sm font-medium",children:"Net Settlement Balance"}),e.jsxs("h2",{className:"text-3xl font-bold",children:["₹",Math.abs(a.netAmount||0).toLocaleString()]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx(we,{className:"bg-white/20 hover:bg-white/30 text-white border-none px-4 py-1 mb-2",children:(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"Receivable from Dealer":"Payable to Dealer"}),e.jsx("p",{className:"text-xs text-white/70",children:a.status==="Completed"?"Settlement Finalized":"Draft Calculation"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:a.caseNumber}),e.jsx("p",{className:"text-slate-600",children:a.dealerName})]}),e.jsx(we,{className:Me(a.status),children:a.status}),e.jsx(we,{className:a.requestType==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300",children:a.requestType})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(te,{variant:"outline",onClick:()=>r(`/worknotes/fnf/${t}`,{state:{applicationName:a.dealerName||"F&F Settlement",registrationNumber:a.caseNumber||"",participants:a.participants||[]}}),children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Overall Progress"}),e.jsxs(es,{children:["Department responses: ",jt," / ",ft]})]}),e.jsxs(Oe,{children:[e.jsx(oc,{value:X,className:"h-3"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"NOC Submitted"}),e.jsx("p",{className:"text-2xl text-green-600",children:a.departmentResponses.filter(ge=>ge.status==="NOC Submitted").length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Dues Pending"}),e.jsx("p",{className:"text-2xl text-red-600",children:a.departmentResponses.filter(ge=>ge.status==="Dues Pending").length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Pending"}),e.jsx("p",{className:"text-2xl text-slate-600",children:a.departmentResponses.filter(ge=>ge.status==="Pending").length})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Finance Status"}),e.jsx("p",{className:"text-lg",children:a.financeReportStatus})]})]})]})]}),e.jsxs(In,{value:m,onValueChange:f,className:"w-full",children:[e.jsxs(Mn,{children:[e.jsx(Ht,{value:"progress",children:"Progress"}),e.jsx(Ht,{value:"details",children:"Case Details"}),e.jsx(Ht,{value:"departments",children:"Department Responses"}),e.jsx(Ht,{value:"documents",children:"Documents"}),e.jsx(Ht,{value:"audit",children:"Audit Trail"})]}),e.jsx(Vt,{value:"progress",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"F&F Settlement Progress"}),e.jsx(es,{children:"Track the complete journey from initiation to completion"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-green-100 border-2 border-green-600 flex items-center justify-center",children:e.jsx($n,{className:"w-6 h-6 text-green-600"})}),e.jsx("div",{className:"w-0.5 h-full bg-green-300 mt-2"})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"F&F Initiated"}),e.jsx(we,{className:"bg-green-600",children:"Completed"})]}),e.jsx("span",{className:"text-sm text-slate-600",children:a.submittedOn})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Full & Final settlement process has been initiated. Case created and basic information collected."}),e.jsx(_e,{className:"bg-green-50 border-green-200",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{className:"text-slate-900",children:a.requestType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer"}),e.jsx("p",{className:"text-slate-900",children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:a.location})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-100 border-green-600":jt>0?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:jt===ft||["Finance Approval","Completed"].includes(a.status)?e.jsx($n,{className:"w-6 h-6 text-green-600"}):jt>0?e.jsx(ja,{className:"w-6 h-6 text-re-red"}):e.jsx(dn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Department Responses Received"}),e.jsx(we,{className:jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-600":jt>0?"bg-re-red":"bg-slate-400",children:jt===ft||["Finance Approval","Completed"].includes(a.status)?"Completed":jt>0?"In Progress":"Pending"})]})}),e.jsxs("p",{className:"text-slate-600 text-sm mb-3",children:["All stakeholder departments submit their NOC or dues information.",jt>0&&` (${jt}/${ft} responses received)`]}),jt>0&&e.jsx(_e,{className:jt===ft||["Finance Approval","Completed"].includes(a.status)?"bg-green-50 border-green-200":"bg-blue-50 border-red-200",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Progress"}),e.jsxs("span",{className:"text-sm",children:[jt," / ",ft," ","departments"]})]}),e.jsx(oc,{value:X,className:"h-2"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[e.jsxs("div",{className:"text-center p-2 bg-green-100 rounded",children:[e.jsx("p",{className:"text-green-700",children:"NOC Submitted"}),e.jsx("p",{className:"text-green-900",children:a.departmentResponses.filter(ge=>ge.status==="NOC Submitted").length})]}),e.jsxs("div",{className:"text-center p-2 bg-red-100 rounded",children:[e.jsx("p",{className:"text-red-700",children:"Dues Pending"}),e.jsx("p",{className:"text-red-900",children:a.departmentResponses.filter(ge=>ge.status==="Dues Pending").length})]}),e.jsxs("div",{className:"text-center p-2 bg-slate-100 rounded",children:[e.jsx("p",{className:"text-slate-700",children:"Pending"}),e.jsx("p",{className:"text-slate-900",children:a.departmentResponses.filter(ge=>ge.status==="Pending").length})]})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":a.status==="Finance Approval"?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx($n,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(hu,{className:"w-6 h-6 text-re-red"}):e.jsx(dn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${a.status==="Completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Finance Final Summary"}),e.jsx(we,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-re-red":"bg-slate-400",children:a.status==="Completed"?"Completed":a.status==="Finance Approval"?"In Progress":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Finance department consolidates all department responses and prepares final settlement summary with total payable and recovery amounts."}),["Finance Approval","Completed"].includes(a.status)&&e.jsx(_e,{className:a.status==="Completed"?"bg-green-50 border-green-200":"bg-blue-50 border-red-200",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-3 bg-green-100 rounded-lg",children:[e.jsx("p",{className:"text-xs text-green-700 mb-1",children:"Payable Amount"}),e.jsxs("p",{className:"text-green-900",children:["₹",((xe=a.totalPayableAmount)==null?void 0:xe.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-red-100 rounded-lg",children:[e.jsx("p",{className:"text-xs text-red-700 mb-1",children:"Receivable amount"}),e.jsxs("p",{className:"text-red-900",children:["₹",((We=a.totalRecoveryAmount)==null?void 0:We.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-red-50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-blue-700 mb-1",children:"Net Amount"}),e.jsxs("p",{className:(a.totalRecoveryAmount||0)>(a.totalPayableAmount||0)?"text-red-900":"text-green-900",children:["₹",Math.abs((a.totalRecoveryAmount||0)-(a.totalPayableAmount||0)).toLocaleString()]})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":a.status==="Finance Approval"?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx($n,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(li,{className:"w-6 h-6 text-re-red"}):e.jsx(dn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${a.status==="Completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Financial Discussion with Dealer"}),e.jsx(we,{className:a.status==="Completed"?"bg-green-600":a.status==="Finance Approval"?"bg-re-red":"bg-slate-400",children:a.status==="Completed"?"Completed":a.status==="Finance Approval"?"In Progress":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Finance team, legal team, and relevant departments discuss final settlement with the dealer. Dealer reviews and agrees to the financial terms."}),a.status==="Finance Approval"&&e.jsx(_e,{className:"bg-orange-50 border-orange-200",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-orange-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-orange-900 mb-1",children:"Ongoing Discussions"}),e.jsx("p",{className:"text-xs text-orange-700",children:"Negotiations in progress regarding recovery/payable amounts. Finance team is working with departments and dealer to resolve discrepancies."})]})]})})})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx($n,{className:"w-6 h-6 text-green-600"}):e.jsx(dn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${a.status==="Completed"?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:"flex-1 pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Full and Final Settlement"}),e.jsx(we,{className:a.status==="Completed"?"bg-green-600":"bg-slate-400",children:a.status==="Completed"?"Completed":"Pending"})]})}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"All financial settlements are processed. Payments made or recoveries completed as per agreed terms. All documentation finalized."})]})]}),e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsx("div",{className:"flex shrink-0 flex-col items-center",children:e.jsx("div",{className:`size-12 shrink-0 aspect-square rounded-full flex items-center justify-center border-2 ${a.status==="Completed"?"bg-green-100 border-green-600":"bg-slate-100 border-slate-300"}`,children:a.status==="Completed"?e.jsx(Hn,{className:"w-6 h-6 text-green-600"}):e.jsx(dn,{className:"w-6 h-6 text-slate-400"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-slate-900",children:"F&F Complete"}),e.jsx(we,{className:a.status==="Completed"?"bg-green-600":"bg-slate-400",children:a.status==="Completed"?"Completed":"Pending"})]}),a.status==="Completed"&&e.jsx("span",{className:"text-sm text-slate-600",children:a.settlementDate||"Oct 15, 2025"})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-3",children:"Full & Final settlement process completed successfully. Case closed. All obligations fulfilled."}),a.status==="Completed"&&e.jsx(_e,{className:"bg-gradient-to-r from-green-50 to-blue-50 border-green-300",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-green-600 flex items-center justify-center",children:e.jsx(Hn,{className:"w-7 h-7 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-green-900",children:"Settlement Successfully Completed"}),e.jsxs("p",{className:"text-xs text-green-700 mt-1",children:["All processes completed. Case Number:"," ",a.caseNumber]})]})]})})})]})]})]})})})]})}),e.jsxs(Vt,{value:"details",className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Basic Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:a.dealerCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:a.dealershipName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:a.location})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{children:a.requestType})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:a.originalRequestId})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:a.submittedOn})]})]})})]}),e.jsxs(_e,{className:"border-red-200 bg-blue-50/30",children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-blue-900",children:"F&F Settlement Information"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:a.lastOperationalDateSales})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:a.lastOperationalDateServices})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Submitted Date (F&F Start)"}),e.jsx("p",{children:a.submittedOn})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Days Elapsed since Submission"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{children:[ae," days"]}),e.jsx(we,{variant:"outline",className:ae<30?"bg-green-100 text-green-700 border-green-300":ae<60?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-red-100 text-red-700 border-red-300",children:ae<30?"Recent":ae<60?"In Progress":"Overdue"})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:a.typeOfClosure})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:a.gst})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:a.salesCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:a.serviceCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:a.gearCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:a.gmaCode})]})]})})]}),a.status==="Under Review"&&e.jsxs(_e,{className:"border-orange-200 bg-orange-50",children:[e.jsxs(Xe,{children:[e.jsx(st,{className:"text-orange-900",children:"Under Review"}),e.jsx(es,{className:"text-orange-700",children:"This case is under negotiation/discussion with the dealer, finance team, legal team, and relevant departments"})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-orange-800",children:"Discussions ongoing regarding recovery/payable amounts. Finance team is working with departments to resolve discrepancies."})})]})]}),e.jsxs(Vt,{value:"departments",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{children:["Department Responses (",jt," / ",ft,")"]}),e.jsx(es,{children:"Status of NOC and dues from all departments"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Amount Type"}),e.jsx(me,{children:"Amount"}),e.jsx(me,{children:"Submitted Date"}),e.jsx(me,{children:"Remarks"}),ye&&e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a.departmentResponses.map(ge=>e.jsxs(lt,{children:[e.jsx(oe,{children:ge.departmentName}),e.jsx(oe,{children:e.jsx(we,{className:ut(ge.status),children:ge.status})}),e.jsx(oe,{children:ge.amountType?e.jsx(we,{variant:"outline",className:ge.duesFlow==="recovery"?"bg-red-100 text-red-900 border-red-400 font-semibold":"bg-emerald-100 text-emerald-900 border-emerald-400 font-semibold",children:ge.amountType}):"-"}),e.jsx(oe,{children:ge.amount?e.jsxs("span",{className:`font-semibold tabular-nums ${ge.duesFlow==="recovery"?"text-red-700":"text-emerald-700"}`,children:["₹",ge.amount.toLocaleString()]}):"-"}),e.jsx(oe,{children:ge.submittedDate||"-"}),e.jsx(oe,{className:"max-w-xs truncate",children:ge.remarks||"-"}),ye&&e.jsx(oe,{children:ue(ge)?e.jsx(te,{variant:"ghost",size:"sm",className:"text-re-red hover:text-blue-700",onClick:()=>{R(ge),Z({remarks:ge.remarks==="-"?"":ge.remarks,amount:ge.amount||0,type:ge.duesFlow==="payable"?"Payable":"Receivable"}),W(null),q(!0)},children:"Action"}):e.jsx("span",{className:"text-slate-400 text-sm",children:"-"})})]},ge.id))})]})})]}),e.jsxs(_e,{className:"border-blue-200 bg-blue-50 mt-6",children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Department Claim vs Finance Validation"}),e.jsx(es,{children:"Final settlement totals are based on finance validated values."})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Department Claim"}),e.jsx(me,{children:"Finance Validated"}),e.jsx(me,{children:"Variance"})]})}),e.jsx(Bs,{children:Ce.map(ge=>e.jsxs(lt,{children:[e.jsx(oe,{children:ge.department}),e.jsx(oe,{children:ge.claimAmount>0?`${ge.claimType} ₹${ge.claimAmount.toLocaleString()}`:"-"}),e.jsx(oe,{children:ge.validatedAmount>0?`${ge.validatedType} ₹${ge.validatedAmount.toLocaleString()}`:"-"}),e.jsx(oe,{className:ge.variance===0?"text-slate-600":ge.variance>0?"text-red-600":"text-green-600",children:ge.claimAmount===0&&ge.validatedAmount===0?"-":`₹${ge.variance.toLocaleString()}`})]},ge.department))})]})})]}),e.jsxs(_e,{className:"mt-6",children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Financial Summary"}),e.jsx(es,{children:"Consolidated view of all payable and receivable amounts"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"p-6 bg-green-50 rounded-lg border border-green-200",children:[e.jsx("p",{className:"text-sm text-green-700 mb-2",children:"Total Payable Amount"}),e.jsxs("p",{className:"text-3xl text-green-600",children:["₹",((Be=a.totalPayableAmount)==null?void 0:Be.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-green-600 mt-1",children:"Amount to be paid to dealer"})]}),e.jsxs("div",{className:"p-6 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-red-700 mb-2",children:"Total receivable amount"}),e.jsxs("p",{className:"text-3xl text-red-600",children:["₹",((rt=a.totalRecoveryAmount)==null?void 0:rt.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-red-600 mt-1",children:"Amount receivable from dealer"})]}),e.jsxs("div",{className:"p-6 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-re-red-hover mb-2",children:"Total Deductions"}),e.jsxs("p",{className:"text-3xl text-re-red font-bold",children:["₹",((ht=a.totalDeductions)==null?void 0:ht.toLocaleString())||"0"]}),e.jsx("p",{className:"text-xs text-re-red mt-1",children:"Warranty holdbacks / Policy penalties"})]}),e.jsxs("div",{className:"p-6 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"Net Settlement Amount"}),e.jsxs("p",{className:`text-3xl font-extrabold ${(a.netAmount||0)<0?"text-red-600":"text-green-600"}`,children:["₹",Math.abs(a.netAmount||0).toLocaleString()]}),e.jsx("p",{className:"text-xs text-blue-600 mt-1",children:(a.netAmount||0)<0?"Receivable from dealer":"Payment to dealer"})]})]})})]}),e.jsxs(_e,{className:"mt-6",children:[e.jsx(Xe,{children:e.jsx(st,{children:"Finance Report Status"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(we,{className:a.financeReportStatus==="Completed"?"bg-green-100 text-green-700 border-green-300":a.financeReportStatus==="In Progress"?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-slate-100 text-slate-700 border-slate-300",children:a.financeReportStatus}),a.financeReportStatus==="Pending"&&e.jsx("p",{className:"text-slate-600 text-sm",children:"Waiting for all department responses before finance can prepare final report"}),a.financeReportStatus==="In Progress"&&e.jsx("p",{className:"text-slate-600 text-sm",children:"Finance team is reviewing department responses and preparing final settlement report"})]}),a.financeRemarks&&e.jsxs("div",{className:"mt-4 p-4 bg-slate-50 rounded-lg",children:[e.jsx(le,{className:"text-slate-600",children:"Finance Remarks"}),e.jsx("p",{className:"mt-1",children:a.financeRemarks})]})]})]})]}),e.jsx(Vt,{value:"documents",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Documents"}),e.jsx(es,{children:"All NOC documents and due statements from departments"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Upload Date"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a.documents.map(ge=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:ge.name})]})}),e.jsx(oe,{children:ge.type}),e.jsx(oe,{children:ge.uploadDate}),e.jsx(oe,{children:e.jsx(we,{variant:ge.status==="Verified"?"default":"secondary",children:ge.status})}),e.jsx(oe,{children:e.jsx(te,{size:"sm",variant:"outline",onClick:()=>{const Je=ge.url,mt=Je.startsWith("/uploads/")&&!Je.startsWith("/uploads/documents/")?Je.replace("/uploads/","/uploads/documents/"):Je;u({fileName:ge.name,filePath:mt,documentType:ge.type})},children:"View"})})]},ge.id))})]})})]})}),e.jsx(Vt,{value:"bank",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Bank Details"}),e.jsx(es,{children:"Dealer bank accounts for settlement disbursement"})]}),e.jsxs(te,{onClick:()=>{D(null),C(!0)},className:"bg-re-red",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Account"]})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.length>0?w.map(ge=>e.jsxs(_e,{className:`relative overflow-hidden ${ge.isPrimary?"border-re-red bg-blue-50/30":""}`,children:[ge.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-re-red text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-red-50 rounded-lg",children:e.jsx(to,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-900",children:ge.bankName}),e.jsx("p",{className:"text-xs text-slate-500",children:ge.branchName})]})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Holder"}),e.jsx("p",{className:"text-sm font-medium",children:ge.accountHolderName})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Number"}),e.jsx("p",{className:"text-sm font-mono tracking-wider",children:ge.accountNumber.replace(/.(?=.{4})/g,"*")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold",children:"IFSC"}),e.jsx("p",{className:"text-sm font-mono",children:ge.ifscCode})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(te,{variant:"ghost",size:"sm",className:"h-8 text-re-red",onClick:()=>{D(ge),C(!0)},children:[e.jsx(ry,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(te,{variant:"ghost",size:"sm",className:"h-8 text-red-600",onClick:()=>Y(ge.id),children:[e.jsx(Zn,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})]},ge.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(to,{className:"w-12 h-12 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-600",children:"No bank details found"}),e.jsx(te,{variant:"link",onClick:()=>C(!0),children:"Add first bank account"})]})})})]})}),e.jsx(Vt,{value:"audit",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Audit Trail"}),e.jsx(es,{children:"Complete history of actions on this F&F case"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:N.length>0?N.map(ge=>{var Je,mt,de,at,ot,ke;return e.jsxs("div",{className:"flex gap-3 pb-4 border-b border-slate-100 last:border-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-400 mt-2"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("p",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[ge.action==="FNF_CREATED"&&e.jsx(we,{className:"bg-re-red h-2 w-2 p-0 rounded-full"}),ge.description&&!((Je=ge.newData)!=null&&Je.action)?ge.description:e.jsxs(e.Fragment,{children:[F(((mt=ge.newData)==null?void 0:mt.action)||ge.action),((de=ge.newData)==null?void 0:de.department)&&e.jsxs("span",{className:"text-re-red ml-1 font-bold",children:["- ",ge.newData.department]})]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:xa(ge.createdAt||ge.timestamp)})]}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-slate-600 mb-2",children:e.jsx(we,{variant:"outline",className:"text-[10px] uppercase",children:((at=ge.actor)==null?void 0:at.name)||ge.userName||"System"})}),(((ot=ge.newData)==null?void 0:ot.remarks)||ge.remarks)&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 border border-slate-200 rounded text-sm text-slate-700",children:((ke=ge.newData)==null?void 0:ke.remarks)||ge.remarks}),ge.newData&&Object.keys(ge.newData).filter(Zt=>Zt!=="remarks"&&Zt!=="status"&&Zt!=="action"&&Zt!=="department").length>0&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold px-1",children:"Changes:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(ge.newData).filter(([Zt])=>Zt!=="remarks"&&Zt!=="action"&&Zt!=="department").map(([Zt,Bt])=>e.jsxs("div",{className:"text-[11px] bg-slate-100 border rounded px-2 py-0.5 flex items-center gap-1",children:[e.jsxs("span",{className:"text-slate-500",children:[Zt,":"]}),e.jsx("span",{className:"text-slate-900 font-medium",children:String(Bt)})]},Zt))})]})]})]},ge.id)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})})]}),e.jsx(ms,{open:p,onOpenChange:h,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Send to All Stakeholders"}),e.jsx(ws,{children:"This will send notifications to all 16 departments to submit their NOC or dues information"})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 bg-blue-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-blue-900 mb-2",children:"Notifications will be sent to:"}),e.jsxs("ul",{className:"text-sm text-blue-800 space-y-1 ml-4",children:[e.jsx("li",{children:"• All 16 departments"}),e.jsxs("li",{children:["• Case Number: ",a.caseNumber]}),e.jsxs("li",{children:["• Dealer: ",a.dealerName]}),e.jsxs("li",{children:["• Type: ",a.requestType]})]})]})}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(te,{onClick:je,className:"bg-re-red hover:bg-blue-700",children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Send Notifications"]})]})]})}),e.jsx(ms,{open:E,onOpenChange:q,children:e.jsxs(us,{className:"sm:max-w-[460px]",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:["Update ",O==null?void 0:O.departmentName," Response"]}),e.jsx(ws,{children:"Provide dues/NOC response with remarks and optional supporting proof."})]}),e.jsxs("div",{className:"grid gap-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"type",className:"text-right",children:"Type"}),e.jsxs("select",{id:"type",className:"col-span-3 flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:$.type,onChange:ge=>Z({...$,type:ge.target.value}),children:[e.jsx("option",{value:"Receivable",children:"Receivable (from dealer)"}),e.jsx("option",{value:"Payable",children:"Payable (to dealer)"}),e.jsx("option",{value:"Deduction",children:"Deduction"})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"amount",className:"text-right",children:"Amount"}),e.jsxs("div",{className:"col-span-3 relative",children:[e.jsx("span",{className:"absolute left-3 top-2.5 text-slate-500 font-medium",children:"₹"}),e.jsx("input",{id:"amount",type:"number",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white pl-7 pr-3 py-2 text-sm",value:$.amount,onChange:ge=>Z({...$,amount:Number(ge.target.value)})})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"remarks",className:"text-right",children:"Remarks"}),e.jsx("textarea",{id:"remarks",className:"col-span-3 flex min-h-[80px] w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",placeholder:"Add response details...",value:$.remarks,onChange:ge=>Z({...$,remarks:ge.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{htmlFor:"proof",className:"text-right",children:"Proof"}),e.jsx("input",{id:"proof",type:"file",className:"col-span-3 text-sm",onChange:ge=>{var Je;return W(((Je=ge.target.files)==null?void 0:Je[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-blue-700",onClick:ce,disabled:P,children:P?"Saving...":"Submit Response"})]})]})}),e.jsx(f_,{isOpen:b,onClose:()=>{C(!1),D(null)},onSubmit:V,editingBank:S,isSubmitting:_}),e.jsx(ho,{isOpen:!!x,onClose:()=>u(null),document:x})]})}function CV({onViewPaymentDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState("pending");g.useEffect(()=>{d()},[]);const d=async()=>{try{a(!0);const u=await ps.getApplications();n(u.data||[])}catch(u){console.error("Fetch error:",u),J.error("Failed to fetch applications")}finally{a(!1)}},m=u=>String(u||"").trim().toLowerCase(),f=u=>{const N=m(u);return N==="verified"||N==="paid"},p=s.flatMap(u=>{const N=u.overallStatus||u.status,v=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(N),w=u.securityDeposits||[];return w.length>0?w.map(j=>({id:j.id,applicationId:u.applicationId||u.id,application:u,paymentStatus:j.status,paymentType:j.depositType,amount:j.amount,createdAt:j.createdAt,verificationDate:j.verifiedAt,isVirtual:!1})):v?["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(N)?[{id:`virtual-${u.id}-sd`,applicationId:u.applicationId||u.id,application:u,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:u.updatedAt,verificationDate:null,isVirtual:!0}]:[{id:`virtual-${u.id}-ff`,applicationId:u.applicationId||u.id,application:u,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:u.updatedAt,verificationDate:null,isVirtual:!0}]:[]}),h=p.filter(u=>i==="all"?!0:i==="pending"?!f(u.paymentStatus):i==="verified"?f(u.paymentStatus):!0),x=u=>{t&&t(u)};return r?e.jsxs("div",{className:"flex items-center justify-center p-20 text-blue-600",children:[e.jsx(dn,{className:"w-8 h-8 animate-spin mr-3"}),e.jsx("span",{children:"Loading Finance Queue..."})]}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white p-6 rounded-2xl border border-slate-100 shadow-sm",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 tracking-tight mb-1",children:"Payment Verification"}),e.jsx("p",{className:"text-slate-500",children:"Review and verify Security Deposit and First Fill payments for dealers"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(te,{onClick:d,variant:"outline",size:"sm",className:"bg-white hover:bg-slate-50","data-testid":"onboarding-finance-queue-sync-btn",children:[e.jsx(dn,{className:"w-4 h-4 mr-2"}),"Sync Dashboard"]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsx("div",{className:"inline-flex p-1 bg-slate-100 rounded-xl",children:e.jsxs("div",{className:"flex items-center px-4 py-2 bg-white rounded-lg text-slate-900 shadow-sm font-medium text-sm","data-testid":"onboarding-finance-queue-pending-count",children:[e.jsx(ya,{className:"w-4 h-4 mr-2 text-blue-600"}),"Pending Payments (",p.filter(u=>!f(u.paymentStatus)).length,")"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(te,{variant:i==="pending"?"secondary":"ghost",size:"sm",onClick:()=>o("pending"),className:i==="pending"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-pending",children:"Pending"}),e.jsx(te,{variant:i==="verified"?"secondary":"ghost",size:"sm",onClick:()=>o("verified"),className:i==="verified"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-verified",children:"Verified"}),e.jsx(te,{variant:i==="all"?"secondary":"ghost",size:"sm",onClick:()=>o("all"),className:i==="all"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-all",children:"All"})]})]}),e.jsx(_e,{className:"border-none shadow-xl overflow-hidden rounded-2xl bg-white","data-testid":"onboarding-finance-queue-table-card",children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ms,{children:[e.jsx(Fs,{className:"bg-slate-50/50",children:e.jsxs(lt,{className:"border-b border-slate-100 uppercase text-[10px] tracking-wider font-bold text-slate-400",children:[e.jsx(me,{className:"py-4 pl-6","data-testid":"onboarding-finance-queue-th-details",children:"Application Details"}),e.jsx(me,{"data-testid":"onboarding-finance-queue-th-location",children:"Location"}),e.jsx(me,{"data-testid":"onboarding-finance-queue-th-stage",children:"Payment Stage"}),e.jsx(me,{"data-testid":"onboarding-finance-queue-th-status",children:"Current Status"}),e.jsx(me,{className:"text-right pr-6","data-testid":"onboarding-finance-queue-th-action",children:"Workflow Action"})]})}),e.jsx(Bs,{children:h.length>0?h.map((u,N)=>{const v=u.paymentStatus||"Awaiting Payment",w=u.application||{};return e.jsxs(lt,{className:"hover:bg-blue-50/20 group transition-all","data-testid":`onboarding-finance-queue-row-${N}`,children:[e.jsx(oe,{className:"py-4 pl-6",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-blue-600 mb-1","data-testid":`onboarding-finance-queue-app-id-${N}`,children:w.applicationId||w.id}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-finance-queue-name-${N}`,children:w.applicantName})})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-col text-sm","data-testid":`onboarding-finance-queue-location-${N}`,children:[e.jsx("span",{className:"text-slate-600 leading-none",children:w.city}),e.jsx("span",{className:"text-slate-400 text-xs mt-1",children:w.state})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2","data-testid":`onboarding-finance-queue-type-${N}`,children:[e.jsx(Wu,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-sm font-medium",children:u.paymentType==="SECURITY_DEPOSIT"?"Security Deposit (₹5L)":"First Fill (₹15L)"})]})}),e.jsx(oe,{children:e.jsx(we,{className:v==="Verified"?"bg-emerald-50 text-emerald-700 border-emerald-100 px-3 py-1 rounded-full":v==="Rejected"?"bg-rose-50 text-rose-700 border-rose-100 px-3 py-1 rounded-full":"bg-red-50 text-re-red-hover border-red-100 px-3 py-1 rounded-full",variant:"outline","data-testid":`onboarding-finance-queue-status-${N}`,children:v})}),e.jsx(oe,{className:"text-right pr-6",children:e.jsx(te,{size:"sm",variant:f(v)?"outline":"default",className:f(v)?"bg-white text-slate-600 border-slate-200":"bg-blue-600 hover:bg-blue-700 shadow-md",onClick:()=>x(u.applicationId||w.id),"data-testid":`onboarding-finance-queue-action-btn-${N}`,children:e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),f(v)?"View Receipt":"Record Payment"]})})})]},u.id)}):e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"h-48 text-center text-slate-400 py-10","data-testid":"onboarding-finance-queue-empty",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-50 rounded-full flex items-center justify-center",children:e.jsx(ln,{className:"w-6 h-6 text-slate-200"})}),e.jsx("p",{className:"text-sm",children:i==="verified"?"No verified payments found":i==="pending"?"No pending payments in the queue":"No onboarding payments found"})]})})})})]})})})]})}function AV({onViewFnFDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[i,o]=g.useState(null),[d,m]=g.useState(!1),[f,p]=g.useState(!1),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState("all");g.useEffect(()=>{j()},[]);const j=async()=>{try{a(!0);const P=(await Re.getFnFSettlements()).data;P.success&&n(P.settlements||[])}catch(R){console.error("Fetch settlements error:",R),J.error("Failed to fetch settlement cases")}finally{a(!1)}},b=R=>{var P,L,$,Z,Q,W,U,M,z,T,F,I;return{id:R.id,caseId:R.settlementId||((P=R.resignation)==null?void 0:P.resignationId)||((L=R.terminationRequest)==null?void 0:L.requestId)||R.id.substring(0,8),dealerCode:(($=R.outlet)==null?void 0:$.code)||((Q=(Z=R.dealer)==null?void 0:Z.dealerCode)==null?void 0:Q.dealerCode)||"N/A",dealerName:((U=(W=R.outlet)==null?void 0:W.dealer)==null?void 0:U.fullName)||((M=R.dealer)==null?void 0:M.legalName)||((z=R.dealer)==null?void 0:z.businessName)||((T=R.dealer)==null?void 0:T.fullName)||"N/A",location:((F=R.outlet)==null?void 0:F.city)||((I=R.outlet)==null?void 0:I.location)||"N/A",terminationType:R.resignationId?"Resignation":"Termination",submittedDate:Qt(R.createdAt),status:R.status==="Calculated"?"Pending Finance Review":R.status==="Settled"?"Settled":R.status,financialData:{totalPayables:parseFloat(R.totalPayables)||0,totalReceivables:parseFloat(R.totalReceivables)||0,netAmount:parseFloat(R.netAmount)||0},settlementAmount:Math.abs(parseFloat(R.netAmount)||0),settlementType:parseFloat(R.netAmount)>0?"Payable to Dealer":"Receivable from Dealer",approvedDate:R.settlementDate?Qt(R.settlementDate):null}},C=s.map(b),S=C.filter(R=>v==="all"?!0:v==="pending"?R.status==="Pending Finance Review"||R.status==="Calculated"||R.status==="Initiated"||R.status==="Under Review":v==="approved"?R.status==="Settled"||R.status==="Completed":!0),D=R=>({receivables:R.totalReceivables||0,payables:R.totalPayables||0,deductions:0,netSettlement:R.netAmount||0,settlementType:(R.netAmount||0)>0?"Payable to Dealer":"Receivable from Dealer",settlementAmount:Math.abs(R.netAmount||0)}),_=R=>{t?t(R.id):(o(R),m(!0))},A=R=>{t?t(R.id):(o(R),p(!0))},E=()=>{const R=D(i.financialData);J.success(`Settlement approved: ${R.settlementType} - ₹${R.settlementAmount.toLocaleString()}`),m(!1),x(""),N(""),o(null)},q=C.filter(R=>R.status==="Pending Finance Review"||R.status==="Calculated"||R.status==="Initiated"||R.status==="Under Review").length,O=C.filter(R=>R.status==="Settled"||R.status==="Completed").length;return r?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"F&F Financial Settlement"}),e.jsx("p",{className:"text-slate-600",children:"Review and process full & final settlements for dealerships"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Pending Review"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:q}),e.jsx(rk,{className:"w-8 h-8 text-re-red"})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Approved Settlements"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:O}),e.jsx(ln,{className:"w-8 h-8 text-green-600"})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Total Cases"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:C.length}),e.jsx(ks,{className:"w-8 h-8 text-blue-600"})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{className:"pb-3",children:e.jsx(st,{className:"text-sm text-slate-600",children:"Net Financial Position"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`text-2xl ${C.reduce((R,P)=>R+(P.financialData.netAmount||0),0)<0?"text-green-600":"text-red-600"}`,children:["₹",Math.abs(C.reduce((R,P)=>R+(P.financialData.netAmount||0),0)).toLocaleString("en-IN")]}),e.jsx(ll,{className:"w-8 h-8 text-purple-600"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:C.reduce((R,P)=>R+(P.financialData.netAmount||0),0)<0?"Net Receivable":"Net Payable"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(te,{variant:v==="all"?"default":"outline",onClick:()=>w("all"),className:v==="all"?"bg-re-red hover:bg-re-red-hover":"",children:["All Cases (",C.length,")"]}),e.jsxs(te,{variant:v==="pending"?"default":"outline",onClick:()=>w("pending"),className:v==="pending"?"bg-re-red hover:bg-re-red-hover":"",children:["Pending Review (",q,")"]}),e.jsxs(te,{variant:v==="approved"?"default":"outline",onClick:()=>w("approved"),className:v==="approved"?"bg-re-red hover:bg-re-red-hover":"",children:["Approved (",O,")"]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"F&F Settlement Queue"}),e.jsx(es,{children:"Review financial status and calculate settlements"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Case ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Location"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Submitted Date"}),e.jsx(me,{children:"Net Settlement"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:S.map(R=>{const P=D(R.financialData);return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:R.caseId}),e.jsx("div",{className:"text-sm text-slate-500",children:R.dealerCode})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:R.dealerName})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:R.location})]})}),e.jsx(oe,{children:e.jsx(we,{variant:R.terminationType==="Resignation"?"default":"secondary",children:R.terminationType})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(er,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:R.submittedDate})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[P.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-4 h-4 text-red-600"}):e.jsx(ll,{className:"w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-slate-900",children:["₹",P.settlementAmount.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-500",children:P.settlementType})]})]})}),e.jsx(oe,{children:e.jsx(we,{variant:R.status==="Settlement Approved"?"default":"secondary",className:R.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:R.status})}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:R.status==="Pending Finance Review"?"default":"outline",className:R.status==="Pending Finance Review"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>A(R),children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"View Details"]})})]},R.id)})})]})})]}),e.jsx(ms,{open:d,onOpenChange:m,children:e.jsxs(us,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Financial Settlement Review"}),e.jsxs(ws,{children:["Review financial details and calculate final settlement for ",i==null?void 0:i.dealerName]})]}),i&&e.jsxs(In,{defaultValue:"breakdown",className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-3",children:[e.jsx(Ht,{value:"breakdown",children:"Financial Breakdown"}),e.jsx(Ht,{value:"calculation",children:"Settlement Calculation"}),e.jsx(Ht,{value:"summary",children:"Final Summary"})]}),e.jsxs(Vt,{value:"breakdown",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(_e,{className:"border-green-200 bg-green-50",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(af,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]}),e.jsx(es,{children:"Amounts company owes to dealer"})]}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Security Deposit"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.securityDeposit.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Inventory Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.inventoryValue.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Equipment Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.equipmentValue.toLocaleString()]})]}),e.jsx("div",{className:"pt-3 border-t border-green-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",(i.financialData.securityDeposit+i.financialData.inventoryValue+i.financialData.equipmentValue).toLocaleString()]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]}),e.jsx(es,{children:"Amounts dealer owes to company"})]}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Outstanding Invoices"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.outstandingInvoices.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Service Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.serviceDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Parts Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.partsDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Advances Given"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.advancesGiven.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Penalties"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.penalties.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Other Charges"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.otherCharges.toLocaleString()]})]}),e.jsx("div",{className:"pt-3 border-t border-red-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",D(i.financialData).receivables.toLocaleString()]})]})})]})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions"]}),e.jsx(es,{children:"Pending claims and deductions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600",children:"Warranty Claims Pending"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",i.financialData.warrantyPending.toLocaleString()]})]})})]})]}),e.jsx(Vt,{value:"calculation",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Settlement Calculation"}),e.jsx(es,{children:"Step-by-step calculation of final settlement amount"})]}),e.jsx(Oe,{className:"space-y-4",children:(()=>{const R=D(i.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-green-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-600 text-lg",children:["+ ₹",R.payables.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables (from Dealer)"}),e.jsxs("span",{className:"text-red-600 text-lg",children:["- ₹",R.receivables.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red text-lg",children:["- ₹",R.deductions.toLocaleString()]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsxs("div",{className:`p-4 rounded-lg ${R.netSettlement>0?"bg-red-100 border-2 border-red-300":"bg-green-100 border-2 border-green-300"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-900",children:"Net Settlement"}),e.jsxs("span",{className:"text-2xl text-slate-900",children:["₹",R.settlementAmount.toLocaleString()]})]}),e.jsx("div",{className:"flex items-center gap-2",children:R.settlementType==="Payable to Dealer"?e.jsxs(e.Fragment,{children:[e.jsx(Go,{className:"w-5 h-5 text-red-600"}),e.jsx("span",{className:"text-red-700",children:"Company needs to pay dealer"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ll,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-green-700",children:"Dealer needs to pay company"})]})})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-blue-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsx("p",{className:"text-sm text-slate-600",children:"Net Settlement = Total Payables - Total Receivables - Total Deductions"}),e.jsxs("p",{className:"text-sm text-slate-600 mt-2",children:["= ₹",R.payables.toLocaleString()," - ₹",R.receivables.toLocaleString()," - ₹",R.deductions.toLocaleString()]})]})]})]})})()})]})}),e.jsxs(Vt,{value:"summary",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Case Summary"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Case ID"}),e.jsx("p",{className:"text-slate-900",children:i.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:i.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:i.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:i.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx("p",{className:"text-slate-900",children:i.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:i.submittedDate})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Final Settlement"})}),e.jsxs(Oe,{className:"space-y-4",children:[(()=>{const R=D(i.financialData);return e.jsxs("div",{className:`p-6 rounded-lg text-center ${R.settlementType==="Payable to Dealer"?"bg-red-100 border-2 border-red-300":"bg-green-100 border-2 border-green-300"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-3",children:[R.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-8 h-8 text-red-600"}):e.jsx(ll,{className:"w-8 h-8 text-green-600"}),e.jsx("span",{className:`text-lg ${R.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:R.settlementType})]}),e.jsxs("div",{className:"text-4xl text-slate-900 mb-2",children:["₹",R.settlementAmount.toLocaleString()]}),e.jsx("p",{className:"text-slate-600",children:R.settlementType==="Payable to Dealer"?"Company will pay this amount to the dealer":"Dealer must pay this amount to the company"})]})})(),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"adjustments",children:"Adjustments (if any)"}),e.jsx(it,{id:"adjustments",value:h,onChange:R=>x(R.target.value),placeholder:"Enter any adjustments to the settlement amount"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"finalNotes",children:"Final Notes"}),e.jsx(Ks,{id:"finalNotes",value:u,onChange:R=>N(R.target.value),placeholder:"Enter any final notes or remarks for this settlement...",rows:4})]})]})]})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(te,{className:"bg-green-600 hover:bg-green-700",onClick:E,children:[e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Approve Settlement"]})]})]})}),e.jsx(ms,{open:f,onOpenChange:p,children:e.jsxs(us,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Settlement Details"}),e.jsxs(ws,{children:["Complete settlement information for ",i==null?void 0:i.dealerName]})]}),i&&e.jsxs(In,{defaultValue:"info",className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-2",children:[e.jsx(Ht,{value:"info",children:"Case Information"}),e.jsx(Ht,{value:"financial",children:"Financial Breakdown"})]}),e.jsx(Vt,{value:"info",className:"space-y-4 mt-4",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-base",children:"Case Details"})}),e.jsx(Oe,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Case ID"}),e.jsx("p",{className:"text-slate-900",children:i.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:i.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:i.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:i.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx(we,{variant:i.terminationType==="Resignation"?"default":"secondary",children:i.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Status"}),e.jsx(we,{variant:i.status==="Settlement Approved"?"default":"secondary",className:i.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:i.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:i.submittedDate})]}),i.approvedDate&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Approved Date"}),e.jsx("p",{className:"text-slate-900",children:i.approvedDate})]})]})})]})}),e.jsx(Vt,{value:"financial",className:"space-y-4 mt-4",children:(()=>{const R=D(i.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs(_e,{className:"border-green-200 bg-green-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(af,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]})}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Security Deposit"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.securityDeposit.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Inventory Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.inventoryValue.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Equipment Value"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.equipmentValue.toLocaleString()]})]}),e.jsx("div",{className:"pt-2 border-t border-green-300",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",R.payables.toLocaleString()]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]})}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Outstanding Invoices"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.outstandingInvoices.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Service Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.serviceDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Parts Dues"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.partsDues.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Advances Given"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.advancesGiven.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Penalties"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.penalties.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Other Charges"}),e.jsxs("span",{className:"text-slate-900",children:["₹",i.financialData.otherCharges.toLocaleString()]})]}),e.jsx("div",{className:"pt-2 border-t border-red-300",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",R.receivables.toLocaleString()]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:"Warranty Claims Pending"}),e.jsxs("span",{className:"text-slate-900 text-lg",children:["₹",i.financialData.warrantyPending.toLocaleString()]})]})})]}),e.jsxs(_e,{className:`${R.settlementType==="Payable to Dealer"?"border-red-300 bg-red-100":"border-green-300 bg-green-100"}`,children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-base",children:"Net Settlement"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-center py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-2",children:[R.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-6 h-6 text-red-600"}):e.jsx(ll,{className:"w-6 h-6 text-green-600"}),e.jsx("span",{className:`text-lg ${R.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:R.settlementType})]}),e.jsxs("div",{className:"text-3xl text-slate-900",children:["₹",R.settlementAmount.toLocaleString()]})]})})]})]})})()})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>p(!1),children:"Close"}),(i==null?void 0:i.status)==="Pending Finance Review"&&e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{p(!1),_(i)},children:"Review & Settle"})]})]})})]})}const $o=(...t)=>t.filter(Boolean).join(" ");function kV({applicationId:t,onBack:s}){var E,q,O,R;const[n,r]=g.useState(null),[a,i]=g.useState([]),[o,d]=g.useState("SECURITY_DEPOSIT"),[m,f]=g.useState(!0),[p,h]=g.useState(!1),[x,u]=g.useState({}),[N,v]=g.useState({verificationTransactionId:"",receivedAmount:"",receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""}),[w,j]=g.useState(!1),[b,C]=g.useState(null),S=a.find(P=>P.depositType===o);g.useEffect(()=>{D()},[t]),g.useEffect(()=>{var P,L,$;if(S)v({verificationTransactionId:S.paymentReference||"",receivedAmount:((P=S.amount)==null?void 0:P.toString())||"",receivedDate:S.verifiedAt?new Date(S.verifiedAt).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],verificationRemarks:S.remarks||""});else{const Z=((L=x.SECURITY_DEPOSIT)==null?void 0:L.amount)||5e5,Q=(($=x.FIRST_FILL)==null?void 0:$.amount)||15e5;v({verificationTransactionId:"",receivedAmount:o==="SECURITY_DEPOSIT"?Z.toString():Q.toString(),receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""})}},[o,S,x]);const D=async()=>{try{f(!0);const[P,L,$]=await Promise.all([ps.getApplicationById(t),ps.getSecurityDeposit(t),ps.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);r(P),i(Array.isArray(L)?L:[L].filter(Boolean)),u($||{})}catch(P){console.error("Fetch error:",P),J.error("Failed to load payment data")}finally{f(!1)}},_=async()=>{if(!N.verificationTransactionId||!N.receivedDate){J.error("Please fill in all required payment details");return}try{h(!0),await ps.updateSecurityDeposit({applicationId:t,depositType:o,amount:Number(N.receivedAmount),paymentReference:N.verificationTransactionId,status:"Verified"}),J.success(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} verified and approved`),await D()}catch{J.error("Failed to verify payment")}finally{h(!1)}},A=async()=>{if(!N.verificationRemarks){J.error("Please provide remarks for rejection");return}try{h(!0),await ps.updateSecurityDeposit({applicationId:t,depositType:o,status:"Rejected",remarks:N.verificationRemarks}),J.error(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} rejected`),await D()}catch{J.error("Failed to reject payment")}finally{h(!1)}};return m?e.jsx("div",{className:"flex items-center justify-center p-20",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl mb-1",children:"Payment Verification"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(te,{size:"sm",variant:o==="SECURITY_DEPOSIT"?"default":"outline",className:o==="SECURITY_DEPOSIT"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>d("SECURITY_DEPOSIT"),children:"Security Deposit"}),e.jsx(te,{size:"sm",variant:o==="FIRST_FILL"?"default":"outline",className:o==="FIRST_FILL"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>d("FIRST_FILL"),children:"First Fill"})]})]})]}),e.jsx(_e,{className:$o("border",(S==null?void 0:S.status)==="Verified"?"border-green-200 bg-green-50":((S==null?void 0:S.status)==="Rejected","border-red-200 bg-red-50")),children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:$o("w-12 h-12 rounded-full flex items-center justify-center",(S==null?void 0:S.status)==="Verified"?"bg-green-100":(S==null?void 0:S.status)==="Rejected"?"bg-red-100":"bg-red-50"),children:e.jsx(ya,{className:$o("w-6 h-6",(S==null?void 0:S.status)==="Verified"?"text-green-600":(S==null?void 0:S.status)==="Rejected"?"text-red-600":"text-re-red")})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-bold",children:o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"}),e.jsx("p",{className:"text-sm text-slate-600",children:(S==null?void 0:S.status)==="Verified"?`Verified on ${Qt(S.verifiedAt)}`:(S==null?void 0:S.status)==="Rejected"?"Payment Rejected":"Awaiting Verification"})]})]}),e.jsx(we,{className:$o((S==null?void 0:S.status)==="Verified"?"bg-green-600":(S==null?void 0:S.status)==="Rejected"?"bg-red-600":"bg-re-red text-white"),children:(S==null?void 0:S.status)||"No Record"})]})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Rr,{className:"w-5 h-5 text-re-red"}),"Applicant Information"]})}),e.jsxs(Oe,{className:"grid grid-cols-2 gap-y-4 gap-x-8",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Application ID"}),e.jsx("p",{className:"text-slate-900 font-medium",children:n.applicationId||n.id})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Applicant Name"}),e.jsx("p",{className:"text-slate-900 font-medium",children:n.applicantName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Location"}),e.jsxs("p",{className:"text-slate-900 font-medium",children:[n.city||n.preferredLocation,", ",n.state]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Email / Phone"}),e.jsx("p",{className:"text-slate-700 text-sm",children:n.email}),e.jsx("p",{className:"text-slate-700 text-sm",children:n.phone})]})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Wu,{className:"w-5 h-5 text-re-red"}),"Deposit Tracking"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg border border-slate-200",children:[e.jsx(le,{className:"text-slate-500 block mb-1",children:"Expected Amount"}),e.jsxs("p",{className:"text-2xl font-bold text-red-900",children:["₹",(o==="SECURITY_DEPOSIT"?((E=x.SECURITY_DEPOSIT)==null?void 0:E.amount)||5e5:((q=x.FIRST_FILL)==null?void 0:q.amount)||15e5).toLocaleString()]})]}),e.jsxs("div",{className:$o("p-4 rounded-lg border",(S==null?void 0:S.status)==="Verified"?"bg-green-50 border-green-200":"bg-blue-50 border-blue-200"),children:[e.jsx(le,{className:"text-slate-500 block mb-1",children:"Receipt Status"}),e.jsx("p",{className:$o("text-2xl font-bold",(S==null?void 0:S.status)==="Verified"?"text-green-700":"text-blue-700"),children:(S==null?void 0:S.status)||"Not Started"})]})]}),(S==null?void 0:S.paymentReference)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-2",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Payment Reference"}),e.jsx("p",{className:"text-slate-900 font-mono",children:S.paymentReference})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Verified By"}),e.jsx("p",{className:"text-slate-900",children:((O=S.verifier)==null?void 0:O.fullName)||"N/A"})]})]})]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2 text-xl",children:[e.jsx(ks,{className:"w-5 h-5 text-re-red"}),"Verification Evidence"]}),e.jsx(es,{children:"Documents uploaded by the applicant for payment proof"})]}),e.jsx(Oe,{children:((R=n.uploadedDocuments)==null?void 0:R.filter(P=>{var L,$,Z,Q;return o==="SECURITY_DEPOSIT"?((L=P.documentType)==null?void 0:L.toLowerCase().includes("security"))&&(($=P.documentType)==null?void 0:$.toLowerCase().includes("deposit")):((Z=P.documentType)==null?void 0:Z.toLowerCase().includes("first"))&&((Q=P.documentType)==null?void 0:Q.toLowerCase().includes("fill"))}).length)>0?e.jsx("div",{className:"space-y-3",children:n.uploadedDocuments.filter(P=>{var L,$,Z,Q;return o==="SECURITY_DEPOSIT"?((L=P.documentType)==null?void 0:L.toLowerCase().includes("security"))&&(($=P.documentType)==null?void 0:$.toLowerCase().includes("deposit")):((Z=P.documentType)==null?void 0:Z.toLowerCase().includes("first"))&&((Q=P.documentType)==null?void 0:Q.toLowerCase().includes("fill"))}).map((P,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-white rounded-lg border border-slate-200 hover:shadow-sm transition-shadow",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded bg-slate-100 flex items-center justify-center",children:e.jsx(ks,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-medium",children:P.fileName||P.name}),e.jsxs("p",{className:"text-xs text-slate-500 uppercase",children:[P.documentType," • ",Qt(P.createdAt)]})]})]}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover hover:bg-red-50",onClick:()=>{C(P),j(!0)},children:"View Receipt"})]},L))}):e.jsxs("div",{className:"text-center py-10 bg-slate-50 rounded-lg border-2 border-dashed border-slate-200",children:[e.jsx(sn,{className:"w-8 h-8 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-slate-500",children:"No payment documents found in this application."})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_e,{className:"border-red-100 shadow-sm",children:[e.jsx(Xe,{className:"bg-red-50/50",children:e.jsxs(st,{className:"flex items-center gap-2 text-lg",children:[e.jsx(af,{className:"w-5 h-5 text-re-red"}),"Finance Action"]})}),e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"verificationTxnId",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:["UTR / Reference Number ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"verificationTxnId",placeholder:"Enter Bank UTR Number",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.verificationTransactionId,onChange:P=>v({...N,verificationTransactionId:P.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"receivedAmount",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:["Amount Received (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"receivedAmount",type:"number",placeholder:(o==="SECURITY_DEPOSIT"?5e5:15e5).toString(),disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.receivedAmount,onChange:P=>v({...N,receivedAmount:P.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"receivedDate",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:["Credit Value Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"receivedDate",type:"date",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:N.receivedDate,onChange:P=>v({...N,receivedDate:P.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"remarks",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:"Verification Remarks"}),e.jsx(Ks,{id:"remarks",placeholder:"Any internal notes for reconciliation...",rows:3,className:"mt-1",value:N.verificationRemarks,onChange:P=>v({...N,verificationRemarks:P.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3",children:[e.jsx(te,{className:$o("w-full transition-all duration-200",(S==null?void 0:S.status)==="Verified"?"bg-green-600 hover:bg-green-600 opacity-90":"bg-re-red hover:bg-re-red-hover"),onClick:_,disabled:p||(S==null?void 0:S.status)==="Verified",children:(S==null?void 0:S.status)==="Verified"?e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"w-4 h-4 mr-2"})," Verified Successfully"]}):e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"w-4 h-4 mr-2"})," Mark as Verified"]})}),(S==null?void 0:S.status)!=="Verified"&&(S==null?void 0:S.status)!=="Rejected"&&e.jsxs(te,{variant:"ghost",className:"w-full text-red-600 hover:text-red-700 hover:bg-red-50",onClick:A,disabled:p,children:[e.jsx(ai,{className:"w-4 h-4 mr-2"}),"Reject / Flag Discrepancy"]})]})]})]}),e.jsxs(_e,{className:"bg-slate-900 text-white border-none shadow-xl",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(dn,{className:"w-4 h-4 text-re-red"}),"Next Steps"]})}),e.jsxs(Oe,{className:"text-xs text-slate-300 space-y-3",children:[e.jsx("p",{children:"Once verified, the following will occur:"}),e.jsxs("ul",{className:"list-disc pl-4 space-y-2",children:[e.jsxs("li",{children:["Applicant status will advance to ",o==="SECURITY_DEPOSIT"?"LOI Issuance":"LOA Approval"]}),e.jsx("li",{children:"Email notification will be sent to Applicant"}),e.jsxs("li",{children:["Digital ",o==="SECURITY_DEPOSIT"?"LOI":"LOA"," generation will be unlocked"]}),e.jsxs("li",{children:["This payment confirms the ",o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"]})]})]})]})]})]}),e.jsx(ho,{isOpen:w,onClose:()=>j(!1),document:b})]}):e.jsx("div",{className:"p-20 text-center",children:"Application not found"})}const nl=["Warranty Department","Accessories Department","Sales Department","RTO Department","Service Department","Parts Department","Finance Department","Insurance Department","Inventory Department","Marketing Department","HR Department","IT Department","Legal Department","Quality Department","Logistics Department","Customer Relations Department"],LS="[DEPARTMENT_CLAIM]",IS="[FINANCE_VALIDATED]",Yg=[{id:"calculations",label:"Verified All Department Calculations"},{id:"bank",label:"Confirmed Bank Account Details"},{id:"docs",label:"Reviewed All Supporting Documents"},{id:"sap",label:"Synced Final Dues with SAP"},{id:"noc",label:"Received All Mandatory NOCs"}];function DV({fnfId:t,onBack:s}){const[n,r]=g.useState(null),[a,i]=g.useState(!0),[o,d]=g.useState("overview"),[m,f]=g.useState([]),[p,h]=g.useState([]),[x,u]=g.useState([]),[N,v]=g.useState(null),[w,j]=g.useState([]),[b,C]=g.useState(!1),[S,D]=g.useState(null),[_,A]=g.useState([]);g.useEffect(()=>{E(),$()},[t]);const E=async()=>{var ie;try{const fe=(await Re.getSettlementDepartments()).data;fe&&fe.success&&((ie=fe.departments)==null?void 0:ie.length)>0}catch(nt){console.error("Fetch departments error:",nt)}},q=ie=>{if(!ie)return ie;let nt=ie.trim();const fe=nl.find(Ke=>Ke.toLowerCase()===nt.toLowerCase());if(fe)return fe;const Fe={sales:"Sales Department",service:"Service Department",spares:"Parts Department",parts:"Parts Department","spares / parts":"Parts Department",finance:"Finance Department",accounts:"Finance Department",warranty:"Warranty Department",marketing:"Marketing Department",hr:"HR Department",it:"IT Department",legal:"Legal Department",logistics:"Logistics Department",quality:"Quality Department",fdd:"Finance Department",apparel:"Accessories Department",accessories:"Accessories Department",dms:"IT Department",rto:"Admin Department",admin:"Admin Department","admin / dd-admin":"Admin Department"}[nt.toLowerCase().replace(" department","")];return Fe||ie},O=(ie,nt)=>nt==="DepartmentClaim"||typeof ie=="string"&&(ie.startsWith(LS)||ie.includes("Clearance:")),R=ie=>(ie==null?void 0:ie.sourceType)==="FinanceValidated"&&typeof(ie==null?void 0:ie.description)=="string"&&ie.description.includes("Auto-seeded from department claim"),P=(ie,nt)=>nt==="FinanceValidated"||typeof ie=="string"&&ie.startsWith(IS),L=ie=>(ie||"").replace(LS,"").replace(IS,"").trim(),$=async(ie=!0)=>{var nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt,Cs,Mt,ze,xt,yt,Ot,Pt,Jt,bs,ns,Ds,ts,js,tn,vn,jn,xn,gn;try{ie&&i(!0);const qt=(await Re.getFnFSettlementById(t)).data;if(qt.success){const Ze=qt.fnf,Gt={id:Ze.id,caseNumber:Ze.settlementId||((nt=Ze.resignation)==null?void 0:nt.resignationId)||((fe=Ze.terminationRequest)==null?void 0:fe.requestId)||Ze.id.substring(0,8),dealerName:((Fe=(Ae=Ze.outlet)==null?void 0:Ae.dealer)==null?void 0:Fe.fullName)||((Ke=Ze.dealer)==null?void 0:Ke.fullName)||"N/A",dealerCode:((Le=Ze.outlet)==null?void 0:Le.code)||((et=(Ue=Ze.dealer)==null?void 0:Ue.dealerCode)==null?void 0:et.dealerCode)||"N/A",location:((dt=Ze.outlet)==null?void 0:dt.city)||((ss=Ze.outlet)==null?void 0:ss.location)||"N/A",terminationType:Ze.resignationId?"Resignation":"Termination",submittedDate:xa(Ze.createdAt),createdAt:Ze.createdAt,dueDate:Ze.settlementDate?xa(Ze.settlementDate):"TBD",status:Ze.status,dealerId:((kt=(Wt=Ze.outlet)==null?void 0:Wt.dealer)==null?void 0:kt.id)||Ze.dealerId,originalRequestId:((wt=Ze.resignation)==null?void 0:wt.resignationId)||((Os=Ze.terminationRequest)==null?void 0:Os.requestId)||((as=Ze.terminationRequest)==null?void 0:as.id)||"N/A",salesCode:((be=(Se=Ze.dealer)==null?void 0:Se.dealerCode)==null?void 0:be.salesCode)||((gt=(bt=(Ve=(pt=Ze.outlet)==null?void 0:pt.dealer)==null?void 0:Ve.dealerProfile)==null?void 0:bt.dealerCode)==null?void 0:gt.salesCode)||"N/A",serviceCode:((is=(rs=Ze.dealer)==null?void 0:rs.dealerCode)==null?void 0:is.serviceCode)||((Ee=(nn=(Ws=(Ts=Ze.outlet)==null?void 0:Ts.dealer)==null?void 0:Ws.dealerProfile)==null?void 0:nn.dealerCode)==null?void 0:Ee.serviceCode)||"N/A",gearCode:((Xt=($t=Ze.dealer)==null?void 0:$t.dealerCode)==null?void 0:Xt.gearCode)||((xt=(ze=(Mt=(Cs=Ze.outlet)==null?void 0:Cs.dealer)==null?void 0:Mt.dealerProfile)==null?void 0:ze.dealerCode)==null?void 0:xt.gearCode)||"N/A",gmaCode:((Ot=(yt=Ze.dealer)==null?void 0:yt.dealerCode)==null?void 0:Ot.gmaCode)||((ns=(bs=(Jt=(Pt=Ze.outlet)==null?void 0:Pt.dealer)==null?void 0:Jt.dealerProfile)==null?void 0:bs.dealerCode)==null?void 0:ns.gmaCode)||"N/A",allLineItems:(Ze.lineItems||[]).filter(It=>It.isActive!==!1),departmentResponses:nl.map(It=>{const As=(Ze.clearances||[]).find(Dn=>q(Dn.department)===It),_r=(Ze.lineItems||[]).filter(Dn=>Dn.isActive!==!1),ca=_r.filter(Dn=>q(Dn.department)===It&&O(Dn.description,Dn.sourceType)),Ca=_r.filter(Dn=>q(Dn.department)===It&&R(Dn)),Yr=ca.length>0?ca:Ca;let Nr=0,kn=0;Yr.forEach(Dn=>{const Aa=Math.abs(parseFloat(Dn.amount)||0);Dn.itemType==="Payable"?Nr+=Aa:kn+=Aa});const Sn=Nr-kn,sr=Math.abs(Sn)>0,wr=(As==null?void 0:As.status)||"Pending",Sr=sr?"Dues Pending":wr==="Cleared"?"NOC Submitted":wr,yn=Sn>0?"payable":Sn<0?"recovery":null;return{id:(As==null?void 0:As.id)||`dept-${It}`,departmentName:It,status:Sr,remarks:(As==null?void 0:As.remarks)||"-",submittedDate:As!=null&&As.clearedAt?xa(As.clearedAt):"-",amount:Math.abs(Sn),duesFlow:yn,amountType:Sn>0?"Payable to dealer":Sn<0?"Receivable from dealer":null,supportingDocument:(As==null?void 0:As.supportingDocument)||null}}),documents:[{name:"Resignation Letter.pdf",size:"N/A",uploadedOn:xa(Ze.createdAt),type:"Resignation",url:"#"},...(Ze.clearances||[]).filter(It=>It.supportingDocument).map(It=>({name:It.supportingDocument.split("/").pop(),size:"N/A",uploadedOn:xa(It.clearedAt),type:`${It.department} Proof`,url:It.supportingDocument})),...(Ze.clearanceDocuments||[]).map(It=>{var As;return{name:It.name||((As=It.supportingDocument)==null?void 0:As.split("/").pop())||"Document",size:"N/A",uploadedOn:xa(It.clearedAt||Ze.createdAt),type:"Finance Upload",url:It.supportingDocument}})]};r(Gt);const St=Ze.bankDetails||((Ds=Ze.dealer)==null?void 0:Ds.bankDetails)||((tn=(js=(ts=Ze.outlet)==null?void 0:ts.dealer)==null?void 0:js.dealerProfile)==null?void 0:tn.bankDetails);St&&St.length>0?j(St):((jn=(vn=Ze.outlet)==null?void 0:vn.dealer)!=null&&jn.id||Ze.dealerId)&&Z(((gn=(xn=Ze.outlet)==null?void 0:xn.dealer)==null?void 0:gn.id)||Ze.dealerId);const qn=[],Er=[],Fr=[],wn=(Ze.lineItems||[]).filter(It=>It.isActive!==!1);(wn.some(It=>P(It.description,It.sourceType))?wn.filter(It=>P(It.description,It.sourceType)):wn.filter(It=>!O(It.description,It.sourceType))).forEach(It=>{const As={id:It.id,department:q(It.department),description:L(It.description||It.remarks||""),amount:Math.abs(It.amount)};It.itemType==="Payable"?qn.push(As):It.itemType==="Deduction"?Fr.push(As):Er.push(As)}),f(qn),h(Er),u(Fr),We({verificationTransactionId:Ze.transactionReference||"",settlementAmount:(Ze.settlementAmount||ft().settlementAmount).toString(),settlementDate:Ze.settlementDate?new Date(Ze.settlementDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],paymentMode:Ze.paymentMode||"",bankReference:"",verificationRemarks:Ze.remarks||"",adjustments:"0"})}}catch(Ye){console.error("Fetch F&F error:",Ye),J.error("Failed to fetch settlement details")}finally{ie&&i(!1)}},Z=async ie=>{try{const fe=(await Re.getDealerBankDetails(ie)).data;fe.success&&j(fe.bankDetails||[])}catch(nt){console.error("Fetch bank details error:",nt)}},Q=async ie=>{ie.preventDefault();const nt=new FormData(ie.currentTarget),fe=Object.fromEntries(nt.entries());try{const Ae=n==null?void 0:n.dealerId;(await Re.saveBankDetail(Ae,{...fe,id:S==null?void 0:S.id,isPrimary:nt.get("isPrimary")==="on"})).data.success&&(J.success("Bank details saved"),Z(Ae),C(!1),D(null))}catch{J.error("Failed to save bank details")}},W=async ie=>{if(confirm("Are you sure you want to delete this bank account?"))try{(await Re.deleteBankDetail(ie)).data.success&&(J.success("Bank detail deleted"),Z(n==null?void 0:n.dealerId))}catch{J.error("Failed to delete bank details")}},U=ie=>{A(nt=>nt.includes(ie)?nt.filter(fe=>fe!==ie):[...nt,ie])},[M,z]=g.useState({department:"",description:"",amount:""}),[T,F]=g.useState({department:"",description:"",amount:""}),[I,K]=g.useState({department:"",description:"",amount:""}),[G,V]=g.useState(null),[Y,re]=g.useState(null),[ae,ue]=g.useState(null),[ye,ce]=g.useState({}),[je,Me]=g.useState({}),[ut,jt]=g.useState({}),ft=()=>{const ie=m.reduce((Fe,Ke)=>Fe+(Number(Ke.amount)||0),0),nt=p.reduce((Fe,Ke)=>Fe+(Number(Ke.amount)||0),0),fe=x.reduce((Fe,Ke)=>Fe+(Number(Ke.amount)||0),0),Ae=ie-nt-fe;return{payables:ie,receivables:nt,deductions:fe,netSettlement:Ae,settlementAmount:Math.abs(Ae),settlementType:Ae>0?"Payable to Dealer":Ae<0?"Receivable from Dealer":"No Settlement Required"}},X=ft(),Ce=nl.map(ie=>{const nt=((n==null?void 0:n.departmentResponses)||[]).find(Wt=>Wt.departmentName===ie),fe=Number(nt==null?void 0:nt.amount)||0,Ae=(nt==null?void 0:nt.amountType)||"-",Fe=m.filter(Wt=>q(Wt.department)===ie).reduce((Wt,kt)=>Wt+(Number(kt.amount)||0),0),Ke=p.filter(Wt=>q(Wt.department)===ie).reduce((Wt,kt)=>Wt+(Number(kt.amount)||0),0),Le=x.filter(Wt=>q(Wt.department)===ie).reduce((Wt,kt)=>Wt+(Number(kt.amount)||0),0),Ue=Fe-Ke-Le,et=Math.abs(Ue),dt=Ue>0?"Payable":Ue<0?"Receivable":"-",ss=et-fe;return{department:ie,claimAmount:fe,claimType:Ae,validatedAmount:et,validatedType:dt,variance:ss}}),[xe,We]=g.useState({verificationTransactionId:"",settlementAmount:X.settlementAmount.toString(),settlementDate:new Date().toISOString().split("T")[0],paymentMode:"",bankReference:"",verificationRemarks:"",adjustments:"0"}),Be=async()=>{var ie,nt;if(!M.department||!M.description||!M.amount){J.error("Please fill in all fields");return}try{const Ae=(await Re.addLineItem(t,{department:M.department,description:M.description,amount:Math.abs(parseFloat(M.amount)),itemType:"Payable"})).data;Ae.success&&(f([...m,{id:Ae.lineItem.id,department:Ae.lineItem.department,description:Ae.lineItem.description,amount:Math.abs(Ae.lineItem.amount)}]),z({department:"",description:"",amount:""}),J.success("Payable item added"),$())}catch(fe){J.error(((nt=(ie=fe.response)==null?void 0:ie.data)==null?void 0:nt.message)||"Failed to add payable item")}},rt=async(ie,nt,fe)=>{ce(Ae=>{const Fe=Ae[ie]||m.find(Ke=>Ke.id===ie);return Fe?{...Ae,[ie]:{...Fe,[nt]:nt==="amount"?Number(fe)||0:fe}}:Ae})},ht=async ie=>{var fe,Ae;const nt=ye[ie];if(!nt){V(null);return}f(Fe=>Fe.map(Ke=>Ke.id===ie?nt:Ke));try{await Re.updateLineItem(ie,{department:nt.department,description:nt.description,amount:-Math.abs(Number(nt.amount)||0)}),V(null),ce(Fe=>{const Ke={...Fe};return delete Ke[ie],Ke}),J.success("Changes saved"),$(!1)}catch(Fe){J.error(((Ae=(fe=Fe.response)==null?void 0:fe.data)==null?void 0:Ae.message)||"Failed to update item"),$(!1)}},ge=async ie=>{var nt,fe;try{(await Re.deleteLineItem(ie)).data.success&&(f(m.filter(Ke=>Ke.id!==ie)),J.info("Payable item removed"),$())}catch(Ae){J.error(((fe=(nt=Ae.response)==null?void 0:nt.data)==null?void 0:fe.message)||"Failed to delete item")}},Je=async()=>{var ie,nt;if(!T.department||!T.description||!T.amount){J.error("Please fill in all fields");return}try{const Ae=(await Re.addLineItem(t,{department:T.department,description:T.description,amount:Math.abs(parseFloat(T.amount)),itemType:"Receivable"})).data;Ae.success&&(h([...p,{id:Ae.lineItem.id,department:Ae.lineItem.department,description:Ae.lineItem.description,amount:Ae.lineItem.amount}]),F({department:"",description:"",amount:""}),J.success("Receivable item added"),$())}catch(fe){J.error(((nt=(ie=fe.response)==null?void 0:ie.data)==null?void 0:nt.message)||"Failed to add receivable item")}},mt=async(ie,nt,fe)=>{Me(Ae=>{const Fe=Ae[ie]||p.find(Ke=>Ke.id===ie);return Fe?{...Ae,[ie]:{...Fe,[nt]:nt==="amount"?Number(fe)||0:fe}}:Ae})},de=async ie=>{var fe,Ae;const nt=je[ie];if(!nt){re(null);return}h(Fe=>Fe.map(Ke=>Ke.id===ie?nt:Ke));try{await Re.updateLineItem(ie,{department:nt.department,description:nt.description,amount:Math.abs(Number(nt.amount)||0)}),re(null),Me(Fe=>{const Ke={...Fe};return delete Ke[ie],Ke}),J.success("Changes saved"),$(!1)}catch(Fe){J.error(((Ae=(fe=Fe.response)==null?void 0:fe.data)==null?void 0:Ae.message)||"Failed to update item"),$(!1)}},at=async ie=>{var nt,fe;try{await Re.deleteLineItem(ie),h(p.filter(Ae=>Ae.id!==ie)),J.info("Receivable item removed"),$()}catch(Ae){J.error(((fe=(nt=Ae.response)==null?void 0:nt.data)==null?void 0:fe.message)||"Failed to delete item")}},ot=async()=>{var ie,nt;if(!I.department||!I.description||!I.amount){J.error("Please fill in all fields");return}try{const Ae=(await Re.addLineItem(t,{department:I.department,description:I.description,amount:Math.abs(parseFloat(I.amount)),itemType:"Deduction"})).data;Ae.success&&(u([...x,{id:Ae.lineItem.id,department:Ae.lineItem.department,description:Ae.lineItem.description,amount:Ae.lineItem.amount}]),K({department:"",description:"",amount:""}),J.success("Deduction item added"),$())}catch(fe){J.error(((nt=(ie=fe.response)==null?void 0:ie.data)==null?void 0:nt.message)||"Failed to add deduction item")}},ke=async(ie,nt,fe)=>{jt(Ae=>{const Fe=Ae[ie]||x.find(Ke=>Ke.id===ie);return Fe?{...Ae,[ie]:{...Fe,[nt]:nt==="amount"?Number(fe)||0:fe}}:Ae})},Zt=async ie=>{var fe,Ae;const nt=ut[ie];if(!nt){ue(null);return}u(Fe=>Fe.map(Ke=>Ke.id===ie?nt:Ke));try{await Re.updateLineItem(ie,{department:nt.department,description:nt.description,amount:Math.abs(Number(nt.amount)||0)}),ue(null),jt(Fe=>{const Ke={...Fe};return delete Ke[ie],Ke}),J.success("Changes saved"),$(!1)}catch(Fe){J.error(((Ae=(fe=Fe.response)==null?void 0:fe.data)==null?void 0:Ae.message)||"Failed to update item"),$(!1)}},Bt=async ie=>{try{await Re.deleteLineItem(ie),u(x.filter(nt=>nt.id!==ie)),J.info("Deduction item removed"),$()}catch{J.error("Failed to delete item")}},_s=async ie=>{var fe;const nt=ie.target.files;if(nt&&nt.length>0){i(!0);try{let Ae=0;for(let Fe=0;Fe<nt.length;Fe++){const Ke=new FormData;Ke.append("file",nt[Fe]),(fe=(await Re.uploadFnFDocument(t,Ke)).data)!=null&&fe.success&&Ae++}J.success(`${Ae} document(s) uploaded successfully`),$(!1)}catch{J.error("Failed to upload document(s)")}finally{i(!1)}}},[Us,fs]=g.useState(!1),Vs=async()=>{if(!xe.verificationTransactionId||!xe.settlementDate||!xe.paymentMode){J.error("Please fill in all required settlement details");return}try{fs(!0);const ie=(X.settlementAmount||0)+parseFloat(xe.adjustments||"0");await RE.updateFnF(t,{status:"Completed",finalSettlementAmount:ie,settlementDate:xe.settlementDate,paymentMode:xe.paymentMode,transactionReference:xe.verificationTransactionId,remarks:xe.verificationRemarks||"Approved by Finance"}),J.success(`F&F Settlement approved and completed for ${n.dealerName}`),setTimeout(()=>s(),1500)}catch(ie){console.error("Approve settlement error:",ie),J.error(ie.message||"Failed to approve settlement")}finally{fs(!1)}},Qs=()=>{if(!xe.verificationRemarks){J.error("Please provide remarks for rejection");return}J.error(`F&F Settlement rejected for ${n.dealerName}`),setTimeout(()=>s(),1500)},Xs=()=>{if(!xe.verificationRemarks){J.error("Please provide details for clarification request");return}J.info(`Clarification request sent for ${n.dealerName}`),setTimeout(()=>s(),1500)};return a?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(cs,{className:"w-8 h-8 animate-spin text-re-red"})}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(te,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Wr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl mb-1",children:"F&F Settlement Review"}),e.jsxs("p",{className:"text-slate-600",children:["Full & Final Settlement for ",n.dealerName]})]})]}),e.jsx(_e,{className:"border-red-200 bg-red-50",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-12 shrink-0 aspect-square rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(ya,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900",children:"Settlement Pending Finance Approval"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Case: ",n.caseNumber," • Due: ",n.dueDate]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(we,{className:"bg-re-red",children:n.status}),e.jsx(we,{variant:n.terminationType==="Resignation"?"default":"secondary",children:n.terminationType})]})]})})}),e.jsx(_e,{className:`${X.settlementType==="Payable to Dealer"?"border-red-300 bg-red-50":X.settlementType==="Receivable from Dealer"?"border-green-300 bg-green-50":"border-slate-300 bg-slate-50"}`,children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[X.settlementType==="Payable to Dealer"?e.jsx(Go,{className:"w-12 h-12 text-red-600"}):X.settlementType==="Receivable from Dealer"?e.jsx(ll,{className:"w-12 h-12 text-green-600"}):e.jsx(ln,{className:"w-12 h-12 text-slate-600"}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm ${X.settlementType==="Payable to Dealer"?"text-red-700":X.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:X.settlementType}),e.jsx("p",{className:"text-3xl text-slate-900",children:X.settlementType==="No Settlement Required"?"₹0":`₹${X.settlementAmount.toLocaleString("en-IN")}`})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-slate-600",children:"Net Settlement Amount"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:X.settlementType==="Payable to Dealer"?"Company will pay to dealer":X.settlementType==="Receivable from Dealer"?"Dealer must pay to company":"No payment required"})]})]})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsxs(In,{value:o,onValueChange:d,className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-5",children:[e.jsx(Ht,{value:"overview",children:"Overview"}),e.jsx(Ht,{value:"financial",children:"Financial"}),e.jsx(Ht,{value:"departments",children:"Departments"}),e.jsx(Ht,{value:"documents",children:"Documents"}),e.jsx(Ht,{value:"bank",children:"Bank Details"})]}),e.jsxs(Vt,{value:"overview",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"w-5 h-5"}),"Case Information"]})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:n.caseNumber})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:n.dealerCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:n.dealerName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:n.location})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Termination Type"}),e.jsx(we,{variant:n.terminationType==="Resignation"?"default":"secondary",children:n.terminationType})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Status"}),e.jsx(we,{className:"bg-re-red",children:n.status})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:n.submittedDate})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Due Date"}),e.jsx("p",{className:"text-slate-900",children:n.dueDate})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Request Age"}),e.jsx("p",{className:"text-slate-900",children:(()=>{const ie=new Date(n.createdAt),fe=Math.abs(new Date().getTime()-ie.getTime()),Ae=Math.ceil(fe/(1e3*60*60*24));return`${Ae} day${Ae!==1?"s":""}`})()})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:n.salesCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:n.serviceCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:n.gearCode})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-slate-500",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:n.gmaCode})]})]})})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"w-5 h-5"}),"Settlement Calculation Summary"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-green-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-700 text-lg",children:["+ ₹",X.payables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables (from Dealer)"}),e.jsxs("span",{className:"text-red-700 text-lg",children:["- ₹",X.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-red-50 rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-lg",children:["- ₹",X.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${X.settlementType==="Payable to Dealer"?"bg-red-100 border-red-300":X.settlementType==="Receivable from Dealer"?"bg-green-100 border-green-300":"bg-slate-100 border-slate-300"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-900",children:"Net Settlement"}),e.jsx("p",{className:`text-sm ${X.settlementType==="Payable to Dealer"?"text-red-700":X.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:X.settlementType})]}),e.jsx("span",{className:"text-2xl text-slate-900",children:X.settlementType==="No Settlement Required"?"₹0":`₹${X.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 border border-red-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Net Settlement = Payables - Receivables - Deductions",e.jsx("br",{}),e.jsx("span",{className:"text-xs",children:"All amounts are editable in the Financial tab"})]})]})]})]})]})]}),e.jsxs(Vt,{value:"financial",className:"space-y-4",children:[e.jsxs(_e,{className:"border-blue-200 bg-blue-50",children:[e.jsxs(Xe,{children:[e.jsx(st,{className:"text-base",children:"Department Claim vs Finance Validation"}),e.jsx(es,{children:"Finance validated values are used for final settlement totals."})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Department Claim"}),e.jsx(me,{children:"Finance Validated"}),e.jsx(me,{children:"Variance"})]})}),e.jsx(Bs,{children:Ce.map(ie=>e.jsxs(lt,{children:[e.jsx(oe,{children:ie.department}),e.jsx(oe,{children:ie.claimAmount>0?`${ie.claimType} ₹${ie.claimAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(oe,{children:ie.validatedAmount>0?`${ie.validatedType} ₹${ie.validatedAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(oe,{className:ie.variance===0?"text-slate-600":ie.variance>0?"text-red-600":"text-green-600",children:ie.claimAmount===0&&ie.validatedAmount===0?"-":`₹${ie.variance.toLocaleString("en-IN")}`})]},ie.department))})]})})]}),e.jsxs(_e,{className:"border-green-200 bg-green-50",children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(af,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer (Editable)"]}),e.jsx(es,{children:"Add or modify amounts company owes to dealer"})]})})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-right",children:"Amount (₹)"}),e.jsx(me,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bs,{children:m.map(ie=>{var nt,fe,Ae;return e.jsxs(lt,{children:[e.jsx(oe,{children:G===ie.id?e.jsxs(Rt,{value:((nt=ye[ie.id])==null?void 0:nt.department)||ie.department,onValueChange:Fe=>rt(ie.id,"department",Fe),children:[e.jsx(_t,{className:"h-8",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(Fe=>e.jsx(Pe,{value:Fe,children:Fe},Fe))})]}):e.jsx("span",{className:"text-slate-900",children:q(ie.department)})}),e.jsx(oe,{children:G===ie.id?e.jsx(it,{value:((fe=ye[ie.id])==null?void 0:fe.description)||ie.description,onChange:Fe=>rt(ie.id,"description",Fe.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(oe,{className:"text-right",children:G===ie.id?e.jsx(it,{type:"number",value:((Ae=ye[ie.id])==null?void 0:Ae.amount)??ie.amount,onChange:Fe=>rt(ie.id,"amount",Fe.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-1",children:[G===ie.id?e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ht(ie.id),children:e.jsx(dl,{className:"w-4 h-4"})}):e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{V(ie.id),ce(Fe=>({...Fe,[ie.id]:{...ie}}))},children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>ge(ie.id),children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},ie.id)})})]}),e.jsxs("div",{className:"border-t border-green-300 pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:"Add New Payable Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Rt,{value:M.department,onValueChange:ie=>z({...M,department:ie}),children:[e.jsx(_t,{className:"col-span-3",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(it,{placeholder:"Description",value:M.description,onChange:ie=>z({...M,description:ie.target.value}),className:"col-span-5"}),e.jsx(it,{type:"number",placeholder:"Amount",value:M.amount,onChange:ie=>z({...M,amount:ie.target.value}),className:"col-span-3"}),e.jsx(te,{onClick:Be,className:"col-span-1 bg-green-600 hover:bg-green-700",children:e.jsx(bn,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-green-400",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables"}),e.jsxs("span",{className:"text-green-700 text-xl",children:["₹",X.payables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(ay,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer (Editable)"]}),e.jsx(es,{children:"Add or modify amounts dealer owes to company"})]})})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-right",children:"Amount (₹)"}),e.jsx(me,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bs,{children:p.map(ie=>{var nt,fe,Ae;return e.jsxs(lt,{children:[e.jsx(oe,{children:Y===ie.id?e.jsxs(Rt,{value:((nt=je[ie.id])==null?void 0:nt.department)||ie.department,onValueChange:Fe=>mt(ie.id,"department",Fe),children:[e.jsx(_t,{className:"h-8",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(Fe=>e.jsx(Pe,{value:Fe,children:Fe},Fe))})]}):e.jsx("span",{className:"text-slate-900",children:q(ie.department)})}),e.jsx(oe,{children:Y===ie.id?e.jsx(it,{value:((fe=je[ie.id])==null?void 0:fe.description)||ie.description,onChange:Fe=>mt(ie.id,"description",Fe.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(oe,{className:"text-right",children:Y===ie.id?e.jsx(it,{type:"number",value:((Ae=je[ie.id])==null?void 0:Ae.amount)??ie.amount,onChange:Fe=>mt(ie.id,"amount",Fe.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-1",children:[Y===ie.id?e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>de(ie.id),children:e.jsx(dl,{className:"w-4 h-4"})}):e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{re(ie.id),Me(Fe=>({...Fe,[ie.id]:{...ie}}))},children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>at(ie.id),children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},ie.id)})})]}),e.jsxs("div",{className:"border-t border-red-300 pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:"Add New Receivable Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Rt,{value:T.department,onValueChange:ie=>F({...T,department:ie}),children:[e.jsx(_t,{className:"col-span-3",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(it,{placeholder:"Description",value:T.description,onChange:ie=>F({...T,description:ie.target.value}),className:"col-span-5"}),e.jsx(it,{type:"number",placeholder:"Amount",value:T.amount,onChange:ie=>F({...T,amount:ie.target.value}),className:"col-span-3"}),e.jsx(te,{onClick:Je,className:"col-span-1 bg-red-600 hover:bg-red-700",children:e.jsx(bn,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-red-400",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables"}),e.jsxs("span",{className:"text-red-700 text-xl",children:["₹",X.receivables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(_e,{className:"border-red-200 bg-red-50",children:[e.jsx(Xe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(st,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red"}),"Deductions (Editable)"]}),e.jsx(es,{children:"Add or modify pending claims and deductions"})]})})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Description"}),e.jsx(me,{className:"text-right",children:"Amount (₹)"}),e.jsx(me,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bs,{children:x.map(ie=>{var nt,fe,Ae;return e.jsxs(lt,{children:[e.jsx(oe,{children:ae===ie.id?e.jsxs(Rt,{value:((nt=ut[ie.id])==null?void 0:nt.department)||ie.department,onValueChange:Fe=>ke(ie.id,"department",Fe),children:[e.jsx(_t,{className:"h-8",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(Fe=>e.jsx(Pe,{value:Fe,children:Fe},Fe))})]}):e.jsx("span",{className:"text-slate-900",children:q(ie.department)})}),e.jsx(oe,{children:ae===ie.id?e.jsx(it,{value:((fe=ut[ie.id])==null?void 0:fe.description)||ie.description,onChange:Fe=>ke(ie.id,"description",Fe.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:ie.description})}),e.jsx(oe,{className:"text-right",children:ae===ie.id?e.jsx(it,{type:"number",value:((Ae=ut[ie.id])==null?void 0:Ae.amount)??ie.amount,onChange:Fe=>ke(ie.id,"amount",Fe.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",ie.amount.toLocaleString("en-IN")]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-1",children:[ae===ie.id?e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Zt(ie.id),children:e.jsx(dl,{className:"w-4 h-4"})}):e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{ue(ie.id),jt(Fe=>({...Fe,[ie.id]:{...ie}}))},children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>Bt(ie.id),children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},ie.id)})})]}),e.jsxs("div",{className:"border-t border-red-300 pt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-700",children:"Add New Deduction Item:"}),e.jsxs("div",{className:"grid grid-cols-12 gap-2",children:[e.jsxs(Rt,{value:I.department,onValueChange:ie=>K({...I,department:ie}),children:[e.jsx(_t,{className:"col-span-3",children:e.jsx(Et,{placeholder:"Department"})}),e.jsx(Tt,{children:nl.map(ie=>e.jsx(Pe,{value:ie,children:ie},ie))})]}),e.jsx(it,{placeholder:"Description",value:I.description,onChange:ie=>K({...I,description:ie.target.value}),className:"col-span-5"}),e.jsx(it,{type:"number",placeholder:"Amount",value:I.amount,onChange:ie=>K({...I,amount:ie.target.value}),className:"col-span-3"}),e.jsx(te,{onClick:ot,className:"col-span-1 bg-re-red hover:bg-re-red-hover",children:e.jsx(bn,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pt-3 border-t-2 border-red-300",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-xl",children:["₹",X.deductions.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(_e,{className:"border-2 border-blue-300 bg-blue-50",children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"w-5 h-5 text-re-red"}),"Final Settlement Summary"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Payables (to Dealer)"}),e.jsxs("span",{className:"text-green-700 text-lg",children:["+ ₹",X.payables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Receivables (from Dealer)"}),e.jsxs("span",{className:"text-red-700 text-lg",children:["- ₹",X.receivables.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-white rounded-lg",children:[e.jsx("span",{className:"text-slate-900",children:"Total Deductions"}),e.jsxs("span",{className:"text-re-red-hover text-lg",children:["- ₹",X.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-blue-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${X.settlementType==="Payable to Dealer"?"bg-red-100 border-red-400":X.settlementType==="Receivable from Dealer"?"bg-green-100 border-green-400":"bg-slate-100 border-slate-400"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-600 mb-1",children:"Net Settlement"}),e.jsx("p",{className:`text-lg ${X.settlementType==="Payable to Dealer"?"text-red-700":X.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:X.settlementType})]}),e.jsx("span",{className:"text-3xl text-slate-900",children:X.settlementType==="No Settlement Required"?"₹0":`₹${X.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-white border border-red-200 rounded-lg",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Calculation Formula"}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Net Settlement = Payables - Receivables - Deductions",e.jsx("br",{}),X.netSettlement>0&&"Positive value means company pays to dealer",X.netSettlement<0&&"Negative value means dealer pays to company",X.netSettlement===0&&"Zero means no payment required from either party"]})]})]})]})]})]}),e.jsxs(Vt,{value:"departments",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-5 h-5"}),"Department Response Progress"]}),e.jsxs(es,{children:[n.departmentResponses.filter(ie=>ie.status!=="Pending").length," of ",n.departmentResponses.length," departments have responded"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(oc,{value:n.departmentResponses.filter(ie=>ie.status!=="Pending").length/n.departmentResponses.length*100,className:"h-3"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-4 bg-green-50 rounded-lg border border-green-200",children:[e.jsx("p",{className:"text-sm text-green-700 mb-1",children:"NOC Submitted"}),e.jsx("p",{className:"text-2xl text-green-600",children:n.departmentResponses.filter(ie=>ie.status==="NOC Submitted").length})]}),e.jsxs("div",{className:"p-4 bg-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-red-700 mb-1",children:"Dues Pending"}),e.jsx("p",{className:"text-2xl text-red-600",children:n.departmentResponses.filter(ie=>ie.status==="Dues Pending").length})]}),e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg border border-slate-200",children:[e.jsx("p",{className:"text-sm text-slate-700 mb-1",children:"Awaiting Response"}),e.jsx("p",{className:"text-2xl text-slate-600",children:n.departmentResponses.filter(ie=>ie.status==="Pending").length})]})]})]})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"All Department Responses"}),e.jsx(es,{children:"Status of NOC and dues clearance from all 16 departments (read-only for Finance; updates are done by department stakeholders)."})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Department"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Amount Type"}),e.jsx(me,{children:"Amount"}),e.jsx(me,{children:"Submitted Date"}),e.jsx(me,{children:"Remarks"})]})}),e.jsx(Bs,{children:n.departmentResponses.map(ie=>e.jsxs(lt,{className:ie.duesFlow==="recovery"?"bg-red-50/40":ie.duesFlow==="payable"?"bg-emerald-50/40":"",children:[e.jsx(oe,{children:ie.departmentName}),e.jsx(oe,{children:e.jsx(we,{className:`border ${ie.status==="NOC Submitted"?"bg-green-100 text-green-700 border-green-300":ie.status==="Dues Pending"?"bg-red-100 text-red-700 border-red-300":"bg-slate-100 text-slate-700 border-slate-300"}`,children:ie.status})}),e.jsx(oe,{children:ie.amountType?e.jsx(we,{variant:"outline",className:ie.duesFlow==="recovery"?"bg-red-100 text-red-900 border-red-400 font-semibold":ie.duesFlow==="payable"?"bg-emerald-100 text-emerald-900 border-emerald-400 font-semibold":"bg-slate-50 text-slate-700 border-slate-200",children:ie.amountType}):"-"}),e.jsx(oe,{children:ie.amount?e.jsxs("span",{className:`rounded-md px-2 py-0.5 font-semibold tabular-nums ${ie.duesFlow==="recovery"?"bg-red-100 text-red-800 ring-1 ring-red-300/70":ie.duesFlow==="payable"?"bg-emerald-100 text-emerald-800 ring-1 ring-emerald-300/70":"text-slate-700"}`,children:["₹",ie.amount.toLocaleString("en-IN")]}):"-"}),e.jsx(oe,{children:ie.submittedDate||"-"}),e.jsx(oe,{className:"max-w-xs truncate",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:ie.remarks||"-"}),ie.supportingDocument&&e.jsxs("button",{onClick:()=>v({fileName:`${ie.departmentName}_Proof`,filePath:ie.supportingDocument,documentType:"Departmental Clearance Proof"}),className:"flex items-center gap-1 text-[10px] text-re-red hover:underline",children:[e.jsx(bu,{className:"w-3 h-3"}),"View Proof"]})]})})]},ie.id))})]})})]}),e.jsx(_e,{className:"bg-blue-50 border-red-200",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(sn,{className:"w-5 h-5 text-re-red mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-900 mb-1",children:"Department Response Guidelines"}),e.jsxs("ul",{className:"text-sm text-slate-700 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"NOC Submitted:"})," Department has no outstanding dues and provided clearance"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Dues Pending:"})," Department has identified amounts to be recovered or paid"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Pending:"})," Department has not yet responded to the F&F request"]})]})]})]})})})]}),e.jsxs(Vt,{value:"documents",className:"space-y-4",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"w-5 h-5"}),"Submitted Documents"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:n.documents.map((ie,nt)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-50 rounded-lg border border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ks,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900",children:ie.name}),e.jsxs("p",{className:"text-sm text-slate-500",children:[ie.size," • ",ie.type," • Uploaded on ",ie.uploadedOn]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ie.url&&ie.url!=="#"&&e.jsxs("button",{onClick:()=>v({fileName:ie.name,filePath:ie.url,documentType:ie.type}),className:"text-re-red hover:text-re-red-hover text-[10px] font-semibold flex items-center gap-1",children:[e.jsx(bu,{className:"w-3 h-3"})," PREVIEW"]}),e.jsx(te,{variant:"outline",size:"sm",onClick:async()=>{if(ie.url&&ie.url!=="#")try{const Ae=await(await fetch(ie.url)).blob(),Fe=window.URL.createObjectURL(Ae),Ke=document.createElement("a");Ke.href=Fe,Ke.download=ie.name||"download",document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),window.URL.revokeObjectURL(Fe)}catch{const Ae=document.createElement("a");Ae.href=ie.url,Ae.download=ie.name||"download",document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)}else J.error("Document URL not available")},children:"Download"})]})]},nt))})})]}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(vr,{className:"w-5 h-5"}),"Upload Settlement Verification Documents"]}),e.jsx(es,{children:"Upload bank receipts, settlement proofs, or any additional documents"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"border-2 border-dashed border-slate-300 rounded-lg p-8 text-center hover:border-red-300 hover:bg-red-50 transition-colors",children:[e.jsx(vr,{className:"w-8 h-8 text-slate-400 mx-auto mb-2"}),e.jsx("p",{className:"text-slate-600 mb-2",children:"Click to upload or drag and drop"}),e.jsx("p",{className:"text-sm text-slate-500",children:"PDF, DOC, DOCX, PNG, JPG, XLSX (max 10MB)"}),e.jsx("input",{type:"file",multiple:!0,className:"hidden",id:"file-upload",onChange:_s,accept:".pdf,.doc,.docx,.png,.jpg,.jpeg,.xlsx,.xls"}),e.jsx("label",{htmlFor:"file-upload",children:e.jsx(te,{variant:"outline",className:"mt-4",asChild:!0,children:e.jsx("span",{children:"Choose Files"})})})]})})})]})]}),e.jsx(Vt,{value:"bank",className:"space-y-4",children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(ad,{className:"w-5 h-5"}),"Dealer Bank Account Details"]}),e.jsx(es,{children:"Manage bank accounts for settlement transfer"})]}),e.jsxs(te,{size:"sm",className:"bg-re-red",onClick:()=>{D(null),C(!0)},children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Bank Account"]})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:w.length>0?w.map(ie=>e.jsxs(_e,{className:`relative ${ie.isPrimary?"border-re-red bg-blue-50/30":""}`,children:[ie.isPrimary&&e.jsx("div",{className:"absolute top-0 right-0 p-1 bg-re-red text-white text-[10px] uppercase font-bold px-2 rounded-bl",children:"Primary"}),e.jsx(Oe,{className:"p-4 pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Holder"}),e.jsx("p",{className:"text-sm font-semibold",children:ie.accountHolderName})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Bank"}),e.jsx("p",{className:"text-xs truncate",children:ie.bankName})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"IFSC"}),e.jsx("p",{className:"text-xs",children:ie.ifscCode})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Number"}),e.jsx("p",{className:"text-xs font-mono",children:ie.accountNumber})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(te,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-re-red",onClick:()=>{D(ie),C(!0)},children:[e.jsx(gr,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(te,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-red-600",onClick:()=>W(ie.id),children:[e.jsx(Zn,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})})]},ie.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(ad,{className:"w-12 h-12 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"No bank details found"})]})})})]})})]})}),e.jsx("div",{className:"space-y-6",children:e.jsxs(_e,{className:"sticky top-6",children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(Wu,{className:"w-5 h-5"}),"Settlement Verification"]}),e.jsx(es,{children:"Enter settlement transaction details"})]}),e.jsx(Oe,{className:"space-y-4",children:n.status==="Completed"?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 text-green-700 mb-2",children:[e.jsx(ln,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:"Settlement Completed"})]}),e.jsx("p",{className:"text-sm text-green-600",children:"This settlement has been finalized and processed."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Settlement Date"}),e.jsx("span",{className:"text-slate-900 font-medium",children:xa(xe.settlementDate)})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Payment Mode"}),e.jsx("span",{className:"text-slate-900 font-medium",children:xe.paymentMode})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Transaction ID"}),e.jsx("span",{className:"text-slate-900 font-medium truncate ml-4 max-w-[150px]",title:xe.verificationTransactionId,children:xe.verificationTransactionId})]}),e.jsxs("div",{className:"flex justify-between items-center py-2 border-b",children:[e.jsx("span",{className:"text-slate-500 text-sm",children:"Final Amount"}),e.jsxs("span",{className:"text-slate-900 font-bold text-lg",children:["₹",parseFloat(xe.settlementAmount).toLocaleString()]})]})]}),xe.verificationRemarks&&e.jsxs("div",{className:"mt-4",children:[e.jsx(le,{className:"text-slate-500 mb-1 block",children:"Finance Remarks"}),e.jsx("div",{className:"p-3 bg-slate-50 rounded border text-sm text-slate-700",children:xe.verificationRemarks})]}),e.jsxs(te,{variant:"outline",className:"w-full mt-4",onClick:()=>window.print(),children:[e.jsx(MI,{className:"w-4 h-4 mr-2"}),"Download Settlement Letter"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 mb-4",children:[e.jsxs("p",{className:"text-sm font-bold text-slate-900 mb-3 flex items-center gap-2",children:[e.jsx(ln,{className:"w-4 h-4 text-re-red"}),"Compliance Checklist"]}),e.jsx("div",{className:"space-y-3",children:Yg.map(ie=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:`check-${ie.id}`,checked:_.includes(ie.id),onChange:()=>U(ie.id),className:"w-4 h-4 mt-1 rounded border-slate-300 text-re-red focus:ring-re-red"}),e.jsx("label",{htmlFor:`check-${ie.id}`,className:"text-sm text-slate-700 leading-tight",children:ie.label})]},ie.id))})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"paymentMode",children:["Payment Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"paymentMode",placeholder:"e.g., NEFT, RTGS, Cheque",value:xe.paymentMode,onChange:ie=>We({...xe,paymentMode:ie.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"verificationTxnId",children:["Transaction ID / Reference ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"verificationTxnId",placeholder:"Enter transaction reference",value:xe.verificationTransactionId,onChange:ie=>We({...xe,verificationTransactionId:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"bankReference",children:"Bank Reference Number"}),e.jsx(it,{id:"bankReference",placeholder:"Enter bank reference",value:xe.bankReference,onChange:ie=>We({...xe,bankReference:ie.target.value})})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"settlementAmount",children:["Settlement Amount (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"settlementAmount",type:"number",placeholder:"Enter settlement amount",value:xe.settlementAmount,onChange:ie=>We({...xe,settlementAmount:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"adjustments",children:"Adjustments (₹)"}),e.jsx(it,{id:"adjustments",type:"number",placeholder:"Enter any adjustments",value:xe.adjustments,onChange:ie=>{const nt=ie.target.value,fe=X.settlementAmount+parseFloat(nt||"0");We({...xe,adjustments:nt,settlementAmount:fe.toString()})}}),parseFloat(xe.adjustments)!==0&&e.jsxs("p",{className:"text-sm text-re-red mt-1 flex items-center gap-1",children:[e.jsx(sn,{className:"w-3 h-3"}),"Adjusted amount: ₹",xe.settlementAmount]})]}),e.jsxs("div",{children:[e.jsxs(le,{htmlFor:"settlementDate",children:["Settlement Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(it,{id:"settlementDate",type:"date",value:xe.settlementDate,onChange:ie=>We({...xe,settlementDate:ie.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"verificationRemarks",children:"Verification Remarks"}),e.jsx(Ks,{id:"verificationRemarks",placeholder:"Enter any remarks or notes...",rows:4,value:xe.verificationRemarks,onChange:ie=>We({...xe,verificationRemarks:ie.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3 border-t",children:[e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700",onClick:Vs,disabled:Us||_.length<Yg.length,children:[Us?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ln,{className:"w-4 h-4 mr-2"}),"Complete Settlement"]}),_.length<Yg.length&&e.jsx("p",{className:"text-[10px] text-center text-red-500 mt-2 italic",children:"Check all compliance items to enable settlement"}),e.jsxs(te,{variant:"outline",className:"w-full border-blue-300 text-re-red hover:bg-blue-50",onClick:Xs,disabled:Us,children:[e.jsx(Gu,{className:"w-4 h-4 mr-2"}),"Request Clarification"]}),e.jsxs(te,{variant:"outline",className:"w-full border-red-300 text-red-600 hover:bg-red-50",onClick:Qs,disabled:Us,children:[e.jsx(ai,{className:"w-4 h-4 mr-2"}),"Reject Settlement"]})]})]})})]})})]}),e.jsx(f_,{isOpen:b,onClose:()=>{C(!1),D(null)},onSubmit:Q,editingBank:S,isSubmitting:!1}),e.jsx(ho,{isOpen:!!N,onClose:()=>v(null),document:N})]}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx("p",{children:"Settlement case not found"}),e.jsx(te,{onClick:s,className:"mt-4",children:"Go Back"})]})}const RV=()=>{const t=Lu(),s=g.useCallback(async()=>{try{t(l1(!0));const[r,a,i,o,d,m,f,p,h,x,u,N,v]=await Promise.all([$s.getRoles().catch(()=>({success:!1})),$s.getZones().catch(()=>({success:!1})),$s.getPermissions().catch(()=>({success:!1})),$s.getRegions().catch(()=>({success:!1})),$s.getUsers().catch(()=>({success:!1})),$s.getStates().catch(()=>({success:!1})),$s.getEmailTemplates().catch(()=>({success:!1})),$s.getDistricts({limit:"all"}).catch(()=>({success:!1})),$s.getAreas({limit:"all"}).catch(()=>({success:!1})),$s.getSlaConfigs().catch(()=>({success:!1})),$s.getASMs().catch(()=>({success:!1})),$s.getZonalManagers().catch(()=>({success:!1})),$s.getDDLeads().catch(()=>({success:!1}))]),w=V=>V.success?V:V.data?V.data:V,j=w(r),b=w(a),C=w(i),S=w(o),D=w(d),_=w(m),A=w(f),E=w(p),q=w(h),O=w(x),R=w(u),P=w(N),L=w(v),$=((D==null?void 0:D.users)||(D==null?void 0:D.data)||[]).map(V=>{var ce;const Y=Array.isArray(V.territoryProfile)?V.territoryProfile:[],re=Y.filter(je=>String(je.locationType||"").toLowerCase()==="zone").map(je=>je.locationName||je.zone).filter(Boolean),ae=Y.filter(je=>String(je.locationType||"").toLowerCase()==="region").map(je=>je.locationName||je.region).filter(Boolean),ue=Array.from(new Set([...V.allZones||[],...re])),ye=Array.from(new Set([...V.allRegions||[],...ae]));return{...V,name:V.fullName||V.name,role:((ce=V.role)==null?void 0:ce.roleName)||(Array.isArray(V.allRoles)&&V.allRoles.length>0?V.allRoles[0]:"System User"),zone:ue.length>0?ue.join(", "):"Global",region:ye.length>0?ye.join(", "):"Unassigned",status:V.isActive!==!1?"Active":"Inactive"}}),Z=((j==null?void 0:j.roles)||(j==null?void 0:j.data)||[]).map(V=>{var Y;return{id:V.id,name:V.roleName,permissions:((Y=V.permissions)==null?void 0:Y.map(re=>re.permissionCode))||[],userCount:V.userCount||0}}),Q=((b==null?void 0:b.zones)||(b==null?void 0:b.data)||[]).map(V=>{var re,ae,ue,ye,ce;const Y=(V.name||V.zoneName||"").toUpperCase();return{id:V.id,name:Y,description:V.description||"",code:V.name?V.name.substring(0,3).toUpperCase():"ZON",regionCount:V.regionCount||0,asmCount:V.asmCount||0,regionalOfficerCount:V.regionalOfficerCount||0,zmCount:V.zmCount||0,states:V.states||[],zonalBusinessHead:{name:((re=V.zonalBusinessHead)==null?void 0:re.name)||((ae=V.zonalBusinessHead)==null?void 0:ae.fullName)||"Not Assigned",email:((ue=V.zonalBusinessHead)==null?void 0:ue.email)||"",phone:((ye=V.zonalBusinessHead)==null?void 0:ye.mobileNumber)||((ce=V.zonalBusinessHead)==null?void 0:ce.phone)||""},zonalManagers:(V.zonalManagers||[]).map(je=>({id:je.id,name:je.name||je.fullName||"Unknown",email:je.email||"",phone:je.phone||je.mobileNumber||"",regions:je.regions||[]}))}}),W=((S==null?void 0:S.regions)||(S==null?void 0:S.data)||[]).map(V=>({id:V.id,code:V.code||(V.name?V.name.substring(0,3).toUpperCase():"REG"),name:V.name||V.regionName,zoneId:V.zoneId,zoneName:V.zoneName||"Unknown",states:V.states||[],cities:V.cities||[],districts:(V.districts||[]).map(Y=>({id:Y.id,name:Y.name,stateId:Y.stateId})),asmCount:V.asmCount||0,regionalOfficerCount:V.regionalOfficerCount||0,regionalManager:V.regionalManager?{id:V.regionalManager.id,name:V.regionalManager.fullName||V.regionalManager.name,email:V.regionalManager.email,phone:V.regionalManager.mobileNumber||V.regionalManager.phone}:void 0,status:V.isActive!==!1?"Active":"Inactive"})),U=Array.isArray(R==null?void 0:R.data)?R.data:Array.isArray(R)?R:[],M=Array.isArray(P==null?void 0:P.data)?P.data:Array.isArray(P)?P:[],z=M.length>0?M:$.filter(V=>{var Y;return(Y=V.allRoles)==null?void 0:Y.some(re=>(re==="ZM"||re==="DD-ZM"||re.includes("ZONAL MANAGER"))&&!re.includes("HEAD"))}).map(V=>{const Y=(V.territoryProfile||[]).find(ue=>ue.roleCode==="ZM"||ue.roleCode==="DD-ZM")||{},re=(V.territoryProfile||[]).filter(ue=>(ue.roleCode==="ZM"||ue.roleCode==="DD-ZM")&&ue.locationType==="region").map(ue=>ue.locationName),ae=(V.territoryProfile||[]).filter(ue=>(ue.roleCode==="ZM"||ue.roleCode==="DD-ZM")&&ue.locationType==="region").map(ue=>ue.locationId);return{id:V.id,name:V.fullName,zmCode:V.employeeId||"N/A",email:V.email,phone:V.mobileNumber,zoneId:Y.zoneId,zoneName:Y.zone||V.zone||"Not Assigned",regionNames:re,assignedRegionIds:ae,status:V.status}}),T=((_==null?void 0:_.states)||(_==null?void 0:_.data)||[]).map(V=>({...V,stateName:V.name})),F=((E==null?void 0:E.districts)||(E==null?void 0:E.data)||[]).map(V=>({...V,districtName:V.name,stateId:V.stateId,asmId:V.asmId,ddAmId:V.ddAmId,zmId:V.zmId})),I=(q.areas||q.data||[]).map(V=>({...V,areaName:V.name,districtId:V.districtId})),K=(O.data||[]).map(V=>{var Y,re;return{id:V.id,stage:V.stageCode||"Unknown",days:V.tatValue||0,enabled:V.isActive!==!1,reminders:((Y=V.reminderConfig)==null?void 0:Y.reminders)||[],escalations:((re=V.escalationConfig)==null?void 0:re.escalations)||[]}}),G=Array.isArray(L==null?void 0:L.data)?L.data:Array.isArray(L)?L:[];t(AA({zones:Q,regionalOffices:W,asms:U,zonalManagerMappings:z,zonalManagers:M,roles:Z,allStates:T,allDistricts:F,allAreas:I,availablePermissions:(C==null?void 0:C.permissions)||(C==null?void 0:C.data)||[],emailTemplates:(A==null?void 0:A.data)||[],slaConfigs:K,users:$,ddLeads:G,loading:!1}))}catch(r){console.error("[useMasterData] Error fetching data:",r),t(C5("Could not load configuration data")),J.error("Could not load configuration data")}finally{t(l1(!1))}},[t]),n=g.useCallback(async r=>{try{t(o1(!0));const a=await $s.getAreas(r);a.success&&t(A5({data:a.data,pagination:a.pagination}))}catch(a){console.error("[useMasterData] Error fetching areas:",a),J.error("Could not load locations")}finally{t(o1(!1))}},[t]);return{fetchInitialData:s,fetchAreas:n}},EV=({selectedZone:t,onZoneClick:s})=>{const{zones:n}=Pn(r=>r.master);return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:n.map(r=>e.jsxs(_e,{className:`border-2 transition-all cursor-pointer ${t===r.id?"border-re-red shadow-lg":"hover:border-red-400"}`,onClick:()=>s(r.id),children:[e.jsx(Xe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ku,{className:"w-5 h-5 text-re-red"}),e.jsx(st,{className:"text-lg",children:r.name.toUpperCase().endsWith("ZONE")?r.name:`${r.name} Zone`})]}),e.jsx(we,{variant:"outline",className:"text-xs",children:r.code})]})}),e.jsxs(Oe,{className:"space-y-3 text-sm",children:[e.jsx("p",{className:"text-slate-600 text-xs leading-relaxed mb-3",children:r.description}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"States"}),e.jsx(we,{variant:"outline",children:r.states.length})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Regions"}),e.jsx(we,{className:"bg-indigo-600",children:r.regionCount})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Regional Officers"}),e.jsx(we,{className:"bg-purple-600",children:r.regionalOfficerCount})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"ASMs"}),e.jsx(we,{className:"bg-green-600",children:r.asmCount})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"ZMs"}),e.jsx(we,{className:"bg-blue-600",children:r.zmCount})]})]})]})]},r.id))})},_V=({selectedZone:t,onAddZone:s,onEditZone:n})=>{const{zones:r}=Pn(i=>i.master),a=r.filter(i=>t==="all"||i.id===t);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Zone Details"}),e.jsx(es,{children:"Geographical coverage and state mappings for each zone"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Zone"]})]})}),e.jsx(Oe,{children:e.jsx(Ib,{className:"h-[400px]",children:e.jsx("div",{className:"space-y-4",children:a.map(i=>e.jsxs("div",{className:"border rounded-lg p-5 space-y-4 bg-gradient-to-br from-white to-slate-50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-red-500 to-re-red rounded-lg flex items-center justify-center shadow-md",children:e.jsx(ku,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:i.name}),e.jsx("p",{className:"text-slate-500 text-sm",children:i.code})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(te,{variant:"outline",size:"sm",onClick:()=>n(i),className:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",children:e.jsx(gr,{className:"w-4 h-4"})})})]}),i.description&&e.jsx("div",{className:"bg-slate-50 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-slate-600",children:i.description})}),e.jsxs("div",{children:[e.jsxs(le,{className:"text-xs text-slate-600 mb-2 block",children:["States Covered (",i.states.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.states.map((o,d)=>e.jsx(we,{variant:"secondary",className:"text-xs border-transparent bg-secondary text-secondary-foreground",children:o},d))})]}),i.zonalBusinessHead&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsx(le,{className:"text-xs text-slate-600 mb-2 block",children:"Zonal Business Head (ZBH)"}),e.jsxs("div",{className:"bg-red-50 border border-red-100 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dc,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:i.zonalBusinessHead.name}),e.jsx(we,{className:"bg-re-red text-white text-[10px] ml-auto",children:"ZBH"})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-6 text-slate-600",children:[e.jsx(Gr,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:i.zonalBusinessHead.email})]})]})]}),i.zonalManagers&&i.zonalManagers.length>0&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsxs(le,{className:"text-xs text-slate-600 mb-2 block",children:["Zonal Managers (",i.zonalManagers.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.zonalManagers.map((o,d)=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-4 h-4 text-slate-600"}),e.jsx("span",{className:"text-sm text-slate-900",children:o.name}),e.jsxs(we,{variant:"outline",className:"text-xs ml-auto",children:["ZM-",d+1]})]}),o.email&&e.jsxs("div",{className:"flex items-center gap-2 ml-6",children:[e.jsx(Gr,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-xs text-slate-600",children:o.email})]}),o.phone&&e.jsx("div",{className:"flex items-center gap-2 ml-6",children:e.jsx("span",{className:"text-xs text-slate-600",children:o.phone})}),o.regions&&o.regions.length>0&&e.jsxs("div",{className:"ml-6 mt-2",children:[e.jsxs(le,{className:"text-xs text-slate-500 mb-1 block",children:["Managed Regions (",o.regions.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.regions.map((m,f)=>e.jsxs(we,{variant:"outline",className:"text-xs bg-white text-foreground",children:[e.jsx(ku,{className:"w-2.5 h-2.5 mr-1"}),m]},f))})]})]},d))})]})]},i.id))})})})]})},TV=({selectedZone:t,onAddRegion:s,onEditRegion:n,onDeleteRegion:r})=>{const{regionalOffices:a}=Pn(o=>o.master),i=a.filter(o=>t==="all"||o.zoneId===t);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Regional Offices"}),e.jsx(es,{children:"Manage regional offices within zones"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Regional Office"]})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Region Code"}),e.jsx(me,{children:"Region Name"}),e.jsx(me,{children:"Zone"}),e.jsx(me,{children:"Regional Manager"}),e.jsx(me,{children:"Districts"}),e.jsx(me,{children:"Cities"}),e.jsx(me,{children:"Regional Officers"}),e.jsx(me,{children:"ASMs"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:i.map(o=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{className:"font-medium",children:o.code})]})}),e.jsx(oe,{className:"font-medium",children:o.name}),e.jsx(oe,{children:o.zoneName}),e.jsx(oe,{children:o.regionalManager?e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm",children:o.regionalManager.name}),e.jsx("span",{className:"text-xs text-slate-500",children:o.regionalManager.email})]}):e.jsx("span",{className:"text-slate-400 italic",children:"Not Assigned"})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.districts||[]).slice(0,2).map((d,m)=>e.jsx(we,{variant:"secondary",className:"text-xs",children:d.name||d},m)),(o.districts||[]).length>2&&e.jsxs(we,{variant:"secondary",className:"text-xs",children:["+",(o.districts||[]).length-2]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[o.cities.slice(0,3).map((d,m)=>e.jsxs("span",{className:"text-xs text-slate-600",children:[d,m<Math.min(o.cities.length,3)-1?",":""]},m)),o.cities.length>3&&e.jsxs("span",{className:"text-xs text-slate-500",children:["+",o.cities.length-3]})]})}),e.jsx(oe,{children:e.jsx(we,{className:"bg-purple-600",children:o.regionalOfficerCount})}),e.jsx(oe,{children:e.jsx(we,{className:"bg-green-600",children:o.asmCount})}),e.jsx(oe,{children:e.jsx(we,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>r(o.id,o.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},PV=({selectedZone:t,onAddASM:s,onEditASM:n,onDeleteASM:r})=>{const{asms:a,zonalManagerMappings:i}=Pn(m=>m.master),o=a.filter(m=>t==="all"||m.zoneId===t),d=g.useMemo(()=>{const m={};return[...a,...i].forEach(f=>{(f.areasManaged||f.districts||[]).forEach(h=>{m[h]||(m[h]=[]),m[h].includes(f.name)||m[h].push(f.name)})}),m},[a,i]);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"District Development Area Managers (DD-AM)"}),e.jsx(es,{children:"Manage DD-AM users across districts (multi-district)"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add DD-AM"]})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"DD-AM Code"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Zone"}),e.jsx(me,{children:"Region"}),e.jsx(me,{children:"Districts Managed"}),e.jsx(me,{children:"Contact"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:o.map(m=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(iM,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"font-medium",children:m.asmCode||"N/A"})]})}),e.jsx(oe,{children:m.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:m.zoneName})}),e.jsx(oe,{className:"text-sm text-slate-600",children:m.regionName}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:m.areasManaged.map((f,p)=>{const h=typeof f=="string"?f:f.id,x=typeof f=="string"?f:f.name,u=(d[h]||[]).filter(v=>v!==m.name),N=u.length>0;return e.jsxs(we,{variant:N?"outline":"secondary",className:`text-xs ${N?"border-red-300 bg-red-50 text-re-red-hover font-medium":""}`,title:N?`Also managed by: ${u.join(", ")}`:void 0,children:[x,N&&e.jsx(ja,{className:"w-2.5 h-2.5 ml-1 inline"})]},p)})})}),e.jsx(oe,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:m.email}),e.jsx("p",{className:"text-slate-500",children:m.phone})]})}),e.jsx(oe,{children:e.jsx(we,{variant:m.status==="Active"?"default":"secondary",className:m.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:m.status})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>n(m),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>r(m.id,m.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},m.id))})]})})]})},OV=({selectedZone:t,onAddZM:s,onEditZM:n,onDeleteZM:r})=>{const{zonalManagers:a}=Pn(o=>o.master),i=(a||[]).filter(o=>t==="all"||o.zoneId===t||o.zones&&o.zones.includes(t));return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Zonal Managers (DD-ZM)"}),e.jsx(es,{children:"Manage Zonal Managers and their region assignments"})]}),e.jsxs(te,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add ZM"]})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"ZM Code"}),e.jsx(me,{children:"Name"}),e.jsx(me,{children:"Zone"}),e.jsx(me,{children:"Regions Managed"}),e.jsx(me,{children:"Contact"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:i.map(o=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:o.zmCode||o.code})]})}),e.jsx(oe,{children:o.name}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(o.zones||[o.zoneName]).map((d,m)=>e.jsx(we,{variant:"outline",children:d},m))})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.regionNames||[]).slice(0,3).map((d,m)=>e.jsx(we,{variant:"secondary",className:"text-xs",children:d},m)),(o.regionNames||[]).length>3&&e.jsxs(we,{variant:"secondary",className:"text-xs",children:["+",(o.regionNames||[]).length-3]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-900",children:o.email}),e.jsx("p",{className:"text-slate-500",children:o.phone})]})}),e.jsx(oe,{children:e.jsx(we,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>r(o.id,o.name),className:"text-re-red hover:text-re-red-hover hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},LV=({userAssignedData:t})=>e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{className:"text-xl",children:"System Users & Territory Assignments"})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"User Details"}),e.jsx(me,{children:"Role"}),e.jsx(me,{children:"Assigned Zone"}),e.jsx(me,{children:"Assigned Region"}),e.jsx(me,{children:"Status"})]})}),e.jsx(Bs,{children:t.map(s=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(Rr,{className:"w-4 h-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(Gr,{className:"w-3 h-3"}),s.email]})]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dc,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-sm font-medium",children:s.role})]})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:s.zone})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"bg-indigo-50 text-indigo-700 border-indigo-200",children:s.region})}),e.jsx(oe,{children:e.jsx(we,{variant:s.status==="Active"?"default":"secondary",className:s.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:s.status})})]},s.id))})]})})]}),IV=({onAddRole:t,onEditRole:s})=>{const{roles:n}=Pn(r=>r.master);return e.jsxs(_e,{className:"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border shadow-sm",children:[e.jsx(Xe,{className:"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx(st,{className:"leading-none text-xl font-bold",children:"Role Definitions"}),e.jsx(es,{className:"text-muted-foreground mt-1.5",children:"Overview of available roles and their access levels"})]}),e.jsxs(te,{onClick:t,className:"bg-re-red hover:bg-re-red-hover h-9",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Role"]})]})}),e.jsx(Oe,{className:"px-6 [&:last-child]:pb-6",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(r=>{var a;return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3 bg-gradient-to-br from-white to-slate-50 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900 font-bold",children:r.name})]}),e.jsxs(we,{variant:"secondary",className:"border-transparent bg-secondary text-secondary-foreground text-xs font-medium",children:[r.userCount||0," users"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"items-center gap-2 font-medium text-xs text-slate-600 mb-2 block",children:"Key Permissions"}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(r.permissions||[]).slice(0,3).map((i,o)=>e.jsx(we,{variant:"outline",className:"border px-2 py-0.5 font-medium text-foreground text-[10px] bg-white/50",children:i.replace(/_/g," ").toLowerCase()},o)),((a=r.permissions)==null?void 0:a.length)>3&&e.jsxs(we,{variant:"outline",className:"text-[10px] border-slate-200",children:["+",r.permissions.length-3]})]})]}),e.jsxs(te,{variant:"outline",size:"sm",onClick:()=>s(r),className:"w-full mt-2 h-8 rounded-md gap-1.5 px-3 border bg-background text-foreground hover:bg-accent hover:text-accent-foreground transition-colors",title:"Edit Permissions",children:[e.jsx(gr,{className:"w-3 h-3 mr-1"}),"Edit Permissions"]})]},r.id)})})})]})},MV=({isOpen:t,onOpenChange:s,role:n,onSave:r})=>{const[a,i]=g.useState([]);g.useEffect(()=>{n&&i(n.permissions||[])},[n,t]);const o=m=>{i(f=>f.includes(m)?f.filter(p=>p!==m):[...f,m])};if(!n)return null;const d=[{title:"Action Permissions",color:"from-green-50 to-emerald-50 border-green-200",textColor:"text-green-900",permissions:[{id:"action:approve",label:"Approve Applications"},{id:"action:reject",label:"Reject Applications"},{id:"action:upload_docs",label:"Upload Documents"},{id:"action:request_changes",label:"Request Changes"},{id:"action:forward",label:"Forward to Others"},{id:"action:reassign",label:"Reassign Applications"},{id:"action:schedule_interview",label:"Schedule Interviews"},{id:"action:add_comments",label:"Add Comments/Notes"},{id:"action:rank_applicants",label:"Rank Applicants"},{id:"action:final_approval",label:"Final Approval"}]},{title:"View/Access Permissions",color:"from-blue-50 to-cyan-50 border-blue-200",textColor:"text-blue-900",permissions:[{id:"view:view_details",label:"Application Details"},{id:"view:view_financial",label:"Financial Information"},{id:"view:view_discussions",label:"Discussion Notes"},{id:"view:view_progress",label:"Progress Tracking"},{id:"view:view_audit",label:"Audit Logs"},{id:"view:view_documents",label:"All Documents"},{id:"view:view_personal",label:"Personal Information"},{id:"view:view_business",label:"Business Details"},{id:"view:view_reports",label:"Reports & Analytics"},{id:"view:view_history",label:"Application History"}]},{title:"Application Stage Access",color:"from-red-50 to-orange-50 border-red-200",textColor:"text-red-900",permissions:[{id:"stage:initial_review",label:"Initial Review"},{id:"stage:field_verification",label:"Field Verification"},{id:"stage:level1_interview",label:"Level 1 Interview"},{id:"stage:level2_interview",label:"Level 2 Interview"},{id:"stage:ranking",label:"Ranking & Selection"},{id:"stage:legal_review",label:"Legal Review"},{id:"stage:financial_review",label:"Financial Review"},{id:"stage:final_approval",label:"Final Approval"},{id:"stage:payment",label:"Payment Verification"},{id:"stage:onboarding",label:"Onboarding"}]}];return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"sm:max-w-lg max-w-3xl max-h-[90vh] overflow-y-auto p-0 gap-0 border-none shadow-2xl custom-scrollbar",children:[e.jsxs(ys,{className:"p-6 pb-2 space-y-2 text-left bg-white sticky top-0 z-10 border-b",children:[e.jsxs(gs,{className:"text-xl font-bold tracking-tight",children:["Edit Role Permissions - ",n.name]}),e.jsxs(ws,{className:"text-slate-500 text-sm",children:["Configure default permissions for all users assigned to the ",n.name," role"]})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-br from-purple-50 to-indigo-50 rounded-xl p-5 border border-purple-100 shadow-sm",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-white rounded-xl shadow-sm flex items-center justify-center border border-purple-100",children:e.jsx(dc,{className:"w-6 h-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-bold text-slate-900",children:n.name}),e.jsxs("p",{className:"text-xs font-medium text-slate-500 uppercase tracking-widest",children:[n.userCount||0," users currently assigned"]})]})]}),e.jsx(we,{className:"bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-full text-[10px] font-bold tracking-wider uppercase",children:"Role Configuration"})]})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("h4",{className:"text-sm font-bold text-slate-800 flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-red-500 rounded-full"}),"Configure Default Permissions"]}),e.jsx("div",{className:"space-y-4",children:d.map((m,f)=>e.jsxs("div",{className:`border rounded-xl p-5 bg-gradient-to-br ${m.color} shadow-sm transition-all hover:shadow-md`,children:[e.jsxs("h5",{className:`text-sm font-bold ${m.textColor} mb-4 flex items-center justify-between`,children:[m.title,e.jsxs("span",{className:"text-[10px] bg-white/50 px-2 py-0.5 rounded-full opacity-70 italic font-normal",children:["Section ",f+1]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-y-3 gap-x-6",children:m.permissions.map(p=>e.jsxs("div",{className:"flex items-center space-x-3 group cursor-pointer p-1 rounded-md hover:bg-white/40 transition-colors",children:[e.jsx(Tn,{id:`perm-${p.id}`,checked:a.includes(p.id),onCheckedChange:()=>o(p.id),className:"border-slate-300 data-[state=checked]:bg-purple-600 data-[state=checked]:border-purple-600"}),e.jsx("label",{htmlFor:`perm-${p.id}`,className:"text-sm font-medium text-slate-700 cursor-pointer group-hover:text-slate-900 transition-colors flex-1",children:p.label})]},p.id))})]},f))})]})]}),e.jsxs("div",{className:"flex gap-3 p-6 pt-4 border-t sticky bottom-0 bg-white/80 backdrop-blur-md z-10",children:[e.jsx(te,{variant:"ghost",onClick:()=>s(!1),className:"flex-1 h-11 font-bold text-slate-600 hover:bg-slate-100",children:"Cancel"}),e.jsxs(te,{onClick:()=>r(n.id,a),className:"flex-1 h-11 bg-purple-600 hover:bg-purple-700 font-bold text-white shadow-lg shadow-purple-200",children:[e.jsx(dl,{className:"w-4 h-4 mr-2"}),"Save Role Permissions"]})]})]})})},FV=({isOpen:t,onOpenChange:s,onSave:n})=>{const[r,a]=g.useState(""),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(!1);g.useEffect(()=>{t&&(a(""),o(""),m(""),p(!1))},[t]);const h=async()=>{if(!(!r.trim()||!i.trim())){p(!0);try{await n({roleName:r.trim(),roleCode:i.trim(),description:d.trim()||void 0}),s(!1)}finally{p(!1)}}};return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"sm:max-w-md",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Add Role"}),e.jsx(ws,{children:"Create a new role for Master Configuration."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"role-name",children:"Role Name"}),e.jsx(it,{id:"role-name",value:r,onChange:x=>a(x.target.value),placeholder:"e.g. Finance Admin"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"role-code",children:"Role Code"}),e.jsx(it,{id:"role-code",value:i,onChange:x=>o(x.target.value),placeholder:"e.g. FINANCE_ADMIN"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"role-description",children:"Description"}),e.jsx(Ks,{id:"role-description",value:d,onChange:x=>m(x.target.value),placeholder:"Optional",rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{variant:"outline",onClick:()=>s(!1),disabled:f,children:"Cancel"}),e.jsx(te,{onClick:h,disabled:f||!r.trim()||!i.trim(),children:f?"Saving...":"Create Role"})]})]})})},BV=({onEditTemplate:t,onDeleteTemplate:s})=>{const{emailTemplates:n}=Pn(r=>r.master);return e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{children:[e.jsx(st,{children:"Email & Letter Templates"}),e.jsx(es,{children:"Templates and trigger codes come from system seed data. Edit wording and layout here; new triggers are not added from this screen."})]})}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Template Name"}),e.jsx(me,{children:"Subject"}),e.jsx(me,{children:"Trigger Code"}),e.jsx(me,{children:"Modified Date"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsxs(Bs,{children:[n.map(r=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-red-50 rounded-lg flex items-center justify-center",children:e.jsx(Gr,{className:"w-4 h-4 text-re-red"})}),e.jsx("span",{className:"font-medium text-slate-900",children:r.name||r.templateCode})]})}),e.jsx(oe,{className:"text-slate-600 max-w-xs truncate",children:r.subject}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"bg-slate-50 text-[10px] font-mono",children:r.templateCode||"-"})}),e.jsx(oe,{className:"text-slate-500 text-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(er,{className:"w-3.5 h-3.5"}),r.updatedAt?Qt(r.updatedAt):"-"]})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>t(r),children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>s(r.id),className:"text-red-500 hover:text-re-red hover:bg-red-50",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},r.id)),n.length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Gr,{className:"w-8 h-8 text-slate-200"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No templates configured yet"})]})})})]})]})})]})},$V=({onAddLocation:t,onEditLocation:s,onDeleteLocation:n,onSearch:r,onPageChange:a,searchTerm:i,states:o,stateFilter:d,onStateFilterChange:m,statusFilter:f,onStatusFilterChange:p})=>{const{allAreas:h,areasPagination:x,isAreasLoading:u}=Pn(N=>N.master);return e.jsx("div",{className:"space-y-4",children:e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(st,{children:"Dealership Locations"}),e.jsxs(es,{children:["Manage ",x.total," geographical locations and their operational status"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search locations...",value:i,onChange:N=>r(N.target.value),className:"pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-red-500 w-64 transition-all"})]}),e.jsxs(Rt,{value:d,onValueChange:m,children:[e.jsx(_t,{className:"w-48",children:e.jsx(Et,{placeholder:"All States"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All States"}),o.map(N=>e.jsx(Pe,{value:N.id,children:N.name||N.stateName},N.id))]})]}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"w-44",children:e.jsx(Et,{placeholder:"Opportunity Filter"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Opportunities"}),e.jsx(Pe,{value:"active",children:"Opportunity: Yes"}),e.jsx(Pe,{value:"inactive",children:"Opportunity: No"})]})]}),e.jsxs(te,{onClick:t,className:"bg-re-red hover:bg-re-red-hover whitespace-nowrap",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Location"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:`relative ${u?"opacity-50 pointer-events-none":""}`,children:[e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"State"}),e.jsx(me,{children:"City"}),e.jsx(me,{children:"District"}),e.jsx(me,{children:"Active Period"}),e.jsx(me,{children:"Opportunity"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:h.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"h-32 text-center text-slate-500 italic",children:i?"No locations found matching your search":"No locations available"})}):h.map(N=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"font-medium",children:N.stateName||"N/A"})]})}),e.jsx(oe,{className:"font-medium text-slate-900",children:N.city||"N/A"}),e.jsx(oe,{className:"text-slate-600 text-sm",children:N.name}),e.jsx(oe,{children:N.openFrom&&N.openTo?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"From:"}),e.jsx(we,{variant:"outline",className:"text-xs font-medium",children:Qt(N.openFrom)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"To:"}),e.jsx(we,{variant:"outline",className:"text-xs font-medium",children:Qt(N.openTo)})]})]}):e.jsx("span",{className:"text-slate-400 italic text-sm",children:"Not Defined"})}),e.jsx(oe,{children:e.jsx(we,{variant:N.isOpportunity?"default":"secondary",className:N.isOpportunity?"bg-green-600 hover:bg-green-700 text-white border-transparent":"",children:N.isOpportunity?"Yes":"No"})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(te,{variant:"outline",size:"sm",onClick:()=>s(N),className:"h-8 w-8 p-0",children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"outline",size:"sm",onClick:()=>n(N.id),className:"h-8 w-8 p-0 text-re-red hover:bg-red-50 hover:text-re-red-hover",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},N.id))})]}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/10 backdrop-blur-[1px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-re-red"})})]}),x.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6 pt-4 border-t border-slate-100",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:["Showing ",e.jsx("span",{className:"font-medium text-slate-900",children:(x.page-1)*x.limit+1})," to ",e.jsx("span",{className:"font-medium text-slate-900",children:Math.min(x.page*x.limit,x.total)})," of ",e.jsx("span",{className:"font-medium text-slate-900",children:x.total})," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{variant:"outline",size:"sm",onClick:()=>a(x.page-1),disabled:x.page<=1||u,className:"h-8",children:"Previous"}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,x.totalPages)},(N,v)=>{let w=x.page;return x.page<=3?w=v+1:x.page>=x.totalPages-2?w=x.totalPages-4+v:w=x.page-2+v,w<=0||w>x.totalPages?null:e.jsx(te,{variant:x.page===w?"default":"outline",size:"sm",onClick:()=>a(w),disabled:u,className:"h-8 w-8 p-0",children:w},w)})}),e.jsx(te,{variant:"outline",size:"sm",onClick:()=>a(x.page+1),disabled:x.page>=x.totalPages||u,className:"h-8",children:"Next"})]})]})]})]})})};var qV=Symbol("radix.slottable");function zV(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=qV,s}var[fp]=oa("Tooltip",[lo]),pp=lo(),p_="TooltipProvider",UV=700,Dy="tooltip.open",[VV,oj]=fp(p_),x_=t=>{const{__scopeTooltip:s,delayDuration:n=UV,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=t,o=g.useRef(!0),d=g.useRef(!1),m=g.useRef(0);return g.useEffect(()=>{const f=m.current;return()=>window.clearTimeout(f)},[]),e.jsx(VV,{scope:s,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(m.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:d,onPointerInTransitChange:g.useCallback(f=>{d.current=f},[]),disableHoverableContent:a,children:i})};x_.displayName=p_;var Ou="Tooltip",[HV,ih]=fp(Ou),g_=t=>{const{__scopeTooltip:s,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:d}=t,m=oj(Ou,t.__scopeTooltip),f=pp(s),[p,h]=g.useState(null),x=yr(),u=g.useRef(0),N=o??m.disableHoverableContent,v=d??m.delayDuration,w=g.useRef(!1),[j,b]=Li({prop:r,defaultProp:a??!1,onChange:A=>{A?(m.onOpen(),document.dispatchEvent(new CustomEvent(Dy))):m.onClose(),i==null||i(A)},caller:Ou}),C=g.useMemo(()=>j?w.current?"delayed-open":"instant-open":"closed",[j]),S=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,w.current=!1,b(!0)},[b]),D=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,b(!1)},[b]),_=g.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>{w.current=!0,b(!0),u.current=0},v)},[v,b]);return g.useEffect(()=>()=>{u.current&&(window.clearTimeout(u.current),u.current=0)},[]),e.jsx(Vf,{...f,children:e.jsx(HV,{scope:s,contentId:x,open:j,stateAttribute:C,trigger:p,onTriggerChange:h,onTriggerEnter:g.useCallback(()=>{m.isOpenDelayedRef.current?_():S()},[m.isOpenDelayedRef,_,S]),onTriggerLeave:g.useCallback(()=>{N?D():(window.clearTimeout(u.current),u.current=0)},[D,N]),onOpen:S,onClose:D,disableHoverableContent:N,children:n})})};g_.displayName=Ou;var Ry="TooltipTrigger",v_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=ih(Ry,n),i=oj(Ry,n),o=pp(n),d=g.useRef(null),m=Ys(s,d,a.onTriggerChange),f=g.useRef(!1),p=g.useRef(!1),h=g.useCallback(()=>f.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),e.jsx(Qu,{asChild:!0,...o,children:e.jsx(Ss.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:m,onPointerMove:Yt(t.onPointerMove,x=>{x.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Yt(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Yt(t.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Yt(t.onFocus,()=>{f.current||a.onOpen()}),onBlur:Yt(t.onBlur,a.onClose),onClick:Yt(t.onClick,a.onClose)})})});v_.displayName=Ry;var cj="TooltipPortal",[WV,GV]=fp(cj,{forceMount:void 0}),y_=t=>{const{__scopeTooltip:s,forceMount:n,children:r,container:a}=t,i=ih(cj,s);return e.jsx(WV,{scope:s,forceMount:n,children:e.jsx(jr,{present:n||i.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};y_.displayName=cj;var md="TooltipContent",b_=g.forwardRef((t,s)=>{const n=GV(md,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=t,o=ih(md,t.__scopeTooltip);return e.jsx(jr,{present:r||o.open,children:o.disableHoverableContent?e.jsx(j_,{side:a,...i,ref:s}):e.jsx(KV,{side:a,...i,ref:s})})}),KV=g.forwardRef((t,s)=>{const n=ih(md,t.__scopeTooltip),r=oj(md,t.__scopeTooltip),a=g.useRef(null),i=Ys(s,a),[o,d]=g.useState(null),{trigger:m,onClose:f}=n,p=a.current,{onPointerInTransitChange:h}=r,x=g.useCallback(()=>{d(null),h(!1)},[h]),u=g.useCallback((N,v)=>{const w=N.currentTarget,j={x:N.clientX,y:N.clientY},b=XV(j,w.getBoundingClientRect()),C=JV(j,b),S=eH(v.getBoundingClientRect()),D=sH([...C,...S]);d(D),h(!0)},[h]);return g.useEffect(()=>()=>x(),[x]),g.useEffect(()=>{if(m&&p){const N=w=>u(w,p),v=w=>u(w,m);return m.addEventListener("pointerleave",N),p.addEventListener("pointerleave",v),()=>{m.removeEventListener("pointerleave",N),p.removeEventListener("pointerleave",v)}}},[m,p,u,x]),g.useEffect(()=>{if(o){const N=v=>{const w=v.target,j={x:v.clientX,y:v.clientY},b=(m==null?void 0:m.contains(w))||(p==null?void 0:p.contains(w)),C=!tH(j,o);b?x():C&&(x(),f())};return document.addEventListener("pointermove",N),()=>document.removeEventListener("pointermove",N)}},[m,p,o,f,x]),e.jsx(j_,{...t,ref:i})}),[YV,ZV]=fp(Ou,{isInside:!1}),QV=zV("TooltipContent"),j_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...d}=t,m=ih(md,n),f=pp(n),{onClose:p}=m;return g.useEffect(()=>(document.addEventListener(Dy,p),()=>document.removeEventListener(Dy,p)),[p]),g.useEffect(()=>{if(m.trigger){const h=x=>{const u=x.target;u!=null&&u.contains(m.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[m.trigger,p]),e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:e.jsxs(Hf,{"data-state":m.stateAttribute,...f,...d,ref:s,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(QV,{children:r}),e.jsx(YV,{scope:n,isInside:!0,children:e.jsx(X7,{id:m.contentId,role:"tooltip",children:a||r})})]})})});b_.displayName=md;var N_="TooltipArrow",w_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=pp(n);return ZV(N_,n).isInside?null:e.jsx(Wf,{...a,...r,ref:s})});w_.displayName=N_;function XV(t,s){const n=Math.abs(s.top-t.y),r=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),i=Math.abs(s.left-t.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function JV(t,s,n=5){const r=[];switch(s){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function eH(t){const{top:s,right:n,bottom:r,left:a}=t;return[{x:a,y:s},{x:n,y:s},{x:n,y:r},{x:a,y:r}]}function tH(t,s){const{x:n,y:r}=t;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const d=s[i],m=s[o],f=d.x,p=d.y,h=m.x,x=m.y;p>r!=x>r&&n<(h-f)*(r-p)/(x-p)+f&&(a=!a)}return a}function sH(t){const s=t.slice();return s.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),nH(s)}function nH(t){if(t.length<=1)return t.slice();const s=[];for(let r=0;r<t.length;r++){const a=t[r];for(;s.length>=2;){const i=s[s.length-1],o=s[s.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))s.pop();else break}s.push(a)}s.pop();const n=[];for(let r=t.length-1;r>=0;r--){const a=t[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var rH=x_,aH=g_,iH=v_,lH=y_,oH=b_,cH=w_;function xp({delayDuration:t=0,...s}){return e.jsx(rH,{"data-slot":"tooltip-provider",delayDuration:t,...s})}function dj({...t}){return e.jsx(xp,{children:e.jsx(aH,{"data-slot":"tooltip",...t})})}function uj({...t}){return e.jsx(iH,{"data-slot":"tooltip-trigger",...t})}function hj({className:t,sideOffset:s=0,children:n,...r}){return e.jsx(lH,{children:e.jsxs(oH,{"data-slot":"tooltip-content",sideOffset:s,className:Nt("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,e.jsx(cH,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const dH=({isOpen:t,onOpenChange:s,editingASMId:n,asmManagerId:r,setAsmManagerId:a,asmStatus:i,setAsmStatus:o,selectedASMZone:d,setSelectedASMZone:m,selectedASMRegion:f,setSelectedASMRegion:p,selectedASMStates:h,setSelectedASMStates:x,selectedASMDistricts:u,setSelectedASMDistricts:N,onSave:v,asmRoleCode:w,userAssignedData:j,districtsAssignedToOthers:b,getDistrictsForSelectedState:C})=>{const{zones:S,regionalOffices:D}=Pn(A=>A.master),_=j.filter(A=>{const E=(A.allRoles||[]).map(O=>String(O||"").toUpperCase()),q=String(A.roleCode||"").toUpperCase();return E.includes("DD-AM")||q==="DD-AM"});return Ct.useEffect(()=>{if(r&&t){const A=j.find(E=>E.id===r);if(A&&A.territoryProfile){const E=A.territoryProfile.filter(q=>q.roleCode===w&&q.locationType==="district").map(q=>q.locationId);E.length>0&&N(E)}}},[r,w,t,j,N]),e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," DD Area Manager"]}),e.jsx(ws,{children:"Configure DD-AM details and district assignment"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Zone"}),e.jsxs(Rt,{value:d,onValueChange:A=>{m(A),p(""),x([]),N([])},children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select zone"})}),e.jsx(Tt,{children:S.map(A=>e.jsx(Pe,{value:A.id,children:A.name},A.id))})]})]}),d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Regional Office"}),e.jsxs(Rt,{value:f,onValueChange:A=>{p(A),x([]),N([])},children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select regional office"})}),e.jsx(Tt,{children:D.filter(A=>A.zoneId===d).map(A=>e.jsx(Pe,{value:A.id,children:A.name},A.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Select DD-AM User"}),e.jsxs(Rt,{value:r,onValueChange:a,children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select DD-AM"})}),e.jsx(Tt,{className:"max-h-64",children:_.map(A=>e.jsxs(Pe,{value:A.id,children:[A.name," (",A.employeeId||"No ID",")"]},A.id))})]})]})]}),f&&e.jsxs("div",{children:[e.jsx(le,{children:"States Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-48 overflow-y-auto bg-slate-50",children:(()=>{const A=D.find(q=>q.id===f),E=((A==null?void 0:A.states)||[]).map(q=>typeof q=="string"?q:q.name);return E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(q=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:`asm-state-${q}`,checked:h.some(O=>O.toLowerCase()===q.toLowerCase()),onCheckedChange:O=>{if(O)x([...h,q]);else{x(h.filter(P=>P.toLowerCase()!==q.toLowerCase()));const R=C(q);N(u.filter(P=>!R.some(L=>L.id===P)))}}}),e.jsx("label",{htmlFor:`asm-state-${q}`,className:"text-sm cursor-pointer text-slate-900",children:q})]},q))}):e.jsx("p",{className:"text-sm text-slate-500",children:"No states available for this regional office"})})()})]}),h.length>0&&e.jsxs("div",{children:[e.jsx(le,{children:"Districts/Cities Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-64 overflow-y-auto bg-slate-50",children:e.jsx(xp,{children:h.map(A=>{const E=C(A);return E.length===0?null:e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-sm text-re-red-hover mb-2 pb-1 border-b border-slate-200",children:A}),e.jsx("div",{className:"space-y-2 ml-2",children:E.map(q=>e.jsx("div",{children:e.jsxs(dj,{children:[e.jsx(uj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 py-0.5",children:[e.jsx(Tn,{id:`asm-district-${q.id}`,checked:u.includes(q.id),disabled:!!b[q.id],onCheckedChange:O=>{N(O?[...u,q.id]:u.filter(R=>R!==q.id))}}),e.jsx("label",{htmlFor:`asm-district-${q.id}`,className:`text-sm flex items-center gap-1.5 ${b[q.id]?"text-slate-400 cursor-not-allowed":"cursor-pointer text-slate-900"}`,children:q.name})]})}),b[q.id]&&e.jsx(hj,{children:e.jsxs("p",{children:["Already managed by: ",b[q.id].join(", ")]})})]})},q.id))})]},A)})})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs(le,{children:["DD Area Manager ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:r,onValueChange:A=>{var q;a(A);const E=j.find(O=>O.id===A);if(E){const O=(E.territoryProfile||[]).find(R=>R.roleCode===w);O!=null&&O.zoneId&&m(O.zoneId),O!=null&&O.regionId&&p(O.regionId),N(((q=E.areasManaged)==null?void 0:q.filter(R=>R.roleCode===w).map(R=>R.id))||[]),x(E.stateNames||[])}},disabled:!!n,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900",children:e.jsx(Et,{placeholder:"Select DD-AM User"})}),e.jsx(Tt,{className:"max-h-60",children:_.length>0?_.map(A=>e.jsx(Pe,{value:A.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium text-slate-900",children:A.name}),e.jsx("span",{className:"text-xs text-slate-500",children:A.email})]})},A.id)):e.jsx("div",{className:"p-2 text-sm text-slate-500 text-center",children:"No users available"})})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Status"}),e.jsxs(Rt,{value:i,onValueChange:A=>o(A),children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:v,children:"Save DD-AM"})]})]})]})})};var MS=1,uH=.9,hH=.8,mH=.17,Zg=.1,Qg=.999,fH=.9999,pH=.99,xH=/[\\\/_+.#"@\[\(\{&]/,gH=/[\\\/_+.#"@\[\(\{&]/g,vH=/[\s-]/,S_=/[\s-]/g;function Ey(t,s,n,r,a,i,o){if(i===s.length)return a===t.length?MS:pH;var d=`${a},${i}`;if(o[d]!==void 0)return o[d];for(var m=r.charAt(i),f=n.indexOf(m,a),p=0,h,x,u,N;f>=0;)h=Ey(t,s,n,r,f+1,i+1,o),h>p&&(f===a?h*=MS:xH.test(t.charAt(f-1))?(h*=hH,u=t.slice(a,f-1).match(gH),u&&a>0&&(h*=Math.pow(Qg,u.length))):vH.test(t.charAt(f-1))?(h*=uH,N=t.slice(a,f-1).match(S_),N&&a>0&&(h*=Math.pow(Qg,N.length))):(h*=mH,a>0&&(h*=Math.pow(Qg,f-a))),t.charAt(f)!==s.charAt(i)&&(h*=fH)),(h<Zg&&n.charAt(f-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(f-1)!==r.charAt(i))&&(x=Ey(t,s,n,r,f+1,i+2,o),x*Zg>h&&(h=x*Zg)),h>p&&(p=h),f=n.indexOf(m,f+1);return o[d]=p,p}function FS(t){return t.toLowerCase().replace(S_," ")}function yH(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Ey(t,s,FS(t),FS(s),0,0,{})}var cu='[cmdk-group=""]',Xg='[cmdk-group-items=""]',bH='[cmdk-group-heading=""]',C_='[cmdk-item=""]',BS=`${C_}:not([aria-disabled="true"])`,_y="cmdk-item-select",Kc="data-value",jH=(t,s,n)=>yH(t,s,n),A_=g.createContext(void 0),lh=()=>g.useContext(A_),k_=g.createContext(void 0),mj=()=>g.useContext(k_),D_=g.createContext(void 0),R_=g.forwardRef((t,s)=>{let n=Yc(()=>{var F,I;return{search:"",value:(I=(F=t.value)!=null?F:t.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Yc(()=>new Set),a=Yc(()=>new Map),i=Yc(()=>new Map),o=Yc(()=>new Set),d=E_(t),{label:m,children:f,value:p,onValueChange:h,filter:x,shouldFilter:u,loop:N,disablePointerSelection:v=!1,vimBindings:w=!0,...j}=t,b=yr(),C=yr(),S=yr(),D=g.useRef(null),_=TH();cc(()=>{if(p!==void 0){let F=p.trim();n.current.value=F,A.emit()}},[p]),cc(()=>{_(6,L)},[]);let A=g.useMemo(()=>({subscribe:F=>(o.current.add(F),()=>o.current.delete(F)),snapshot:()=>n.current,setState:(F,I,K)=>{var G,V,Y,re;if(!Object.is(n.current[F],I)){if(n.current[F]=I,F==="search")P(),O(),_(1,R);else if(F==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ae=document.getElementById(S);ae?ae.focus():(G=document.getElementById(b))==null||G.focus()}if(_(7,()=>{var ae;n.current.selectedItemId=(ae=$())==null?void 0:ae.id,A.emit()}),K||_(5,L),((V=d.current)==null?void 0:V.value)!==void 0){let ae=I??"";(re=(Y=d.current).onValueChange)==null||re.call(Y,ae);return}}A.emit()}},emit:()=>{o.current.forEach(F=>F())}}),[]),E=g.useMemo(()=>({value:(F,I,K)=>{var G;I!==((G=i.current.get(F))==null?void 0:G.value)&&(i.current.set(F,{value:I,keywords:K}),n.current.filtered.items.set(F,q(I,K)),_(2,()=>{O(),A.emit()}))},item:(F,I)=>(r.current.add(F),I&&(a.current.has(I)?a.current.get(I).add(F):a.current.set(I,new Set([F]))),_(3,()=>{P(),O(),n.current.value||R(),A.emit()}),()=>{i.current.delete(F),r.current.delete(F),n.current.filtered.items.delete(F);let K=$();_(4,()=>{P(),(K==null?void 0:K.getAttribute("id"))===F&&R(),A.emit()})}),group:F=>(a.current.has(F)||a.current.set(F,new Set),()=>{i.current.delete(F),a.current.delete(F)}),filter:()=>d.current.shouldFilter,label:m||t["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:b,inputId:S,labelId:C,listInnerRef:D}),[]);function q(F,I){var K,G;let V=(G=(K=d.current)==null?void 0:K.filter)!=null?G:jH;return F?V(F,n.current.search,I):0}function O(){if(!n.current.search||d.current.shouldFilter===!1)return;let F=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(G=>{let V=a.current.get(G),Y=0;V.forEach(re=>{let ae=F.get(re);Y=Math.max(ae,Y)}),I.push([G,Y])});let K=D.current;Z().sort((G,V)=>{var Y,re;let ae=G.getAttribute("id"),ue=V.getAttribute("id");return((Y=F.get(ue))!=null?Y:0)-((re=F.get(ae))!=null?re:0)}).forEach(G=>{let V=G.closest(Xg);V?V.appendChild(G.parentElement===V?G:G.closest(`${Xg} > *`)):K.appendChild(G.parentElement===K?G:G.closest(`${Xg} > *`))}),I.sort((G,V)=>V[1]-G[1]).forEach(G=>{var V;let Y=(V=D.current)==null?void 0:V.querySelector(`${cu}[${Kc}="${encodeURIComponent(G[0])}"]`);Y==null||Y.parentElement.appendChild(Y)})}function R(){let F=Z().find(K=>K.getAttribute("aria-disabled")!=="true"),I=F==null?void 0:F.getAttribute(Kc);A.setState("value",I||void 0)}function P(){var F,I,K,G;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let V=0;for(let Y of r.current){let re=(I=(F=i.current.get(Y))==null?void 0:F.value)!=null?I:"",ae=(G=(K=i.current.get(Y))==null?void 0:K.keywords)!=null?G:[],ue=q(re,ae);n.current.filtered.items.set(Y,ue),ue>0&&V++}for(let[Y,re]of a.current)for(let ae of re)if(n.current.filtered.items.get(ae)>0){n.current.filtered.groups.add(Y);break}n.current.filtered.count=V}function L(){var F,I,K;let G=$();G&&(((F=G.parentElement)==null?void 0:F.firstChild)===G&&((K=(I=G.closest(cu))==null?void 0:I.querySelector(bH))==null||K.scrollIntoView({block:"nearest"})),G.scrollIntoView({block:"nearest"}))}function $(){var F;return(F=D.current)==null?void 0:F.querySelector(`${C_}[aria-selected="true"]`)}function Z(){var F;return Array.from(((F=D.current)==null?void 0:F.querySelectorAll(BS))||[])}function Q(F){let I=Z()[F];I&&A.setState("value",I.getAttribute(Kc))}function W(F){var I;let K=$(),G=Z(),V=G.findIndex(re=>re===K),Y=G[V+F];(I=d.current)!=null&&I.loop&&(Y=V+F<0?G[G.length-1]:V+F===G.length?G[0]:G[V+F]),Y&&A.setState("value",Y.getAttribute(Kc))}function U(F){let I=$(),K=I==null?void 0:I.closest(cu),G;for(;K&&!G;)K=F>0?EH(K,cu):_H(K,cu),G=K==null?void 0:K.querySelector(BS);G?A.setState("value",G.getAttribute(Kc)):W(F)}let M=()=>Q(Z().length-1),z=F=>{F.preventDefault(),F.metaKey?M():F.altKey?U(1):W(1)},T=F=>{F.preventDefault(),F.metaKey?Q(0):F.altKey?U(-1):W(-1)};return g.createElement(Ss.div,{ref:s,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:F=>{var I;(I=j.onKeyDown)==null||I.call(j,F);let K=F.nativeEvent.isComposing||F.keyCode===229;if(!(F.defaultPrevented||K))switch(F.key){case"n":case"j":{w&&F.ctrlKey&&z(F);break}case"ArrowDown":{z(F);break}case"p":case"k":{w&&F.ctrlKey&&T(F);break}case"ArrowUp":{T(F);break}case"Home":{F.preventDefault(),Q(0);break}case"End":{F.preventDefault(),M();break}case"Enter":{F.preventDefault();let G=$();if(G){let V=new Event(_y);G.dispatchEvent(V)}}}}},g.createElement("label",{"cmdk-label":"",htmlFor:E.inputId,id:E.labelId,style:OH},m),gp(t,F=>g.createElement(k_.Provider,{value:A},g.createElement(A_.Provider,{value:E},F))))}),NH=g.forwardRef((t,s)=>{var n,r;let a=yr(),i=g.useRef(null),o=g.useContext(D_),d=lh(),m=E_(t),f=(r=(n=m.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;cc(()=>{if(!f)return d.item(a,o==null?void 0:o.id)},[f]);let p=__(a,i,[t.value,t.children,i],t.keywords),h=mj(),x=ao(_=>_.value&&_.value===p.current),u=ao(_=>f||d.filter()===!1?!0:_.search?_.filtered.items.get(a)>0:!0);g.useEffect(()=>{let _=i.current;if(!(!_||t.disabled))return _.addEventListener(_y,N),()=>_.removeEventListener(_y,N)},[u,t.onSelect,t.disabled]);function N(){var _,A;v(),(A=(_=m.current).onSelect)==null||A.call(_,p.current)}function v(){h.setState("value",p.current,!0)}if(!u)return null;let{disabled:w,value:j,onSelect:b,forceMount:C,keywords:S,...D}=t;return g.createElement(Ss.div,{ref:Hr(i,s),...D,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!x,"data-disabled":!!w,"data-selected":!!x,onPointerMove:w||d.getDisablePointerSelection()?void 0:v,onClick:w?void 0:N},t.children)}),wH=g.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...i}=t,o=yr(),d=g.useRef(null),m=g.useRef(null),f=yr(),p=lh(),h=ao(u=>a||p.filter()===!1?!0:u.search?u.filtered.groups.has(o):!0);cc(()=>p.group(o),[]),__(o,d,[t.value,t.heading,m]);let x=g.useMemo(()=>({id:o,forceMount:a}),[a]);return g.createElement(Ss.div,{ref:Hr(d,s),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&g.createElement("div",{ref:m,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),gp(t,u=>g.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},g.createElement(D_.Provider,{value:x},u))))}),SH=g.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=g.useRef(null),i=ao(o=>!o.search);return!n&&!i?null:g.createElement(Ss.div,{ref:Hr(a,s),...r,"cmdk-separator":"",role:"separator"})}),CH=g.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,i=mj(),o=ao(f=>f.search),d=ao(f=>f.selectedItemId),m=lh();return g.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),g.createElement(Ss.input,{ref:s,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":m.listId,"aria-labelledby":m.labelId,"aria-activedescendant":d,id:m.inputId,type:"text",value:a?t.value:o,onChange:f=>{a||i.setState("search",f.target.value),n==null||n(f.target.value)}})}),AH=g.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,i=g.useRef(null),o=g.useRef(null),d=ao(f=>f.selectedItemId),m=lh();return g.useEffect(()=>{if(o.current&&i.current){let f=o.current,p=i.current,h,x=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let u=f.offsetHeight;p.style.setProperty("--cmdk-list-height",u.toFixed(1)+"px")})});return x.observe(f),()=>{cancelAnimationFrame(h),x.unobserve(f)}}},[]),g.createElement(Ss.div,{ref:Hr(i,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":r,id:m.listId},gp(t,f=>g.createElement("div",{ref:Hr(o,m.listInnerRef),"cmdk-list-sizer":""},f)))}),kH=g.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...d}=t;return g.createElement(qb,{open:n,onOpenChange:r},g.createElement(zb,{container:o},g.createElement(ip,{"cmdk-overlay":"",className:a}),g.createElement(lp,{"aria-label":t.label,"cmdk-dialog":"",className:i},g.createElement(R_,{ref:s,...d}))))}),DH=g.forwardRef((t,s)=>ao(n=>n.filtered.count===0)?g.createElement(Ss.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),RH=g.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...i}=t;return g.createElement(Ss.div,{ref:s,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},gp(t,o=>g.createElement("div",{"aria-hidden":!0},o)))}),kd=Object.assign(R_,{List:AH,Item:NH,Input:CH,Group:wH,Separator:SH,Dialog:kH,Empty:DH,Loading:RH});function EH(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function _H(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function E_(t){let s=g.useRef(t);return cc(()=>{s.current=t}),s}var cc=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Yc(t){let s=g.useRef();return s.current===void 0&&(s.current=t()),s}function ao(t){let s=mj(),n=()=>t(s.snapshot());return g.useSyncExternalStore(s.subscribe,n,n)}function __(t,s,n,r=[]){let a=g.useRef(),i=lh();return cc(()=>{var o;let d=(()=>{var f;for(let p of n){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(f=p.current.textContent)==null?void 0:f.trim():a.current}})(),m=r.map(f=>f.trim());i.value(t,d,m),(o=s.current)==null||o.setAttribute(Kc,d),a.current=d}),a}var TH=()=>{let[t,s]=g.useState(),n=Yc(()=>new Map);return cc(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function PH(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function gp({asChild:t,children:s},n){return t&&g.isValidElement(s)?g.cloneElement(PH(s),{ref:s.ref},n(s.props.children)):n(s)}var OH={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function LH({className:t,...s}){return e.jsx(kd,{"data-slot":"command",className:Nt("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...s})}function IH({className:t,...s}){return e.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[e.jsx(wa,{className:"size-4 shrink-0 opacity-50"}),e.jsx(kd.Input,{"data-slot":"command-input",className:Nt("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...s})]})}function MH({className:t,...s}){return e.jsx(kd.List,{"data-slot":"command-list",className:Nt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...s})}function FH({...t}){return e.jsx(kd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function BH({className:t,...s}){return e.jsx(kd.Group,{"data-slot":"command-group",className:Nt("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...s})}function $S({className:t,...s}){return e.jsx(kd.Item,{"data-slot":"command-item",className:Nt("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}const $H=({value:t,onChange:s,asmUsers:n,className:r})=>{const[a,i]=g.useState(!1),o=n.find(d=>d.id===t);return e.jsxs(_u,{open:a,onOpenChange:i,children:[e.jsx(Tu,{asChild:!0,children:e.jsxs(te,{variant:"outline",role:"combobox","aria-expanded":a,className:Nt("w-full min-w-0 justify-between",r),children:[e.jsx("span",{className:"truncate text-left",children:t==="__none__"?"Unassign":o?`${o.fullName} (${o.employeeId||o.email})`:"Select ASM"}),e.jsx(LI,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Pu,{className:"w-[360px] max-w-[90vw] p-0",children:e.jsxs(LH,{children:[e.jsx(IH,{placeholder:"Search ASM by name/email/id..."}),e.jsxs(MH,{className:"max-h-64 overflow-y-auto custom-scrollbar-slim",children:[e.jsx(FH,{children:"No ASM found."}),e.jsxs(BH,{children:[e.jsxs($S,{value:"Unassign __none__",onSelect:()=>{s("__none__"),i(!1)},children:[e.jsx($n,{className:Nt("mr-2 h-4 w-4",t==="__none__"?"opacity-100":"opacity-0")}),"Unassign"]}),n.map(d=>e.jsxs($S,{value:`${d.fullName} ${d.email} ${d.employeeId||""}`,onSelect:()=>{s(d.id),i(!1)},children:[e.jsx($n,{className:Nt("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.fullName," (",d.employeeId||d.email,")"]},d.id))]})]})]})})]})},qH=()=>{const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,i]=g.useState([]),[o,d]=g.useState({}),m=async()=>{var h,x,u,N;try{s(!0);const v=await $s.getDealerAsmMappings();v!=null&&v.success&&(r(((h=v.data)==null?void 0:h.dealers)||[]),i(((x=v.data)==null?void 0:x.asmUsers)||[]))}catch(v){J.error(((N=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:N.message)||"Failed to load dealer ASM mappings")}finally{s(!1)}};g.useEffect(()=>{m()},[]);const f=g.useMemo(()=>[...n].sort((h,x)=>{const u=String(h.status||"").toLowerCase()==="active",N=String(x.status||"").toLowerCase()==="active";return u!==N?u?-1:1:String(h.dealerName||"").localeCompare(String(x.dealerName||""))}),[n]),p=async h=>{var u,N;const x=o[h]||"";try{const v=await $s.saveDealerAsmMapping({dealerId:h,asmUserId:x==="__none__"?null:x||null});v!=null&&v.success?(J.success(v.message||"Dealer ASM mapping updated"),await m()):J.error((v==null?void 0:v.message)||"Failed to save mapping")}catch(v){J.error(((N=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:N.message)||"Failed to save mapping")}};return e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Dealer-Level ASM Assignment"}),e.jsx(es,{children:"Assign Sales ASM to onboarded dealers. DD-AM remains district-level in the section above."})]}),e.jsx(Oe,{children:t?e.jsx("p",{className:"text-sm text-slate-500",children:"Loading mappings..."}):e.jsxs(Ms,{className:"w-full",children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Dealer"}),e.jsx(me,{children:"Dealer Code"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Current ASM"}),e.jsx(me,{children:"Assign ASM"})]})}),e.jsxs(Bs,{children:[f.length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center text-slate-500 py-8",children:"No dealers available for ASM mapping yet."})}),f.map(h=>{var x;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:h.dealerName}),e.jsx("span",{className:"text-xs text-slate-500",children:h.legalName})]})}),e.jsx(oe,{children:h.dealerCode||"N/A"}),e.jsx(oe,{children:e.jsx(we,{variant:String(h.status||"").toLowerCase()==="active"?"default":"secondary",className:String(h.status||"").toLowerCase()==="active"?"bg-emerald-100 text-emerald-700 hover:bg-emerald-200":"",children:h.status||"Unknown"})}),e.jsx(oe,{children:h.assignedAsm?e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{children:h.assignedAsm.fullName}),e.jsx("span",{className:"text-xs text-slate-500 truncate",children:h.assignedAsm.employeeId||h.assignedAsm.email})]}):e.jsx("span",{className:"text-slate-400 text-sm",children:"Unassigned"})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx($H,{asmUsers:a,value:o[h.dealerId]??((x=h.assignedAsm)==null?void 0:x.id)??"__none__",onChange:u=>d(N=>({...N,[h.dealerId]:u})),className:"flex-1 min-w-[180px]"}),e.jsx(te,{size:"sm",className:"shrink-0 bg-re-red hover:bg-re-red-hover text-white",onClick:()=>p(h.dealerId),children:"Assign"})]})})]},h.dealerId)})]})]})})]})},zH=({isOpen:t,onOpenChange:s,editingZMId:n,zmManagerId:r,setZmManagerId:a,zmStatus:i,setZmStatus:o,selectedZone:d,setSelectedZone:m,selectedRegions:f,setSelectedRegions:p,onSave:h,userAssignedData:x})=>{const{zones:u,regionalOffices:N}=Pn(j=>j.master),v=x.filter(j=>(j.allRoles||[]).some(C=>{const S=(C||"").toUpperCase();return["ZM","ZONAL MANAGER","ZBH","ZONE BUSINESS HEAD","RM","RBM","REGIONAL MANAGER"].includes(S)||S.includes("ZONAL")||S.includes("REGIONAL")})),w=N.filter(j=>j.zoneId===d);return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," Zonal Manager"]}),e.jsx(ws,{children:"Assign Zonal Manager to Regions within a Zone"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-b border-slate-100 pb-4",children:[e.jsxs(le,{children:["Select Zonal Manager User ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:r,onValueChange:j=>{a(j);const b=x.find(C=>C.id===j);b&&(b.zoneId&&m(b.zoneId),b.assignedRegionIds&&p(b.assignedRegionIds))},disabled:!!n,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900 border-slate-200",children:e.jsx(Et,{placeholder:"Select ZM User"})}),e.jsx(Tt,{className:"max-h-60",children:v.map(j=>e.jsx(Pe,{value:j.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium text-slate-900",children:j.name}),e.jsx("span",{className:"text-xs text-slate-500",children:j.email})]})},j.id))})]})]}),e.jsxs("div",{children:[e.jsxs(le,{children:["Managed Zone ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Rt,{value:d,onValueChange:j=>{m(j),p([])},children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{placeholder:"Select zone"})}),e.jsx(Tt,{children:u.map(j=>e.jsx(Pe,{value:j.id,children:j.name},j.id))})]})]}),d&&e.jsxs("div",{children:[e.jsxs(le,{className:"mb-2 block",children:["Assigned Regions ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"border border-slate-200 rounded-lg p-4 bg-slate-50/50 max-h-60 overflow-y-auto",children:e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[w.map(j=>e.jsxs("div",{className:"flex items-center space-x-3 p-2 rounded hover:bg-white transition-colors",children:[e.jsx(Tn,{id:`region-${j.id}`,checked:f.includes(j.id),onCheckedChange:b=>{p(b?[...f,j.id]:f.filter(C=>C!==j.id))}}),e.jsxs("label",{htmlFor:`region-${j.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[j.name,e.jsx("span",{className:"text-xs text-slate-500 block mt-1",children:j.code||"No Code"})]})]},j.id)),w.length===0&&e.jsx("p",{className:"text-sm text-slate-500 italic text-center py-4",children:"No regions found for this zone"})]})})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Status"}),e.jsxs(Rt,{value:i,onValueChange:j=>o(j),children:[e.jsx(_t,{className:"mt-2",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-6",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:h,children:"Save Zonal Manager"})]})]})]})})},UH=({isOpen:t,onOpenChange:s,editingZoneId:n,zoneName:r,setZoneName:a,zoneCode:i,setZoneCode:o,zoneDescription:d,setZoneDescription:m,zonalBusinessHeadId:f,setZonalBusinessHeadId:p,userAssignedData:h,onSave:x})=>{const u=(h||[]).filter(v=>{if(f!=="none"&&v.id===f)return!0;const w=(v.allRoles||[]).map(b=>String(b||"").toUpperCase()),j=String(v.roleCode||v.role||"").toUpperCase();return j==="ZBH"||j.includes("ZONAL BUSINESS HEAD")||w.some(b=>{const C=String(b||"").toUpperCase();return C==="ZBH"||C==="ZONE BUSINESS HEAD"||C==="ZONAL BUSINESS HEAD"})}),N=u.length>0?u:h||[];return Ct.useEffect(()=>{},[n,t]),e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-md",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," Zone"]}),e.jsx(ws,{children:"Configure zonal details and geographical boundaries"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Zone Name"}),e.jsx(it,{placeholder:"e.g., North Zone",className:"mt-2 text-slate-900",value:r,onChange:v=>a(v.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Zone Code"}),e.jsx(it,{placeholder:"e.g., NZ",className:"mt-2 text-slate-900",value:i,onChange:v=>o(v.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Zonal Business Head"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900",children:e.jsx(Et,{placeholder:"Select Head"})}),e.jsxs(Tt,{className:"max-h-60",children:[e.jsx(Pe,{value:"none",children:"None / Unassigned"}),N.map(v=>e.jsxs(Pe,{value:v.id,children:[v.name," (",v.email,")"]},v.id))]})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Description"}),e.jsx(Ks,{placeholder:"Describe the zone's coverage...",className:"mt-2 text-slate-900",rows:3,value:d,onChange:v=>m(v.target.value)})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:x,children:"Save Zone"})]})]})]})})},VH=({isOpen:t,onOpenChange:s,editingRegionId:n,regionName:r,setRegionName:a,regionDescription:i,setRegionDescription:o,selectedRegionZone:d,setSelectedRegionZone:m,regionalManagerId:f,setRegionalManagerId:p,selectedRegionStates:h,setSelectedRegionStates:x,onSave:u,userAssignedData:N})=>{const{zones:v,allStates:w,allDistricts:j,regionalOffices:b}=Pn(R=>R.master),[C,S]=Ct.useState([]),D=Ct.useMemo(()=>{const R={};return(b||[]).forEach(P=>{P.id!==n&&(P.districts||[]).forEach(L=>{R[L.id]=P.name})}),R},[b,n]),_=Ct.useMemo(()=>{if(!d)return w;const R=new Set(j.filter(P=>P.zoneId===d||!P.zoneId||h.includes(P.id)).map(P=>P.stateId).filter(Boolean));return w.filter(P=>P.zoneId===d||R.has(P.id)||!P.zoneId)},[w,j,d,h]),A=Ct.useMemo(()=>C.length===0?[]:j.filter(R=>C.includes(R.stateId)&&(!R.zoneId||R.zoneId===d||R.regionId===n)),[j,C,d,n]),E=Ct.useMemo(()=>{const R={};return A.forEach(P=>{const L=w.find(Z=>Z.id===P.stateId),$=(L==null?void 0:L.name)||P.stateId;R[P.stateId]||(R[P.stateId]={stateName:$,districts:[]}),R[P.stateId].districts.push(P)}),Object.values(R)},[A,w]);Ct.useEffect(()=>{if(!t){S([]);return}if(h.length>0){const R=Array.from(new Set(j.filter(P=>h.includes(P.id)).map(P=>P.stateId).filter(Boolean)));S(R)}},[t]);const q=R=>{m(R),S([]),x([])},O=(R,P)=>{if(P)S(L=>[...L,R]);else{S($=>$.filter(Z=>Z!==R));const L=j.filter($=>$.stateId===R).map($=>$.id);x(h.filter($=>!L.includes($)))}};return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n?"Edit":"Add"," Regional Office"]}),e.jsx(ws,{children:"Configure regional office details and coverage area"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{children:"Region Name"}),e.jsx(it,{placeholder:"e.g., Delhi NCR Region",className:"mt-2 text-slate-900",value:r,onChange:R=>a(R.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Zone"}),e.jsxs(Rt,{value:d,onValueChange:q,children:[e.jsx(_t,{className:"mt-2 text-slate-900",children:e.jsx(Et,{placeholder:"Select zone"})}),e.jsx(Tt,{children:v.map(R=>e.jsx(Pe,{value:R.id,children:R.name},R.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Regional Manager"}),e.jsxs(Rt,{value:f,onValueChange:p,children:[e.jsx(_t,{className:"mt-2 w-full text-slate-900",children:e.jsx(Et,{placeholder:"Select from available users"})}),e.jsx(Tt,{className:"max-h-60",children:N.map(R=>e.jsxs(Pe,{value:R.id,children:[R.name||R.fullName,R.email?` — ${R.email}`:""]},R.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Description"}),e.jsx(Ks,{placeholder:"Describe the region...",className:"mt-2 text-slate-900",rows:2,value:i,onChange:R=>o(R.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{children:"States Covered"}),!d&&e.jsx("p",{className:"text-xs text-re-red mt-1",children:"Select a zone first to see available states"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-40 overflow-y-auto bg-slate-50",children:_.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:d?"No states with available districts in this zone":"Select a zone to load states"}):e.jsx("div",{className:"space-y-2",children:_.map(R=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:`region-state-${R.id}`,checked:C.includes(R.id),disabled:!d,onCheckedChange:P=>O(R.id,!!P)}),e.jsx("label",{htmlFor:`region-state-${R.id}`,className:`text-sm cursor-pointer ${d?"text-slate-900":"text-slate-400"}`,children:R.name})]},R.id))})}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[C.length," ",C.length===1?"state":"states"," selected"]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Districts Covered"}),e.jsx("div",{className:"mt-2 border rounded-lg p-3 max-h-56 overflow-y-auto bg-slate-50",children:C.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"Select one or more states above to see districts"}):E.length===0?e.jsx("p",{className:"text-xs text-slate-400 italic",children:"No available districts in the selected states for this zone"}):e.jsx(xp,{children:E.map(({stateName:R,districts:P})=>e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("h4",{className:"text-xs font-semibold text-re-red-hover uppercase tracking-wide mb-2 pb-1 border-b border-slate-200",children:R}),e.jsx("div",{className:"space-y-2 ml-1",children:P.map(L=>{const $=D[L.id],Z=L.zoneId&&L.zoneId!==d&&L.regionId!==n,Q=!!($||Z),W=$?`Already assigned to region: ${$}`:Z?"Belongs to a different zone":"";return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(dj,{children:[e.jsx(uj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 w-full",children:[e.jsx(Tn,{id:`region-district-${L.id}`,disabled:Q,checked:h.includes(L.id),onCheckedChange:U=>{x(U?[...h,L.id]:h.filter(M=>M!==L.id))}}),e.jsxs("label",{htmlFor:`region-district-${L.id}`,className:`text-sm flex-1 ${Q?"text-slate-400 cursor-not-allowed line-through":"text-slate-900 cursor-pointer"}`,children:[L.name,$&&e.jsxs("span",{className:"ml-2 text-xs text-red-400 font-normal no-underline",style:{textDecoration:"none"},children:["(in ",$,")"]})]})]})}),Q&&W&&e.jsx(hj,{children:e.jsx("p",{className:"text-xs",children:W})})]})},L.id)})})]},R))})}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:[h.length," ",h.length===1?"district":"districts"," selected"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:u,children:"Save Regional Office"})]})]})]})})};var vp="Switch",[HH]=oa(vp),[WH,GH]=HH(vp),T_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:d,value:m="on",onCheckedChange:f,form:p,...h}=t,[x,u]=g.useState(null),N=Ys(s,C=>u(C)),v=g.useRef(!1),w=x?p||!!x.closest("form"):!0,[j,b]=Li({prop:a,defaultProp:i??!1,onChange:f,caller:vp});return e.jsxs(WH,{scope:n,checked:j,disabled:d,children:[e.jsx(Ss.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":I_(j),"data-disabled":d?"":void 0,disabled:d,value:m,...h,ref:N,onClick:Yt(t.onClick,C=>{b(S=>!S),w&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),w&&e.jsx(L_,{control:x,bubbles:!v.current,name:r,value:m,checked:j,required:o,disabled:d,form:p,style:{transform:"translateX(-100%)"}})]})});T_.displayName=vp;var P_="SwitchThumb",O_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,...r}=t,a=GH(P_,n);return e.jsx(Ss.span,{"data-state":I_(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:s})});O_.displayName=P_;var KH="SwitchBubbleInput",L_=g.forwardRef(({__scopeSwitch:t,control:s,checked:n,bubbles:r=!0,...a},i)=>{const o=g.useRef(null),d=Ys(o,i),m=Zy(n),f=Qy(s);return g.useEffect(()=>{const p=o.current;if(!p)return;const h=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(h,"checked").set;if(m!==n&&u){const N=new Event("click",{bubbles:r});u.call(p,n),p.dispatchEvent(N)}},[m,n,r]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:d,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});L_.displayName=KH;function I_(t){return t?"checked":"unchecked"}var YH=T_,ZH=O_;function yp({className:t,...s}){return e.jsx(YH,{"data-slot":"switch",className:Nt("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-background focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(ZH,{"data-slot":"switch-thumb",className:Nt("bg-card dark:data-[state=unchecked]:bg-card-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}var Jg,qS;function QH(){if(qS)return Jg;qS=1;function t(){this.__data__=[],this.size=0}return Jg=t,Jg}var e0,zS;function M_(){if(zS)return e0;zS=1;function t(s,n){return s===n||s!==s&&n!==n}return e0=t,e0}var t0,US;function bp(){if(US)return t0;US=1;var t=M_();function s(n,r){for(var a=n.length;a--;)if(t(n[a][0],r))return a;return-1}return t0=s,t0}var s0,VS;function XH(){if(VS)return s0;VS=1;var t=bp(),s=Array.prototype,n=s.splice;function r(a){var i=this.__data__,o=t(i,a);if(o<0)return!1;var d=i.length-1;return o==d?i.pop():n.call(i,o,1),--this.size,!0}return s0=r,s0}var n0,HS;function JH(){if(HS)return n0;HS=1;var t=bp();function s(n){var r=this.__data__,a=t(r,n);return a<0?void 0:r[a][1]}return n0=s,n0}var r0,WS;function eW(){if(WS)return r0;WS=1;var t=bp();function s(n){return t(this.__data__,n)>-1}return r0=s,r0}var a0,GS;function tW(){if(GS)return a0;GS=1;var t=bp();function s(n,r){var a=this.__data__,i=t(a,n);return i<0?(++this.size,a.push([n,r])):a[i][1]=r,this}return a0=s,a0}var i0,KS;function jp(){if(KS)return i0;KS=1;var t=QH(),s=XH(),n=JH(),r=eW(),a=tW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++d<m;){var f=o[d];this.set(f[0],f[1])}}return i.prototype.clear=t,i.prototype.delete=s,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,i0=i,i0}var l0,YS;function sW(){if(YS)return l0;YS=1;var t=jp();function s(){this.__data__=new t,this.size=0}return l0=s,l0}var o0,ZS;function nW(){if(ZS)return o0;ZS=1;function t(s){var n=this.__data__,r=n.delete(s);return this.size=n.size,r}return o0=t,o0}var c0,QS;function rW(){if(QS)return c0;QS=1;function t(s){return this.__data__.get(s)}return c0=t,c0}var d0,XS;function aW(){if(XS)return d0;XS=1;function t(s){return this.__data__.has(s)}return d0=t,d0}var u0,JS;function F_(){if(JS)return u0;JS=1;var t=typeof Vo=="object"&&Vo&&Vo.Object===Object&&Vo;return u0=t,u0}var h0,eC;function vl(){if(eC)return h0;eC=1;var t=F_(),s=typeof self=="object"&&self&&self.Object===Object&&self,n=t||s||Function("return this")();return h0=n,h0}var m0,tC;function fj(){if(tC)return m0;tC=1;var t=vl(),s=t.Symbol;return m0=s,m0}var f0,sC;function iW(){if(sC)return f0;sC=1;var t=fj(),s=Object.prototype,n=s.hasOwnProperty,r=s.toString,a=t?t.toStringTag:void 0;function i(o){var d=n.call(o,a),m=o[a];try{o[a]=void 0;var f=!0}catch{}var p=r.call(o);return f&&(d?o[a]=m:delete o[a]),p}return f0=i,f0}var p0,nC;function lW(){if(nC)return p0;nC=1;var t=Object.prototype,s=t.toString;function n(r){return s.call(r)}return p0=n,p0}var x0,rC;function Np(){if(rC)return x0;rC=1;var t=fj(),s=iW(),n=lW(),r="[object Null]",a="[object Undefined]",i=t?t.toStringTag:void 0;function o(d){return d==null?d===void 0?a:r:i&&i in Object(d)?s(d):n(d)}return x0=o,x0}var g0,aC;function B_(){if(aC)return g0;aC=1;function t(s){var n=typeof s;return s!=null&&(n=="object"||n=="function")}return g0=t,g0}var v0,iC;function $_(){if(iC)return v0;iC=1;var t=Np(),s=B_(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(d){if(!s(d))return!1;var m=t(d);return m==r||m==a||m==n||m==i}return v0=o,v0}var y0,lC;function oW(){if(lC)return y0;lC=1;var t=vl(),s=t["__core-js_shared__"];return y0=s,y0}var b0,oC;function cW(){if(oC)return b0;oC=1;var t=oW(),s=(function(){var r=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!s&&s in r}return b0=n,b0}var j0,cC;function q_(){if(cC)return j0;cC=1;var t=Function.prototype,s=t.toString;function n(r){if(r!=null){try{return s.call(r)}catch{}try{return r+""}catch{}}return""}return j0=n,j0}var N0,dC;function dW(){if(dC)return N0;dC=1;var t=$_(),s=cW(),n=B_(),r=q_(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,d=Object.prototype,m=o.toString,f=d.hasOwnProperty,p=RegExp("^"+m.call(f).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(x){if(!n(x)||s(x))return!1;var u=t(x)?p:i;return u.test(r(x))}return N0=h,N0}var w0,uC;function uW(){if(uC)return w0;uC=1;function t(s,n){return s==null?void 0:s[n]}return w0=t,w0}var S0,hC;function Dd(){if(hC)return S0;hC=1;var t=dW(),s=uW();function n(r,a){var i=s(r,a);return t(i)?i:void 0}return S0=n,S0}var C0,mC;function pj(){if(mC)return C0;mC=1;var t=Dd(),s=vl(),n=t(s,"Map");return C0=n,C0}var A0,fC;function wp(){if(fC)return A0;fC=1;var t=Dd(),s=t(Object,"create");return A0=s,A0}var k0,pC;function hW(){if(pC)return k0;pC=1;var t=wp();function s(){this.__data__=t?t(null):{},this.size=0}return k0=s,k0}var D0,xC;function mW(){if(xC)return D0;xC=1;function t(s){var n=this.has(s)&&delete this.__data__[s];return this.size-=n?1:0,n}return D0=t,D0}var R0,gC;function fW(){if(gC)return R0;gC=1;var t=wp(),s="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(i){var o=this.__data__;if(t){var d=o[i];return d===s?void 0:d}return r.call(o,i)?o[i]:void 0}return R0=a,R0}var E0,vC;function pW(){if(vC)return E0;vC=1;var t=wp(),s=Object.prototype,n=s.hasOwnProperty;function r(a){var i=this.__data__;return t?i[a]!==void 0:n.call(i,a)}return E0=r,E0}var _0,yC;function xW(){if(yC)return _0;yC=1;var t=wp(),s="__lodash_hash_undefined__";function n(r,a){var i=this.__data__;return this.size+=this.has(r)?0:1,i[r]=t&&a===void 0?s:a,this}return _0=n,_0}var T0,bC;function gW(){if(bC)return T0;bC=1;var t=hW(),s=mW(),n=fW(),r=pW(),a=xW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++d<m;){var f=o[d];this.set(f[0],f[1])}}return i.prototype.clear=t,i.prototype.delete=s,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,T0=i,T0}var P0,jC;function vW(){if(jC)return P0;jC=1;var t=gW(),s=jp(),n=pj();function r(){this.size=0,this.__data__={hash:new t,map:new(n||s),string:new t}}return P0=r,P0}var O0,NC;function yW(){if(NC)return O0;NC=1;function t(s){var n=typeof s;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?s!=="__proto__":s===null}return O0=t,O0}var L0,wC;function Sp(){if(wC)return L0;wC=1;var t=yW();function s(n,r){var a=n.__data__;return t(r)?a[typeof r=="string"?"string":"hash"]:a.map}return L0=s,L0}var I0,SC;function bW(){if(SC)return I0;SC=1;var t=Sp();function s(n){var r=t(this,n).delete(n);return this.size-=r?1:0,r}return I0=s,I0}var M0,CC;function jW(){if(CC)return M0;CC=1;var t=Sp();function s(n){return t(this,n).get(n)}return M0=s,M0}var F0,AC;function NW(){if(AC)return F0;AC=1;var t=Sp();function s(n){return t(this,n).has(n)}return F0=s,F0}var B0,kC;function wW(){if(kC)return B0;kC=1;var t=Sp();function s(n,r){var a=t(this,n),i=a.size;return a.set(n,r),this.size+=a.size==i?0:1,this}return B0=s,B0}var $0,DC;function z_(){if(DC)return $0;DC=1;var t=vW(),s=bW(),n=jW(),r=NW(),a=wW();function i(o){var d=-1,m=o==null?0:o.length;for(this.clear();++d<m;){var f=o[d];this.set(f[0],f[1])}}return i.prototype.clear=t,i.prototype.delete=s,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,$0=i,$0}var q0,RC;function SW(){if(RC)return q0;RC=1;var t=jp(),s=pj(),n=z_(),r=200;function a(i,o){var d=this.__data__;if(d instanceof t){var m=d.__data__;if(!s||m.length<r-1)return m.push([i,o]),this.size=++d.size,this;d=this.__data__=new n(m)}return d.set(i,o),this.size=d.size,this}return q0=a,q0}var z0,EC;function CW(){if(EC)return z0;EC=1;var t=jp(),s=sW(),n=nW(),r=rW(),a=aW(),i=SW();function o(d){var m=this.__data__=new t(d);this.size=m.size}return o.prototype.clear=s,o.prototype.delete=n,o.prototype.get=r,o.prototype.has=a,o.prototype.set=i,z0=o,z0}var U0,_C;function AW(){if(_C)return U0;_C=1;var t="__lodash_hash_undefined__";function s(n){return this.__data__.set(n,t),this}return U0=s,U0}var V0,TC;function kW(){if(TC)return V0;TC=1;function t(s){return this.__data__.has(s)}return V0=t,V0}var H0,PC;function DW(){if(PC)return H0;PC=1;var t=z_(),s=AW(),n=kW();function r(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new t;++i<o;)this.add(a[i])}return r.prototype.add=r.prototype.push=s,r.prototype.has=n,H0=r,H0}var W0,OC;function RW(){if(OC)return W0;OC=1;function t(s,n){for(var r=-1,a=s==null?0:s.length;++r<a;)if(n(s[r],r,s))return!0;return!1}return W0=t,W0}var G0,LC;function EW(){if(LC)return G0;LC=1;function t(s,n){return s.has(n)}return G0=t,G0}var K0,IC;function U_(){if(IC)return K0;IC=1;var t=DW(),s=RW(),n=EW(),r=1,a=2;function i(o,d,m,f,p,h){var x=m&r,u=o.length,N=d.length;if(u!=N&&!(x&&N>u))return!1;var v=h.get(o),w=h.get(d);if(v&&w)return v==d&&w==o;var j=-1,b=!0,C=m&a?new t:void 0;for(h.set(o,d),h.set(d,o);++j<u;){var S=o[j],D=d[j];if(f)var _=x?f(D,S,j,d,o,h):f(S,D,j,o,d,h);if(_!==void 0){if(_)continue;b=!1;break}if(C){if(!s(d,function(A,E){if(!n(C,E)&&(S===A||p(S,A,m,f,h)))return C.push(E)})){b=!1;break}}else if(!(S===D||p(S,D,m,f,h))){b=!1;break}}return h.delete(o),h.delete(d),b}return K0=i,K0}var Y0,MC;function _W(){if(MC)return Y0;MC=1;var t=vl(),s=t.Uint8Array;return Y0=s,Y0}var Z0,FC;function TW(){if(FC)return Z0;FC=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a,i){r[++n]=[i,a]}),r}return Z0=t,Z0}var Q0,BC;function PW(){if(BC)return Q0;BC=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a){r[++n]=a}),r}return Q0=t,Q0}var X0,$C;function OW(){if($C)return X0;$C=1;var t=fj(),s=_W(),n=M_(),r=U_(),a=TW(),i=PW(),o=1,d=2,m="[object Boolean]",f="[object Date]",p="[object Error]",h="[object Map]",x="[object Number]",u="[object RegExp]",N="[object Set]",v="[object String]",w="[object Symbol]",j="[object ArrayBuffer]",b="[object DataView]",C=t?t.prototype:void 0,S=C?C.valueOf:void 0;function D(_,A,E,q,O,R,P){switch(E){case b:if(_.byteLength!=A.byteLength||_.byteOffset!=A.byteOffset)return!1;_=_.buffer,A=A.buffer;case j:return!(_.byteLength!=A.byteLength||!R(new s(_),new s(A)));case m:case f:case x:return n(+_,+A);case p:return _.name==A.name&&_.message==A.message;case u:case v:return _==A+"";case h:var L=a;case N:var $=q&o;if(L||(L=i),_.size!=A.size&&!$)return!1;var Z=P.get(_);if(Z)return Z==A;q|=d,P.set(_,A);var Q=r(L(_),L(A),q,O,R,P);return P.delete(_),Q;case w:if(S)return S.call(_)==S.call(A)}return!1}return X0=D,X0}var J0,qC;function LW(){if(qC)return J0;qC=1;function t(s,n){for(var r=-1,a=n.length,i=s.length;++r<a;)s[i+r]=n[r];return s}return J0=t,J0}var ev,zC;function xj(){if(zC)return ev;zC=1;var t=Array.isArray;return ev=t,ev}var tv,UC;function IW(){if(UC)return tv;UC=1;var t=LW(),s=xj();function n(r,a,i){var o=a(r);return s(r)?o:t(o,i(r))}return tv=n,tv}var sv,VC;function MW(){if(VC)return sv;VC=1;function t(s,n){for(var r=-1,a=s==null?0:s.length,i=0,o=[];++r<a;){var d=s[r];n(d,r,s)&&(o[i++]=d)}return o}return sv=t,sv}var nv,HC;function FW(){if(HC)return nv;HC=1;function t(){return[]}return nv=t,nv}var rv,WC;function BW(){if(WC)return rv;WC=1;var t=MW(),s=FW(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),t(a(o),function(d){return r.call(o,d)}))}:s;return rv=i,rv}var av,GC;function $W(){if(GC)return av;GC=1;function t(s,n){for(var r=-1,a=Array(s);++r<s;)a[r]=n(r);return a}return av=t,av}var iv,KC;function Cp(){if(KC)return iv;KC=1;function t(s){return s!=null&&typeof s=="object"}return iv=t,iv}var lv,YC;function qW(){if(YC)return lv;YC=1;var t=Np(),s=Cp(),n="[object Arguments]";function r(a){return s(a)&&t(a)==n}return lv=r,lv}var ov,ZC;function zW(){if(ZC)return ov;ZC=1;var t=qW(),s=Cp(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,i=t((function(){return arguments})())?t:function(o){return s(o)&&r.call(o,"callee")&&!a.call(o,"callee")};return ov=i,ov}var xu={exports:{}},cv,QC;function UW(){if(QC)return cv;QC=1;function t(){return!1}return cv=t,cv}xu.exports;var XC;function V_(){return XC||(XC=1,(function(t,s){var n=vl(),r=UW(),a=s&&!s.nodeType&&s,i=a&&!0&&t&&!t.nodeType&&t,o=i&&i.exports===a,d=o?n.Buffer:void 0,m=d?d.isBuffer:void 0,f=m||r;t.exports=f})(xu,xu.exports)),xu.exports}var dv,JC;function VW(){if(JC)return dv;JC=1;var t=9007199254740991,s=/^(?:0|[1-9]\d*)$/;function n(r,a){var i=typeof r;return a=a??t,!!a&&(i=="number"||i!="symbol"&&s.test(r))&&r>-1&&r%1==0&&r<a}return dv=n,dv}var uv,e2;function H_(){if(e2)return uv;e2=1;var t=9007199254740991;function s(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return uv=s,uv}var hv,t2;function HW(){if(t2)return hv;t2=1;var t=Np(),s=H_(),n=Cp(),r="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",d="[object Error]",m="[object Function]",f="[object Map]",p="[object Number]",h="[object Object]",x="[object RegExp]",u="[object Set]",N="[object String]",v="[object WeakMap]",w="[object ArrayBuffer]",j="[object DataView]",b="[object Float32Array]",C="[object Float64Array]",S="[object Int8Array]",D="[object Int16Array]",_="[object Int32Array]",A="[object Uint8Array]",E="[object Uint8ClampedArray]",q="[object Uint16Array]",O="[object Uint32Array]",R={};R[b]=R[C]=R[S]=R[D]=R[_]=R[A]=R[E]=R[q]=R[O]=!0,R[r]=R[a]=R[w]=R[i]=R[j]=R[o]=R[d]=R[m]=R[f]=R[p]=R[h]=R[x]=R[u]=R[N]=R[v]=!1;function P(L){return n(L)&&s(L.length)&&!!R[t(L)]}return hv=P,hv}var mv,s2;function WW(){if(s2)return mv;s2=1;function t(s){return function(n){return s(n)}}return mv=t,mv}var gu={exports:{}};gu.exports;var n2;function GW(){return n2||(n2=1,(function(t,s){var n=F_(),r=s&&!s.nodeType&&s,a=r&&!0&&t&&!t.nodeType&&t,i=a&&a.exports===r,o=i&&n.process,d=(function(){try{var m=a&&a.require&&a.require("util").types;return m||o&&o.binding&&o.binding("util")}catch{}})();t.exports=d})(gu,gu.exports)),gu.exports}var fv,r2;function W_(){if(r2)return fv;r2=1;var t=HW(),s=WW(),n=GW(),r=n&&n.isTypedArray,a=r?s(r):t;return fv=a,fv}var pv,a2;function KW(){if(a2)return pv;a2=1;var t=$W(),s=zW(),n=xj(),r=V_(),a=VW(),i=W_(),o=Object.prototype,d=o.hasOwnProperty;function m(f,p){var h=n(f),x=!h&&s(f),u=!h&&!x&&r(f),N=!h&&!x&&!u&&i(f),v=h||x||u||N,w=v?t(f.length,String):[],j=w.length;for(var b in f)(p||d.call(f,b))&&!(v&&(b=="length"||u&&(b=="offset"||b=="parent")||N&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||a(b,j)))&&w.push(b);return w}return pv=m,pv}var xv,i2;function YW(){if(i2)return xv;i2=1;var t=Object.prototype;function s(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||t;return n===a}return xv=s,xv}var gv,l2;function ZW(){if(l2)return gv;l2=1;function t(s,n){return function(r){return s(n(r))}}return gv=t,gv}var vv,o2;function QW(){if(o2)return vv;o2=1;var t=ZW(),s=t(Object.keys,Object);return vv=s,vv}var yv,c2;function XW(){if(c2)return yv;c2=1;var t=YW(),s=QW(),n=Object.prototype,r=n.hasOwnProperty;function a(i){if(!t(i))return s(i);var o=[];for(var d in Object(i))r.call(i,d)&&d!="constructor"&&o.push(d);return o}return yv=a,yv}var bv,d2;function JW(){if(d2)return bv;d2=1;var t=$_(),s=H_();function n(r){return r!=null&&s(r.length)&&!t(r)}return bv=n,bv}var jv,u2;function eG(){if(u2)return jv;u2=1;var t=KW(),s=XW(),n=JW();function r(a){return n(a)?t(a):s(a)}return jv=r,jv}var Nv,h2;function tG(){if(h2)return Nv;h2=1;var t=IW(),s=BW(),n=eG();function r(a){return t(a,n,s)}return Nv=r,Nv}var wv,m2;function sG(){if(m2)return wv;m2=1;var t=tG(),s=1,n=Object.prototype,r=n.hasOwnProperty;function a(i,o,d,m,f,p){var h=d&s,x=t(i),u=x.length,N=t(o),v=N.length;if(u!=v&&!h)return!1;for(var w=u;w--;){var j=x[w];if(!(h?j in o:r.call(o,j)))return!1}var b=p.get(i),C=p.get(o);if(b&&C)return b==o&&C==i;var S=!0;p.set(i,o),p.set(o,i);for(var D=h;++w<u;){j=x[w];var _=i[j],A=o[j];if(m)var E=h?m(A,_,j,o,i,p):m(_,A,j,i,o,p);if(!(E===void 0?_===A||f(_,A,d,m,p):E)){S=!1;break}D||(D=j=="constructor")}if(S&&!D){var q=i.constructor,O=o.constructor;q!=O&&"constructor"in i&&"constructor"in o&&!(typeof q=="function"&&q instanceof q&&typeof O=="function"&&O instanceof O)&&(S=!1)}return p.delete(i),p.delete(o),S}return wv=a,wv}var Sv,f2;function nG(){if(f2)return Sv;f2=1;var t=Dd(),s=vl(),n=t(s,"DataView");return Sv=n,Sv}var Cv,p2;function rG(){if(p2)return Cv;p2=1;var t=Dd(),s=vl(),n=t(s,"Promise");return Cv=n,Cv}var Av,x2;function aG(){if(x2)return Av;x2=1;var t=Dd(),s=vl(),n=t(s,"Set");return Av=n,Av}var kv,g2;function iG(){if(g2)return kv;g2=1;var t=Dd(),s=vl(),n=t(s,"WeakMap");return kv=n,kv}var Dv,v2;function lG(){if(v2)return Dv;v2=1;var t=nG(),s=pj(),n=rG(),r=aG(),a=iG(),i=Np(),o=q_(),d="[object Map]",m="[object Object]",f="[object Promise]",p="[object Set]",h="[object WeakMap]",x="[object DataView]",u=o(t),N=o(s),v=o(n),w=o(r),j=o(a),b=i;return(t&&b(new t(new ArrayBuffer(1)))!=x||s&&b(new s)!=d||n&&b(n.resolve())!=f||r&&b(new r)!=p||a&&b(new a)!=h)&&(b=function(C){var S=i(C),D=S==m?C.constructor:void 0,_=D?o(D):"";if(_)switch(_){case u:return x;case N:return d;case v:return f;case w:return p;case j:return h}return S}),Dv=b,Dv}var Rv,y2;function oG(){if(y2)return Rv;y2=1;var t=CW(),s=U_(),n=OW(),r=sG(),a=lG(),i=xj(),o=V_(),d=W_(),m=1,f="[object Arguments]",p="[object Array]",h="[object Object]",x=Object.prototype,u=x.hasOwnProperty;function N(v,w,j,b,C,S){var D=i(v),_=i(w),A=D?p:a(v),E=_?p:a(w);A=A==f?h:A,E=E==f?h:E;var q=A==h,O=E==h,R=A==E;if(R&&o(v)){if(!o(w))return!1;D=!0,q=!1}if(R&&!q)return S||(S=new t),D||d(v)?s(v,w,j,b,C,S):n(v,w,A,j,b,C,S);if(!(j&m)){var P=q&&u.call(v,"__wrapped__"),L=O&&u.call(w,"__wrapped__");if(P||L){var $=P?v.value():v,Z=L?w.value():w;return S||(S=new t),C($,Z,j,b,S)}}return R?(S||(S=new t),r(v,w,j,b,C,S)):!1}return Rv=N,Rv}var Ev,b2;function cG(){if(b2)return Ev;b2=1;var t=oG(),s=Cp();function n(r,a,i,o,d){return r===a?!0:r==null||a==null||!s(r)&&!s(a)?r!==r&&a!==a:t(r,a,i,o,n,d)}return Ev=n,Ev}var _v,j2;function dG(){if(j2)return _v;j2=1;var t=cG();function s(n,r){return t(n,r)}return _v=s,_v}var Wm={exports:{}};/*!
|
||
* Quill Editor v1.3.7
|
||
* https://quilljs.com/
|
||
* Copyright (c) 2014, Jason Chen
|
||
* Copyright (c) 2013, salesforce.com
|
||
*/var uG=Wm.exports,N2;function hG(){return N2||(N2=1,(function(t,s){(function(r,a){t.exports=a()})(typeof self<"u"?self:uG,function(){return(function(n){var r={};function a(i){if(r[i])return r[i].exports;var o=r[i]={i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=n,a.c=r,a.d=function(i,o,d){a.o(i,o)||Object.defineProperty(i,o,{configurable:!1,enumerable:!0,get:d})},a.n=function(i){var o=i&&i.__esModule?function(){return i.default}:function(){return i};return a.d(o,"a",o),o},a.o=function(i,o){return Object.prototype.hasOwnProperty.call(i,o)},a.p="",a(a.s=109)})([(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(17),o=a(18),d=a(19),m=a(45),f=a(46),p=a(47),h=a(48),x=a(49),u=a(12),N=a(32),v=a(33),w=a(31),j=a(1),b={Scope:j.Scope,create:j.create,find:j.find,query:j.query,register:j.register,Container:i.default,Format:o.default,Leaf:d.default,Embed:h.default,Scroll:m.default,Block:p.default,Inline:f.default,Text:x.default,Attributor:{Attribute:u.default,Class:N.default,Style:v.default,Store:w.default}};r.default=b}),(function(n,r,a){var i=this&&this.__extends||(function(){var w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,b){j.__proto__=b}||function(j,b){for(var C in b)b.hasOwnProperty(C)&&(j[C]=b[C])};return function(j,b){w(j,b);function C(){this.constructor=j}j.prototype=b===null?Object.create(b):(C.prototype=b.prototype,new C)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=(function(w){i(j,w);function j(b){var C=this;return b="[Parchment] "+b,C=w.call(this,b)||this,C.message=b,C.name=C.constructor.name,C}return j})(Error);r.ParchmentError=o;var d={},m={},f={},p={};r.DATA_KEY="__blot";var h;(function(w){w[w.TYPE=3]="TYPE",w[w.LEVEL=12]="LEVEL",w[w.ATTRIBUTE=13]="ATTRIBUTE",w[w.BLOT=14]="BLOT",w[w.INLINE=7]="INLINE",w[w.BLOCK=11]="BLOCK",w[w.BLOCK_BLOT=10]="BLOCK_BLOT",w[w.INLINE_BLOT=6]="INLINE_BLOT",w[w.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",w[w.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",w[w.ANY=15]="ANY"})(h=r.Scope||(r.Scope={}));function x(w,j){var b=N(w);if(b==null)throw new o("Unable to create "+w+" blot");var C=b,S=w instanceof Node||w.nodeType===Node.TEXT_NODE?w:C.create(j);return new C(S,j)}r.create=x;function u(w,j){return j===void 0&&(j=!1),w==null?null:w[r.DATA_KEY]!=null?w[r.DATA_KEY].blot:j?u(w.parentNode,j):null}r.find=u;function N(w,j){j===void 0&&(j=h.ANY);var b;if(typeof w=="string")b=p[w]||d[w];else if(w instanceof Text||w.nodeType===Node.TEXT_NODE)b=p.text;else if(typeof w=="number")w&h.LEVEL&h.BLOCK?b=p.block:w&h.LEVEL&h.INLINE&&(b=p.inline);else if(w instanceof HTMLElement){var C=(w.getAttribute("class")||"").split(/\s+/);for(var S in C)if(b=m[C[S]],b)break;b=b||f[w.tagName]}return b==null?null:j&h.LEVEL&b.scope&&j&h.TYPE&b.scope?b:null}r.query=N;function v(){for(var w=[],j=0;j<arguments.length;j++)w[j]=arguments[j];if(w.length>1)return w.map(function(S){return v(S)});var b=w[0];if(typeof b.blotName!="string"&&typeof b.attrName!="string")throw new o("Invalid definition");if(b.blotName==="abstract")throw new o("Cannot register abstract class");if(p[b.blotName||b.attrName]=b,typeof b.keyName=="string")d[b.keyName]=b;else if(b.className!=null&&(m[b.className]=b),b.tagName!=null){Array.isArray(b.tagName)?b.tagName=b.tagName.map(function(S){return S.toUpperCase()}):b.tagName=b.tagName.toUpperCase();var C=Array.isArray(b.tagName)?b.tagName:[b.tagName];C.forEach(function(S){(f[S]==null||b.className==null)&&(f[S]=b)})}return b}r.register=v}),(function(n,r,a){var i=a(51),o=a(11),d=a(3),m=a(20),f="\0",p=function(h){Array.isArray(h)?this.ops=h:h!=null&&Array.isArray(h.ops)?this.ops=h.ops:this.ops=[]};p.prototype.insert=function(h,x){var u={};return h.length===0?this:(u.insert=h,x!=null&&typeof x=="object"&&Object.keys(x).length>0&&(u.attributes=x),this.push(u))},p.prototype.delete=function(h){return h<=0?this:this.push({delete:h})},p.prototype.retain=function(h,x){if(h<=0)return this;var u={retain:h};return x!=null&&typeof x=="object"&&Object.keys(x).length>0&&(u.attributes=x),this.push(u)},p.prototype.push=function(h){var x=this.ops.length,u=this.ops[x-1];if(h=d(!0,{},h),typeof u=="object"){if(typeof h.delete=="number"&&typeof u.delete=="number")return this.ops[x-1]={delete:u.delete+h.delete},this;if(typeof u.delete=="number"&&h.insert!=null&&(x-=1,u=this.ops[x-1],typeof u!="object"))return this.ops.unshift(h),this;if(o(h.attributes,u.attributes)){if(typeof h.insert=="string"&&typeof u.insert=="string")return this.ops[x-1]={insert:u.insert+h.insert},typeof h.attributes=="object"&&(this.ops[x-1].attributes=h.attributes),this;if(typeof h.retain=="number"&&typeof u.retain=="number")return this.ops[x-1]={retain:u.retain+h.retain},typeof h.attributes=="object"&&(this.ops[x-1].attributes=h.attributes),this}}return x===this.ops.length?this.ops.push(h):this.ops.splice(x,0,h),this},p.prototype.chop=function(){var h=this.ops[this.ops.length-1];return h&&h.retain&&!h.attributes&&this.ops.pop(),this},p.prototype.filter=function(h){return this.ops.filter(h)},p.prototype.forEach=function(h){this.ops.forEach(h)},p.prototype.map=function(h){return this.ops.map(h)},p.prototype.partition=function(h){var x=[],u=[];return this.forEach(function(N){var v=h(N)?x:u;v.push(N)}),[x,u]},p.prototype.reduce=function(h,x){return this.ops.reduce(h,x)},p.prototype.changeLength=function(){return this.reduce(function(h,x){return x.insert?h+m.length(x):x.delete?h-x.delete:h},0)},p.prototype.length=function(){return this.reduce(function(h,x){return h+m.length(x)},0)},p.prototype.slice=function(h,x){h=h||0,typeof x!="number"&&(x=1/0);for(var u=[],N=m.iterator(this.ops),v=0;v<x&&N.hasNext();){var w;v<h?w=N.next(h-v):(w=N.next(x-v),u.push(w)),v+=m.length(w)}return new p(u)},p.prototype.compose=function(h){var x=m.iterator(this.ops),u=m.iterator(h.ops),N=[],v=u.peek();if(v!=null&&typeof v.retain=="number"&&v.attributes==null){for(var w=v.retain;x.peekType()==="insert"&&x.peekLength()<=w;)w-=x.peekLength(),N.push(x.next());v.retain-w>0&&u.next(v.retain-w)}for(var j=new p(N);x.hasNext()||u.hasNext();)if(u.peekType()==="insert")j.push(u.next());else if(x.peekType()==="delete")j.push(x.next());else{var b=Math.min(x.peekLength(),u.peekLength()),C=x.next(b),S=u.next(b);if(typeof S.retain=="number"){var D={};typeof C.retain=="number"?D.retain=b:D.insert=C.insert;var _=m.attributes.compose(C.attributes,S.attributes,typeof C.retain=="number");if(_&&(D.attributes=_),j.push(D),!u.hasNext()&&o(j.ops[j.ops.length-1],D)){var A=new p(x.rest());return j.concat(A).chop()}}else typeof S.delete=="number"&&typeof C.retain=="number"&&j.push(S)}return j.chop()},p.prototype.concat=function(h){var x=new p(this.ops.slice());return h.ops.length>0&&(x.push(h.ops[0]),x.ops=x.ops.concat(h.ops.slice(1))),x},p.prototype.diff=function(h,x){if(this.ops===h.ops)return new p;var u=[this,h].map(function(b){return b.map(function(C){if(C.insert!=null)return typeof C.insert=="string"?C.insert:f;var S=b===h?"on":"with";throw new Error("diff() called "+S+" non-document")}).join("")}),N=new p,v=i(u[0],u[1],x),w=m.iterator(this.ops),j=m.iterator(h.ops);return v.forEach(function(b){for(var C=b[1].length;C>0;){var S=0;switch(b[0]){case i.INSERT:S=Math.min(j.peekLength(),C),N.push(j.next(S));break;case i.DELETE:S=Math.min(C,w.peekLength()),w.next(S),N.delete(S);break;case i.EQUAL:S=Math.min(w.peekLength(),j.peekLength(),C);var D=w.next(S),_=j.next(S);o(D.insert,_.insert)?N.retain(S,m.attributes.diff(D.attributes,_.attributes)):N.push(_).delete(S);break}C-=S}}),N.chop()},p.prototype.eachLine=function(h,x){x=x||`
|
||
`;for(var u=m.iterator(this.ops),N=new p,v=0;u.hasNext();){if(u.peekType()!=="insert")return;var w=u.peek(),j=m.length(w)-u.peekLength(),b=typeof w.insert=="string"?w.insert.indexOf(x,j)-j:-1;if(b<0)N.push(u.next());else if(b>0)N.push(u.next(b));else{if(h(N,u.next(1).attributes||{},v)===!1)return;v+=1,N=new p}}N.length()>0&&h(N,{},v)},p.prototype.transform=function(h,x){if(x=!!x,typeof h=="number")return this.transformPosition(h,x);for(var u=m.iterator(this.ops),N=m.iterator(h.ops),v=new p;u.hasNext()||N.hasNext();)if(u.peekType()==="insert"&&(x||N.peekType()!=="insert"))v.retain(m.length(u.next()));else if(N.peekType()==="insert")v.push(N.next());else{var w=Math.min(u.peekLength(),N.peekLength()),j=u.next(w),b=N.next(w);if(j.delete)continue;b.delete?v.push(b):v.retain(w,m.attributes.transform(j.attributes,b.attributes,x))}return v.chop()},p.prototype.transformPosition=function(h,x){x=!!x;for(var u=m.iterator(this.ops),N=0;u.hasNext()&&N<=h;){var v=u.peekLength(),w=u.peekType();if(u.next(),w==="delete"){h-=Math.min(v,h-N);continue}else w==="insert"&&(N<h||!x)&&(h+=v);N+=v}return h},n.exports=p}),(function(n,r){var a=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=Object.defineProperty,d=Object.getOwnPropertyDescriptor,m=function(u){return typeof Array.isArray=="function"?Array.isArray(u):i.call(u)==="[object Array]"},f=function(u){if(!u||i.call(u)!=="[object Object]")return!1;var N=a.call(u,"constructor"),v=u.constructor&&u.constructor.prototype&&a.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!N&&!v)return!1;var w;for(w in u);return typeof w>"u"||a.call(u,w)},p=function(u,N){o&&N.name==="__proto__"?o(u,N.name,{enumerable:!0,configurable:!0,value:N.newValue,writable:!0}):u[N.name]=N.newValue},h=function(u,N){if(N==="__proto__")if(a.call(u,N)){if(d)return d(u,N).value}else return;return u[N]};n.exports=function x(){var u,N,v,w,j,b,C=arguments[0],S=1,D=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},S=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});S<D;++S)if(u=arguments[S],u!=null)for(N in u)v=h(C,N),w=h(u,N),C!==w&&(_&&w&&(f(w)||(j=m(w)))?(j?(j=!1,b=v&&m(v)?v:[]):b=v&&f(v)?v:{},p(C,{name:N,newValue:x(_,b,w)})):typeof w<"u"&&p(C,{name:N,newValue:w}));return C}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BlockEmbed=r.bubbleFormats=void 0;var i=(function(){function R(P,L){for(var $=0;$<L.length;$++){var Z=L[$];Z.enumerable=Z.enumerable||!1,Z.configurable=!0,"value"in Z&&(Z.writable=!0),Object.defineProperty(P,Z.key,Z)}}return function(P,L,$){return L&&R(P.prototype,L),$&&R(P,$),P}})(),o=function R(P,L,$){P===null&&(P=Function.prototype);var Z=Object.getOwnPropertyDescriptor(P,L);if(Z===void 0){var Q=Object.getPrototypeOf(P);return Q===null?void 0:R(Q,L,$)}else{if("value"in Z)return Z.value;var W=Z.get;return W===void 0?void 0:W.call($)}},d=a(3),m=C(d),f=a(2),p=C(f),h=a(0),x=C(h),u=a(16),N=C(u),v=a(6),w=C(v),j=a(7),b=C(j);function C(R){return R&&R.__esModule?R:{default:R}}function S(R,P){if(!(R instanceof P))throw new TypeError("Cannot call a class as a function")}function D(R,P){if(!R)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:R}function _(R,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);R.prototype=Object.create(P&&P.prototype,{constructor:{value:R,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(R,P):R.__proto__=P)}var A=1,E=(function(R){_(P,R);function P(){return S(this,P),D(this,(P.__proto__||Object.getPrototypeOf(P)).apply(this,arguments))}return i(P,[{key:"attach",value:function(){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"attach",this).call(this),this.attributes=new x.default.Attributor.Store(this.domNode)}},{key:"delta",value:function(){return new p.default().insert(this.value(),(0,m.default)(this.formats(),this.attributes.values()))}},{key:"format",value:function($,Z){var Q=x.default.query($,x.default.Scope.BLOCK_ATTRIBUTE);Q!=null&&this.attributes.attribute(Q,Z)}},{key:"formatAt",value:function($,Z,Q,W){this.format(Q,W)}},{key:"insertAt",value:function($,Z,Q){if(typeof Z=="string"&&Z.endsWith(`
|
||
`)){var W=x.default.create(q.blotName);this.parent.insertBefore(W,$===0?this:this.next),W.insertAt(0,Z.slice(0,-1))}else o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertAt",this).call(this,$,Z,Q)}}]),P})(x.default.Embed);E.scope=x.default.Scope.BLOCK_BLOT;var q=(function(R){_(P,R);function P(L){S(this,P);var $=D(this,(P.__proto__||Object.getPrototypeOf(P)).call(this,L));return $.cache={},$}return i(P,[{key:"delta",value:function(){return this.cache.delta==null&&(this.cache.delta=this.descendants(x.default.Leaf).reduce(function($,Z){return Z.length()===0?$:$.insert(Z.value(),O(Z))},new p.default).insert(`
|
||
`,O(this))),this.cache.delta}},{key:"deleteAt",value:function($,Z){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"deleteAt",this).call(this,$,Z),this.cache={}}},{key:"formatAt",value:function($,Z,Q,W){Z<=0||(x.default.query(Q,x.default.Scope.BLOCK)?$+Z===this.length()&&this.format(Q,W):o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"formatAt",this).call(this,$,Math.min(Z,this.length()-$-1),Q,W),this.cache={})}},{key:"insertAt",value:function($,Z,Q){if(Q!=null)return o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertAt",this).call(this,$,Z,Q);if(Z.length!==0){var W=Z.split(`
|
||
`),U=W.shift();U.length>0&&($<this.length()-1||this.children.tail==null?o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertAt",this).call(this,Math.min($,this.length()-1),U):this.children.tail.insertAt(this.children.tail.length(),U),this.cache={});var M=this;W.reduce(function(z,T){return M=M.split(z,!0),M.insertAt(0,T),T.length},$+U.length)}}},{key:"insertBefore",value:function($,Z){var Q=this.children.head;o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"insertBefore",this).call(this,$,Z),Q instanceof N.default&&Q.remove(),this.cache={}}},{key:"length",value:function(){return this.cache.length==null&&(this.cache.length=o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"length",this).call(this)+A),this.cache.length}},{key:"moveChildren",value:function($,Z){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"moveChildren",this).call(this,$,Z),this.cache={}}},{key:"optimize",value:function($){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"optimize",this).call(this,$),this.cache={}}},{key:"path",value:function($){return o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"path",this).call(this,$,!0)}},{key:"removeChild",value:function($){o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"removeChild",this).call(this,$),this.cache={}}},{key:"split",value:function($){var Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(Z&&($===0||$>=this.length()-A)){var Q=this.clone();return $===0?(this.parent.insertBefore(Q,this),this):(this.parent.insertBefore(Q,this.next),Q)}else{var W=o(P.prototype.__proto__||Object.getPrototypeOf(P.prototype),"split",this).call(this,$,Z);return this.cache={},W}}}]),P})(x.default.Block);q.blotName="block",q.tagName="P",q.defaultChild="break",q.allowedChildren=[w.default,x.default.Embed,b.default];function O(R){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return R==null||(typeof R.formats=="function"&&(P=(0,m.default)(P,R.formats())),R.parent==null||R.parent.blotName=="scroll"||R.parent.statics.scope!==R.statics.scope)?P:O(R.parent,P)}r.bubbleFormats=O,r.BlockEmbed=E,r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.overload=r.expandConfig=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},o=(function(){function M(z,T){var F=[],I=!0,K=!1,G=void 0;try{for(var V=z[Symbol.iterator](),Y;!(I=(Y=V.next()).done)&&(F.push(Y.value),!(T&&F.length===T));I=!0);}catch(re){K=!0,G=re}finally{try{!I&&V.return&&V.return()}finally{if(K)throw G}}return F}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return M(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function M(z,T){for(var F=0;F<T.length;F++){var I=T[F];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(z,I.key,I)}}return function(z,T,F){return T&&M(z.prototype,T),F&&M(z,F),z}})();a(50);var m=a(2),f=O(m),p=a(14),h=O(p),x=a(8),u=O(x),N=a(9),v=O(N),w=a(0),j=O(w),b=a(15),C=O(b),S=a(3),D=O(S),_=a(10),A=O(_),E=a(34),q=O(E);function O(M){return M&&M.__esModule?M:{default:M}}function R(M,z,T){return z in M?Object.defineProperty(M,z,{value:T,enumerable:!0,configurable:!0,writable:!0}):M[z]=T,M}function P(M,z){if(!(M instanceof z))throw new TypeError("Cannot call a class as a function")}var L=(0,A.default)("quill"),$=(function(){d(M,null,[{key:"debug",value:function(T){T===!0&&(T="log"),A.default.level(T)}},{key:"find",value:function(T){return T.__quill||j.default.find(T)}},{key:"import",value:function(T){return this.imports[T]==null&&L.error("Cannot import "+T+". Are you sure it was registered?"),this.imports[T]}},{key:"register",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof T!="string"){var G=T.attrName||T.blotName;typeof G=="string"?this.register("formats/"+G,T,F):Object.keys(T).forEach(function(V){I.register(V,T[V],F)})}else this.imports[T]!=null&&!K&&L.warn("Overwriting "+T+" with",F),this.imports[T]=F,(T.startsWith("blots/")||T.startsWith("formats/"))&&F.blotName!=="abstract"?j.default.register(F):T.startsWith("modules")&&typeof F.register=="function"&&F.register()}}]);function M(z){var T=this,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(P(this,M),this.options=Z(z,F),this.container=this.options.container,this.container==null)return L.error("Invalid Quill container",z);this.options.debug&&M.debug(this.options.debug);var I=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",this.container.__quill=this,this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.root.setAttribute("data-gramm",!1),this.scrollingContainer=this.options.scrollingContainer||this.root,this.emitter=new u.default,this.scroll=j.default.create(this.root,{emitter:this.emitter,whitelist:this.options.formats}),this.editor=new h.default(this.scroll),this.selection=new C.default(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.theme.init(),this.emitter.on(u.default.events.EDITOR_CHANGE,function(G){G===u.default.events.TEXT_CHANGE&&T.root.classList.toggle("ql-blank",T.editor.isBlank())}),this.emitter.on(u.default.events.SCROLL_UPDATE,function(G,V){var Y=T.selection.lastRange,re=Y&&Y.length===0?Y.index:void 0;Q.call(T,function(){return T.editor.update(null,V,re)},G)});var K=this.clipboard.convert(`<div class='ql-editor' style="white-space: normal;">`+I+"<p><br></p></div>");this.setContents(K),this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable()}return d(M,[{key:"addContainer",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof T=="string"){var I=T;T=document.createElement("div"),T.classList.add(I)}return this.container.insertBefore(T,F),T}},{key:"blur",value:function(){this.selection.setRange(null)}},{key:"deleteText",value:function(T,F,I){var K=this,G=W(T,F,I),V=o(G,4);return T=V[0],F=V[1],I=V[3],Q.call(this,function(){return K.editor.deleteText(T,F)},I,T,-1*F)}},{key:"disable",value:function(){this.enable(!1)}},{key:"enable",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(T),this.container.classList.toggle("ql-disabled",!T)}},{key:"focus",value:function(){var T=this.scrollingContainer.scrollTop;this.selection.focus(),this.scrollingContainer.scrollTop=T,this.scrollIntoView()}},{key:"format",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.default.sources.API;return Q.call(this,function(){var G=I.getSelection(!0),V=new f.default;if(G==null)return V;if(j.default.query(T,j.default.Scope.BLOCK))V=I.editor.formatLine(G.index,G.length,R({},T,F));else{if(G.length===0)return I.selection.format(T,F),V;V=I.editor.formatText(G.index,G.length,R({},T,F))}return I.setSelection(G,u.default.sources.SILENT),V},K)}},{key:"formatLine",value:function(T,F,I,K,G){var V=this,Y=void 0,re=W(T,F,I,K,G),ae=o(re,4);return T=ae[0],F=ae[1],Y=ae[2],G=ae[3],Q.call(this,function(){return V.editor.formatLine(T,F,Y)},G,T,0)}},{key:"formatText",value:function(T,F,I,K,G){var V=this,Y=void 0,re=W(T,F,I,K,G),ae=o(re,4);return T=ae[0],F=ae[1],Y=ae[2],G=ae[3],Q.call(this,function(){return V.editor.formatText(T,F,Y)},G,T,0)}},{key:"getBounds",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,I=void 0;typeof T=="number"?I=this.selection.getBounds(T,F):I=this.selection.getBounds(T.index,T.length);var K=this.container.getBoundingClientRect();return{bottom:I.bottom-K.top,height:I.height,left:I.left-K.left,right:I.right-K.left,top:I.top-K.top,width:I.width}}},{key:"getContents",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-T,I=W(T,F),K=o(I,2);return T=K[0],F=K[1],this.editor.getContents(T,F)}},{key:"getFormat",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof T=="number"?this.editor.getFormat(T,F):this.editor.getFormat(T.index,T.length)}},{key:"getIndex",value:function(T){return T.offset(this.scroll)}},{key:"getLength",value:function(){return this.scroll.length()}},{key:"getLeaf",value:function(T){return this.scroll.leaf(T)}},{key:"getLine",value:function(T){return this.scroll.line(T)}},{key:"getLines",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof T!="number"?this.scroll.lines(T.index,T.length):this.scroll.lines(T,F)}},{key:"getModule",value:function(T){return this.theme.modules[T]}},{key:"getSelection",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return T&&this.focus(),this.update(),this.selection.getRange()[0]}},{key:"getText",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-T,I=W(T,F),K=o(I,2);return T=K[0],F=K[1],this.editor.getText(T,F)}},{key:"hasFocus",value:function(){return this.selection.hasFocus()}},{key:"insertEmbed",value:function(T,F,I){var K=this,G=arguments.length>3&&arguments[3]!==void 0?arguments[3]:M.sources.API;return Q.call(this,function(){return K.editor.insertEmbed(T,F,I)},G,T)}},{key:"insertText",value:function(T,F,I,K,G){var V=this,Y=void 0,re=W(T,0,I,K,G),ae=o(re,4);return T=ae[0],Y=ae[2],G=ae[3],Q.call(this,function(){return V.editor.insertText(T,F,Y)},G,T,F.length)}},{key:"isEnabled",value:function(){return!this.container.classList.contains("ql-disabled")}},{key:"off",value:function(){return this.emitter.off.apply(this.emitter,arguments)}},{key:"on",value:function(){return this.emitter.on.apply(this.emitter,arguments)}},{key:"once",value:function(){return this.emitter.once.apply(this.emitter,arguments)}},{key:"pasteHTML",value:function(T,F,I){this.clipboard.dangerouslyPasteHTML(T,F,I)}},{key:"removeFormat",value:function(T,F,I){var K=this,G=W(T,F,I),V=o(G,4);return T=V[0],F=V[1],I=V[3],Q.call(this,function(){return K.editor.removeFormat(T,F)},I,T)}},{key:"scrollIntoView",value:function(){this.selection.scrollIntoView(this.scrollingContainer)}},{key:"setContents",value:function(T){var F=this,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Q.call(this,function(){T=new f.default(T);var K=F.getLength(),G=F.editor.deleteText(0,K),V=F.editor.applyDelta(T),Y=V.ops[V.ops.length-1];Y!=null&&typeof Y.insert=="string"&&Y.insert[Y.insert.length-1]===`
|
||
`&&(F.editor.deleteText(F.getLength()-1,1),V.delete(1));var re=G.compose(V);return re},I)}},{key:"setSelection",value:function(T,F,I){if(T==null)this.selection.setRange(null,F||M.sources.API);else{var K=W(T,F,I),G=o(K,4);T=G[0],F=G[1],I=G[3],this.selection.setRange(new b.Range(T,F),I),I!==u.default.sources.SILENT&&this.selection.scrollIntoView(this.scrollingContainer)}}},{key:"setText",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API,I=new f.default().insert(T);return this.setContents(I,F)}},{key:"update",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:u.default.sources.USER,F=this.scroll.update(T);return this.selection.update(T),F}},{key:"updateContents",value:function(T){var F=this,I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Q.call(this,function(){return T=new f.default(T),F.editor.applyDelta(T,I)},I,!0)}}]),M})();$.DEFAULTS={bounds:null,formats:null,modules:{},placeholder:"",readOnly:!1,scrollingContainer:null,strict:!0,theme:"default"},$.events=u.default.events,$.sources=u.default.sources,$.version="1.3.7",$.imports={delta:f.default,parchment:j.default,"core/module":v.default,"core/theme":q.default};function Z(M,z){if(z=(0,D.default)(!0,{container:M,modules:{clipboard:!0,keyboard:!0,history:!0}},z),!z.theme||z.theme===$.DEFAULTS.theme)z.theme=q.default;else if(z.theme=$.import("themes/"+z.theme),z.theme==null)throw new Error("Invalid theme "+z.theme+". Did you register it?");var T=(0,D.default)(!0,{},z.theme.DEFAULTS);[T,z].forEach(function(K){K.modules=K.modules||{},Object.keys(K.modules).forEach(function(G){K.modules[G]===!0&&(K.modules[G]={})})});var F=Object.keys(T.modules).concat(Object.keys(z.modules)),I=F.reduce(function(K,G){var V=$.import("modules/"+G);return V==null?L.error("Cannot load "+G+" module. Are you sure you registered it?"):K[G]=V.DEFAULTS||{},K},{});return z.modules!=null&&z.modules.toolbar&&z.modules.toolbar.constructor!==Object&&(z.modules.toolbar={container:z.modules.toolbar}),z=(0,D.default)(!0,{},$.DEFAULTS,{modules:I},T,z),["bounds","container","scrollingContainer"].forEach(function(K){typeof z[K]=="string"&&(z[K]=document.querySelector(z[K]))}),z.modules=Object.keys(z.modules).reduce(function(K,G){return z.modules[G]&&(K[G]=z.modules[G]),K},{}),z}function Q(M,z,T,F){if(this.options.strict&&!this.isEnabled()&&z===u.default.sources.USER)return new f.default;var I=T==null?null:this.getSelection(),K=this.editor.delta,G=M();if(I!=null&&(T===!0&&(T=I.index),F==null?I=U(I,G,z):F!==0&&(I=U(I,T,F,z)),this.setSelection(I,u.default.sources.SILENT)),G.length()>0){var V,Y=[u.default.events.TEXT_CHANGE,G,K,z];if((V=this.emitter).emit.apply(V,[u.default.events.EDITOR_CHANGE].concat(Y)),z!==u.default.sources.SILENT){var re;(re=this.emitter).emit.apply(re,Y)}}return G}function W(M,z,T,F,I){var K={};return typeof M.index=="number"&&typeof M.length=="number"?typeof z!="number"?(I=F,F=T,T=z,z=M.length,M=M.index):(z=M.length,M=M.index):typeof z!="number"&&(I=F,F=T,T=z,z=0),(typeof T>"u"?"undefined":i(T))==="object"?(K=T,I=F):typeof T=="string"&&(F!=null?K[T]=F:I=T),I=I||u.default.sources.API,[M,z,K,I]}function U(M,z,T,F){if(M==null)return null;var I=void 0,K=void 0;if(z instanceof f.default){var G=[M.index,M.index+M.length].map(function(ae){return z.transformPosition(ae,F!==u.default.sources.USER)}),V=o(G,2);I=V[0],K=V[1]}else{var Y=[M.index,M.index+M.length].map(function(ae){return ae<z||ae===z&&F===u.default.sources.USER?ae:T>=0?ae+T:Math.max(z,ae+T)}),re=o(Y,2);I=re[0],K=re[1]}return new b.Range(I,K-I)}r.expandConfig=Z,r.overload=W,r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:w(D,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(7),m=h(d),f=a(0),p=h(f);function h(w){return w&&w.__esModule?w:{default:w}}function x(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function u(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function N(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var v=(function(w){N(j,w);function j(){return x(this,j),u(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"formatAt",value:function(C,S,D,_){if(j.compare(this.statics.blotName,D)<0&&p.default.query(D,p.default.Scope.BLOT)){var A=this.isolate(C,S);_&&A.wrap(D,_)}else o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"formatAt",this).call(this,C,S,D,_)}},{key:"optimize",value:function(C){if(o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"optimize",this).call(this,C),this.parent instanceof j&&j.compare(this.statics.blotName,this.parent.statics.blotName)>0){var S=this.parent.isolate(this.offset(),this.length());this.moveChildren(S),S.wrap(this)}}}],[{key:"compare",value:function(C,S){var D=j.order.indexOf(C),_=j.order.indexOf(S);return D>=0||_>=0?D-_:C===S?0:C<S?-1:1}}]),j})(p.default.Inline);v.allowedChildren=[v,p.default.Embed,m.default],v.order=["cursor","inline","underline","strike","italic","bold","script","link","code"],r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default.Text);r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function b(C,S){for(var D=0;D<S.length;D++){var _=S[D];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(C,_.key,_)}}return function(C,S,D){return S&&b(C.prototype,S),D&&b(C,D),C}})(),o=function b(C,S,D){C===null&&(C=Function.prototype);var _=Object.getOwnPropertyDescriptor(C,S);if(_===void 0){var A=Object.getPrototypeOf(C);return A===null?void 0:b(A,S,D)}else{if("value"in _)return _.value;var E=_.get;return E===void 0?void 0:E.call(D)}},d=a(54),m=h(d),f=a(10),p=h(f);function h(b){return b&&b.__esModule?b:{default:b}}function x(b,C){if(!(b instanceof C))throw new TypeError("Cannot call a class as a function")}function u(b,C){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:b}function N(b,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);b.prototype=Object.create(C&&C.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(b,C):b.__proto__=C)}var v=(0,p.default)("quill:events"),w=["selectionchange","mousedown","mouseup","click"];w.forEach(function(b){document.addEventListener(b,function(){for(var C=arguments.length,S=Array(C),D=0;D<C;D++)S[D]=arguments[D];[].slice.call(document.querySelectorAll(".ql-container")).forEach(function(_){if(_.__quill&&_.__quill.emitter){var A;(A=_.__quill.emitter).handleDOM.apply(A,S)}})})});var j=(function(b){N(C,b);function C(){x(this,C);var S=u(this,(C.__proto__||Object.getPrototypeOf(C)).call(this));return S.listeners={},S.on("error",v.error),S}return i(C,[{key:"emit",value:function(){v.log.apply(v,arguments),o(C.prototype.__proto__||Object.getPrototypeOf(C.prototype),"emit",this).apply(this,arguments)}},{key:"handleDOM",value:function(D){for(var _=arguments.length,A=Array(_>1?_-1:0),E=1;E<_;E++)A[E-1]=arguments[E];(this.listeners[D.type]||[]).forEach(function(q){var O=q.node,R=q.handler;(D.target===O||O.contains(D.target))&&R.apply(void 0,[D].concat(A))})}},{key:"listenDOM",value:function(D,_,A){this.listeners[D]||(this.listeners[D]=[]),this.listeners[D].push({node:_,handler:A})}}]),C})(m.default);j.events={EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change"},j.sources={API:"api",SILENT:"silent",USER:"user"},r.default=j}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});function i(d,m){if(!(d instanceof m))throw new TypeError("Cannot call a class as a function")}var o=function d(m){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};i(this,d),this.quill=m,this.options=f};o.DEFAULTS={},r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=["error","warn","log","info"],o="warn";function d(f){if(i.indexOf(f)<=i.indexOf(o)){for(var p,h=arguments.length,x=Array(h>1?h-1:0),u=1;u<h;u++)x[u-1]=arguments[u];(p=console)[f].apply(p,x)}}function m(f){return i.reduce(function(p,h){return p[h]=d.bind(console,h,f),p},{})}d.level=m.level=function(f){o=f},r.default=m}),(function(n,r,a){var i=Array.prototype.slice,o=a(52),d=a(53),m=n.exports=function(x,u,N){return N||(N={}),x===u?!0:x instanceof Date&&u instanceof Date?x.getTime()===u.getTime():!x||!u||typeof x!="object"&&typeof u!="object"?N.strict?x===u:x==u:h(x,u,N)};function f(x){return x==null}function p(x){return!(!x||typeof x!="object"||typeof x.length!="number"||typeof x.copy!="function"||typeof x.slice!="function"||x.length>0&&typeof x[0]!="number")}function h(x,u,N){var v,w;if(f(x)||f(u)||x.prototype!==u.prototype)return!1;if(d(x))return d(u)?(x=i.call(x),u=i.call(u),m(x,u,N)):!1;if(p(x)){if(!p(u)||x.length!==u.length)return!1;for(v=0;v<x.length;v++)if(x[v]!==u[v])return!1;return!0}try{var j=o(x),b=o(u)}catch{return!1}if(j.length!=b.length)return!1;for(j.sort(),b.sort(),v=j.length-1;v>=0;v--)if(j[v]!=b[v])return!1;for(v=j.length-1;v>=0;v--)if(w=j[v],!m(x[w],u[w],N))return!1;return typeof x==typeof u}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(1),o=(function(){function d(m,f,p){p===void 0&&(p={}),this.attrName=m,this.keyName=f;var h=i.Scope.TYPE&i.Scope.ATTRIBUTE;p.scope!=null?this.scope=p.scope&i.Scope.LEVEL|h:this.scope=i.Scope.ATTRIBUTE,p.whitelist!=null&&(this.whitelist=p.whitelist)}return d.keys=function(m){return[].map.call(m.attributes,function(f){return f.name})},d.prototype.add=function(m,f){return this.canAdd(m,f)?(m.setAttribute(this.keyName,f),!0):!1},d.prototype.canAdd=function(m,f){var p=i.query(m,i.Scope.BLOT&(this.scope|i.Scope.TYPE));return p==null?!1:this.whitelist==null?!0:typeof f=="string"?this.whitelist.indexOf(f.replace(/["']/g,""))>-1:this.whitelist.indexOf(f)>-1},d.prototype.remove=function(m){m.removeAttribute(this.keyName)},d.prototype.value=function(m){var f=m.getAttribute(this.keyName);return this.canAdd(m,f)&&f?f:""},d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Code=void 0;var i=(function(){function E(q,O){var R=[],P=!0,L=!1,$=void 0;try{for(var Z=q[Symbol.iterator](),Q;!(P=(Q=Z.next()).done)&&(R.push(Q.value),!(O&&R.length===O));P=!0);}catch(W){L=!0,$=W}finally{try{!P&&Z.return&&Z.return()}finally{if(L)throw $}}return R}return function(q,O){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return E(q,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(q,O){for(var R=0;R<O.length;R++){var P=O[R];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(q,P.key,P)}}return function(q,O,R){return O&&E(q.prototype,O),R&&E(q,R),q}})(),d=function E(q,O,R){q===null&&(q=Function.prototype);var P=Object.getOwnPropertyDescriptor(q,O);if(P===void 0){var L=Object.getPrototypeOf(q);return L===null?void 0:E(L,O,R)}else{if("value"in P)return P.value;var $=P.get;return $===void 0?void 0:$.call(R)}},m=a(2),f=b(m),p=a(0),h=b(p),x=a(4),u=b(x),N=a(6),v=b(N),w=a(7),j=b(w);function b(E){return E&&E.__esModule?E:{default:E}}function C(E,q){if(!(E instanceof q))throw new TypeError("Cannot call a class as a function")}function S(E,q){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return q&&(typeof q=="object"||typeof q=="function")?q:E}function D(E,q){if(typeof q!="function"&&q!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof q);E.prototype=Object.create(q&&q.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),q&&(Object.setPrototypeOf?Object.setPrototypeOf(E,q):E.__proto__=q)}var _=(function(E){D(q,E);function q(){return C(this,q),S(this,(q.__proto__||Object.getPrototypeOf(q)).apply(this,arguments))}return q})(v.default);_.blotName="code",_.tagName="CODE";var A=(function(E){D(q,E);function q(){return C(this,q),S(this,(q.__proto__||Object.getPrototypeOf(q)).apply(this,arguments))}return o(q,[{key:"delta",value:function(){var R=this,P=this.domNode.textContent;return P.endsWith(`
|
||
`)&&(P=P.slice(0,-1)),P.split(`
|
||
`).reduce(function(L,$){return L.insert($).insert(`
|
||
`,R.formats())},new f.default)}},{key:"format",value:function(R,P){if(!(R===this.statics.blotName&&P)){var L=this.descendant(j.default,this.length()-1),$=i(L,1),Z=$[0];Z!=null&&Z.deleteAt(Z.length()-1,1),d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"format",this).call(this,R,P)}}},{key:"formatAt",value:function(R,P,L,$){if(P!==0&&!(h.default.query(L,h.default.Scope.BLOCK)==null||L===this.statics.blotName&&$===this.statics.formats(this.domNode))){var Z=this.newlineIndex(R);if(!(Z<0||Z>=R+P)){var Q=this.newlineIndex(R,!0)+1,W=Z-Q+1,U=this.isolate(Q,W),M=U.next;U.format(L,$),M instanceof q&&M.formatAt(0,R-Q+P-W,L,$)}}}},{key:"insertAt",value:function(R,P,L){if(L==null){var $=this.descendant(j.default,R),Z=i($,2),Q=Z[0],W=Z[1];Q.insertAt(W,P)}}},{key:"length",value:function(){var R=this.domNode.textContent.length;return this.domNode.textContent.endsWith(`
|
||
`)?R:R+1}},{key:"newlineIndex",value:function(R){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(P)return this.domNode.textContent.slice(0,R).lastIndexOf(`
|
||
`);var L=this.domNode.textContent.slice(R).indexOf(`
|
||
`);return L>-1?R+L:-1}},{key:"optimize",value:function(R){this.domNode.textContent.endsWith(`
|
||
`)||this.appendChild(h.default.create("text",`
|
||
`)),d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"optimize",this).call(this,R);var P=this.next;P!=null&&P.prev===this&&P.statics.blotName===this.statics.blotName&&this.statics.formats(this.domNode)===P.statics.formats(P.domNode)&&(P.optimize(R),P.moveChildren(this),P.remove())}},{key:"replace",value:function(R){d(q.prototype.__proto__||Object.getPrototypeOf(q.prototype),"replace",this).call(this,R),[].slice.call(this.domNode.querySelectorAll("*")).forEach(function(P){var L=h.default.find(P);L==null?P.parentNode.removeChild(P):L instanceof h.default.Embed?L.remove():L.unwrap()})}}],[{key:"create",value:function(R){var P=d(q.__proto__||Object.getPrototypeOf(q),"create",this).call(this,R);return P.setAttribute("spellcheck",!1),P}},{key:"formats",value:function(){return!0}}]),q})(u.default);A.blotName="code-block",A.tagName="PRE",A.TAB=" ",r.Code=_,r.default=A}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},o=(function(){function M(z,T){var F=[],I=!0,K=!1,G=void 0;try{for(var V=z[Symbol.iterator](),Y;!(I=(Y=V.next()).done)&&(F.push(Y.value),!(T&&F.length===T));I=!0);}catch(re){K=!0,G=re}finally{try{!I&&V.return&&V.return()}finally{if(K)throw G}}return F}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return M(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function M(z,T){for(var F=0;F<T.length;F++){var I=T[F];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(z,I.key,I)}}return function(z,T,F){return T&&M(z.prototype,T),F&&M(z,F),z}})(),m=a(2),f=P(m),p=a(20),h=P(p),x=a(0),u=P(x),N=a(13),v=P(N),w=a(24),j=P(w),b=a(4),C=P(b),S=a(16),D=P(S),_=a(21),A=P(_),E=a(11),q=P(E),O=a(3),R=P(O);function P(M){return M&&M.__esModule?M:{default:M}}function L(M,z,T){return z in M?Object.defineProperty(M,z,{value:T,enumerable:!0,configurable:!0,writable:!0}):M[z]=T,M}function $(M,z){if(!(M instanceof z))throw new TypeError("Cannot call a class as a function")}var Z=/^[ -~]*$/,Q=(function(){function M(z){$(this,M),this.scroll=z,this.delta=this.getDelta()}return d(M,[{key:"applyDelta",value:function(T){var F=this,I=!1;this.scroll.update();var K=this.scroll.length();return this.scroll.batchStart(),T=U(T),T.reduce(function(G,V){var Y=V.retain||V.delete||V.insert.length||1,re=V.attributes||{};if(V.insert!=null){if(typeof V.insert=="string"){var ae=V.insert;ae.endsWith(`
|
||
`)&&I&&(I=!1,ae=ae.slice(0,-1)),G>=K&&!ae.endsWith(`
|
||
`)&&(I=!0),F.scroll.insertAt(G,ae);var ue=F.scroll.line(G),ye=o(ue,2),ce=ye[0],je=ye[1],Me=(0,R.default)({},(0,b.bubbleFormats)(ce));if(ce instanceof C.default){var ut=ce.descendant(u.default.Leaf,je),jt=o(ut,1),ft=jt[0];Me=(0,R.default)(Me,(0,b.bubbleFormats)(ft))}re=h.default.attributes.diff(Me,re)||{}}else if(i(V.insert)==="object"){var X=Object.keys(V.insert)[0];if(X==null)return G;F.scroll.insertAt(G,X,V.insert[X])}K+=Y}return Object.keys(re).forEach(function(Ce){F.scroll.formatAt(G,Y,Ce,re[Ce])}),G+Y},0),T.reduce(function(G,V){return typeof V.delete=="number"?(F.scroll.deleteAt(G,V.delete),G):G+(V.retain||V.insert.length||1)},0),this.scroll.batchEnd(),this.update(T)}},{key:"deleteText",value:function(T,F){return this.scroll.deleteAt(T,F),this.update(new f.default().retain(T).delete(F))}},{key:"formatLine",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.scroll.update(),Object.keys(K).forEach(function(G){if(!(I.scroll.whitelist!=null&&!I.scroll.whitelist[G])){var V=I.scroll.lines(T,Math.max(F,1)),Y=F;V.forEach(function(re){var ae=re.length();if(!(re instanceof v.default))re.format(G,K[G]);else{var ue=T-re.offset(I.scroll),ye=re.newlineIndex(ue+Y)-ue+1;re.formatAt(ue,ye,G,K[G])}Y-=ae})}}),this.scroll.optimize(),this.update(new f.default().retain(T).retain(F,(0,A.default)(K)))}},{key:"formatText",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Object.keys(K).forEach(function(G){I.scroll.formatAt(T,F,G,K[G])}),this.update(new f.default().retain(T).retain(F,(0,A.default)(K)))}},{key:"getContents",value:function(T,F){return this.delta.slice(T,T+F)}},{key:"getDelta",value:function(){return this.scroll.lines().reduce(function(T,F){return T.concat(F.delta())},new f.default)}},{key:"getFormat",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,I=[],K=[];F===0?this.scroll.path(T).forEach(function(V){var Y=o(V,1),re=Y[0];re instanceof C.default?I.push(re):re instanceof u.default.Leaf&&K.push(re)}):(I=this.scroll.lines(T,F),K=this.scroll.descendants(u.default.Leaf,T,F));var G=[I,K].map(function(V){if(V.length===0)return{};for(var Y=(0,b.bubbleFormats)(V.shift());Object.keys(Y).length>0;){var re=V.shift();if(re==null)return Y;Y=W((0,b.bubbleFormats)(re),Y)}return Y});return R.default.apply(R.default,G)}},{key:"getText",value:function(T,F){return this.getContents(T,F).filter(function(I){return typeof I.insert=="string"}).map(function(I){return I.insert}).join("")}},{key:"insertEmbed",value:function(T,F,I){return this.scroll.insertAt(T,F,I),this.update(new f.default().retain(T).insert(L({},F,I)))}},{key:"insertText",value:function(T,F){var I=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return F=F.replace(/\r\n/g,`
|
||
`).replace(/\r/g,`
|
||
`),this.scroll.insertAt(T,F),Object.keys(K).forEach(function(G){I.scroll.formatAt(T,F.length,G,K[G])}),this.update(new f.default().retain(T).insert(F,(0,A.default)(K)))}},{key:"isBlank",value:function(){if(this.scroll.children.length==0)return!0;if(this.scroll.children.length>1)return!1;var T=this.scroll.children.head;return T.statics.blotName!==C.default.blotName||T.children.length>1?!1:T.children.head instanceof D.default}},{key:"removeFormat",value:function(T,F){var I=this.getText(T,F),K=this.scroll.line(T+F),G=o(K,2),V=G[0],Y=G[1],re=0,ae=new f.default;V!=null&&(V instanceof v.default?re=V.newlineIndex(Y)-Y+1:re=V.length()-Y,ae=V.delta().slice(Y,Y+re-1).insert(`
|
||
`));var ue=this.getContents(T,F+re),ye=ue.diff(new f.default().insert(I).concat(ae)),ce=new f.default().retain(T).concat(ye);return this.applyDelta(ce)}},{key:"update",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,K=this.delta;if(F.length===1&&F[0].type==="characterData"&&F[0].target.data.match(Z)&&u.default.find(F[0].target)){var G=u.default.find(F[0].target),V=(0,b.bubbleFormats)(G),Y=G.offset(this.scroll),re=F[0].oldValue.replace(j.default.CONTENTS,""),ae=new f.default().insert(re),ue=new f.default().insert(G.value()),ye=new f.default().retain(Y).concat(ae.diff(ue,I));T=ye.reduce(function(ce,je){return je.insert?ce.insert(je.insert,V):ce.push(je)},new f.default),this.delta=K.compose(T)}else this.delta=this.getDelta(),(!T||!(0,q.default)(K.compose(T),this.delta))&&(T=K.diff(this.delta,I));return T}}]),M})();function W(M,z){return Object.keys(z).reduce(function(T,F){return M[F]==null||(z[F]===M[F]?T[F]=z[F]:Array.isArray(z[F])?z[F].indexOf(M[F])<0&&(T[F]=z[F].concat([M[F]])):T[F]=[z[F],M[F]]),T},{})}function U(M){return M.reduce(function(z,T){if(T.insert===1){var F=(0,A.default)(T.attributes);return delete F.image,z.insert({image:T.attributes.image},F)}if(T.attributes!=null&&(T.attributes.list===!0||T.attributes.bullet===!0)&&(T=(0,A.default)(T),T.attributes.list?T.attributes.list="ordered":(T.attributes.list="bullet",delete T.attributes.bullet)),typeof T.insert=="string"){var I=T.insert.replace(/\r\n/g,`
|
||
`).replace(/\r/g,`
|
||
`);return z.insert(I,T.attributes)}return z.push(T)},new f.default)}r.default=Q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Range=void 0;var i=(function(){function E(q,O){var R=[],P=!0,L=!1,$=void 0;try{for(var Z=q[Symbol.iterator](),Q;!(P=(Q=Z.next()).done)&&(R.push(Q.value),!(O&&R.length===O));P=!0);}catch(W){L=!0,$=W}finally{try{!P&&Z.return&&Z.return()}finally{if(L)throw $}}return R}return function(q,O){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return E(q,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(q,O){for(var R=0;R<O.length;R++){var P=O[R];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(q,P.key,P)}}return function(q,O,R){return O&&E(q.prototype,O),R&&E(q,R),q}})(),d=a(0),m=j(d),f=a(21),p=j(f),h=a(11),x=j(h),u=a(8),N=j(u),v=a(10),w=j(v);function j(E){return E&&E.__esModule?E:{default:E}}function b(E){if(Array.isArray(E)){for(var q=0,O=Array(E.length);q<E.length;q++)O[q]=E[q];return O}else return Array.from(E)}function C(E,q){if(!(E instanceof q))throw new TypeError("Cannot call a class as a function")}var S=(0,w.default)("quill:selection"),D=function E(q){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;C(this,E),this.index=q,this.length=O},_=(function(){function E(q,O){var R=this;C(this,E),this.emitter=O,this.scroll=q,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=m.default.create("cursor",this),this.lastRange=this.savedRange=new D(0,0),this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,function(){R.mouseDown||setTimeout(R.update.bind(R,N.default.sources.USER),1)}),this.emitter.on(N.default.events.EDITOR_CHANGE,function(P,L){P===N.default.events.TEXT_CHANGE&&L.length()>0&&R.update(N.default.sources.SILENT)}),this.emitter.on(N.default.events.SCROLL_BEFORE_UPDATE,function(){if(R.hasFocus()){var P=R.getNativeRange();P!=null&&P.start.node!==R.cursor.textNode&&R.emitter.once(N.default.events.SCROLL_UPDATE,function(){try{R.setNativeRange(P.start.node,P.start.offset,P.end.node,P.end.offset)}catch{}})}}),this.emitter.on(N.default.events.SCROLL_OPTIMIZE,function(P,L){if(L.range){var $=L.range,Z=$.startNode,Q=$.startOffset,W=$.endNode,U=$.endOffset;R.setNativeRange(Z,Q,W,U)}}),this.update(N.default.sources.SILENT)}return o(E,[{key:"handleComposition",value:function(){var O=this;this.root.addEventListener("compositionstart",function(){O.composing=!0}),this.root.addEventListener("compositionend",function(){if(O.composing=!1,O.cursor.parent){var R=O.cursor.restore();if(!R)return;setTimeout(function(){O.setNativeRange(R.startNode,R.startOffset,R.endNode,R.endOffset)},1)}})}},{key:"handleDragging",value:function(){var O=this;this.emitter.listenDOM("mousedown",document.body,function(){O.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,function(){O.mouseDown=!1,O.update(N.default.sources.USER)})}},{key:"focus",value:function(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}},{key:"format",value:function(O,R){if(!(this.scroll.whitelist!=null&&!this.scroll.whitelist[O])){this.scroll.update();var P=this.getNativeRange();if(!(P==null||!P.native.collapsed||m.default.query(O,m.default.Scope.BLOCK))){if(P.start.node!==this.cursor.textNode){var L=m.default.find(P.start.node,!1);if(L==null)return;if(L instanceof m.default.Leaf){var $=L.split(P.start.offset);L.parent.insertBefore(this.cursor,$)}else L.insertBefore(this.cursor,P.start.node);this.cursor.attach()}this.cursor.format(O,R),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}}},{key:"getBounds",value:function(O){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,P=this.scroll.length();O=Math.min(O,P-1),R=Math.min(O+R,P-1)-O;var L=void 0,$=this.scroll.leaf(O),Z=i($,2),Q=Z[0],W=Z[1];if(Q==null)return null;var U=Q.position(W,!0),M=i(U,2);L=M[0],W=M[1];var z=document.createRange();if(R>0){z.setStart(L,W);var T=this.scroll.leaf(O+R),F=i(T,2);if(Q=F[0],W=F[1],Q==null)return null;var I=Q.position(W,!0),K=i(I,2);return L=K[0],W=K[1],z.setEnd(L,W),z.getBoundingClientRect()}else{var G="left",V=void 0;return L instanceof Text?(W<L.data.length?(z.setStart(L,W),z.setEnd(L,W+1)):(z.setStart(L,W-1),z.setEnd(L,W),G="right"),V=z.getBoundingClientRect()):(V=Q.domNode.getBoundingClientRect(),W>0&&(G="right")),{bottom:V.top+V.height,height:V.height,left:V[G],right:V[G],top:V.top,width:0}}}},{key:"getNativeRange",value:function(){var O=document.getSelection();if(O==null||O.rangeCount<=0)return null;var R=O.getRangeAt(0);if(R==null)return null;var P=this.normalizeNative(R);return S.info("getNativeRange",P),P}},{key:"getRange",value:function(){var O=this.getNativeRange();if(O==null)return[null,null];var R=this.normalizedToRange(O);return[R,O]}},{key:"hasFocus",value:function(){return document.activeElement===this.root}},{key:"normalizedToRange",value:function(O){var R=this,P=[[O.start.node,O.start.offset]];O.native.collapsed||P.push([O.end.node,O.end.offset]);var L=P.map(function(Q){var W=i(Q,2),U=W[0],M=W[1],z=m.default.find(U,!0),T=z.offset(R.scroll);return M===0?T:z instanceof m.default.Container?T+z.length():T+z.index(U,M)}),$=Math.min(Math.max.apply(Math,b(L)),this.scroll.length()-1),Z=Math.min.apply(Math,[$].concat(b(L)));return new D(Z,$-Z)}},{key:"normalizeNative",value:function(O){if(!A(this.root,O.startContainer)||!O.collapsed&&!A(this.root,O.endContainer))return null;var R={start:{node:O.startContainer,offset:O.startOffset},end:{node:O.endContainer,offset:O.endOffset},native:O};return[R.start,R.end].forEach(function(P){for(var L=P.node,$=P.offset;!(L instanceof Text)&&L.childNodes.length>0;)if(L.childNodes.length>$)L=L.childNodes[$],$=0;else if(L.childNodes.length===$)L=L.lastChild,$=L instanceof Text?L.data.length:L.childNodes.length+1;else break;P.node=L,P.offset=$}),R}},{key:"rangeToNative",value:function(O){var R=this,P=O.collapsed?[O.index]:[O.index,O.index+O.length],L=[],$=this.scroll.length();return P.forEach(function(Z,Q){Z=Math.min($-1,Z);var W=void 0,U=R.scroll.leaf(Z),M=i(U,2),z=M[0],T=M[1],F=z.position(T,Q!==0),I=i(F,2);W=I[0],T=I[1],L.push(W,T)}),L.length<2&&(L=L.concat(L)),L}},{key:"scrollIntoView",value:function(O){var R=this.lastRange;if(R!=null){var P=this.getBounds(R.index,R.length);if(P!=null){var L=this.scroll.length()-1,$=this.scroll.line(Math.min(R.index,L)),Z=i($,1),Q=Z[0],W=Q;if(R.length>0){var U=this.scroll.line(Math.min(R.index+R.length,L)),M=i(U,1);W=M[0]}if(!(Q==null||W==null)){var z=O.getBoundingClientRect();P.top<z.top?O.scrollTop-=z.top-P.top:P.bottom>z.bottom&&(O.scrollTop+=P.bottom-z.bottom)}}}}},{key:"setNativeRange",value:function(O,R){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:O,L=arguments.length>3&&arguments[3]!==void 0?arguments[3]:R,$=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(S.info("setNativeRange",O,R,P,L),!(O!=null&&(this.root.parentNode==null||O.parentNode==null||P.parentNode==null))){var Z=document.getSelection();if(Z!=null)if(O!=null){this.hasFocus()||this.root.focus();var Q=(this.getNativeRange()||{}).native;if(Q==null||$||O!==Q.startContainer||R!==Q.startOffset||P!==Q.endContainer||L!==Q.endOffset){O.tagName=="BR"&&(R=[].indexOf.call(O.parentNode.childNodes,O),O=O.parentNode),P.tagName=="BR"&&(L=[].indexOf.call(P.parentNode.childNodes,P),P=P.parentNode);var W=document.createRange();W.setStart(O,R),W.setEnd(P,L),Z.removeAllRanges(),Z.addRange(W)}}else Z.removeAllRanges(),this.root.blur(),document.body.focus()}}},{key:"setRange",value:function(O){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:N.default.sources.API;if(typeof R=="string"&&(P=R,R=!1),S.info("setRange",O),O!=null){var L=this.rangeToNative(O);this.setNativeRange.apply(this,b(L).concat([R]))}else this.setNativeRange(null);this.update(P)}},{key:"update",value:function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.default.sources.USER,R=this.lastRange,P=this.getRange(),L=i(P,2),$=L[0],Z=L[1];if(this.lastRange=$,this.lastRange!=null&&(this.savedRange=this.lastRange),!(0,x.default)(R,this.lastRange)){var Q;!this.composing&&Z!=null&&Z.native.collapsed&&Z.start.node!==this.cursor.textNode&&this.cursor.restore();var W=[N.default.events.SELECTION_CHANGE,(0,p.default)(this.lastRange),(0,p.default)(R),O];if((Q=this.emitter).emit.apply(Q,[N.default.events.EDITOR_CHANGE].concat(W)),O!==N.default.sources.SILENT){var U;(U=this.emitter).emit.apply(U,W)}}}}]),E})();function A(E,q){try{q.parentNode}catch{return!1}return q instanceof Text&&(q=q.parentNode),E.contains(q)}r.Range=D,r.default=_}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(0),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return i(v,[{key:"insertInto",value:function(j,b){j.children.length===0?o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"insertInto",this).call(this,j,b):this.remove()}},{key:"length",value:function(){return 0}},{key:"value",value:function(){return""}}],[{key:"value",value:function(){}}]),v})(m.default.Embed);u.blotName="break",u.tagName="BR",r.default=u}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(44),d=a(30),m=a(1),f=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.build(),N}return x.prototype.appendChild=function(u){this.insertBefore(u)},x.prototype.attach=function(){h.prototype.attach.call(this),this.children.forEach(function(u){u.attach()})},x.prototype.build=function(){var u=this;this.children=new o.default,[].slice.call(this.domNode.childNodes).reverse().forEach(function(N){try{var v=p(N);u.insertBefore(v,u.children.head||void 0)}catch(w){if(w instanceof m.ParchmentError)return;throw w}})},x.prototype.deleteAt=function(u,N){if(u===0&&N===this.length())return this.remove();this.children.forEachAt(u,N,function(v,w,j){v.deleteAt(w,j)})},x.prototype.descendant=function(u,N){var v=this.children.find(N),w=v[0],j=v[1];return u.blotName==null&&u(w)||u.blotName!=null&&w instanceof u?[w,j]:w instanceof x?w.descendant(u,j):[null,-1]},x.prototype.descendants=function(u,N,v){N===void 0&&(N=0),v===void 0&&(v=Number.MAX_VALUE);var w=[],j=v;return this.children.forEachAt(N,v,function(b,C,S){(u.blotName==null&&u(b)||u.blotName!=null&&b instanceof u)&&w.push(b),b instanceof x&&(w=w.concat(b.descendants(u,C,j))),j-=S}),w},x.prototype.detach=function(){this.children.forEach(function(u){u.detach()}),h.prototype.detach.call(this)},x.prototype.formatAt=function(u,N,v,w){this.children.forEachAt(u,N,function(j,b,C){j.formatAt(b,C,v,w)})},x.prototype.insertAt=function(u,N,v){var w=this.children.find(u),j=w[0],b=w[1];if(j)j.insertAt(b,N,v);else{var C=v==null?m.create("text",N):m.create(N,v);this.appendChild(C)}},x.prototype.insertBefore=function(u,N){if(this.statics.allowedChildren!=null&&!this.statics.allowedChildren.some(function(v){return u instanceof v}))throw new m.ParchmentError("Cannot insert "+u.statics.blotName+" into "+this.statics.blotName);u.insertInto(this,N)},x.prototype.length=function(){return this.children.reduce(function(u,N){return u+N.length()},0)},x.prototype.moveChildren=function(u,N){this.children.forEach(function(v){u.insertBefore(v,N)})},x.prototype.optimize=function(u){if(h.prototype.optimize.call(this,u),this.children.length===0)if(this.statics.defaultChild!=null){var N=m.create(this.statics.defaultChild);this.appendChild(N),N.optimize(u)}else this.remove()},x.prototype.path=function(u,N){N===void 0&&(N=!1);var v=this.children.find(u,N),w=v[0],j=v[1],b=[[this,u]];return w instanceof x?b.concat(w.path(j,N)):(w!=null&&b.push([w,j]),b)},x.prototype.removeChild=function(u){this.children.remove(u)},x.prototype.replace=function(u){u instanceof x&&u.moveChildren(this),h.prototype.replace.call(this,u)},x.prototype.split=function(u,N){if(N===void 0&&(N=!1),!N){if(u===0)return this;if(u===this.length())return this.next}var v=this.clone();return this.parent.insertBefore(v,this.next),this.children.forEachAt(u,this.length(),function(w,j,b){w=w.split(j,N),v.appendChild(w)}),v},x.prototype.unwrap=function(){this.moveChildren(this.parent,this.next),this.remove()},x.prototype.update=function(u,N){var v=this,w=[],j=[];u.forEach(function(b){b.target===v.domNode&&b.type==="childList"&&(w.push.apply(w,b.addedNodes),j.push.apply(j,b.removedNodes))}),j.forEach(function(b){if(!(b.parentNode!=null&&b.tagName!=="IFRAME"&&document.body.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_CONTAINED_BY)){var C=m.find(b);C!=null&&(C.domNode.parentNode==null||C.domNode.parentNode===v.domNode)&&C.detach()}}),w.filter(function(b){return b.parentNode==v.domNode}).sort(function(b,C){return b===C?0:b.compareDocumentPosition(C)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1}).forEach(function(b){var C=null;b.nextSibling!=null&&(C=m.find(b.nextSibling));var S=p(b);(S.next!=C||S.next==null)&&(S.parent!=null&&S.parent.removeChild(v),v.insertBefore(S,C||void 0))})},x})(d.default);function p(h){var x=m.find(h);if(x==null)try{x=m.create(h)}catch{x=m.create(m.Scope.INLINE),[].slice.call(h.childNodes).forEach(function(N){x.domNode.appendChild(N)}),h.parentNode&&h.parentNode.replaceChild(x.domNode,h),x.attach()}return x}r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12),d=a(31),m=a(17),f=a(1),p=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.attributes=new d.default(N.domNode),N}return x.formats=function(u){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return u.tagName.toLowerCase()},x.prototype.format=function(u,N){var v=f.query(u);v instanceof o.default?this.attributes.attribute(v,N):N&&v!=null&&(u!==this.statics.blotName||this.formats()[u]!==N)&&this.replaceWith(u,N)},x.prototype.formats=function(){var u=this.attributes.values(),N=this.statics.formats(this.domNode);return N!=null&&(u[this.statics.blotName]=N),u},x.prototype.replaceWith=function(u,N){var v=h.prototype.replaceWith.call(this,u,N);return this.attributes.copy(v),v},x.prototype.update=function(u,N){var v=this;h.prototype.update.call(this,u,N),u.some(function(w){return w.target===v.domNode&&w.type==="attributes"})&&this.attributes.build()},x.prototype.wrap=function(u,N){var v=h.prototype.wrap.call(this,u,N);return v instanceof x&&v.statics.scope===this.statics.scope&&this.attributes.move(v),v},x})(m.default);r.default=p}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(30),d=a(1),m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.value=function(h){return!0},p.prototype.index=function(h,x){return this.domNode===h||this.domNode.compareDocumentPosition(h)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(x,1):-1},p.prototype.position=function(h,x){var u=[].indexOf.call(this.parent.domNode.childNodes,this.domNode);return h>0&&(u+=1),[this.parent.domNode,u]},p.prototype.value=function(){var h;return h={},h[this.statics.blotName]=this.statics.value(this.domNode)||!0,h},p.scope=d.Scope.INLINE_BLOT,p})(o.default);r.default=m}),(function(n,r,a){var i=a(11),o=a(3),d={attributes:{compose:function(f,p,h){typeof f!="object"&&(f={}),typeof p!="object"&&(p={});var x=o(!0,{},p);h||(x=Object.keys(x).reduce(function(N,v){return x[v]!=null&&(N[v]=x[v]),N},{}));for(var u in f)f[u]!==void 0&&p[u]===void 0&&(x[u]=f[u]);return Object.keys(x).length>0?x:void 0},diff:function(f,p){typeof f!="object"&&(f={}),typeof p!="object"&&(p={});var h=Object.keys(f).concat(Object.keys(p)).reduce(function(x,u){return i(f[u],p[u])||(x[u]=p[u]===void 0?null:p[u]),x},{});return Object.keys(h).length>0?h:void 0},transform:function(f,p,h){if(typeof f!="object")return p;if(typeof p=="object"){if(!h)return p;var x=Object.keys(p).reduce(function(u,N){return f[N]===void 0&&(u[N]=p[N]),u},{});return Object.keys(x).length>0?x:void 0}}},iterator:function(f){return new m(f)},length:function(f){return typeof f.delete=="number"?f.delete:typeof f.retain=="number"?f.retain:typeof f.insert=="string"?f.insert.length:1}};function m(f){this.ops=f,this.index=0,this.offset=0}m.prototype.hasNext=function(){return this.peekLength()<1/0},m.prototype.next=function(f){f||(f=1/0);var p=this.ops[this.index];if(p){var h=this.offset,x=d.length(p);if(f>=x-h?(f=x-h,this.index+=1,this.offset=0):this.offset+=f,typeof p.delete=="number")return{delete:f};var u={};return p.attributes&&(u.attributes=p.attributes),typeof p.retain=="number"?u.retain=f:typeof p.insert=="string"?u.insert=p.insert.substr(h,f):u.insert=p.insert,u}else return{retain:1/0}},m.prototype.peek=function(){return this.ops[this.index]},m.prototype.peekLength=function(){return this.ops[this.index]?d.length(this.ops[this.index])-this.offset:1/0},m.prototype.peekType=function(){return this.ops[this.index]?typeof this.ops[this.index].delete=="number"?"delete":typeof this.ops[this.index].retain=="number"?"retain":"insert":"retain"},m.prototype.rest=function(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);var f=this.offset,p=this.index,h=this.next(),x=this.ops.slice(this.index);return this.offset=f,this.index=p,[h].concat(x)}else return[]},n.exports=d}),(function(n,r){var a=(function(){function i(v,w){return w!=null&&v instanceof w}var o;try{o=Map}catch{o=function(){}}var d;try{d=Set}catch{d=function(){}}var m;try{m=Promise}catch{m=function(){}}function f(v,w,j,b,C){typeof w=="object"&&(j=w.depth,b=w.prototype,C=w.includeNonEnumerable,w=w.circular);var S=[],D=[],_=typeof Buffer<"u";typeof w>"u"&&(w=!0),typeof j>"u"&&(j=1/0);function A(E,q){if(E===null)return null;if(q===0)return E;var O,R;if(typeof E!="object")return E;if(i(E,o))O=new o;else if(i(E,d))O=new d;else if(i(E,m))O=new m(function(z,T){E.then(function(F){z(A(F,q-1))},function(F){T(A(F,q-1))})});else if(f.__isArray(E))O=[];else if(f.__isRegExp(E))O=new RegExp(E.source,N(E)),E.lastIndex&&(O.lastIndex=E.lastIndex);else if(f.__isDate(E))O=new Date(E.getTime());else{if(_&&Buffer.isBuffer(E))return Buffer.allocUnsafe?O=Buffer.allocUnsafe(E.length):O=new Buffer(E.length),E.copy(O),O;i(E,Error)?O=Object.create(E):typeof b>"u"?(R=Object.getPrototypeOf(E),O=Object.create(R)):(O=Object.create(b),R=b)}if(w){var P=S.indexOf(E);if(P!=-1)return D[P];S.push(E),D.push(O)}i(E,o)&&E.forEach(function(z,T){var F=A(T,q-1),I=A(z,q-1);O.set(F,I)}),i(E,d)&&E.forEach(function(z){var T=A(z,q-1);O.add(T)});for(var L in E){var $;R&&($=Object.getOwnPropertyDescriptor(R,L)),!($&&$.set==null)&&(O[L]=A(E[L],q-1))}if(Object.getOwnPropertySymbols)for(var Z=Object.getOwnPropertySymbols(E),L=0;L<Z.length;L++){var Q=Z[L],W=Object.getOwnPropertyDescriptor(E,Q);W&&!W.enumerable&&!C||(O[Q]=A(E[Q],q-1),W.enumerable||Object.defineProperty(O,Q,{enumerable:!1}))}if(C)for(var U=Object.getOwnPropertyNames(E),L=0;L<U.length;L++){var M=U[L],W=Object.getOwnPropertyDescriptor(E,M);W&&W.enumerable||(O[M]=A(E[M],q-1),Object.defineProperty(O,M,{enumerable:!1}))}return O}return A(v,j)}f.clonePrototype=function(w){if(w===null)return null;var j=function(){};return j.prototype=w,new j};function p(v){return Object.prototype.toString.call(v)}f.__objToStr=p;function h(v){return typeof v=="object"&&p(v)==="[object Date]"}f.__isDate=h;function x(v){return typeof v=="object"&&p(v)==="[object Array]"}f.__isArray=x;function u(v){return typeof v=="object"&&p(v)==="[object RegExp]"}f.__isRegExp=u;function N(v){var w="";return v.global&&(w+="g"),v.ignoreCase&&(w+="i"),v.multiline&&(w+="m"),w}return f.__getRegExpFlags=N,f})();typeof n=="object"&&n.exports&&(n.exports=a)}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function O(R,P){var L=[],$=!0,Z=!1,Q=void 0;try{for(var W=R[Symbol.iterator](),U;!($=(U=W.next()).done)&&(L.push(U.value),!(P&&L.length===P));$=!0);}catch(M){Z=!0,Q=M}finally{try{!$&&W.return&&W.return()}finally{if(Z)throw Q}}return L}return function(R,P){if(Array.isArray(R))return R;if(Symbol.iterator in Object(R))return O(R,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function O(R,P){for(var L=0;L<P.length;L++){var $=P[L];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(R,$.key,$)}}return function(R,P,L){return P&&O(R.prototype,P),L&&O(R,L),R}})(),d=function O(R,P,L){R===null&&(R=Function.prototype);var $=Object.getOwnPropertyDescriptor(R,P);if($===void 0){var Z=Object.getPrototypeOf(R);return Z===null?void 0:O(Z,P,L)}else{if("value"in $)return $.value;var Q=$.get;return Q===void 0?void 0:Q.call(L)}},m=a(0),f=S(m),p=a(8),h=S(p),x=a(4),u=S(x),N=a(16),v=S(N),w=a(13),j=S(w),b=a(25),C=S(b);function S(O){return O&&O.__esModule?O:{default:O}}function D(O,R){if(!(O instanceof R))throw new TypeError("Cannot call a class as a function")}function _(O,R){if(!O)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:O}function A(O,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);O.prototype=Object.create(R&&R.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(O,R):O.__proto__=R)}function E(O){return O instanceof u.default||O instanceof x.BlockEmbed}var q=(function(O){A(R,O);function R(P,L){D(this,R);var $=_(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,P));return $.emitter=L.emitter,Array.isArray(L.whitelist)&&($.whitelist=L.whitelist.reduce(function(Z,Q){return Z[Q]=!0,Z},{})),$.domNode.addEventListener("DOMNodeInserted",function(){}),$.optimize(),$.enable(),$}return o(R,[{key:"batchStart",value:function(){this.batch=!0}},{key:"batchEnd",value:function(){this.batch=!1,this.optimize()}},{key:"deleteAt",value:function(L,$){var Z=this.line(L),Q=i(Z,2),W=Q[0],U=Q[1],M=this.line(L+$),z=i(M,1),T=z[0];if(d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"deleteAt",this).call(this,L,$),T!=null&&W!==T&&U>0){if(W instanceof x.BlockEmbed||T instanceof x.BlockEmbed){this.optimize();return}if(W instanceof j.default){var F=W.newlineIndex(W.length(),!0);if(F>-1&&(W=W.split(F+1),W===T)){this.optimize();return}}else if(T instanceof j.default){var I=T.newlineIndex(0);I>-1&&T.split(I+1)}var K=T.children.head instanceof v.default?null:T.children.head;W.moveChildren(T,K),W.remove()}this.optimize()}},{key:"enable",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",L)}},{key:"formatAt",value:function(L,$,Z,Q){this.whitelist!=null&&!this.whitelist[Z]||(d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"formatAt",this).call(this,L,$,Z,Q),this.optimize())}},{key:"insertAt",value:function(L,$,Z){if(!(Z!=null&&this.whitelist!=null&&!this.whitelist[$])){if(L>=this.length())if(Z==null||f.default.query($,f.default.Scope.BLOCK)==null){var Q=f.default.create(this.statics.defaultChild);this.appendChild(Q),Z==null&&$.endsWith(`
|
||
`)&&($=$.slice(0,-1)),Q.insertAt(0,$,Z)}else{var W=f.default.create($,Z);this.appendChild(W)}else d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"insertAt",this).call(this,L,$,Z);this.optimize()}}},{key:"insertBefore",value:function(L,$){if(L.statics.scope===f.default.Scope.INLINE_BLOT){var Z=f.default.create(this.statics.defaultChild);Z.appendChild(L),L=Z}d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"insertBefore",this).call(this,L,$)}},{key:"leaf",value:function(L){return this.path(L).pop()||[null,-1]}},{key:"line",value:function(L){return L===this.length()?this.line(L-1):this.descendant(E,L)}},{key:"lines",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,Z=function Q(W,U,M){var z=[],T=M;return W.children.forEachAt(U,M,function(F,I,K){E(F)?z.push(F):F instanceof f.default.Container&&(z=z.concat(Q(F,I,T))),T-=K}),z};return Z(this,L,$)}},{key:"optimize",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch!==!0&&(d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"optimize",this).call(this,L,$),L.length>0&&this.emitter.emit(h.default.events.SCROLL_OPTIMIZE,L,$))}},{key:"path",value:function(L){return d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"path",this).call(this,L).slice(1)}},{key:"update",value:function(L){if(this.batch!==!0){var $=h.default.sources.USER;typeof L=="string"&&($=L),Array.isArray(L)||(L=this.observer.takeRecords()),L.length>0&&this.emitter.emit(h.default.events.SCROLL_BEFORE_UPDATE,$,L),d(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"update",this).call(this,L.concat([])),L.length>0&&this.emitter.emit(h.default.events.SCROLL_UPDATE,$,L)}}}]),R})(f.default.Scroll);q.blotName="scroll",q.className="ql-editor",q.tagName="DIV",q.defaultChild="block",q.allowedChildren=[u.default,x.BlockEmbed,C.default],r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SHORTKEY=r.default=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},o=(function(){function V(Y,re){var ae=[],ue=!0,ye=!1,ce=void 0;try{for(var je=Y[Symbol.iterator](),Me;!(ue=(Me=je.next()).done)&&(ae.push(Me.value),!(re&&ae.length===re));ue=!0);}catch(ut){ye=!0,ce=ut}finally{try{!ue&&je.return&&je.return()}finally{if(ye)throw ce}}return ae}return function(Y,re){if(Array.isArray(Y))return Y;if(Symbol.iterator in Object(Y))return V(Y,re);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function V(Y,re){for(var ae=0;ae<re.length;ae++){var ue=re[ae];ue.enumerable=ue.enumerable||!1,ue.configurable=!0,"value"in ue&&(ue.writable=!0),Object.defineProperty(Y,ue.key,ue)}}return function(Y,re,ae){return re&&V(Y.prototype,re),ae&&V(Y,ae),Y}})(),m=a(21),f=O(m),p=a(11),h=O(p),x=a(3),u=O(x),N=a(2),v=O(N),w=a(20),j=O(w),b=a(0),C=O(b),S=a(5),D=O(S),_=a(10),A=O(_),E=a(9),q=O(E);function O(V){return V&&V.__esModule?V:{default:V}}function R(V,Y,re){return Y in V?Object.defineProperty(V,Y,{value:re,enumerable:!0,configurable:!0,writable:!0}):V[Y]=re,V}function P(V,Y){if(!(V instanceof Y))throw new TypeError("Cannot call a class as a function")}function L(V,Y){if(!V)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y&&(typeof Y=="object"||typeof Y=="function")?Y:V}function $(V,Y){if(typeof Y!="function"&&Y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof Y);V.prototype=Object.create(Y&&Y.prototype,{constructor:{value:V,enumerable:!1,writable:!0,configurable:!0}}),Y&&(Object.setPrototypeOf?Object.setPrototypeOf(V,Y):V.__proto__=Y)}var Z=(0,A.default)("quill:keyboard"),Q=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",W=(function(V){$(Y,V),d(Y,null,[{key:"match",value:function(ae,ue){return ue=G(ue),["altKey","ctrlKey","metaKey","shiftKey"].some(function(ye){return!!ue[ye]!==ae[ye]&&ue[ye]!==null})?!1:ue.key===(ae.which||ae.keyCode)}}]);function Y(re,ae){P(this,Y);var ue=L(this,(Y.__proto__||Object.getPrototypeOf(Y)).call(this,re,ae));return ue.bindings={},Object.keys(ue.options.bindings).forEach(function(ye){ye==="list autofill"&&re.scroll.whitelist!=null&&!re.scroll.whitelist.list||ue.options.bindings[ye]&&ue.addBinding(ue.options.bindings[ye])}),ue.addBinding({key:Y.keys.ENTER,shiftKey:null},F),ue.addBinding({key:Y.keys.ENTER,metaKey:null,ctrlKey:null,altKey:null},function(){}),/Firefox/i.test(navigator.userAgent)?(ue.addBinding({key:Y.keys.BACKSPACE},{collapsed:!0},M),ue.addBinding({key:Y.keys.DELETE},{collapsed:!0},z)):(ue.addBinding({key:Y.keys.BACKSPACE},{collapsed:!0,prefix:/^.?$/},M),ue.addBinding({key:Y.keys.DELETE},{collapsed:!0,suffix:/^.?$/},z)),ue.addBinding({key:Y.keys.BACKSPACE},{collapsed:!1},T),ue.addBinding({key:Y.keys.DELETE},{collapsed:!1},T),ue.addBinding({key:Y.keys.BACKSPACE,altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},M),ue.listen(),ue}return d(Y,[{key:"addBinding",value:function(ae){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ye=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ce=G(ae);if(ce==null||ce.key==null)return Z.warn("Attempted to add invalid keyboard binding",ce);typeof ue=="function"&&(ue={handler:ue}),typeof ye=="function"&&(ye={handler:ye}),ce=(0,u.default)(ce,ue,ye),this.bindings[ce.key]=this.bindings[ce.key]||[],this.bindings[ce.key].push(ce)}},{key:"listen",value:function(){var ae=this;this.quill.root.addEventListener("keydown",function(ue){if(!ue.defaultPrevented){var ye=ue.which||ue.keyCode,ce=(ae.bindings[ye]||[]).filter(function(ot){return Y.match(ue,ot)});if(ce.length!==0){var je=ae.quill.getSelection();if(!(je==null||!ae.quill.hasFocus())){var Me=ae.quill.getLine(je.index),ut=o(Me,2),jt=ut[0],ft=ut[1],X=ae.quill.getLeaf(je.index),Ce=o(X,2),xe=Ce[0],We=Ce[1],Be=je.length===0?[xe,We]:ae.quill.getLeaf(je.index+je.length),rt=o(Be,2),ht=rt[0],ge=rt[1],Je=xe instanceof C.default.Text?xe.value().slice(0,We):"",mt=ht instanceof C.default.Text?ht.value().slice(ge):"",de={collapsed:je.length===0,empty:je.length===0&&jt.length()<=1,format:ae.quill.getFormat(je),offset:ft,prefix:Je,suffix:mt},at=ce.some(function(ot){if(ot.collapsed!=null&&ot.collapsed!==de.collapsed||ot.empty!=null&&ot.empty!==de.empty||ot.offset!=null&&ot.offset!==de.offset)return!1;if(Array.isArray(ot.format)){if(ot.format.every(function(ke){return de.format[ke]==null}))return!1}else if(i(ot.format)==="object"&&!Object.keys(ot.format).every(function(ke){return ot.format[ke]===!0?de.format[ke]!=null:ot.format[ke]===!1?de.format[ke]==null:(0,h.default)(ot.format[ke],de.format[ke])}))return!1;return ot.prefix!=null&&!ot.prefix.test(de.prefix)||ot.suffix!=null&&!ot.suffix.test(de.suffix)?!1:ot.handler.call(ae,je,de)!==!0});at&&ue.preventDefault()}}}})}}]),Y})(q.default);W.keys={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},W.DEFAULTS={bindings:{bold:K("bold"),italic:K("italic"),underline:K("underline"),indent:{key:W.keys.TAB,format:["blockquote","indent","list"],handler:function(Y,re){if(re.collapsed&&re.offset!==0)return!0;this.quill.format("indent","+1",D.default.sources.USER)}},outdent:{key:W.keys.TAB,shiftKey:!0,format:["blockquote","indent","list"],handler:function(Y,re){if(re.collapsed&&re.offset!==0)return!0;this.quill.format("indent","-1",D.default.sources.USER)}},"outdent backspace":{key:W.keys.BACKSPACE,collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler:function(Y,re){re.format.indent!=null?this.quill.format("indent","-1",D.default.sources.USER):re.format.list!=null&&this.quill.format("list",!1,D.default.sources.USER)}},"indent code-block":I(!0),"outdent code-block":I(!1),"remove tab":{key:W.keys.TAB,shiftKey:!0,collapsed:!0,prefix:/\t$/,handler:function(Y){this.quill.deleteText(Y.index-1,1,D.default.sources.USER)}},tab:{key:W.keys.TAB,handler:function(Y){this.quill.history.cutoff();var re=new v.default().retain(Y.index).delete(Y.length).insert(" ");this.quill.updateContents(re,D.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(Y.index+1,D.default.sources.SILENT)}},"list empty enter":{key:W.keys.ENTER,collapsed:!0,format:["list"],empty:!0,handler:function(Y,re){this.quill.format("list",!1,D.default.sources.USER),re.format.indent&&this.quill.format("indent",!1,D.default.sources.USER)}},"checklist enter":{key:W.keys.ENTER,collapsed:!0,format:{list:"checked"},handler:function(Y){var re=this.quill.getLine(Y.index),ae=o(re,2),ue=ae[0],ye=ae[1],ce=(0,u.default)({},ue.formats(),{list:"checked"}),je=new v.default().retain(Y.index).insert(`
|
||
`,ce).retain(ue.length()-ye-1).retain(1,{list:"unchecked"});this.quill.updateContents(je,D.default.sources.USER),this.quill.setSelection(Y.index+1,D.default.sources.SILENT),this.quill.scrollIntoView()}},"header enter":{key:W.keys.ENTER,collapsed:!0,format:["header"],suffix:/^$/,handler:function(Y,re){var ae=this.quill.getLine(Y.index),ue=o(ae,2),ye=ue[0],ce=ue[1],je=new v.default().retain(Y.index).insert(`
|
||
`,re.format).retain(ye.length()-ce-1).retain(1,{header:null});this.quill.updateContents(je,D.default.sources.USER),this.quill.setSelection(Y.index+1,D.default.sources.SILENT),this.quill.scrollIntoView()}},"list autofill":{key:" ",collapsed:!0,format:{list:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler:function(Y,re){var ae=re.prefix.length,ue=this.quill.getLine(Y.index),ye=o(ue,2),ce=ye[0],je=ye[1];if(je>ae)return!0;var Me=void 0;switch(re.prefix.trim()){case"[]":case"[ ]":Me="unchecked";break;case"[x]":Me="checked";break;case"-":case"*":Me="bullet";break;default:Me="ordered"}this.quill.insertText(Y.index," ",D.default.sources.USER),this.quill.history.cutoff();var ut=new v.default().retain(Y.index-je).delete(ae+1).retain(ce.length()-2-je).retain(1,{list:Me});this.quill.updateContents(ut,D.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(Y.index-ae,D.default.sources.SILENT)}},"code exit":{key:W.keys.ENTER,collapsed:!0,format:["code-block"],prefix:/\n\n$/,suffix:/^\s+$/,handler:function(Y){var re=this.quill.getLine(Y.index),ae=o(re,2),ue=ae[0],ye=ae[1],ce=new v.default().retain(Y.index+ue.length()-ye-2).retain(1,{"code-block":null}).delete(1);this.quill.updateContents(ce,D.default.sources.USER)}},"embed left":U(W.keys.LEFT,!1),"embed left shift":U(W.keys.LEFT,!0),"embed right":U(W.keys.RIGHT,!1),"embed right shift":U(W.keys.RIGHT,!0)}};function U(V,Y){var re,ae=V===W.keys.LEFT?"prefix":"suffix";return re={key:V,shiftKey:Y,altKey:null},R(re,ae,/^$/),R(re,"handler",function(ye){var ce=ye.index;V===W.keys.RIGHT&&(ce+=ye.length+1);var je=this.quill.getLeaf(ce),Me=o(je,1),ut=Me[0];return ut instanceof C.default.Embed?(V===W.keys.LEFT?Y?this.quill.setSelection(ye.index-1,ye.length+1,D.default.sources.USER):this.quill.setSelection(ye.index-1,D.default.sources.USER):Y?this.quill.setSelection(ye.index,ye.length+1,D.default.sources.USER):this.quill.setSelection(ye.index+ye.length+1,D.default.sources.USER),!1):!0}),re}function M(V,Y){if(!(V.index===0||this.quill.getLength()<=1)){var re=this.quill.getLine(V.index),ae=o(re,1),ue=ae[0],ye={};if(Y.offset===0){var ce=this.quill.getLine(V.index-1),je=o(ce,1),Me=je[0];if(Me!=null&&Me.length()>1){var ut=ue.formats(),jt=this.quill.getFormat(V.index-1,1);ye=j.default.attributes.diff(ut,jt)||{}}}var ft=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(Y.prefix)?2:1;this.quill.deleteText(V.index-ft,ft,D.default.sources.USER),Object.keys(ye).length>0&&this.quill.formatLine(V.index-ft,ft,ye,D.default.sources.USER),this.quill.focus()}}function z(V,Y){var re=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(Y.suffix)?2:1;if(!(V.index>=this.quill.getLength()-re)){var ae={},ue=0,ye=this.quill.getLine(V.index),ce=o(ye,1),je=ce[0];if(Y.offset>=je.length()-1){var Me=this.quill.getLine(V.index+1),ut=o(Me,1),jt=ut[0];if(jt){var ft=je.formats(),X=this.quill.getFormat(V.index,1);ae=j.default.attributes.diff(ft,X)||{},ue=jt.length()}}this.quill.deleteText(V.index,re,D.default.sources.USER),Object.keys(ae).length>0&&this.quill.formatLine(V.index+ue-1,re,ae,D.default.sources.USER)}}function T(V){var Y=this.quill.getLines(V),re={};if(Y.length>1){var ae=Y[0].formats(),ue=Y[Y.length-1].formats();re=j.default.attributes.diff(ue,ae)||{}}this.quill.deleteText(V,D.default.sources.USER),Object.keys(re).length>0&&this.quill.formatLine(V.index,1,re,D.default.sources.USER),this.quill.setSelection(V.index,D.default.sources.SILENT),this.quill.focus()}function F(V,Y){var re=this;V.length>0&&this.quill.scroll.deleteAt(V.index,V.length);var ae=Object.keys(Y.format).reduce(function(ue,ye){return C.default.query(ye,C.default.Scope.BLOCK)&&!Array.isArray(Y.format[ye])&&(ue[ye]=Y.format[ye]),ue},{});this.quill.insertText(V.index,`
|
||
`,ae,D.default.sources.USER),this.quill.setSelection(V.index+1,D.default.sources.SILENT),this.quill.focus(),Object.keys(Y.format).forEach(function(ue){ae[ue]==null&&(Array.isArray(Y.format[ue])||ue!=="link"&&re.quill.format(ue,Y.format[ue],D.default.sources.USER))})}function I(V){return{key:W.keys.TAB,shiftKey:!V,format:{"code-block":!0},handler:function(re){var ae=C.default.query("code-block"),ue=re.index,ye=re.length,ce=this.quill.scroll.descendant(ae,ue),je=o(ce,2),Me=je[0],ut=je[1];if(Me!=null){var jt=this.quill.getIndex(Me),ft=Me.newlineIndex(ut,!0)+1,X=Me.newlineIndex(jt+ut+ye),Ce=Me.domNode.textContent.slice(ft,X).split(`
|
||
`);ut=0,Ce.forEach(function(xe,We){V?(Me.insertAt(ft+ut,ae.TAB),ut+=ae.TAB.length,We===0?ue+=ae.TAB.length:ye+=ae.TAB.length):xe.startsWith(ae.TAB)&&(Me.deleteAt(ft+ut,ae.TAB.length),ut-=ae.TAB.length,We===0?ue-=ae.TAB.length:ye-=ae.TAB.length),ut+=xe.length+1}),this.quill.update(D.default.sources.USER),this.quill.setSelection(ue,ye,D.default.sources.SILENT)}}}}function K(V){return{key:V[0].toUpperCase(),shortKey:!0,handler:function(re,ae){this.quill.format(V,!ae.format[V],D.default.sources.USER)}}}function G(V){if(typeof V=="string"||typeof V=="number")return G({key:V});if((typeof V>"u"?"undefined":i(V))==="object"&&(V=(0,f.default)(V,!1)),typeof V.key=="string")if(W.keys[V.key.toUpperCase()]!=null)V.key=W.keys[V.key.toUpperCase()];else if(V.key.length===1)V.key=V.key.toUpperCase().charCodeAt(0);else return null;return V.shortKey&&(V[Q]=V.shortKey,delete V.shortKey),V}r.default=W,r.SHORTKEY=Q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function j(b,C){var S=[],D=!0,_=!1,A=void 0;try{for(var E=b[Symbol.iterator](),q;!(D=(q=E.next()).done)&&(S.push(q.value),!(C&&S.length===C));D=!0);}catch(O){_=!0,A=O}finally{try{!D&&E.return&&E.return()}finally{if(_)throw A}}return S}return function(b,C){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return j(b,C);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var D=Object.getOwnPropertyDescriptor(b,C);if(D===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in D)return D.value;var A=D.get;return A===void 0?void 0:A.call(S)}},d=(function(){function j(b,C){for(var S=0;S<C.length;S++){var D=C[S];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(b,D.key,D)}}return function(b,C,S){return C&&j(b.prototype,C),S&&j(b,S),b}})(),m=a(0),f=x(m),p=a(7),h=x(p);function x(j){return j&&j.__esModule?j:{default:j}}function u(j,b){if(!(j instanceof b))throw new TypeError("Cannot call a class as a function")}function N(j,b){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:j}function v(j,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);j.prototype=Object.create(b&&b.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(j,b):j.__proto__=b)}var w=(function(j){v(b,j),d(b,null,[{key:"value",value:function(){}}]);function b(C,S){u(this,b);var D=N(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,C));return D.selection=S,D.textNode=document.createTextNode(b.CONTENTS),D.domNode.appendChild(D.textNode),D._length=0,D}return d(b,[{key:"detach",value:function(){this.parent!=null&&this.parent.removeChild(this)}},{key:"format",value:function(S,D){if(this._length!==0)return o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"format",this).call(this,S,D);for(var _=this,A=0;_!=null&&_.statics.scope!==f.default.Scope.BLOCK_BLOT;)A+=_.offset(_.parent),_=_.parent;_!=null&&(this._length=b.CONTENTS.length,_.optimize(),_.formatAt(A,b.CONTENTS.length,S,D),this._length=0)}},{key:"index",value:function(S,D){return S===this.textNode?0:o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"index",this).call(this,S,D)}},{key:"length",value:function(){return this._length}},{key:"position",value:function(){return[this.textNode,this.textNode.data.length]}},{key:"remove",value:function(){o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"remove",this).call(this),this.parent=null}},{key:"restore",value:function(){if(!(this.selection.composing||this.parent==null)){var S=this.textNode,D=this.selection.getNativeRange(),_=void 0,A=void 0,E=void 0;if(D!=null&&D.start.node===S&&D.end.node===S){var q=[S,D.start.offset,D.end.offset];_=q[0],A=q[1],E=q[2]}for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);if(this.textNode.data!==b.CONTENTS){var O=this.textNode.data.split(b.CONTENTS).join("");this.next instanceof h.default?(_=this.next.domNode,this.next.insertAt(0,O),this.textNode.data=b.CONTENTS):(this.textNode.data=O,this.parent.insertBefore(f.default.create(this.textNode),this),this.textNode=document.createTextNode(b.CONTENTS),this.domNode.appendChild(this.textNode))}if(this.remove(),A!=null){var R=[A,E].map(function(L){return Math.max(0,Math.min(_.data.length,L-1))}),P=i(R,2);return A=P[0],E=P[1],{startNode:_,startOffset:A,endNode:_,endOffset:E}}}}},{key:"update",value:function(S,D){var _=this;if(S.some(function(E){return E.type==="characterData"&&E.target===_.textNode})){var A=this.restore();A&&(D.range=A)}}},{key:"value",value:function(){return""}}]),b})(f.default.Embed);w.blotName="cursor",w.className="ql-cursor",w.tagName="span",w.CONTENTS="\uFEFF",r.default=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=f(i),d=a(4),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return v})(o.default.Container);u.allowedChildren=[m.default,d.BlockEmbed,u],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.ColorStyle=r.ColorClass=r.ColorAttributor=void 0;var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:w(D,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(0),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function p(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function h(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function x(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var u=(function(w){x(j,w);function j(){return p(this,j),h(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"value",value:function(C){var S=o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"value",this).call(this,C);return S.startsWith("rgb(")?(S=S.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),"#"+S.split(",").map(function(D){return("00"+parseInt(D).toString(16)).slice(-2)}).join("")):S}}]),j})(m.default.Attributor.Style),N=new m.default.Attributor.Class("color","ql-color",{scope:m.default.Scope.INLINE}),v=new u("color","color",{scope:m.default.Scope.INLINE});r.ColorAttributor=u,r.ColorClass=N,r.ColorStyle=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.sanitize=r.default=void 0;var i=(function(){function v(w,j){for(var b=0;b<j.length;b++){var C=j[b];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}return function(w,j,b){return j&&v(w.prototype,j),b&&v(w,b),w}})(),o=function v(w,j,b){w===null&&(w=Function.prototype);var C=Object.getOwnPropertyDescriptor(w,j);if(C===void 0){var S=Object.getPrototypeOf(w);return S===null?void 0:v(S,j,b)}else{if("value"in C)return C.value;var D=C.get;return D===void 0?void 0:D.call(b)}},d=a(6),m=f(d);function f(v){return v&&v.__esModule?v:{default:v}}function p(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}function h(v,w){if(!v)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:v}function x(v,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);v.prototype=Object.create(w&&w.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(v,w):v.__proto__=w)}var u=(function(v){x(w,v);function w(){return p(this,w),h(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}return i(w,[{key:"format",value:function(b,C){if(b!==this.statics.blotName||!C)return o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"format",this).call(this,b,C);C=this.constructor.sanitize(C),this.domNode.setAttribute("href",C)}}],[{key:"create",value:function(b){var C=o(w.__proto__||Object.getPrototypeOf(w),"create",this).call(this,b);return b=this.sanitize(b),C.setAttribute("href",b),C.setAttribute("rel","noopener noreferrer"),C.setAttribute("target","_blank"),C}},{key:"formats",value:function(b){return b.getAttribute("href")}},{key:"sanitize",value:function(b){return N(b,this.PROTOCOL_WHITELIST)?b:this.SANITIZED_URL}}]),w})(m.default);u.blotName="link",u.tagName="A",u.SANITIZED_URL="about:blank",u.PROTOCOL_WHITELIST=["http","https","mailto","tel"];function N(v,w){var j=document.createElement("a");j.href=v;var b=j.href.slice(0,j.href.indexOf(":"));return w.indexOf(b)>-1}r.default=u,r.sanitize=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},o=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),d=a(23),m=h(d),f=a(107),p=h(f);function h(w){return w&&w.__esModule?w:{default:w}}function x(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}var u=0;function N(w,j){w.setAttribute(j,w.getAttribute(j)!=="true")}var v=(function(){function w(j){var b=this;x(this,w),this.select=j,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",function(){b.togglePicker()}),this.label.addEventListener("keydown",function(C){switch(C.keyCode){case m.default.keys.ENTER:b.togglePicker();break;case m.default.keys.ESCAPE:b.escape(),C.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}return o(w,[{key:"togglePicker",value:function(){this.container.classList.toggle("ql-expanded"),N(this.label,"aria-expanded"),N(this.options,"aria-hidden")}},{key:"buildItem",value:function(b){var C=this,S=document.createElement("span");return S.tabIndex="0",S.setAttribute("role","button"),S.classList.add("ql-picker-item"),b.hasAttribute("value")&&S.setAttribute("data-value",b.getAttribute("value")),b.textContent&&S.setAttribute("data-label",b.textContent),S.addEventListener("click",function(){C.selectItem(S,!0)}),S.addEventListener("keydown",function(D){switch(D.keyCode){case m.default.keys.ENTER:C.selectItem(S,!0),D.preventDefault();break;case m.default.keys.ESCAPE:C.escape(),D.preventDefault();break}}),S}},{key:"buildLabel",value:function(){var b=document.createElement("span");return b.classList.add("ql-picker-label"),b.innerHTML=p.default,b.tabIndex="0",b.setAttribute("role","button"),b.setAttribute("aria-expanded","false"),this.container.appendChild(b),b}},{key:"buildOptions",value:function(){var b=this,C=document.createElement("span");C.classList.add("ql-picker-options"),C.setAttribute("aria-hidden","true"),C.tabIndex="-1",C.id="ql-picker-options-"+u,u+=1,this.label.setAttribute("aria-controls",C.id),this.options=C,[].slice.call(this.select.options).forEach(function(S){var D=b.buildItem(S);C.appendChild(D),S.selected===!0&&b.selectItem(D)}),this.container.appendChild(C)}},{key:"buildPicker",value:function(){var b=this;[].slice.call(this.select.attributes).forEach(function(C){b.container.setAttribute(C.name,C.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}},{key:"escape",value:function(){var b=this;this.close(),setTimeout(function(){return b.label.focus()},1)}},{key:"close",value:function(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}},{key:"selectItem",value:function(b){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,S=this.container.querySelector(".ql-selected");if(b!==S&&(S!=null&&S.classList.remove("ql-selected"),b!=null&&(b.classList.add("ql-selected"),this.select.selectedIndex=[].indexOf.call(b.parentNode.children,b),b.hasAttribute("data-value")?this.label.setAttribute("data-value",b.getAttribute("data-value")):this.label.removeAttribute("data-value"),b.hasAttribute("data-label")?this.label.setAttribute("data-label",b.getAttribute("data-label")):this.label.removeAttribute("data-label"),C))){if(typeof Event=="function")this.select.dispatchEvent(new Event("change"));else if((typeof Event>"u"?"undefined":i(Event))==="object"){var D=document.createEvent("Event");D.initEvent("change",!0,!0),this.select.dispatchEvent(D)}this.close()}}},{key:"update",value:function(){var b=void 0;if(this.select.selectedIndex>-1){var C=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];b=this.select.options[this.select.selectedIndex],this.selectItem(C)}else this.selectItem(null);var S=b!=null&&b!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",S)}}]),w})();r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(0),o=Z(i),d=a(5),m=Z(d),f=a(4),p=Z(f),h=a(16),x=Z(h),u=a(25),N=Z(u),v=a(24),w=Z(v),j=a(35),b=Z(j),C=a(6),S=Z(C),D=a(22),_=Z(D),A=a(7),E=Z(A),q=a(55),O=Z(q),R=a(42),P=Z(R),L=a(23),$=Z(L);function Z(Q){return Q&&Q.__esModule?Q:{default:Q}}m.default.register({"blots/block":p.default,"blots/block/embed":f.BlockEmbed,"blots/break":x.default,"blots/container":N.default,"blots/cursor":w.default,"blots/embed":b.default,"blots/inline":S.default,"blots/scroll":_.default,"blots/text":E.default,"modules/clipboard":O.default,"modules/history":P.default,"modules/keyboard":$.default}),o.default.register(p.default,x.default,w.default,S.default,_.default,E.default),r.default=m.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(1),o=(function(){function d(m){this.domNode=m,this.domNode[i.DATA_KEY]={blot:this}}return Object.defineProperty(d.prototype,"statics",{get:function(){return this.constructor},enumerable:!0,configurable:!0}),d.create=function(m){if(this.tagName==null)throw new i.ParchmentError("Blot definition missing tagName");var f;return Array.isArray(this.tagName)?(typeof m=="string"&&(m=m.toUpperCase(),parseInt(m).toString()===m&&(m=parseInt(m))),typeof m=="number"?f=document.createElement(this.tagName[m-1]):this.tagName.indexOf(m)>-1?f=document.createElement(m):f=document.createElement(this.tagName[0])):f=document.createElement(this.tagName),this.className&&f.classList.add(this.className),f},d.prototype.attach=function(){this.parent!=null&&(this.scroll=this.parent.scroll)},d.prototype.clone=function(){var m=this.domNode.cloneNode(!1);return i.create(m)},d.prototype.detach=function(){this.parent!=null&&this.parent.removeChild(this),delete this.domNode[i.DATA_KEY]},d.prototype.deleteAt=function(m,f){var p=this.isolate(m,f);p.remove()},d.prototype.formatAt=function(m,f,p,h){var x=this.isolate(m,f);if(i.query(p,i.Scope.BLOT)!=null&&h)x.wrap(p,h);else if(i.query(p,i.Scope.ATTRIBUTE)!=null){var u=i.create(this.statics.scope);x.wrap(u),u.format(p,h)}},d.prototype.insertAt=function(m,f,p){var h=p==null?i.create("text",f):i.create(f,p),x=this.split(m);this.parent.insertBefore(h,x)},d.prototype.insertInto=function(m,f){f===void 0&&(f=null),this.parent!=null&&this.parent.children.remove(this);var p=null;m.children.insertBefore(this,f),f!=null&&(p=f.domNode),(this.domNode.parentNode!=m.domNode||this.domNode.nextSibling!=p)&&m.domNode.insertBefore(this.domNode,p),this.parent=m,this.attach()},d.prototype.isolate=function(m,f){var p=this.split(m);return p.split(f),p},d.prototype.length=function(){return 1},d.prototype.offset=function(m){return m===void 0&&(m=this.parent),this.parent==null||this==m?0:this.parent.children.offset(this)+this.parent.offset(m)},d.prototype.optimize=function(m){this.domNode[i.DATA_KEY]!=null&&delete this.domNode[i.DATA_KEY].mutations},d.prototype.remove=function(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()},d.prototype.replace=function(m){m.parent!=null&&(m.parent.insertBefore(this,m.next),m.remove())},d.prototype.replaceWith=function(m,f){var p=typeof m=="string"?i.create(m,f):m;return p.replace(this),p},d.prototype.split=function(m,f){return m===0?this:this.next},d.prototype.update=function(m,f){},d.prototype.wrap=function(m,f){var p=typeof m=="string"?i.create(m,f):m;return this.parent!=null&&this.parent.insertBefore(p,this.next),p.appendChild(this),p},d.blotName="abstract",d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(12),o=a(32),d=a(33),m=a(1),f=(function(){function p(h){this.attributes={},this.domNode=h,this.build()}return p.prototype.attribute=function(h,x){x?h.add(this.domNode,x)&&(h.value(this.domNode)!=null?this.attributes[h.attrName]=h:delete this.attributes[h.attrName]):(h.remove(this.domNode),delete this.attributes[h.attrName])},p.prototype.build=function(){var h=this;this.attributes={};var x=i.default.keys(this.domNode),u=o.default.keys(this.domNode),N=d.default.keys(this.domNode);x.concat(u).concat(N).forEach(function(v){var w=m.query(v,m.Scope.ATTRIBUTE);w instanceof i.default&&(h.attributes[w.attrName]=w)})},p.prototype.copy=function(h){var x=this;Object.keys(this.attributes).forEach(function(u){var N=x.attributes[u].value(x.domNode);h.format(u,N)})},p.prototype.move=function(h){var x=this;this.copy(h),Object.keys(this.attributes).forEach(function(u){x.attributes[u].remove(x.domNode)}),this.attributes={}},p.prototype.values=function(){var h=this;return Object.keys(this.attributes).reduce(function(x,u){return x[u]=h.attributes[u].value(h.domNode),x},{})},p})();r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f,p){var h=f.getAttribute("class")||"";return h.split(/\s+/).filter(function(x){return x.indexOf(p+"-")===0})}var m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.keys=function(h){return(h.getAttribute("class")||"").split(/\s+/).map(function(x){return x.split("-").slice(0,-1).join("-")})},p.prototype.add=function(h,x){return this.canAdd(h,x)?(this.remove(h),h.classList.add(this.keyName+"-"+x),!0):!1},p.prototype.remove=function(h){var x=d(h,this.keyName);x.forEach(function(u){h.classList.remove(u)}),h.classList.length===0&&h.removeAttribute("class")},p.prototype.value=function(h){var x=d(h,this.keyName)[0]||"",u=x.slice(this.keyName.length+1);return this.canAdd(h,u)?u:""},p})(o.default);r.default=m}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f){var p=f.split("-"),h=p.slice(1).map(function(x){return x[0].toUpperCase()+x.slice(1)}).join("");return p[0]+h}var m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.keys=function(h){return(h.getAttribute("style")||"").split(";").map(function(x){var u=x.split(":");return u[0].trim()})},p.prototype.add=function(h,x){return this.canAdd(h,x)?(h.style[d(this.keyName)]=x,!0):!1},p.prototype.remove=function(h){h.style[d(this.keyName)]="",h.getAttribute("style")||h.removeAttribute("style")},p.prototype.value=function(h){var x=h.style[d(this.keyName)];return this.canAdd(h,x)?x:""},p})(o.default);r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function m(f,p){for(var h=0;h<p.length;h++){var x=p[h];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(f,x.key,x)}}return function(f,p,h){return p&&m(f.prototype,p),h&&m(f,h),f}})();function o(m,f){if(!(m instanceof f))throw new TypeError("Cannot call a class as a function")}var d=(function(){function m(f,p){o(this,m),this.quill=f,this.options=p,this.modules={}}return i(m,[{key:"init",value:function(){var p=this;Object.keys(this.options.modules).forEach(function(h){p.modules[h]==null&&p.addModule(h)})}},{key:"addModule",value:function(p){var h=this.quill.constructor.import("modules/"+p);return this.modules[p]=new h(this.quill,this.options.modules[p]||{}),this.modules[p]}}]),m})();d.DEFAULTS={modules:{}},d.themes={default:d},r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function j(b,C){for(var S=0;S<C.length;S++){var D=C[S];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(b,D.key,D)}}return function(b,C,S){return C&&j(b.prototype,C),S&&j(b,S),b}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var D=Object.getOwnPropertyDescriptor(b,C);if(D===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in D)return D.value;var A=D.get;return A===void 0?void 0:A.call(S)}},d=a(0),m=h(d),f=a(7),p=h(f);function h(j){return j&&j.__esModule?j:{default:j}}function x(j,b){if(!(j instanceof b))throw new TypeError("Cannot call a class as a function")}function u(j,b){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:j}function N(j,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);j.prototype=Object.create(b&&b.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(j,b):j.__proto__=b)}var v="\uFEFF",w=(function(j){N(b,j);function b(C){x(this,b);var S=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,C));return S.contentNode=document.createElement("span"),S.contentNode.setAttribute("contenteditable",!1),[].slice.call(S.domNode.childNodes).forEach(function(D){S.contentNode.appendChild(D)}),S.leftGuard=document.createTextNode(v),S.rightGuard=document.createTextNode(v),S.domNode.appendChild(S.leftGuard),S.domNode.appendChild(S.contentNode),S.domNode.appendChild(S.rightGuard),S}return i(b,[{key:"index",value:function(S,D){return S===this.leftGuard?0:S===this.rightGuard?1:o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"index",this).call(this,S,D)}},{key:"restore",value:function(S){var D=void 0,_=void 0,A=S.data.split(v).join("");if(S===this.leftGuard)if(this.prev instanceof p.default){var E=this.prev.length();this.prev.insertAt(E,A),D={startNode:this.prev.domNode,startOffset:E+A.length}}else _=document.createTextNode(A),this.parent.insertBefore(m.default.create(_),this),D={startNode:_,startOffset:A.length};else S===this.rightGuard&&(this.next instanceof p.default?(this.next.insertAt(0,A),D={startNode:this.next.domNode,startOffset:A.length}):(_=document.createTextNode(A),this.parent.insertBefore(m.default.create(_),this.next),D={startNode:_,startOffset:A.length}));return S.data=v,D}},{key:"update",value:function(S,D){var _=this;S.forEach(function(A){if(A.type==="characterData"&&(A.target===_.leftGuard||A.target===_.rightGuard)){var E=_.restore(A.target);E&&(D.range=E)}})}}]),b})(m.default.Embed);r.default=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.AlignStyle=r.AlignClass=r.AlignAttribute=void 0;var i=a(0),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}var m={scope:o.default.Scope.BLOCK,whitelist:["right","center","justify"]},f=new o.default.Attributor.Attribute("align","align",m),p=new o.default.Attributor.Class("align","ql-align",m),h=new o.default.Attributor.Style("align","text-align",m);r.AlignAttribute=f,r.AlignClass=p,r.AlignStyle=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.BackgroundStyle=r.BackgroundClass=void 0;var i=a(0),o=m(i),d=a(26);function m(h){return h&&h.__esModule?h:{default:h}}var f=new o.default.Attributor.Class("background","ql-bg",{scope:o.default.Scope.INLINE}),p=new d.ColorAttributor("background","background-color",{scope:o.default.Scope.INLINE});r.BackgroundClass=f,r.BackgroundStyle=p}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.DirectionStyle=r.DirectionClass=r.DirectionAttribute=void 0;var i=a(0),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}var m={scope:o.default.Scope.BLOCK,whitelist:["rtl"]},f=new o.default.Attributor.Attribute("direction","dir",m),p=new o.default.Attributor.Class("direction","ql-direction",m),h=new o.default.Attributor.Style("direction","direction",m);r.DirectionAttribute=f,r.DirectionClass=p,r.DirectionStyle=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.FontClass=r.FontStyle=void 0;var i=(function(){function j(b,C){for(var S=0;S<C.length;S++){var D=C[S];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(b,D.key,D)}}return function(b,C,S){return C&&j(b.prototype,C),S&&j(b,S),b}})(),o=function j(b,C,S){b===null&&(b=Function.prototype);var D=Object.getOwnPropertyDescriptor(b,C);if(D===void 0){var _=Object.getPrototypeOf(b);return _===null?void 0:j(_,C,S)}else{if("value"in D)return D.value;var A=D.get;return A===void 0?void 0:A.call(S)}},d=a(0),m=f(d);function f(j){return j&&j.__esModule?j:{default:j}}function p(j,b){if(!(j instanceof b))throw new TypeError("Cannot call a class as a function")}function h(j,b){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:j}function x(j,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);j.prototype=Object.create(b&&b.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(j,b):j.__proto__=b)}var u={scope:m.default.Scope.INLINE,whitelist:["serif","monospace"]},N=new m.default.Attributor.Class("font","ql-font",u),v=(function(j){x(b,j);function b(){return p(this,b),h(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return i(b,[{key:"value",value:function(S){return o(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"value",this).call(this,S).replace(/["']/g,"")}}]),b})(m.default.Attributor.Style),w=new v("font","font-family",u);r.FontStyle=w,r.FontClass=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SizeStyle=r.SizeClass=void 0;var i=a(0),o=d(i);function d(p){return p&&p.__esModule?p:{default:p}}var m=new o.default.Attributor.Class("size","ql-size",{scope:o.default.Scope.INLINE,whitelist:["small","large","huge"]}),f=new o.default.Attributor.Style("size","font-size",{scope:o.default.Scope.INLINE,whitelist:["10px","18px","32px"]});r.SizeClass=m,r.SizeStyle=f}),(function(n,r,a){n.exports={align:{"":a(76),center:a(77),right:a(78),justify:a(79)},background:a(80),blockquote:a(81),bold:a(82),clean:a(83),code:a(58),"code-block":a(58),color:a(84),direction:{"":a(85),rtl:a(86)},float:{center:a(87),full:a(88),left:a(89),right:a(90)},formula:a(91),header:{1:a(92),2:a(93)},italic:a(94),image:a(95),indent:{"+1":a(96),"-1":a(97)},link:a(98),list:{ordered:a(99),bullet:a(100),check:a(101)},script:{sub:a(102),super:a(103)},strike:a(104),underline:a(105),video:a(106)}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.getLastChangeIndex=r.default=void 0;var i=(function(){function C(S,D){for(var _=0;_<D.length;_++){var A=D[_];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(S,A.key,A)}}return function(S,D,_){return D&&C(S.prototype,D),_&&C(S,_),S}})(),o=a(0),d=x(o),m=a(5),f=x(m),p=a(9),h=x(p);function x(C){return C&&C.__esModule?C:{default:C}}function u(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}function N(C,S){if(!C)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:C}function v(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(C,S):C.__proto__=S)}var w=(function(C){v(S,C);function S(D,_){u(this,S);var A=N(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,D,_));return A.lastRecorded=0,A.ignoreChange=!1,A.clear(),A.quill.on(f.default.events.EDITOR_CHANGE,function(E,q,O,R){E!==f.default.events.TEXT_CHANGE||A.ignoreChange||(!A.options.userOnly||R===f.default.sources.USER?A.record(q,O):A.transform(q))}),A.quill.keyboard.addBinding({key:"Z",shortKey:!0},A.undo.bind(A)),A.quill.keyboard.addBinding({key:"Z",shortKey:!0,shiftKey:!0},A.redo.bind(A)),/Win/i.test(navigator.platform)&&A.quill.keyboard.addBinding({key:"Y",shortKey:!0},A.redo.bind(A)),A}return i(S,[{key:"change",value:function(_,A){if(this.stack[_].length!==0){var E=this.stack[_].pop();this.stack[A].push(E),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(E[_],f.default.sources.USER),this.ignoreChange=!1;var q=b(E[_]);this.quill.setSelection(q)}}},{key:"clear",value:function(){this.stack={undo:[],redo:[]}}},{key:"cutoff",value:function(){this.lastRecorded=0}},{key:"record",value:function(_,A){if(_.ops.length!==0){this.stack.redo=[];var E=this.quill.getContents().diff(A),q=Date.now();if(this.lastRecorded+this.options.delay>q&&this.stack.undo.length>0){var O=this.stack.undo.pop();E=E.compose(O.undo),_=O.redo.compose(_)}else this.lastRecorded=q;this.stack.undo.push({redo:_,undo:E}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift()}}},{key:"redo",value:function(){this.change("redo","undo")}},{key:"transform",value:function(_){this.stack.undo.forEach(function(A){A.undo=_.transform(A.undo,!0),A.redo=_.transform(A.redo,!0)}),this.stack.redo.forEach(function(A){A.undo=_.transform(A.undo,!0),A.redo=_.transform(A.redo,!0)})}},{key:"undo",value:function(){this.change("undo","redo")}}]),S})(h.default);w.DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};function j(C){var S=C.ops[C.ops.length-1];return S==null?!1:S.insert!=null?typeof S.insert=="string"&&S.insert.endsWith(`
|
||
`):S.attributes!=null?Object.keys(S.attributes).some(function(D){return d.default.query(D,d.default.Scope.BLOCK)!=null}):!1}function b(C){var S=C.reduce(function(_,A){return _+=A.delete||0,_},0),D=C.length()-S;return j(C)&&(D-=1),D}r.default=w,r.getLastChangeIndex=b}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BaseTooltip=void 0;var i=(function(){function F(I,K){for(var G=0;G<K.length;G++){var V=K[G];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(I,V.key,V)}}return function(I,K,G){return K&&F(I.prototype,K),G&&F(I,G),I}})(),o=function F(I,K,G){I===null&&(I=Function.prototype);var V=Object.getOwnPropertyDescriptor(I,K);if(V===void 0){var Y=Object.getPrototypeOf(I);return Y===null?void 0:F(Y,K,G)}else{if("value"in V)return V.value;var re=V.get;return re===void 0?void 0:re.call(G)}},d=a(3),m=q(d),f=a(2),p=q(f),h=a(8),x=q(h),u=a(23),N=q(u),v=a(34),w=q(v),j=a(59),b=q(j),C=a(60),S=q(C),D=a(28),_=q(D),A=a(61),E=q(A);function q(F){return F&&F.__esModule?F:{default:F}}function O(F,I){if(!(F instanceof I))throw new TypeError("Cannot call a class as a function")}function R(F,I){if(!F)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return I&&(typeof I=="object"||typeof I=="function")?I:F}function P(F,I){if(typeof I!="function"&&I!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof I);F.prototype=Object.create(I&&I.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),I&&(Object.setPrototypeOf?Object.setPrototypeOf(F,I):F.__proto__=I)}var L=[!1,"center","right","justify"],$=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],Z=[!1,"serif","monospace"],Q=["1","2","3",!1],W=["small",!1,"large","huge"],U=(function(F){P(I,F);function I(K,G){O(this,I);var V=R(this,(I.__proto__||Object.getPrototypeOf(I)).call(this,K,G)),Y=function re(ae){if(!document.body.contains(K.root))return document.body.removeEventListener("click",re);V.tooltip!=null&&!V.tooltip.root.contains(ae.target)&&document.activeElement!==V.tooltip.textbox&&!V.quill.hasFocus()&&V.tooltip.hide(),V.pickers!=null&&V.pickers.forEach(function(ue){ue.container.contains(ae.target)||ue.close()})};return K.emitter.listenDOM("click",document.body,Y),V}return i(I,[{key:"addModule",value:function(G){var V=o(I.prototype.__proto__||Object.getPrototypeOf(I.prototype),"addModule",this).call(this,G);return G==="toolbar"&&this.extendToolbar(V),V}},{key:"buildButtons",value:function(G,V){G.forEach(function(Y){var re=Y.getAttribute("class")||"";re.split(/\s+/).forEach(function(ae){if(ae.startsWith("ql-")&&(ae=ae.slice(3),V[ae]!=null))if(ae==="direction")Y.innerHTML=V[ae][""]+V[ae].rtl;else if(typeof V[ae]=="string")Y.innerHTML=V[ae];else{var ue=Y.value||"";ue!=null&&V[ae][ue]&&(Y.innerHTML=V[ae][ue])}})})}},{key:"buildPickers",value:function(G,V){var Y=this;this.pickers=G.map(function(ae){if(ae.classList.contains("ql-align"))return ae.querySelector("option")==null&&T(ae,L),new S.default(ae,V.align);if(ae.classList.contains("ql-background")||ae.classList.contains("ql-color")){var ue=ae.classList.contains("ql-background")?"background":"color";return ae.querySelector("option")==null&&T(ae,$,ue==="background"?"#ffffff":"#000000"),new b.default(ae,V[ue])}else return ae.querySelector("option")==null&&(ae.classList.contains("ql-font")?T(ae,Z):ae.classList.contains("ql-header")?T(ae,Q):ae.classList.contains("ql-size")&&T(ae,W)),new _.default(ae)});var re=function(){Y.pickers.forEach(function(ue){ue.update()})};this.quill.on(x.default.events.EDITOR_CHANGE,re)}}]),I})(w.default);U.DEFAULTS=(0,m.default)(!0,{},w.default.DEFAULTS,{modules:{toolbar:{handlers:{formula:function(){this.quill.theme.tooltip.edit("formula")},image:function(){var I=this,K=this.container.querySelector("input.ql-image[type=file]");K==null&&(K=document.createElement("input"),K.setAttribute("type","file"),K.setAttribute("accept","image/png, image/gif, image/jpeg, image/bmp, image/x-icon"),K.classList.add("ql-image"),K.addEventListener("change",function(){if(K.files!=null&&K.files[0]!=null){var G=new FileReader;G.onload=function(V){var Y=I.quill.getSelection(!0);I.quill.updateContents(new p.default().retain(Y.index).delete(Y.length).insert({image:V.target.result}),x.default.sources.USER),I.quill.setSelection(Y.index+1,x.default.sources.SILENT),K.value=""},G.readAsDataURL(K.files[0])}}),this.container.appendChild(K)),K.click()},video:function(){this.quill.theme.tooltip.edit("video")}}}}});var M=(function(F){P(I,F);function I(K,G){O(this,I);var V=R(this,(I.__proto__||Object.getPrototypeOf(I)).call(this,K,G));return V.textbox=V.root.querySelector('input[type="text"]'),V.listen(),V}return i(I,[{key:"listen",value:function(){var G=this;this.textbox.addEventListener("keydown",function(V){N.default.match(V,"enter")?(G.save(),V.preventDefault()):N.default.match(V,"escape")&&(G.cancel(),V.preventDefault())})}},{key:"cancel",value:function(){this.hide()}},{key:"edit",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),V!=null?this.textbox.value=V:G!==this.root.getAttribute("data-mode")&&(this.textbox.value=""),this.position(this.quill.getBounds(this.quill.selection.savedRange)),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute("data-"+G)||""),this.root.setAttribute("data-mode",G)}},{key:"restoreFocus",value:function(){var G=this.quill.scrollingContainer.scrollTop;this.quill.focus(),this.quill.scrollingContainer.scrollTop=G}},{key:"save",value:function(){var G=this.textbox.value;switch(this.root.getAttribute("data-mode")){case"link":{var V=this.quill.root.scrollTop;this.linkRange?(this.quill.formatText(this.linkRange,"link",G,x.default.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",G,x.default.sources.USER)),this.quill.root.scrollTop=V;break}case"video":G=z(G);case"formula":{if(!G)break;var Y=this.quill.getSelection(!0);if(Y!=null){var re=Y.index+Y.length;this.quill.insertEmbed(re,this.root.getAttribute("data-mode"),G,x.default.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(re+1," ",x.default.sources.USER),this.quill.setSelection(re+2,x.default.sources.USER)}break}}this.textbox.value="",this.hide()}}]),I})(E.default);function z(F){var I=F.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||F.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return I?(I[1]||"https")+"://www.youtube.com/embed/"+I[2]+"?showinfo=0":(I=F.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?(I[1]||"https")+"://player.vimeo.com/video/"+I[2]+"/":F}function T(F,I){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;I.forEach(function(G){var V=document.createElement("option");G===K?V.setAttribute("selected","selected"):V.setAttribute("value",G),F.appendChild(V)})}r.BaseTooltip=M,r.default=U}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function o(){this.head=this.tail=null,this.length=0}return o.prototype.append=function(){for(var d=[],m=0;m<arguments.length;m++)d[m]=arguments[m];this.insertBefore(d[0],null),d.length>1&&this.append.apply(this,d.slice(1))},o.prototype.contains=function(d){for(var m,f=this.iterator();m=f();)if(m===d)return!0;return!1},o.prototype.insertBefore=function(d,m){d&&(d.next=m,m!=null?(d.prev=m.prev,m.prev!=null&&(m.prev.next=d),m.prev=d,m===this.head&&(this.head=d)):this.tail!=null?(this.tail.next=d,d.prev=this.tail,this.tail=d):(d.prev=null,this.head=this.tail=d),this.length+=1)},o.prototype.offset=function(d){for(var m=0,f=this.head;f!=null;){if(f===d)return m;m+=f.length(),f=f.next}return-1},o.prototype.remove=function(d){this.contains(d)&&(d.prev!=null&&(d.prev.next=d.next),d.next!=null&&(d.next.prev=d.prev),d===this.head&&(this.head=d.next),d===this.tail&&(this.tail=d.prev),this.length-=1)},o.prototype.iterator=function(d){return d===void 0&&(d=this.head),function(){var m=d;return d!=null&&(d=d.next),m}},o.prototype.find=function(d,m){m===void 0&&(m=!1);for(var f,p=this.iterator();f=p();){var h=f.length();if(d<h||m&&d===h&&(f.next==null||f.next.length()!==0))return[f,d];d-=h}return[null,0]},o.prototype.forEach=function(d){for(var m,f=this.iterator();m=f();)d(m)},o.prototype.forEachAt=function(d,m,f){if(!(m<=0))for(var p=this.find(d),h=p[0],x=p[1],u,N=d-x,v=this.iterator(h);(u=v())&&N<d+m;){var w=u.length();d>N?f(u,d-N,Math.min(m,N+w-d)):f(u,0,Math.min(w,d+m-N)),N+=w}},o.prototype.map=function(d){return this.reduce(function(m,f){return m.push(d(f)),m},[])},o.prototype.reduce=function(d,m){for(var f,p=this.iterator();f=p();)m=d(m,f);return m},o})();r.default=i}),(function(n,r,a){var i=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,u){x.__proto__=u}||function(x,u){for(var N in u)u.hasOwnProperty(N)&&(x[N]=u[N])};return function(x,u){h(x,u);function N(){this.constructor=x}x.prototype=u===null?Object.create(u):(N.prototype=u.prototype,new N)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(17),d=a(1),m={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},f=100,p=(function(h){i(x,h);function x(u){var N=h.call(this,u)||this;return N.scroll=N,N.observer=new MutationObserver(function(v){N.update(v)}),N.observer.observe(N.domNode,m),N.attach(),N}return x.prototype.detach=function(){h.prototype.detach.call(this),this.observer.disconnect()},x.prototype.deleteAt=function(u,N){this.update(),u===0&&N===this.length()?this.children.forEach(function(v){v.remove()}):h.prototype.deleteAt.call(this,u,N)},x.prototype.formatAt=function(u,N,v,w){this.update(),h.prototype.formatAt.call(this,u,N,v,w)},x.prototype.insertAt=function(u,N,v){this.update(),h.prototype.insertAt.call(this,u,N,v)},x.prototype.optimize=function(u,N){var v=this;u===void 0&&(u=[]),N===void 0&&(N={}),h.prototype.optimize.call(this,N);for(var w=[].slice.call(this.observer.takeRecords());w.length>0;)u.push(w.pop());for(var j=function(D,_){_===void 0&&(_=!0),!(D==null||D===v)&&D.domNode.parentNode!=null&&(D.domNode[d.DATA_KEY].mutations==null&&(D.domNode[d.DATA_KEY].mutations=[]),_&&j(D.parent))},b=function(D){D.domNode[d.DATA_KEY]==null||D.domNode[d.DATA_KEY].mutations==null||(D instanceof o.default&&D.children.forEach(b),D.optimize(N))},C=u,S=0;C.length>0;S+=1){if(S>=f)throw new Error("[Parchment] Maximum optimize iterations reached");for(C.forEach(function(D){var _=d.find(D.target,!0);_!=null&&(_.domNode===D.target&&(D.type==="childList"?(j(d.find(D.previousSibling,!1)),[].forEach.call(D.addedNodes,function(A){var E=d.find(A,!1);j(E,!1),E instanceof o.default&&E.children.forEach(function(q){j(q,!1)})})):D.type==="attributes"&&j(_.prev)),j(_))}),this.children.forEach(b),C=[].slice.call(this.observer.takeRecords()),w=C.slice();w.length>0;)u.push(w.pop())}},x.prototype.update=function(u,N){var v=this;N===void 0&&(N={}),u=u||this.observer.takeRecords(),u.map(function(w){var j=d.find(w.target,!0);return j==null?null:j.domNode[d.DATA_KEY].mutations==null?(j.domNode[d.DATA_KEY].mutations=[w],j):(j.domNode[d.DATA_KEY].mutations.push(w),null)}).forEach(function(w){w==null||w===v||w.domNode[d.DATA_KEY]==null||w.update(w.domNode[d.DATA_KEY].mutations||[],N)}),this.domNode[d.DATA_KEY].mutations!=null&&h.prototype.update.call(this,this.domNode[d.DATA_KEY].mutations,N),this.optimize(u,N)},x.blotName="scroll",x.defaultChild="block",x.scope=d.Scope.BLOCK_BLOT,x.tagName="DIV",x})(o.default);r.default=p}),(function(n,r,a){var i=this&&this.__extends||(function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,x){h.__proto__=x}||function(h,x){for(var u in x)x.hasOwnProperty(u)&&(h[u]=x[u])};return function(h,x){p(h,x);function u(){this.constructor=h}h.prototype=x===null?Object.create(x):(u.prototype=x.prototype,new u)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1);function m(p,h){if(Object.keys(p).length!==Object.keys(h).length)return!1;for(var x in p)if(p[x]!==h[x])return!1;return!0}var f=(function(p){i(h,p);function h(){return p!==null&&p.apply(this,arguments)||this}return h.formats=function(x){if(x.tagName!==h.tagName)return p.formats.call(this,x)},h.prototype.format=function(x,u){var N=this;x===this.statics.blotName&&!u?(this.children.forEach(function(v){v instanceof o.default||(v=v.wrap(h.blotName,!0)),N.attributes.copy(v)}),this.unwrap()):p.prototype.format.call(this,x,u)},h.prototype.formatAt=function(x,u,N,v){if(this.formats()[N]!=null||d.query(N,d.Scope.ATTRIBUTE)){var w=this.isolate(x,u);w.format(N,v)}else p.prototype.formatAt.call(this,x,u,N,v)},h.prototype.optimize=function(x){p.prototype.optimize.call(this,x);var u=this.formats();if(Object.keys(u).length===0)return this.unwrap();var N=this.next;N instanceof h&&N.prev===this&&m(u,N.formats())&&(N.moveChildren(this),N.remove())},h.blotName="inline",h.scope=d.Scope.INLINE_BLOT,h.tagName="SPAN",h})(o.default);r.default=f}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1),m=(function(f){i(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.formats=function(h){var x=d.query(p.blotName).tagName;if(h.tagName!==x)return f.formats.call(this,h)},p.prototype.format=function(h,x){d.query(h,d.Scope.BLOCK)!=null&&(h===this.statics.blotName&&!x?this.replaceWith(p.blotName):f.prototype.format.call(this,h,x))},p.prototype.formatAt=function(h,x,u,N){d.query(u,d.Scope.BLOCK)!=null?this.format(u,N):f.prototype.formatAt.call(this,h,x,u,N)},p.prototype.insertAt=function(h,x,u){if(u==null||d.query(x,d.Scope.INLINE)!=null)f.prototype.insertAt.call(this,h,x,u);else{var N=this.split(h),v=d.create(x,u);N.parent.insertBefore(v,N)}},p.prototype.update=function(h,x){navigator.userAgent.match(/Trident/)?this.build():f.prototype.update.call(this,h,x)},p.blotName="block",p.scope=d.Scope.BLOCK_BLOT,p.tagName="P",p})(o.default);r.default=m}),(function(n,r,a){var i=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,p){f.__proto__=p}||function(f,p){for(var h in p)p.hasOwnProperty(h)&&(f[h]=p[h])};return function(f,p){m(f,p);function h(){this.constructor=f}f.prototype=p===null?Object.create(p):(h.prototype=p.prototype,new h)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=(function(m){i(f,m);function f(){return m!==null&&m.apply(this,arguments)||this}return f.formats=function(p){},f.prototype.format=function(p,h){m.prototype.formatAt.call(this,0,this.length(),p,h)},f.prototype.formatAt=function(p,h,x,u){p===0&&h===this.length()?this.format(x,u):m.prototype.formatAt.call(this,p,h,x,u)},f.prototype.formats=function(){return this.statics.formats(this.domNode)},f})(o.default);r.default=d}),(function(n,r,a){var i=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,h){p.__proto__=h}||function(p,h){for(var x in h)h.hasOwnProperty(x)&&(p[x]=h[x])};return function(p,h){f(p,h);function x(){this.constructor=p}p.prototype=h===null?Object.create(h):(x.prototype=h.prototype,new x)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=a(1),m=(function(f){i(p,f);function p(h){var x=f.call(this,h)||this;return x.text=x.statics.value(x.domNode),x}return p.create=function(h){return document.createTextNode(h)},p.value=function(h){var x=h.data;return x.normalize&&(x=x.normalize()),x},p.prototype.deleteAt=function(h,x){this.domNode.data=this.text=this.text.slice(0,h)+this.text.slice(h+x)},p.prototype.index=function(h,x){return this.domNode===h?x:-1},p.prototype.insertAt=function(h,x,u){u==null?(this.text=this.text.slice(0,h)+x+this.text.slice(h),this.domNode.data=this.text):f.prototype.insertAt.call(this,h,x,u)},p.prototype.length=function(){return this.text.length},p.prototype.optimize=function(h){f.prototype.optimize.call(this,h),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof p&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())},p.prototype.position=function(h,x){return[this.domNode,h]},p.prototype.split=function(h,x){if(x===void 0&&(x=!1),!x){if(h===0)return this;if(h===this.length())return this.next}var u=d.create(this.domNode.splitText(h));return this.parent.insertBefore(u,this.next),this.text=this.statics.value(this.domNode),u},p.prototype.update=function(h,x){var u=this;h.some(function(N){return N.type==="characterData"&&N.target===u.domNode})&&(this.text=this.statics.value(this.domNode))},p.prototype.value=function(){return this.text},p.blotName="text",p.scope=d.Scope.INLINE_BLOT,p})(o.default);r.default=m}),(function(n,r,a){var i=document.createElement("div");if(i.classList.toggle("test-class",!1),i.classList.contains("test-class")){var o=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(d,m){return arguments.length>1&&!this.contains(d)==!m?m:o.call(this,d)}}String.prototype.startsWith||(String.prototype.startsWith=function(d,m){return m=m||0,this.substr(m,d.length)===d}),String.prototype.endsWith||(String.prototype.endsWith=function(d,m){var f=this.toString();(typeof m!="number"||!isFinite(m)||Math.floor(m)!==m||m>f.length)&&(m=f.length),m-=d.length;var p=f.indexOf(d,m);return p!==-1&&p===m}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(m){if(this===null)throw new TypeError("Array.prototype.find called on null or undefined");if(typeof m!="function")throw new TypeError("predicate must be a function");for(var f=Object(this),p=f.length>>>0,h=arguments[1],x,u=0;u<p;u++)if(x=f[u],m.call(h,x,u,f))return x}}),document.addEventListener("DOMContentLoaded",function(){document.execCommand("enableObjectResizing",!1,!1),document.execCommand("autoUrlDetect",!1,!1)})}),(function(n,r){var a=-1,i=1,o=0;function d(S,D,_){if(S==D)return S?[[o,S]]:[];(_<0||S.length<_)&&(_=null);var A=h(S,D),E=S.substring(0,A);S=S.substring(A),D=D.substring(A),A=x(S,D);var q=S.substring(S.length-A);S=S.substring(0,S.length-A),D=D.substring(0,D.length-A);var O=m(S,D);return E&&O.unshift([o,E]),q&&O.push([o,q]),N(O),_!=null&&(O=j(O,_)),O=b(O),O}function m(S,D){var _;if(!S)return[[i,D]];if(!D)return[[a,S]];var A=S.length>D.length?S:D,E=S.length>D.length?D:S,q=A.indexOf(E);if(q!=-1)return _=[[i,A.substring(0,q)],[o,E],[i,A.substring(q+E.length)]],S.length>D.length&&(_[0][0]=_[2][0]=a),_;if(E.length==1)return[[a,S],[i,D]];var O=u(S,D);if(O){var R=O[0],P=O[1],L=O[2],$=O[3],Z=O[4],Q=d(R,L),W=d(P,$);return Q.concat([[o,Z]],W)}return f(S,D)}function f(S,D){for(var _=S.length,A=D.length,E=Math.ceil((_+A)/2),q=E,O=2*E,R=new Array(O),P=new Array(O),L=0;L<O;L++)R[L]=-1,P[L]=-1;R[q+1]=0,P[q+1]=0;for(var $=_-A,Z=$%2!=0,Q=0,W=0,U=0,M=0,z=0;z<E;z++){for(var T=-z+Q;T<=z-W;T+=2){var F=q+T,I;T==-z||T!=z&&R[F-1]<R[F+1]?I=R[F+1]:I=R[F-1]+1;for(var K=I-T;I<_&&K<A&&S.charAt(I)==D.charAt(K);)I++,K++;if(R[F]=I,I>_)W+=2;else if(K>A)Q+=2;else if(Z){var G=q+$-T;if(G>=0&&G<O&&P[G]!=-1){var V=_-P[G];if(I>=V)return p(S,D,I,K)}}}for(var Y=-z+U;Y<=z-M;Y+=2){var G=q+Y,V;Y==-z||Y!=z&&P[G-1]<P[G+1]?V=P[G+1]:V=P[G-1]+1;for(var re=V-Y;V<_&&re<A&&S.charAt(_-V-1)==D.charAt(A-re-1);)V++,re++;if(P[G]=V,V>_)M+=2;else if(re>A)U+=2;else if(!Z){var F=q+$-Y;if(F>=0&&F<O&&R[F]!=-1){var I=R[F],K=q+I-F;if(V=_-V,I>=V)return p(S,D,I,K)}}}}return[[a,S],[i,D]]}function p(S,D,_,A){var E=S.substring(0,_),q=D.substring(0,A),O=S.substring(_),R=D.substring(A),P=d(E,q),L=d(O,R);return P.concat(L)}function h(S,D){if(!S||!D||S.charAt(0)!=D.charAt(0))return 0;for(var _=0,A=Math.min(S.length,D.length),E=A,q=0;_<E;)S.substring(q,E)==D.substring(q,E)?(_=E,q=_):A=E,E=Math.floor((A-_)/2+_);return E}function x(S,D){if(!S||!D||S.charAt(S.length-1)!=D.charAt(D.length-1))return 0;for(var _=0,A=Math.min(S.length,D.length),E=A,q=0;_<E;)S.substring(S.length-E,S.length-q)==D.substring(D.length-E,D.length-q)?(_=E,q=_):A=E,E=Math.floor((A-_)/2+_);return E}function u(S,D){var _=S.length>D.length?S:D,A=S.length>D.length?D:S;if(_.length<4||A.length*2<_.length)return null;function E(W,U,M){for(var z=W.substring(M,M+Math.floor(W.length/4)),T=-1,F="",I,K,G,V;(T=U.indexOf(z,T+1))!=-1;){var Y=h(W.substring(M),U.substring(T)),re=x(W.substring(0,M),U.substring(0,T));F.length<re+Y&&(F=U.substring(T-re,T)+U.substring(T,T+Y),I=W.substring(0,M-re),K=W.substring(M+Y),G=U.substring(0,T-re),V=U.substring(T+Y))}return F.length*2>=W.length?[I,K,G,V,F]:null}var q=E(_,A,Math.ceil(_.length/4)),O=E(_,A,Math.ceil(_.length/2)),R;if(!q&&!O)return null;O?q?R=q[4].length>O[4].length?q:O:R=O:R=q;var P,L,$,Z;S.length>D.length?(P=R[0],L=R[1],$=R[2],Z=R[3]):($=R[0],Z=R[1],P=R[2],L=R[3]);var Q=R[4];return[P,L,$,Z,Q]}function N(S){S.push([o,""]);for(var D=0,_=0,A=0,E="",q="",O;D<S.length;)switch(S[D][0]){case i:A++,q+=S[D][1],D++;break;case a:_++,E+=S[D][1],D++;break;case o:_+A>1?(_!==0&&A!==0&&(O=h(q,E),O!==0&&(D-_-A>0&&S[D-_-A-1][0]==o?S[D-_-A-1][1]+=q.substring(0,O):(S.splice(0,0,[o,q.substring(0,O)]),D++),q=q.substring(O),E=E.substring(O)),O=x(q,E),O!==0&&(S[D][1]=q.substring(q.length-O)+S[D][1],q=q.substring(0,q.length-O),E=E.substring(0,E.length-O))),_===0?S.splice(D-A,_+A,[i,q]):A===0?S.splice(D-_,_+A,[a,E]):S.splice(D-_-A,_+A,[a,E],[i,q]),D=D-_-A+(_?1:0)+(A?1:0)+1):D!==0&&S[D-1][0]==o?(S[D-1][1]+=S[D][1],S.splice(D,1)):D++,A=0,_=0,E="",q="";break}S[S.length-1][1]===""&&S.pop();var R=!1;for(D=1;D<S.length-1;)S[D-1][0]==o&&S[D+1][0]==o&&(S[D][1].substring(S[D][1].length-S[D-1][1].length)==S[D-1][1]?(S[D][1]=S[D-1][1]+S[D][1].substring(0,S[D][1].length-S[D-1][1].length),S[D+1][1]=S[D-1][1]+S[D+1][1],S.splice(D-1,1),R=!0):S[D][1].substring(0,S[D+1][1].length)==S[D+1][1]&&(S[D-1][1]+=S[D+1][1],S[D][1]=S[D][1].substring(S[D+1][1].length)+S[D+1][1],S.splice(D+1,1),R=!0)),D++;R&&N(S)}var v=d;v.INSERT=i,v.DELETE=a,v.EQUAL=o,n.exports=v;function w(S,D){if(D===0)return[o,S];for(var _=0,A=0;A<S.length;A++){var E=S[A];if(E[0]===a||E[0]===o){var q=_+E[1].length;if(D===q)return[A+1,S];if(D<q){S=S.slice();var O=D-_,R=[E[0],E[1].slice(0,O)],P=[E[0],E[1].slice(O)];return S.splice(A,1,R,P),[A+1,S]}else _=q}}throw new Error("cursor_pos is out of bounds!")}function j(S,D){var _=w(S,D),A=_[1],E=_[0],q=A[E],O=A[E+1];if(q==null)return S;if(q[0]!==o)return S;if(O!=null&&q[1]+O[1]===O[1]+q[1])return A.splice(E,2,O,q),C(A,E,2);if(O!=null&&O[1].indexOf(q[1])===0){A.splice(E,2,[O[0],q[1]],[0,q[1]]);var R=O[1].slice(q[1].length);return R.length>0&&A.splice(E+2,0,[O[0],R]),C(A,E,3)}else return S}function b(S){for(var D=!1,_=function(O){return O.charCodeAt(0)>=56320&&O.charCodeAt(0)<=57343},A=function(O){return O.charCodeAt(O.length-1)>=55296&&O.charCodeAt(O.length-1)<=56319},E=2;E<S.length;E+=1)S[E-2][0]===o&&A(S[E-2][1])&&S[E-1][0]===a&&_(S[E-1][1])&&S[E][0]===i&&_(S[E][1])&&(D=!0,S[E-1][1]=S[E-2][1].slice(-1)+S[E-1][1],S[E][1]=S[E-2][1].slice(-1)+S[E][1],S[E-2][1]=S[E-2][1].slice(0,-1));if(!D)return S;for(var q=[],E=0;E<S.length;E+=1)S[E][1].length>0&&q.push(S[E]);return q}function C(S,D,_){for(var A=D+_-1;A>=0&&A>=D-1;A--)if(A+1<S.length){var E=S[A],q=S[A+1];E[0]===q[1]&&S.splice(A,2,[E[0],E[1]+q[1]])}return S}}),(function(n,r){r=n.exports=typeof Object.keys=="function"?Object.keys:a,r.shim=a;function a(i){var o=[];for(var d in i)o.push(d);return o}}),(function(n,r){var a=(function(){return Object.prototype.toString.call(arguments)})()=="[object Arguments]";r=n.exports=a?i:o,r.supported=i;function i(d){return Object.prototype.toString.call(d)=="[object Arguments]"}r.unsupported=o;function o(d){return d&&typeof d=="object"&&typeof d.length=="number"&&Object.prototype.hasOwnProperty.call(d,"callee")&&!Object.prototype.propertyIsEnumerable.call(d,"callee")||!1}}),(function(n,r){var a=Object.prototype.hasOwnProperty,i="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(i=!1));function d(f,p,h){this.fn=f,this.context=p,this.once=h||!1}function m(){this._events=new o,this._eventsCount=0}m.prototype.eventNames=function(){var p=[],h,x;if(this._eventsCount===0)return p;for(x in h=this._events)a.call(h,x)&&p.push(i?x.slice(1):x);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(h)):p},m.prototype.listeners=function(p,h){var x=i?i+p:p,u=this._events[x];if(h)return!!u;if(!u)return[];if(u.fn)return[u.fn];for(var N=0,v=u.length,w=new Array(v);N<v;N++)w[N]=u[N].fn;return w},m.prototype.emit=function(p,h,x,u,N,v){var w=i?i+p:p;if(!this._events[w])return!1;var j=this._events[w],b=arguments.length,C,S;if(j.fn){switch(j.once&&this.removeListener(p,j.fn,void 0,!0),b){case 1:return j.fn.call(j.context),!0;case 2:return j.fn.call(j.context,h),!0;case 3:return j.fn.call(j.context,h,x),!0;case 4:return j.fn.call(j.context,h,x,u),!0;case 5:return j.fn.call(j.context,h,x,u,N),!0;case 6:return j.fn.call(j.context,h,x,u,N,v),!0}for(S=1,C=new Array(b-1);S<b;S++)C[S-1]=arguments[S];j.fn.apply(j.context,C)}else{var D=j.length,_;for(S=0;S<D;S++)switch(j[S].once&&this.removeListener(p,j[S].fn,void 0,!0),b){case 1:j[S].fn.call(j[S].context);break;case 2:j[S].fn.call(j[S].context,h);break;case 3:j[S].fn.call(j[S].context,h,x);break;case 4:j[S].fn.call(j[S].context,h,x,u);break;default:if(!C)for(_=1,C=new Array(b-1);_<b;_++)C[_-1]=arguments[_];j[S].fn.apply(j[S].context,C)}}return!0},m.prototype.on=function(p,h,x){var u=new d(h,x||this),N=i?i+p:p;return this._events[N]?this._events[N].fn?this._events[N]=[this._events[N],u]:this._events[N].push(u):(this._events[N]=u,this._eventsCount++),this},m.prototype.once=function(p,h,x){var u=new d(h,x||this,!0),N=i?i+p:p;return this._events[N]?this._events[N].fn?this._events[N]=[this._events[N],u]:this._events[N].push(u):(this._events[N]=u,this._eventsCount++),this},m.prototype.removeListener=function(p,h,x,u){var N=i?i+p:p;if(!this._events[N])return this;if(!h)return--this._eventsCount===0?this._events=new o:delete this._events[N],this;var v=this._events[N];if(v.fn)v.fn===h&&(!u||v.once)&&(!x||v.context===x)&&(--this._eventsCount===0?this._events=new o:delete this._events[N]);else{for(var w=0,j=[],b=v.length;w<b;w++)(v[w].fn!==h||u&&!v[w].once||x&&v[w].context!==x)&&j.push(v[w]);j.length?this._events[N]=j.length===1?j[0]:j:--this._eventsCount===0?this._events=new o:delete this._events[N]}return this},m.prototype.removeAllListeners=function(p){var h;return p?(h=i?i+p:p,this._events[h]&&(--this._eventsCount===0?this._events=new o:delete this._events[h])):(this._events=new o,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prototype.setMaxListeners=function(){return this},m.prefixed=i,m.EventEmitter=m,typeof n<"u"&&(n.exports=m)}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.matchText=r.matchSpacing=r.matchNewline=r.matchBlot=r.matchAttributor=r.default=void 0;var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(X){return typeof X}:function(X){return X&&typeof Symbol=="function"&&X.constructor===Symbol&&X!==Symbol.prototype?"symbol":typeof X},o=(function(){function X(Ce,xe){var We=[],Be=!0,rt=!1,ht=void 0;try{for(var ge=Ce[Symbol.iterator](),Je;!(Be=(Je=ge.next()).done)&&(We.push(Je.value),!(xe&&We.length===xe));Be=!0);}catch(mt){rt=!0,ht=mt}finally{try{!Be&&ge.return&&ge.return()}finally{if(rt)throw ht}}return We}return function(Ce,xe){if(Array.isArray(Ce))return Ce;if(Symbol.iterator in Object(Ce))return X(Ce,xe);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function X(Ce,xe){for(var We=0;We<xe.length;We++){var Be=xe[We];Be.enumerable=Be.enumerable||!1,Be.configurable=!0,"value"in Be&&(Be.writable=!0),Object.defineProperty(Ce,Be.key,Be)}}return function(Ce,xe,We){return xe&&X(Ce.prototype,xe),We&&X(Ce,We),Ce}})(),m=a(3),f=P(m),p=a(2),h=P(p),x=a(0),u=P(x),N=a(5),v=P(N),w=a(10),j=P(w),b=a(9),C=P(b),S=a(36),D=a(37),_=a(13),A=P(_),E=a(26),q=a(38),O=a(39),R=a(40);function P(X){return X&&X.__esModule?X:{default:X}}function L(X,Ce,xe){return Ce in X?Object.defineProperty(X,Ce,{value:xe,enumerable:!0,configurable:!0,writable:!0}):X[Ce]=xe,X}function $(X,Ce){if(!(X instanceof Ce))throw new TypeError("Cannot call a class as a function")}function Z(X,Ce){if(!X)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ce&&(typeof Ce=="object"||typeof Ce=="function")?Ce:X}function Q(X,Ce){if(typeof Ce!="function"&&Ce!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof Ce);X.prototype=Object.create(Ce&&Ce.prototype,{constructor:{value:X,enumerable:!1,writable:!0,configurable:!0}}),Ce&&(Object.setPrototypeOf?Object.setPrototypeOf(X,Ce):X.__proto__=Ce)}var W=(0,j.default)("quill:clipboard"),U="__ql-matcher",M=[[Node.TEXT_NODE,ft],[Node.TEXT_NODE,Me],["br",ye],[Node.ELEMENT_NODE,Me],[Node.ELEMENT_NODE,ue],[Node.ELEMENT_NODE,ut],[Node.ELEMENT_NODE,ae],[Node.ELEMENT_NODE,jt],["li",je],["b",re.bind(re,"bold")],["i",re.bind(re,"italic")],["style",ce]],z=[S.AlignAttribute,q.DirectionAttribute].reduce(function(X,Ce){return X[Ce.keyName]=Ce,X},{}),T=[S.AlignStyle,D.BackgroundStyle,E.ColorStyle,q.DirectionStyle,O.FontStyle,R.SizeStyle].reduce(function(X,Ce){return X[Ce.keyName]=Ce,X},{}),F=(function(X){Q(Ce,X);function Ce(xe,We){$(this,Ce);var Be=Z(this,(Ce.__proto__||Object.getPrototypeOf(Ce)).call(this,xe,We));return Be.quill.root.addEventListener("paste",Be.onPaste.bind(Be)),Be.container=Be.quill.addContainer("ql-clipboard"),Be.container.setAttribute("contenteditable",!0),Be.container.setAttribute("tabindex",-1),Be.matchers=[],M.concat(Be.options.matchers).forEach(function(rt){var ht=o(rt,2),ge=ht[0],Je=ht[1];!We.matchVisual&&Je===ut||Be.addMatcher(ge,Je)}),Be}return d(Ce,[{key:"addMatcher",value:function(We,Be){this.matchers.push([We,Be])}},{key:"convert",value:function(We){if(typeof We=="string")return this.container.innerHTML=We.replace(/\>\r?\n +\</g,"><"),this.convert();var Be=this.quill.getFormat(this.quill.selection.savedRange.index);if(Be[A.default.blotName]){var rt=this.container.innerText;return this.container.innerHTML="",new h.default().insert(rt,L({},A.default.blotName,Be[A.default.blotName]))}var ht=this.prepareMatching(),ge=o(ht,2),Je=ge[0],mt=ge[1],de=Y(this.container,Je,mt);return G(de,`
|
||
`)&&de.ops[de.ops.length-1].attributes==null&&(de=de.compose(new h.default().retain(de.length()-1).delete(1))),W.log("convert",this.container.innerHTML,de),this.container.innerHTML="",de}},{key:"dangerouslyPasteHTML",value:function(We,Be){var rt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:v.default.sources.API;if(typeof We=="string")this.quill.setContents(this.convert(We),Be),this.quill.setSelection(0,v.default.sources.SILENT);else{var ht=this.convert(Be);this.quill.updateContents(new h.default().retain(We).concat(ht),rt),this.quill.setSelection(We+ht.length(),v.default.sources.SILENT)}}},{key:"onPaste",value:function(We){var Be=this;if(!(We.defaultPrevented||!this.quill.isEnabled())){var rt=this.quill.getSelection(),ht=new h.default().retain(rt.index),ge=this.quill.scrollingContainer.scrollTop;this.container.focus(),this.quill.selection.update(v.default.sources.SILENT),setTimeout(function(){ht=ht.concat(Be.convert()).delete(rt.length),Be.quill.updateContents(ht,v.default.sources.USER),Be.quill.setSelection(ht.length()-rt.length,v.default.sources.SILENT),Be.quill.scrollingContainer.scrollTop=ge,Be.quill.focus()},1)}}},{key:"prepareMatching",value:function(){var We=this,Be=[],rt=[];return this.matchers.forEach(function(ht){var ge=o(ht,2),Je=ge[0],mt=ge[1];switch(Je){case Node.TEXT_NODE:rt.push(mt);break;case Node.ELEMENT_NODE:Be.push(mt);break;default:[].forEach.call(We.container.querySelectorAll(Je),function(de){de[U]=de[U]||[],de[U].push(mt)});break}}),[Be,rt]}}]),Ce})(C.default);F.DEFAULTS={matchers:[],matchVisual:!0};function I(X,Ce,xe){return(typeof Ce>"u"?"undefined":i(Ce))==="object"?Object.keys(Ce).reduce(function(We,Be){return I(We,Be,Ce[Be])},X):X.reduce(function(We,Be){return Be.attributes&&Be.attributes[Ce]?We.push(Be):We.insert(Be.insert,(0,f.default)({},L({},Ce,xe),Be.attributes))},new h.default)}function K(X){if(X.nodeType!==Node.ELEMENT_NODE)return{};var Ce="__ql-computed-style";return X[Ce]||(X[Ce]=window.getComputedStyle(X))}function G(X,Ce){for(var xe="",We=X.ops.length-1;We>=0&&xe.length<Ce.length;--We){var Be=X.ops[We];if(typeof Be.insert!="string")break;xe=Be.insert+xe}return xe.slice(-1*Ce.length)===Ce}function V(X){if(X.childNodes.length===0)return!1;var Ce=K(X);return["block","list-item"].indexOf(Ce.display)>-1}function Y(X,Ce,xe){return X.nodeType===X.TEXT_NODE?xe.reduce(function(We,Be){return Be(X,We)},new h.default):X.nodeType===X.ELEMENT_NODE?[].reduce.call(X.childNodes||[],function(We,Be){var rt=Y(Be,Ce,xe);return Be.nodeType===X.ELEMENT_NODE&&(rt=Ce.reduce(function(ht,ge){return ge(Be,ht)},rt),rt=(Be[U]||[]).reduce(function(ht,ge){return ge(Be,ht)},rt)),We.concat(rt)},new h.default):new h.default}function re(X,Ce,xe){return I(xe,X,!0)}function ae(X,Ce){var xe=u.default.Attributor.Attribute.keys(X),We=u.default.Attributor.Class.keys(X),Be=u.default.Attributor.Style.keys(X),rt={};return xe.concat(We).concat(Be).forEach(function(ht){var ge=u.default.query(ht,u.default.Scope.ATTRIBUTE);ge!=null&&(rt[ge.attrName]=ge.value(X),rt[ge.attrName])||(ge=z[ht],ge!=null&&(ge.attrName===ht||ge.keyName===ht)&&(rt[ge.attrName]=ge.value(X)||void 0),ge=T[ht],ge!=null&&(ge.attrName===ht||ge.keyName===ht)&&(ge=T[ht],rt[ge.attrName]=ge.value(X)||void 0))}),Object.keys(rt).length>0&&(Ce=I(Ce,rt)),Ce}function ue(X,Ce){var xe=u.default.query(X);if(xe==null)return Ce;if(xe.prototype instanceof u.default.Embed){var We={},Be=xe.value(X);Be!=null&&(We[xe.blotName]=Be,Ce=new h.default().insert(We,xe.formats(X)))}else typeof xe.formats=="function"&&(Ce=I(Ce,xe.blotName,xe.formats(X)));return Ce}function ye(X,Ce){return G(Ce,`
|
||
`)||Ce.insert(`
|
||
`),Ce}function ce(){return new h.default}function je(X,Ce){var xe=u.default.query(X);if(xe==null||xe.blotName!=="list-item"||!G(Ce,`
|
||
`))return Ce;for(var We=-1,Be=X.parentNode;!Be.classList.contains("ql-clipboard");)(u.default.query(Be)||{}).blotName==="list"&&(We+=1),Be=Be.parentNode;return We<=0?Ce:Ce.compose(new h.default().retain(Ce.length()-1).retain(1,{indent:We}))}function Me(X,Ce){return G(Ce,`
|
||
`)||(V(X)||Ce.length()>0&&X.nextSibling&&V(X.nextSibling))&&Ce.insert(`
|
||
`),Ce}function ut(X,Ce){if(V(X)&&X.nextElementSibling!=null&&!G(Ce,`
|
||
|
||
`)){var xe=X.offsetHeight+parseFloat(K(X).marginTop)+parseFloat(K(X).marginBottom);X.nextElementSibling.offsetTop>X.offsetTop+xe*1.5&&Ce.insert(`
|
||
`)}return Ce}function jt(X,Ce){var xe={},We=X.style||{};return We.fontStyle&&K(X).fontStyle==="italic"&&(xe.italic=!0),We.fontWeight&&(K(X).fontWeight.startsWith("bold")||parseInt(K(X).fontWeight)>=700)&&(xe.bold=!0),Object.keys(xe).length>0&&(Ce=I(Ce,xe)),parseFloat(We.textIndent||0)>0&&(Ce=new h.default().insert(" ").concat(Ce)),Ce}function ft(X,Ce){var xe=X.data;if(X.parentNode.tagName==="O:P")return Ce.insert(xe.trim());if(xe.trim().length===0&&X.parentNode.classList.contains("ql-clipboard"))return Ce;if(!K(X.parentNode).whiteSpace.startsWith("pre")){var We=function(rt,ht){return ht=ht.replace(/[^\u00a0]/g,""),ht.length<1&&rt?" ":ht};xe=xe.replace(/\r\n/g," ").replace(/\n/g," "),xe=xe.replace(/\s\s+/g,We.bind(We,!0)),(X.previousSibling==null&&V(X.parentNode)||X.previousSibling!=null&&V(X.previousSibling))&&(xe=xe.replace(/^\s+/,We.bind(We,!1))),(X.nextSibling==null&&V(X.parentNode)||X.nextSibling!=null&&V(X.nextSibling))&&(xe=xe.replace(/\s+$/,We.bind(We,!1)))}return Ce.insert(xe)}r.default=F,r.matchAttributor=ae,r.matchBlot=ue,r.matchNewline=Me,r.matchSpacing=ut,r.matchText=ft}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(6),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return i(v,[{key:"optimize",value:function(j){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"optimize",this).call(this,j),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}}],[{key:"create",value:function(){return o(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this)}},{key:"formats",value:function(){return!0}}]),v})(m.default);u.blotName="bold",u.tagName=["STRONG","B"],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.addControls=r.default=void 0;var i=(function(){function R(P,L){var $=[],Z=!0,Q=!1,W=void 0;try{for(var U=P[Symbol.iterator](),M;!(Z=(M=U.next()).done)&&($.push(M.value),!(L&&$.length===L));Z=!0);}catch(z){Q=!0,W=z}finally{try{!Z&&U.return&&U.return()}finally{if(Q)throw W}}return $}return function(P,L){if(Array.isArray(P))return P;if(Symbol.iterator in Object(P))return R(P,L);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function R(P,L){for(var $=0;$<L.length;$++){var Z=L[$];Z.enumerable=Z.enumerable||!1,Z.configurable=!0,"value"in Z&&(Z.writable=!0),Object.defineProperty(P,Z.key,Z)}}return function(P,L,$){return L&&R(P.prototype,L),$&&R(P,$),P}})(),d=a(2),m=j(d),f=a(0),p=j(f),h=a(5),x=j(h),u=a(10),N=j(u),v=a(9),w=j(v);function j(R){return R&&R.__esModule?R:{default:R}}function b(R,P,L){return P in R?Object.defineProperty(R,P,{value:L,enumerable:!0,configurable:!0,writable:!0}):R[P]=L,R}function C(R,P){if(!(R instanceof P))throw new TypeError("Cannot call a class as a function")}function S(R,P){if(!R)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:R}function D(R,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);R.prototype=Object.create(P&&P.prototype,{constructor:{value:R,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(R,P):R.__proto__=P)}var _=(0,N.default)("quill:toolbar"),A=(function(R){D(P,R);function P(L,$){C(this,P);var Z=S(this,(P.__proto__||Object.getPrototypeOf(P)).call(this,L,$));if(Array.isArray(Z.options.container)){var Q=document.createElement("div");q(Q,Z.options.container),L.container.parentNode.insertBefore(Q,L.container),Z.container=Q}else typeof Z.options.container=="string"?Z.container=document.querySelector(Z.options.container):Z.container=Z.options.container;if(!(Z.container instanceof HTMLElement)){var W;return W=_.error("Container required for toolbar",Z.options),S(Z,W)}return Z.container.classList.add("ql-toolbar"),Z.controls=[],Z.handlers={},Object.keys(Z.options.handlers).forEach(function(U){Z.addHandler(U,Z.options.handlers[U])}),[].forEach.call(Z.container.querySelectorAll("button, select"),function(U){Z.attach(U)}),Z.quill.on(x.default.events.EDITOR_CHANGE,function(U,M){U===x.default.events.SELECTION_CHANGE&&Z.update(M)}),Z.quill.on(x.default.events.SCROLL_OPTIMIZE,function(){var U=Z.quill.selection.getRange(),M=i(U,1),z=M[0];Z.update(z)}),Z}return o(P,[{key:"addHandler",value:function($,Z){this.handlers[$]=Z}},{key:"attach",value:function($){var Z=this,Q=[].find.call($.classList,function(U){return U.indexOf("ql-")===0});if(Q){if(Q=Q.slice(3),$.tagName==="BUTTON"&&$.setAttribute("type","button"),this.handlers[Q]==null){if(this.quill.scroll.whitelist!=null&&this.quill.scroll.whitelist[Q]==null){_.warn("ignoring attaching to disabled format",Q,$);return}if(p.default.query(Q)==null){_.warn("ignoring attaching to nonexistent format",Q,$);return}}var W=$.tagName==="SELECT"?"change":"click";$.addEventListener(W,function(U){var M=void 0;if($.tagName==="SELECT"){if($.selectedIndex<0)return;var z=$.options[$.selectedIndex];z.hasAttribute("selected")?M=!1:M=z.value||!1}else $.classList.contains("ql-active")?M=!1:M=$.value||!$.hasAttribute("value"),U.preventDefault();Z.quill.focus();var T=Z.quill.selection.getRange(),F=i(T,1),I=F[0];if(Z.handlers[Q]!=null)Z.handlers[Q].call(Z,M);else if(p.default.query(Q).prototype instanceof p.default.Embed){if(M=prompt("Enter "+Q),!M)return;Z.quill.updateContents(new m.default().retain(I.index).delete(I.length).insert(b({},Q,M)),x.default.sources.USER)}else Z.quill.format(Q,M,x.default.sources.USER);Z.update(I)}),this.controls.push([Q,$])}}},{key:"update",value:function($){var Z=$==null?{}:this.quill.getFormat($);this.controls.forEach(function(Q){var W=i(Q,2),U=W[0],M=W[1];if(M.tagName==="SELECT"){var z=void 0;if($==null)z=null;else if(Z[U]==null)z=M.querySelector("option[selected]");else if(!Array.isArray(Z[U])){var T=Z[U];typeof T=="string"&&(T=T.replace(/\"/g,'\\"')),z=M.querySelector('option[value="'+T+'"]')}z==null?(M.value="",M.selectedIndex=-1):z.selected=!0}else if($==null)M.classList.remove("ql-active");else if(M.hasAttribute("value")){var F=Z[U]===M.getAttribute("value")||Z[U]!=null&&Z[U].toString()===M.getAttribute("value")||Z[U]==null&&!M.getAttribute("value");M.classList.toggle("ql-active",F)}else M.classList.toggle("ql-active",Z[U]!=null)})}}]),P})(w.default);A.DEFAULTS={};function E(R,P,L){var $=document.createElement("button");$.setAttribute("type","button"),$.classList.add("ql-"+P),L!=null&&($.value=L),R.appendChild($)}function q(R,P){Array.isArray(P[0])||(P=[P]),P.forEach(function(L){var $=document.createElement("span");$.classList.add("ql-formats"),L.forEach(function(Z){if(typeof Z=="string")E($,Z);else{var Q=Object.keys(Z)[0],W=Z[Q];Array.isArray(W)?O($,Q,W):E($,Q,W)}}),R.appendChild($)})}function O(R,P,L){var $=document.createElement("select");$.classList.add("ql-"+P),L.forEach(function(Z){var Q=document.createElement("option");Z!==!1?Q.setAttribute("value",Z):Q.setAttribute("selected","selected"),$.appendChild(Q)}),R.appendChild($)}A.DEFAULTS={container:null,handlers:{clean:function(){var P=this,L=this.quill.getSelection();if(L!=null)if(L.length==0){var $=this.quill.getFormat();Object.keys($).forEach(function(Z){p.default.query(Z,p.default.Scope.INLINE)!=null&&P.quill.format(Z,!1)})}else this.quill.removeFormat(L,x.default.sources.USER)},direction:function(P){var L=this.quill.getFormat().align;P==="rtl"&&L==null?this.quill.format("align","right",x.default.sources.USER):!P&&L==="right"&&this.quill.format("align",!1,x.default.sources.USER),this.quill.format("direction",P,x.default.sources.USER)},indent:function(P){var L=this.quill.getSelection(),$=this.quill.getFormat(L),Z=parseInt($.indent||0);if(P==="+1"||P==="-1"){var Q=P==="+1"?1:-1;$.direction==="rtl"&&(Q*=-1),this.quill.format("indent",Z+Q,x.default.sources.USER)}},link:function(P){P===!0&&(P=prompt("Enter link URL:")),this.quill.format("link",P,x.default.sources.USER)},list:function(P){var L=this.quill.getSelection(),$=this.quill.getFormat(L);P==="check"?$.list==="checked"||$.list==="unchecked"?this.quill.format("list",!1,x.default.sources.USER):this.quill.format("list","unchecked",x.default.sources.USER):this.quill.format("list",P,x.default.sources.USER)}}},r.default=A,r.addControls=q}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polyline class="ql-even ql-stroke" points="5 7 3 9 5 11"></polyline> <polyline class="ql-even ql-stroke" points="13 7 15 9 13 11"></polyline> <line class=ql-stroke x1=10 x2=8 y1=5 y2=13></line> </svg>'}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(28),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(w,j){p(this,v);var b=h(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,w));return b.label.innerHTML=j,b.container.classList.add("ql-color-picker"),[].slice.call(b.container.querySelectorAll(".ql-picker-item"),0,7).forEach(function(C){C.classList.add("ql-primary")}),b}return i(v,[{key:"buildItem",value:function(j){var b=o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"buildItem",this).call(this,j);return b.style.backgroundColor=j.getAttribute("value")||"",b}},{key:"selectItem",value:function(j,b){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"selectItem",this).call(this,j,b);var C=this.label.querySelector(".ql-color-label"),S=j&&j.getAttribute("data-value")||"";C&&(C.tagName==="line"?C.style.stroke=S:C.style.fill=S)}}]),v})(m.default);r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(28),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(w,j){p(this,v);var b=h(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,w));return b.container.classList.add("ql-icon-picker"),[].forEach.call(b.container.querySelectorAll(".ql-picker-item"),function(C){C.innerHTML=j[C.getAttribute("data-value")||""]}),b.defaultItem=b.container.querySelector(".ql-selected"),b.selectItem(b.defaultItem),b}return i(v,[{key:"selectItem",value:function(j,b){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"selectItem",this).call(this,j,b),j=j||this.defaultItem,this.label.innerHTML=j.innerHTML}}]),v})(m.default);r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function m(f,p){for(var h=0;h<p.length;h++){var x=p[h];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(f,x.key,x)}}return function(f,p,h){return p&&m(f.prototype,p),h&&m(f,h),f}})();function o(m,f){if(!(m instanceof f))throw new TypeError("Cannot call a class as a function")}var d=(function(){function m(f,p){var h=this;o(this,m),this.quill=f,this.boundsContainer=p||document.body,this.root=f.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,this.quill.root===this.quill.scrollingContainer&&this.quill.root.addEventListener("scroll",function(){h.root.style.marginTop=-1*h.quill.root.scrollTop+"px"}),this.hide()}return i(m,[{key:"hide",value:function(){this.root.classList.add("ql-hidden")}},{key:"position",value:function(p){var h=p.left+p.width/2-this.root.offsetWidth/2,x=p.bottom+this.quill.root.scrollTop;this.root.style.left=h+"px",this.root.style.top=x+"px",this.root.classList.remove("ql-flip");var u=this.boundsContainer.getBoundingClientRect(),N=this.root.getBoundingClientRect(),v=0;if(N.right>u.right&&(v=u.right-N.right,this.root.style.left=h+v+"px"),N.left<u.left&&(v=u.left-N.left,this.root.style.left=h+v+"px"),N.bottom>u.bottom){var w=N.bottom-N.top,j=p.bottom-p.top+w;this.root.style.top=x-j+"px",this.root.classList.add("ql-flip")}return v}},{key:"show",value:function(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}]),m})();r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function O(R,P){var L=[],$=!0,Z=!1,Q=void 0;try{for(var W=R[Symbol.iterator](),U;!($=(U=W.next()).done)&&(L.push(U.value),!(P&&L.length===P));$=!0);}catch(M){Z=!0,Q=M}finally{try{!$&&W.return&&W.return()}finally{if(Z)throw Q}}return L}return function(R,P){if(Array.isArray(R))return R;if(Symbol.iterator in Object(R))return O(R,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function O(R,P,L){R===null&&(R=Function.prototype);var $=Object.getOwnPropertyDescriptor(R,P);if($===void 0){var Z=Object.getPrototypeOf(R);return Z===null?void 0:O(Z,P,L)}else{if("value"in $)return $.value;var Q=$.get;return Q===void 0?void 0:Q.call(L)}},d=(function(){function O(R,P){for(var L=0;L<P.length;L++){var $=P[L];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(R,$.key,$)}}return function(R,P,L){return P&&O(R.prototype,P),L&&O(R,L),R}})(),m=a(3),f=C(m),p=a(8),h=C(p),x=a(43),u=C(x),N=a(27),v=C(N),w=a(15),j=a(41),b=C(j);function C(O){return O&&O.__esModule?O:{default:O}}function S(O,R){if(!(O instanceof R))throw new TypeError("Cannot call a class as a function")}function D(O,R){if(!O)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R&&(typeof R=="object"||typeof R=="function")?R:O}function _(O,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof R);O.prototype=Object.create(R&&R.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}),R&&(Object.setPrototypeOf?Object.setPrototypeOf(O,R):O.__proto__=R)}var A=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],E=(function(O){_(R,O);function R(P,L){S(this,R),L.modules.toolbar!=null&&L.modules.toolbar.container==null&&(L.modules.toolbar.container=A);var $=D(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,P,L));return $.quill.container.classList.add("ql-snow"),$}return d(R,[{key:"extendToolbar",value:function(L){L.container.classList.add("ql-snow"),this.buildButtons([].slice.call(L.container.querySelectorAll("button")),b.default),this.buildPickers([].slice.call(L.container.querySelectorAll("select")),b.default),this.tooltip=new q(this.quill,this.options.bounds),L.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"K",shortKey:!0},function($,Z){L.handlers.link.call(L,!Z.format.link)})}}]),R})(u.default);E.DEFAULTS=(0,f.default)(!0,{},u.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(R){if(R){var P=this.quill.getSelection();if(P==null||P.length==0)return;var L=this.quill.getText(P);/^\S+@\S+\.\S+$/.test(L)&&L.indexOf("mailto:")!==0&&(L="mailto:"+L);var $=this.quill.theme.tooltip;$.edit("link",L)}else this.quill.format("link",!1)}}}}});var q=(function(O){_(R,O);function R(P,L){S(this,R);var $=D(this,(R.__proto__||Object.getPrototypeOf(R)).call(this,P,L));return $.preview=$.root.querySelector("a.ql-preview"),$}return d(R,[{key:"listen",value:function(){var L=this;o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"listen",this).call(this),this.root.querySelector("a.ql-action").addEventListener("click",function($){L.root.classList.contains("ql-editing")?L.save():L.edit("link",L.preview.textContent),$.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",function($){if(L.linkRange!=null){var Z=L.linkRange;L.restoreFocus(),L.quill.formatText(Z,"link",!1,h.default.sources.USER),delete L.linkRange}$.preventDefault(),L.hide()}),this.quill.on(h.default.events.SELECTION_CHANGE,function($,Z,Q){if($!=null){if($.length===0&&Q===h.default.sources.USER){var W=L.quill.scroll.descendant(v.default,$.index),U=i(W,2),M=U[0],z=U[1];if(M!=null){L.linkRange=new w.Range($.index-z,M.length());var T=v.default.formats(M.domNode);L.preview.textContent=T,L.preview.setAttribute("href",T),L.show(),L.position(L.quill.getBounds(L.linkRange));return}}else delete L.linkRange;L.hide()}})}},{key:"show",value:function(){o(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"show",this).call(this),this.root.removeAttribute("data-mode")}}]),R})(x.BaseTooltip);q.TEMPLATE=['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-action"></a>','<a class="ql-remove"></a>'].join(""),r.default=E}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(29),o=Be(i),d=a(36),m=a(38),f=a(64),p=a(65),h=Be(p),x=a(66),u=Be(x),N=a(67),v=Be(N),w=a(37),j=a(26),b=a(39),C=a(40),S=a(56),D=Be(S),_=a(68),A=Be(_),E=a(27),q=Be(E),O=a(69),R=Be(O),P=a(70),L=Be(P),$=a(71),Z=Be($),Q=a(72),W=Be(Q),U=a(73),M=Be(U),z=a(13),T=Be(z),F=a(74),I=Be(F),K=a(75),G=Be(K),V=a(57),Y=Be(V),re=a(41),ae=Be(re),ue=a(28),ye=Be(ue),ce=a(59),je=Be(ce),Me=a(60),ut=Be(Me),jt=a(61),ft=Be(jt),X=a(108),Ce=Be(X),xe=a(62),We=Be(xe);function Be(rt){return rt&&rt.__esModule?rt:{default:rt}}o.default.register({"attributors/attribute/direction":m.DirectionAttribute,"attributors/class/align":d.AlignClass,"attributors/class/background":w.BackgroundClass,"attributors/class/color":j.ColorClass,"attributors/class/direction":m.DirectionClass,"attributors/class/font":b.FontClass,"attributors/class/size":C.SizeClass,"attributors/style/align":d.AlignStyle,"attributors/style/background":w.BackgroundStyle,"attributors/style/color":j.ColorStyle,"attributors/style/direction":m.DirectionStyle,"attributors/style/font":b.FontStyle,"attributors/style/size":C.SizeStyle},!0),o.default.register({"formats/align":d.AlignClass,"formats/direction":m.DirectionClass,"formats/indent":f.IndentClass,"formats/background":w.BackgroundStyle,"formats/color":j.ColorStyle,"formats/font":b.FontClass,"formats/size":C.SizeClass,"formats/blockquote":h.default,"formats/code-block":T.default,"formats/header":u.default,"formats/list":v.default,"formats/bold":D.default,"formats/code":z.Code,"formats/italic":A.default,"formats/link":q.default,"formats/script":R.default,"formats/strike":L.default,"formats/underline":Z.default,"formats/image":W.default,"formats/video":M.default,"formats/list/item":N.ListItem,"modules/formula":I.default,"modules/syntax":G.default,"modules/toolbar":Y.default,"themes/bubble":Ce.default,"themes/snow":We.default,"ui/icons":ae.default,"ui/picker":ye.default,"ui/icon-picker":ut.default,"ui/color-picker":je.default,"ui/tooltip":ft.default},!0),r.default=o.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.IndentClass=void 0;var i=(function(){function v(w,j){for(var b=0;b<j.length;b++){var C=j[b];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(w,C.key,C)}}return function(w,j,b){return j&&v(w.prototype,j),b&&v(w,b),w}})(),o=function v(w,j,b){w===null&&(w=Function.prototype);var C=Object.getOwnPropertyDescriptor(w,j);if(C===void 0){var S=Object.getPrototypeOf(w);return S===null?void 0:v(S,j,b)}else{if("value"in C)return C.value;var D=C.get;return D===void 0?void 0:D.call(b)}},d=a(0),m=f(d);function f(v){return v&&v.__esModule?v:{default:v}}function p(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}function h(v,w){if(!v)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:v}function x(v,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);v.prototype=Object.create(w&&w.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(v,w):v.__proto__=w)}var u=(function(v){x(w,v);function w(){return p(this,w),h(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}return i(w,[{key:"add",value:function(b,C){if(C==="+1"||C==="-1"){var S=this.value(b)||0;C=C==="+1"?S+1:S-1}return C===0?(this.remove(b),!0):o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"add",this).call(this,b,C)}},{key:"canAdd",value:function(b,C){return o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"canAdd",this).call(this,b,C)||o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"canAdd",this).call(this,b,parseInt(C))}},{key:"value",value:function(b){return parseInt(o(w.prototype.__proto__||Object.getPrototypeOf(w.prototype),"value",this).call(this,b))||void 0}}]),w})(m.default.Attributor.Class),N=new u("indent","ql-indent",{scope:m.default.Scope.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});r.IndentClass=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(4),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="blockquote",h.tagName="blockquote",r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function u(N,v){for(var w=0;w<v.length;w++){var j=v[w];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(N,j.key,j)}}return function(N,v,w){return v&&u(N.prototype,v),w&&u(N,w),N}})(),o=a(4),d=m(o);function m(u){return u&&u.__esModule?u:{default:u}}function f(u,N){if(!(u instanceof N))throw new TypeError("Cannot call a class as a function")}function p(u,N){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:u}function h(u,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);u.prototype=Object.create(N&&N.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(u,N):u.__proto__=N)}var x=(function(u){h(N,u);function N(){return f(this,N),p(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return i(N,null,[{key:"formats",value:function(w){return this.tagName.indexOf(w.tagName)+1}}]),N})(d.default);x.blotName="header",x.tagName=["H1","H2","H3","H4","H5","H6"],r.default=x}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.ListItem=void 0;var i=(function(){function S(D,_){for(var A=0;A<_.length;A++){var E=_[A];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(D,E.key,E)}}return function(D,_,A){return _&&S(D.prototype,_),A&&S(D,A),D}})(),o=function S(D,_,A){D===null&&(D=Function.prototype);var E=Object.getOwnPropertyDescriptor(D,_);if(E===void 0){var q=Object.getPrototypeOf(D);return q===null?void 0:S(q,_,A)}else{if("value"in E)return E.value;var O=E.get;return O===void 0?void 0:O.call(A)}},d=a(0),m=u(d),f=a(4),p=u(f),h=a(25),x=u(h);function u(S){return S&&S.__esModule?S:{default:S}}function N(S,D,_){return D in S?Object.defineProperty(S,D,{value:_,enumerable:!0,configurable:!0,writable:!0}):S[D]=_,S}function v(S,D){if(!(S instanceof D))throw new TypeError("Cannot call a class as a function")}function w(S,D){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:S}function j(S,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);S.prototype=Object.create(D&&D.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(S,D):S.__proto__=D)}var b=(function(S){j(D,S);function D(){return v(this,D),w(this,(D.__proto__||Object.getPrototypeOf(D)).apply(this,arguments))}return i(D,[{key:"format",value:function(A,E){A===C.blotName&&!E?this.replaceWith(m.default.create(this.statics.scope)):o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"format",this).call(this,A,E)}},{key:"remove",value:function(){this.prev==null&&this.next==null?this.parent.remove():o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"remove",this).call(this)}},{key:"replaceWith",value:function(A,E){return this.parent.isolate(this.offset(this.parent),this.length()),A===this.parent.statics.blotName?(this.parent.replaceWith(A,E),this):(this.parent.unwrap(),o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"replaceWith",this).call(this,A,E))}}],[{key:"formats",value:function(A){return A.tagName===this.tagName?void 0:o(D.__proto__||Object.getPrototypeOf(D),"formats",this).call(this,A)}}]),D})(p.default);b.blotName="list-item",b.tagName="LI";var C=(function(S){j(D,S),i(D,null,[{key:"create",value:function(A){var E=A==="ordered"?"OL":"UL",q=o(D.__proto__||Object.getPrototypeOf(D),"create",this).call(this,E);return(A==="checked"||A==="unchecked")&&q.setAttribute("data-checked",A==="checked"),q}},{key:"formats",value:function(A){if(A.tagName==="OL")return"ordered";if(A.tagName==="UL")return A.hasAttribute("data-checked")?A.getAttribute("data-checked")==="true"?"checked":"unchecked":"bullet"}}]);function D(_){v(this,D);var A=w(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,_)),E=function(O){if(O.target.parentNode===_){var R=A.statics.formats(_),P=m.default.find(O.target);R==="checked"?P.format("list","unchecked"):R==="unchecked"&&P.format("list","checked")}};return _.addEventListener("touchstart",E),_.addEventListener("mousedown",E),A}return i(D,[{key:"format",value:function(A,E){this.children.length>0&&this.children.tail.format(A,E)}},{key:"formats",value:function(){return N({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(A,E){if(A instanceof b)o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"insertBefore",this).call(this,A,E);else{var q=E==null?this.length():E.offset(this),O=this.split(q);O.parent.insertBefore(A,O)}}},{key:"optimize",value:function(A){o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"optimize",this).call(this,A);var E=this.next;E!=null&&E.prev===this&&E.statics.blotName===this.statics.blotName&&E.domNode.tagName===this.domNode.tagName&&E.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(E.moveChildren(this),E.remove())}},{key:"replace",value:function(A){if(A.statics.blotName!==this.statics.blotName){var E=m.default.create(this.statics.defaultChild);A.moveChildren(E),this.appendChild(E)}o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"replace",this).call(this,A)}}]),D})(x.default);C.blotName="list",C.scope=m.default.Scope.BLOCK_BLOT,C.tagName=["OL","UL"],C.defaultChild="list-item",C.allowedChildren=[b],r.ListItem=b,r.default=C}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(56),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="italic",h.tagName=["EM","I"],r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function N(v,w){for(var j=0;j<w.length;j++){var b=w[j];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}return function(v,w,j){return w&&N(v.prototype,w),j&&N(v,j),v}})(),o=function N(v,w,j){v===null&&(v=Function.prototype);var b=Object.getOwnPropertyDescriptor(v,w);if(b===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:N(C,w,j)}else{if("value"in b)return b.value;var S=b.get;return S===void 0?void 0:S.call(j)}},d=a(6),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function p(N,v){if(!(N instanceof v))throw new TypeError("Cannot call a class as a function")}function h(N,v){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:N}function x(N,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);N.prototype=Object.create(v&&v.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(N,v):N.__proto__=v)}var u=(function(N){x(v,N);function v(){return p(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return i(v,null,[{key:"create",value:function(j){return j==="super"?document.createElement("sup"):j==="sub"?document.createElement("sub"):o(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this,j)}},{key:"formats",value:function(j){if(j.tagName==="SUB")return"sub";if(j.tagName==="SUP")return"super"}}]),v})(m.default);u.blotName="script",u.tagName=["SUB","SUP"],r.default=u}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(6),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="strike",h.tagName="S",r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=a(6),o=d(i);function d(x){return x&&x.__esModule?x:{default:x}}function m(x,u){if(!(x instanceof u))throw new TypeError("Cannot call a class as a function")}function f(x,u){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:x}function p(x,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);x.prototype=Object.create(u&&u.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(x,u):x.__proto__=u)}var h=(function(x){p(u,x);function u(){return m(this,u),f(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}return u})(o.default);h.blotName="underline",h.tagName="U",r.default=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:w(D,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(0),m=p(d),f=a(27);function p(w){return w&&w.__esModule?w:{default:w}}function h(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function x(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function u(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var N=["alt","height","width"],v=(function(w){u(j,w);function j(){return h(this,j),x(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"format",value:function(C,S){N.indexOf(C)>-1?S?this.domNode.setAttribute(C,S):this.domNode.removeAttribute(C):o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"format",this).call(this,C,S)}}],[{key:"create",value:function(C){var S=o(j.__proto__||Object.getPrototypeOf(j),"create",this).call(this,C);return typeof C=="string"&&S.setAttribute("src",this.sanitize(C)),S}},{key:"formats",value:function(C){return N.reduce(function(S,D){return C.hasAttribute(D)&&(S[D]=C.getAttribute(D)),S},{})}},{key:"match",value:function(C){return/\.(jpe?g|gif|png)$/.test(C)||/^data:image\/.+;base64/.test(C)}},{key:"sanitize",value:function(C){return(0,f.sanitize)(C,["http","https","data"])?C:"//:0"}},{key:"value",value:function(C){return C.getAttribute("src")}}]),j})(m.default.Embed);v.blotName="image",v.tagName="IMG",r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var i=(function(){function w(j,b){for(var C=0;C<b.length;C++){var S=b[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,b,C){return b&&w(j.prototype,b),C&&w(j,C),j}})(),o=function w(j,b,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,b);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:w(D,b,C)}else{if("value"in S)return S.value;var _=S.get;return _===void 0?void 0:_.call(C)}},d=a(4),m=a(27),f=p(m);function p(w){return w&&w.__esModule?w:{default:w}}function h(w,j){if(!(w instanceof j))throw new TypeError("Cannot call a class as a function")}function x(w,j){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:w}function u(w,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);w.prototype=Object.create(j&&j.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(w,j):w.__proto__=j)}var N=["height","width"],v=(function(w){u(j,w);function j(){return h(this,j),x(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return i(j,[{key:"format",value:function(C,S){N.indexOf(C)>-1?S?this.domNode.setAttribute(C,S):this.domNode.removeAttribute(C):o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"format",this).call(this,C,S)}}],[{key:"create",value:function(C){var S=o(j.__proto__||Object.getPrototypeOf(j),"create",this).call(this,C);return S.setAttribute("frameborder","0"),S.setAttribute("allowfullscreen",!0),S.setAttribute("src",this.sanitize(C)),S}},{key:"formats",value:function(C){return N.reduce(function(S,D){return C.hasAttribute(D)&&(S[D]=C.getAttribute(D)),S},{})}},{key:"sanitize",value:function(C){return f.default.sanitize(C)}},{key:"value",value:function(C){return C.getAttribute("src")}}]),j})(d.BlockEmbed);v.blotName="video",v.className="ql-video",v.tagName="IFRAME",r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.FormulaBlot=void 0;var i=(function(){function C(S,D){for(var _=0;_<D.length;_++){var A=D[_];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(S,A.key,A)}}return function(S,D,_){return D&&C(S.prototype,D),_&&C(S,_),S}})(),o=function C(S,D,_){S===null&&(S=Function.prototype);var A=Object.getOwnPropertyDescriptor(S,D);if(A===void 0){var E=Object.getPrototypeOf(S);return E===null?void 0:C(E,D,_)}else{if("value"in A)return A.value;var q=A.get;return q===void 0?void 0:q.call(_)}},d=a(35),m=u(d),f=a(5),p=u(f),h=a(9),x=u(h);function u(C){return C&&C.__esModule?C:{default:C}}function N(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}function v(C,S){if(!C)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:C}function w(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(C,S):C.__proto__=S)}var j=(function(C){w(S,C);function S(){return N(this,S),v(this,(S.__proto__||Object.getPrototypeOf(S)).apply(this,arguments))}return i(S,null,[{key:"create",value:function(_){var A=o(S.__proto__||Object.getPrototypeOf(S),"create",this).call(this,_);return typeof _=="string"&&(window.katex.render(_,A,{throwOnError:!1,errorColor:"#f00"}),A.setAttribute("data-value",_)),A}},{key:"value",value:function(_){return _.getAttribute("data-value")}}]),S})(m.default);j.blotName="formula",j.className="ql-formula",j.tagName="SPAN";var b=(function(C){w(S,C),i(S,null,[{key:"register",value:function(){p.default.register(j,!0)}}]);function S(){N(this,S);var D=v(this,(S.__proto__||Object.getPrototypeOf(S)).call(this));if(window.katex==null)throw new Error("Formula module requires KaTeX.");return D}return S})(x.default);r.FormulaBlot=j,r.default=b}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.CodeToken=r.CodeBlock=void 0;var i=(function(){function _(A,E){for(var q=0;q<E.length;q++){var O=E[q];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(A,O.key,O)}}return function(A,E,q){return E&&_(A.prototype,E),q&&_(A,q),A}})(),o=function _(A,E,q){A===null&&(A=Function.prototype);var O=Object.getOwnPropertyDescriptor(A,E);if(O===void 0){var R=Object.getPrototypeOf(A);return R===null?void 0:_(R,E,q)}else{if("value"in O)return O.value;var P=O.get;return P===void 0?void 0:P.call(q)}},d=a(0),m=v(d),f=a(5),p=v(f),h=a(9),x=v(h),u=a(13),N=v(u);function v(_){return _&&_.__esModule?_:{default:_}}function w(_,A){if(!(_ instanceof A))throw new TypeError("Cannot call a class as a function")}function j(_,A){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A&&(typeof A=="object"||typeof A=="function")?A:_}function b(_,A){if(typeof A!="function"&&A!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof A);_.prototype=Object.create(A&&A.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),A&&(Object.setPrototypeOf?Object.setPrototypeOf(_,A):_.__proto__=A)}var C=(function(_){b(A,_);function A(){return w(this,A),j(this,(A.__proto__||Object.getPrototypeOf(A)).apply(this,arguments))}return i(A,[{key:"replaceWith",value:function(q){this.domNode.textContent=this.domNode.textContent,this.attach(),o(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"replaceWith",this).call(this,q)}},{key:"highlight",value:function(q){var O=this.domNode.textContent;this.cachedText!==O&&((O.trim().length>0||this.cachedText==null)&&(this.domNode.innerHTML=q(O),this.domNode.normalize(),this.attach()),this.cachedText=O)}}]),A})(N.default);C.className="ql-syntax";var S=new m.default.Attributor.Class("token","hljs",{scope:m.default.Scope.INLINE}),D=(function(_){b(A,_),i(A,null,[{key:"register",value:function(){p.default.register(S,!0),p.default.register(C,!0)}}]);function A(E,q){w(this,A);var O=j(this,(A.__proto__||Object.getPrototypeOf(A)).call(this,E,q));if(typeof O.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var R=null;return O.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(R),R=setTimeout(function(){O.highlight(),R=null},O.options.interval)}),O.highlight(),O}return i(A,[{key:"highlight",value:function(){var q=this;if(!this.quill.selection.composing){this.quill.update(p.default.sources.USER);var O=this.quill.getSelection();this.quill.scroll.descendants(C).forEach(function(R){R.highlight(q.options.highlight)}),this.quill.update(p.default.sources.SILENT),O!=null&&this.quill.setSelection(O,p.default.sources.SILENT)}}}]),A})(x.default);D.DEFAULTS={highlight:(function(){return window.hljs==null?null:function(_){var A=window.hljs.highlightAuto(_);return A.value}})(),interval:1e3},r.CodeBlock=C,r.CodeToken=S,r.default=D}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=3 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=13 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=9 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=14 x2=4 y1=14 y2=14></line> <line class=ql-stroke x1=12 x2=6 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=5 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=9 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=15 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=15 x2=3 y1=14 y2=14></line> <line class=ql-stroke x1=15 x2=3 y1=4 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <g class="ql-fill ql-color-label"> <polygon points="6 6.868 6 6 5 6 5 7 5.942 7 6 6.868"></polygon> <rect height=1 width=1 x=4 y=4></rect> <polygon points="6.817 5 6 5 6 6 6.38 6 6.817 5"></polygon> <rect height=1 width=1 x=2 y=6></rect> <rect height=1 width=1 x=3 y=5></rect> <rect height=1 width=1 x=4 y=7></rect> <polygon points="4 11.439 4 11 3 11 3 12 3.755 12 4 11.439"></polygon> <rect height=1 width=1 x=2 y=12></rect> <rect height=1 width=1 x=2 y=9></rect> <rect height=1 width=1 x=2 y=15></rect> <polygon points="4.63 10 4 10 4 11 4.192 11 4.63 10"></polygon> <rect height=1 width=1 x=3 y=8></rect> <path d=M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z></path> <path d=M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z></path> <path d=M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z></path> <rect height=1 width=1 x=12 y=2></rect> <rect height=1 width=1 x=11 y=3></rect> <path d=M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z></path> <rect height=1 width=1 x=2 y=3></rect> <rect height=1 width=1 x=6 y=2></rect> <rect height=1 width=1 x=3 y=2></rect> <rect height=1 width=1 x=5 y=3></rect> <rect height=1 width=1 x=9 y=2></rect> <rect height=1 width=1 x=15 y=14></rect> <polygon points="13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174"></polygon> <rect height=1 width=1 x=13 y=7></rect> <rect height=1 width=1 x=15 y=5></rect> <rect height=1 width=1 x=14 y=6></rect> <rect height=1 width=1 x=15 y=8></rect> <rect height=1 width=1 x=14 y=9></rect> <path d=M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z></path> <rect height=1 width=1 x=14 y=3></rect> <polygon points="12 6.868 12 6 11.62 6 12 6.868"></polygon> <rect height=1 width=1 x=15 y=2></rect> <rect height=1 width=1 x=12 y=5></rect> <rect height=1 width=1 x=13 y=4></rect> <polygon points="12.933 9 13 9 13 8 12.495 8 12.933 9"></polygon> <rect height=1 width=1 x=9 y=14></rect> <rect height=1 width=1 x=8 y=15></rect> <path d=M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z></path> <rect height=1 width=1 x=5 y=15></rect> <path d=M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z></path> <rect height=1 width=1 x=11 y=15></rect> <path d=M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z></path> <rect height=1 width=1 x=14 y=15></rect> <rect height=1 width=1 x=15 y=11></rect> </g> <polyline class=ql-stroke points="5.5 13 9 5 12.5 13"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=11 y2=11></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <rect class="ql-fill ql-stroke" height=3 width=3 x=4 y=5></rect> <rect class="ql-fill ql-stroke" height=3 width=3 x=11 y=5></rect> <path class="ql-even ql-fill ql-stroke" d=M7,8c0,4.031-3,5-3,5></path> <path class="ql-even ql-fill ql-stroke" d=M14,8c0,4.031-3,5-3,5></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-stroke d=M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z></path> <path class=ql-stroke d=M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z></path> </svg>'}),(function(n,r){n.exports='<svg class="" viewbox="0 0 18 18"> <line class=ql-stroke x1=5 x2=13 y1=3 y2=3></line> <line class=ql-stroke x1=6 x2=9.35 y1=12 y2=3></line> <line class=ql-stroke x1=11 x2=15 y1=11 y2=15></line> <line class=ql-stroke x1=15 x2=11 y1=11 y2=15></line> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=7 x=2 y=14></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class="ql-color-label ql-stroke ql-transparent" x1=3 x2=15 y1=15 y2=15></line> <polyline class=ql-stroke points="5.5 11 9 3 12.5 11"></polyline> <line class=ql-stroke x1=11.63 x2=6.38 y1=9 y2=9></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polygon class="ql-stroke ql-fill" points="3 11 5 9 3 7 3 11"></polygon> <line class="ql-stroke ql-fill" x1=15 x2=11 y1=4 y2=4></line> <path class=ql-fill d=M11,3a3,3,0,0,0,0,6h1V3H11Z></path> <rect class=ql-fill height=11 width=1 x=11 y=4></rect> <rect class=ql-fill height=11 width=1 x=13 y=4></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polygon class="ql-stroke ql-fill" points="15 12 13 10 15 8 15 12"></polygon> <line class="ql-stroke ql-fill" x1=9 x2=5 y1=4 y2=4></line> <path class=ql-fill d=M5,3A3,3,0,0,0,5,9H6V3H5Z></path> <rect class=ql-fill height=11 width=1 x=5 y=4></rect> <rect class=ql-fill height=11 width=1 x=7 y=4></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M14,16H4a1,1,0,0,1,0-2H14A1,1,0,0,1,14,16Z /> <path class=ql-fill d=M14,4H4A1,1,0,0,1,4,2H14A1,1,0,0,1,14,4Z /> <rect class=ql-fill x=3 y=6 width=12 height=6 rx=1 ry=1 /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M13,16H5a1,1,0,0,1,0-2h8A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H5A1,1,0,0,1,5,2h8A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=2 y=6 width=14 height=6 rx=1 ry=1 /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M15,8H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,8Z /> <path class=ql-fill d=M15,12H13a1,1,0,0,1,0-2h2A1,1,0,0,1,15,12Z /> <path class=ql-fill d=M15,16H5a1,1,0,0,1,0-2H15A1,1,0,0,1,15,16Z /> <path class=ql-fill d=M15,4H5A1,1,0,0,1,5,2H15A1,1,0,0,1,15,4Z /> <rect class=ql-fill x=2 y=6 width=8 height=6 rx=1 ry=1 /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M5,8H3A1,1,0,0,1,3,6H5A1,1,0,0,1,5,8Z /> <path class=ql-fill d=M5,12H3a1,1,0,0,1,0-2H5A1,1,0,0,1,5,12Z /> <path class=ql-fill d=M13,16H3a1,1,0,0,1,0-2H13A1,1,0,0,1,13,16Z /> <path class=ql-fill d=M13,4H3A1,1,0,0,1,3,2H13A1,1,0,0,1,13,4Z /> <rect class=ql-fill x=8 y=6 width=8 height=6 rx=1 ry=1 transform="translate(24 18) rotate(-180)"/> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z></path> <rect class=ql-fill height=1.6 rx=0.8 ry=0.8 width=5 x=5.15 y=6.2></rect> <path class=ql-fill d=M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z></path> </svg>'}),(function(n,r){n.exports='<svg viewBox="0 0 18 18"> <path class=ql-fill d=M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z /> </svg>'}),(function(n,r){n.exports='<svg viewBox="0 0 18 18"> <path class=ql-fill d=M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=7 x2=13 y1=4 y2=4></line> <line class=ql-stroke x1=5 x2=11 y1=14 y2=14></line> <line class=ql-stroke x1=8 x2=10 y1=14 y2=4></line> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <rect class=ql-stroke height=10 width=12 x=3 y=4></rect> <circle class=ql-fill cx=6 cy=7 r=1></circle> <polyline class="ql-even ql-fill" points="5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class="ql-fill ql-stroke" points="3 7 3 11 5 9 3 7"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=3 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points="5 7 5 11 3 9 5 7"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=7 x2=11 y1=7 y2=11></line> <path class="ql-even ql-stroke" d=M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z></path> <path class="ql-even ql-stroke" d=M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=7 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=7 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=7 x2=15 y1=14 y2=14></line> <line class="ql-stroke ql-thin" x1=2.5 x2=4.5 y1=5.5 y2=5.5></line> <path class=ql-fill d=M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z></path> <path class="ql-stroke ql-thin" d=M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156></path> <path class="ql-stroke ql-thin" d=M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class=ql-stroke x1=6 x2=15 y1=4 y2=4></line> <line class=ql-stroke x1=6 x2=15 y1=9 y2=9></line> <line class=ql-stroke x1=6 x2=15 y1=14 y2=14></line> <line class=ql-stroke x1=3 x2=3 y1=4 y2=4></line> <line class=ql-stroke x1=3 x2=3 y1=9 y2=9></line> <line class=ql-stroke x1=3 x2=3 y1=14 y2=14></line> </svg>'}),(function(n,r){n.exports='<svg class="" viewbox="0 0 18 18"> <line class=ql-stroke x1=9 x2=15 y1=4 y2=4></line> <polyline class=ql-stroke points="3 4 4 5 6 3"></polyline> <line class=ql-stroke x1=9 x2=15 y1=14 y2=14></line> <polyline class=ql-stroke points="3 14 4 15 6 13"></polyline> <line class=ql-stroke x1=9 x2=15 y1=9 y2=9></line> <polyline class=ql-stroke points="3 9 4 10 6 8"></polyline> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z /> <path class=ql-fill d=M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-fill d=M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z /> <path class=ql-fill d=M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z /> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <line class="ql-stroke ql-thin" x1=15.5 x2=2.5 y1=8.5 y2=9.5></line> <path class=ql-fill d=M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z></path> <path class=ql-fill d=M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z></path> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <path class=ql-stroke d=M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3></path> <rect class=ql-fill height=1 rx=0.5 ry=0.5 width=12 x=3 y=15></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <rect class=ql-stroke height=12 width=12 x=3 y=3></rect> <rect class=ql-fill height=12 width=1 x=5 y=3></rect> <rect class=ql-fill height=12 width=1 x=12 y=3></rect> <rect class=ql-fill height=2 width=8 x=5 y=8></rect> <rect class=ql-fill height=1 width=3 x=3 y=5></rect> <rect class=ql-fill height=1 width=3 x=3 y=7></rect> <rect class=ql-fill height=1 width=3 x=3 y=10></rect> <rect class=ql-fill height=1 width=3 x=3 y=12></rect> <rect class=ql-fill height=1 width=3 x=12 y=5></rect> <rect class=ql-fill height=1 width=3 x=12 y=7></rect> <rect class=ql-fill height=1 width=3 x=12 y=10></rect> <rect class=ql-fill height=1 width=3 x=12 y=12></rect> </svg>'}),(function(n,r){n.exports='<svg viewbox="0 0 18 18"> <polygon class=ql-stroke points="7 11 9 13 11 11 7 11"></polygon> <polygon class=ql-stroke points="7 7 9 5 11 7 7 7"></polygon> </svg>'}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BubbleTooltip=void 0;var i=function A(E,q,O){E===null&&(E=Function.prototype);var R=Object.getOwnPropertyDescriptor(E,q);if(R===void 0){var P=Object.getPrototypeOf(E);return P===null?void 0:A(P,q,O)}else{if("value"in R)return R.value;var L=R.get;return L===void 0?void 0:L.call(O)}},o=(function(){function A(E,q){for(var O=0;O<q.length;O++){var R=q[O];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(E,R.key,R)}}return function(E,q,O){return q&&A(E.prototype,q),O&&A(E,O),E}})(),d=a(3),m=w(d),f=a(8),p=w(f),h=a(43),x=w(h),u=a(15),N=a(41),v=w(N);function w(A){return A&&A.__esModule?A:{default:A}}function j(A,E){if(!(A instanceof E))throw new TypeError("Cannot call a class as a function")}function b(A,E){if(!A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:A}function C(A,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);A.prototype=Object.create(E&&E.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(A,E):A.__proto__=E)}var S=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],D=(function(A){C(E,A);function E(q,O){j(this,E),O.modules.toolbar!=null&&O.modules.toolbar.container==null&&(O.modules.toolbar.container=S);var R=b(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,q,O));return R.quill.container.classList.add("ql-bubble"),R}return o(E,[{key:"extendToolbar",value:function(O){this.tooltip=new _(this.quill,this.options.bounds),this.tooltip.root.appendChild(O.container),this.buildButtons([].slice.call(O.container.querySelectorAll("button")),v.default),this.buildPickers([].slice.call(O.container.querySelectorAll("select")),v.default)}}]),E})(x.default);D.DEFAULTS=(0,m.default)(!0,{},x.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(E){E?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});var _=(function(A){C(E,A);function E(q,O){j(this,E);var R=b(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,q,O));return R.quill.on(p.default.events.EDITOR_CHANGE,function(P,L,$,Z){if(P===p.default.events.SELECTION_CHANGE)if(L!=null&&L.length>0&&Z===p.default.sources.USER){R.show(),R.root.style.left="0px",R.root.style.width="",R.root.style.width=R.root.offsetWidth+"px";var Q=R.quill.getLines(L.index,L.length);if(Q.length===1)R.position(R.quill.getBounds(L));else{var W=Q[Q.length-1],U=R.quill.getIndex(W),M=Math.min(W.length()-1,L.index+L.length-U),z=R.quill.getBounds(new u.Range(U,M));R.position(z)}}else document.activeElement!==R.textbox&&R.quill.hasFocus()&&R.hide()}),R}return o(E,[{key:"listen",value:function(){var O=this;i(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){O.root.classList.remove("ql-editing")}),this.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!O.root.classList.contains("ql-hidden")){var R=O.quill.getSelection();R!=null&&O.position(O.quill.getBounds(R))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(O){var R=i(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"position",this).call(this,O),P=this.root.querySelector(".ql-tooltip-arrow");if(P.style.marginLeft="",R===0)return R;P.style.marginLeft=-1*R-P.offsetWidth/2+"px"}}]),E})(h.BaseTooltip);_.TEMPLATE=['<span class="ql-tooltip-arrow"></span>','<div class="ql-tooltip-editor">','<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">','<a class="ql-close"></a>',"</div>"].join(""),r.BubbleTooltip=_,r.default=D}),(function(n,r,a){n.exports=a(63)})]).default})})(Wm)),Wm.exports}var ti,w2;function mG(){if(w2)return ti;w2=1;var t=ti&&ti.__extends||(function(){var p=function(h,x){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,N){u.__proto__=N}||function(u,N){for(var v in N)N.hasOwnProperty(v)&&(u[v]=N[v])},p(h,x)};return function(h,x){p(h,x);function u(){this.constructor=h}h.prototype=x===null?Object.create(x):(u.prototype=x.prototype,new u)}})(),s=ti&&ti.__assign||function(){return s=Object.assign||function(p){for(var h,x=1,u=arguments.length;x<u;x++){h=arguments[x];for(var N in h)Object.prototype.hasOwnProperty.call(h,N)&&(p[N]=h[N])}return p},s.apply(this,arguments)},n=ti&&ti.__spreadArrays||function(){for(var p=0,h=0,x=arguments.length;h<x;h++)p+=arguments[h].length;for(var u=Array(p),N=0,h=0;h<x;h++)for(var v=arguments[h],w=0,j=v.length;w<j;w++,N++)u[N]=v[w];return u},r=ti&&ti.__importDefault||function(p){return p&&p.__esModule?p:{default:p}},a=r(fd()),i=r(Oy()),o=r(dG()),d=r(hG()),m=(function(p){t(h,p);function h(x){var u=p.call(this,x)||this;u.dirtyProps=["modules","formats","bounds","theme","children"],u.cleanProps=["id","className","style","placeholder","tabIndex","onChange","onChangeSelection","onFocus","onBlur","onKeyPress","onKeyDown","onKeyUp"],u.state={generation:0},u.selection=null,u.onEditorChange=function(v,w,j,b){var C,S,D,_;v==="text-change"?(S=(C=u).onEditorChangeText)===null||S===void 0||S.call(C,u.editor.root.innerHTML,w,b,u.unprivilegedEditor):v==="selection-change"&&((_=(D=u).onEditorChangeSelection)===null||_===void 0||_.call(D,w,b,u.unprivilegedEditor))};var N=u.isControlled()?x.value:x.defaultValue;return u.value=N??"",u}return h.prototype.validateProps=function(x){var u;if(a.default.Children.count(x.children)>1)throw new Error("The Quill editing area can only be composed of a single React element.");if(a.default.Children.count(x.children)){var N=a.default.Children.only(x.children);if(((u=N)===null||u===void 0?void 0:u.type)==="textarea")throw new Error("Quill does not support editing on a <textarea>. Use a <div> instead.")}if(this.lastDeltaChangeSet&&x.value===this.lastDeltaChangeSet)throw new Error("You are passing the `delta` object from the `onChange` event back as `value`. You most probably want `editor.getContents()` instead. See: https://github.com/zenoamaro/react-quill#using-deltas")},h.prototype.shouldComponentUpdate=function(x,u){var N=this,v;if(this.validateProps(x),!this.editor||this.state.generation!==u.generation)return!0;if("value"in x){var w=this.getEditorContents(),j=(v=x.value,v??"");this.isEqualValue(j,w)||this.setEditorContents(this.editor,j)}return x.readOnly!==this.props.readOnly&&this.setEditorReadOnly(this.editor,x.readOnly),n(this.cleanProps,this.dirtyProps).some(function(b){return!o.default(x[b],N.props[b])})},h.prototype.shouldComponentRegenerate=function(x){var u=this;return this.dirtyProps.some(function(N){return!o.default(x[N],u.props[N])})},h.prototype.componentDidMount=function(){this.instantiateEditor(),this.setEditorContents(this.editor,this.getEditorContents())},h.prototype.componentWillUnmount=function(){this.destroyEditor()},h.prototype.componentDidUpdate=function(x,u){var N=this;if(this.editor&&this.shouldComponentRegenerate(x)){var v=this.editor.getContents(),w=this.editor.getSelection();this.regenerationSnapshot={delta:v,selection:w},this.setState({generation:this.state.generation+1}),this.destroyEditor()}if(this.state.generation!==u.generation){var j=this.regenerationSnapshot,v=j.delta,b=j.selection;delete this.regenerationSnapshot,this.instantiateEditor();var C=this.editor;C.setContents(v),f(function(){return N.setEditorSelection(C,b)})}},h.prototype.instantiateEditor=function(){this.editor?this.hookEditor(this.editor):this.editor=this.createEditor(this.getEditingArea(),this.getEditorConfig())},h.prototype.destroyEditor=function(){this.editor&&this.unhookEditor(this.editor)},h.prototype.isControlled=function(){return"value"in this.props},h.prototype.getEditorConfig=function(){return{bounds:this.props.bounds,formats:this.props.formats,modules:this.props.modules,placeholder:this.props.placeholder,readOnly:this.props.readOnly,scrollingContainer:this.props.scrollingContainer,tabIndex:this.props.tabIndex,theme:this.props.theme}},h.prototype.getEditor=function(){if(!this.editor)throw new Error("Accessing non-instantiated editor");return this.editor},h.prototype.createEditor=function(x,u){var N=new d.default(x,u);return u.tabIndex!=null&&this.setEditorTabIndex(N,u.tabIndex),this.hookEditor(N),N},h.prototype.hookEditor=function(x){this.unprivilegedEditor=this.makeUnprivilegedEditor(x),x.on("editor-change",this.onEditorChange)},h.prototype.unhookEditor=function(x){x.off("editor-change",this.onEditorChange)},h.prototype.getEditorContents=function(){return this.value},h.prototype.getEditorSelection=function(){return this.selection},h.prototype.isDelta=function(x){return x&&x.ops},h.prototype.isEqualValue=function(x,u){return this.isDelta(x)&&this.isDelta(u)?o.default(x.ops,u.ops):o.default(x,u)},h.prototype.setEditorContents=function(x,u){var N=this;this.value=u;var v=this.getEditorSelection();typeof u=="string"?x.setContents(x.clipboard.convert(u)):x.setContents(u),f(function(){return N.setEditorSelection(x,v)})},h.prototype.setEditorSelection=function(x,u){if(this.selection=u,u){var N=x.getLength();u.index=Math.max(0,Math.min(u.index,N-1)),u.length=Math.max(0,Math.min(u.length,N-1-u.index)),x.setSelection(u)}},h.prototype.setEditorTabIndex=function(x,u){var N,v;!((v=(N=x)===null||N===void 0?void 0:N.scroll)===null||v===void 0)&&v.domNode&&(x.scroll.domNode.tabIndex=u)},h.prototype.setEditorReadOnly=function(x,u){u?x.disable():x.enable()},h.prototype.makeUnprivilegedEditor=function(x){var u=x;return{getHTML:function(){return u.root.innerHTML},getLength:u.getLength.bind(u),getText:u.getText.bind(u),getContents:u.getContents.bind(u),getSelection:u.getSelection.bind(u),getBounds:u.getBounds.bind(u)}},h.prototype.getEditingArea=function(){if(!this.editingArea)throw new Error("Instantiating on missing editing area");var x=i.default.findDOMNode(this.editingArea);if(!x)throw new Error("Cannot find element for editing area");if(x.nodeType===3)throw new Error("Editing area cannot be a text node");return x},h.prototype.renderEditingArea=function(){var x=this,u=this.props,N=u.children,v=u.preserveWhitespace,w=this.state.generation,j={key:w,ref:function(b){x.editingArea=b}};return a.default.Children.count(N)?a.default.cloneElement(a.default.Children.only(N),j):v?a.default.createElement("pre",s({},j)):a.default.createElement("div",s({},j))},h.prototype.render=function(){var x;return a.default.createElement("div",{id:this.props.id,style:this.props.style,key:this.state.generation,className:"quill "+(x=this.props.className,x??""),onKeyPress:this.props.onKeyPress,onKeyDown:this.props.onKeyDown,onKeyUp:this.props.onKeyUp},this.renderEditingArea())},h.prototype.onEditorChangeText=function(x,u,N,v){var w,j;if(this.editor){var b=this.isDelta(this.value)?v.getContents():v.getHTML();b!==this.getEditorContents()&&(this.lastDeltaChangeSet=u,this.value=b,(j=(w=this.props).onChange)===null||j===void 0||j.call(w,x,u,N,v))}},h.prototype.onEditorChangeSelection=function(x,u,N){var v,w,j,b,C,S;if(this.editor){var D=this.getEditorSelection(),_=!D&&x,A=D&&!x;o.default(x,D)||(this.selection=x,(w=(v=this.props).onChangeSelection)===null||w===void 0||w.call(v,x,u,N),_?(b=(j=this.props).onFocus)===null||b===void 0||b.call(j,x,u,N):A&&((S=(C=this.props).onBlur)===null||S===void 0||S.call(C,D,u,N)))}},h.prototype.focus=function(){this.editor&&this.editor.focus()},h.prototype.blur=function(){this.editor&&(this.selection=null,this.editor.blur())},h.displayName="React Quill",h.Quill=d.default,h.defaultProps={theme:"snow",modules:{},readOnly:!1},h})(a.default.Component);function f(p){Promise.resolve().then(p)}return ti=m,ti}var fG=mG();const pG=Nf(fG),xG={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"}],["link"],["blockquote"],["clean"]]},gG=["header","bold","italic","underline","list","bullet","link","blockquote"];function Gm(t){const s=t||"";return/\{\{\s*[>#\/]/.test(s)||/\{\{>\s*\w+/.test(s)||/<!DOCTYPE/i.test(s)||/<html[\s>]/i.test(s)||/<\/html>/i.test(s)||/<style\b/i.test(s)||/<head[\s>]/i.test(s)}const G_=g.forwardRef(({value:t,onChange:s,tab:n,onTabChange:r,textareaRef:a},i)=>{const o=g.useRef(null),d=g.useMemo(()=>Gm(t),[t]);return g.useImperativeHandle(i,()=>({insertPlaceholder:m=>{var u,N;const f=`{{${m}}}`;if(n==="html"&&a.current){const v=a.current,w=v.selectionStart??0,j=v.selectionEnd??0,b=t.slice(0,w)+f+t.slice(j);s(b),requestAnimationFrame(()=>{v.focus();const C=w+f.length;v.setSelectionRange(C,C)});return}const p=(N=(u=o.current)==null?void 0:u.getEditor)==null?void 0:N.call(u);if(!p)return;const h=p.getSelection(!0),x=(h==null?void 0:h.index)??p.getLength();p.insertText(x,f,"user")}})),e.jsx("div",{className:"flex flex-col gap-2 flex-1 min-h-0",children:e.jsxs(In,{value:n,onValueChange:r,className:"flex flex-col flex-1 gap-2 min-h-0",children:[e.jsxs(Mn,{className:"w-fit",children:[e.jsx(Ht,{value:"visual",disabled:d,className:"text-xs",children:"Rich text"}),e.jsx(Ht,{value:"html",className:"text-xs font-mono",children:"HTML source"})]}),d&&e.jsxs(Ai,{className:"border-red-200 bg-red-50 py-2",children:[e.jsx(qa,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(ki,{className:"text-[11px] text-red-900",children:["This template uses layout partials (",e.jsx("code",{className:"font-mono",children:"{{> ...}}"}),"), block helpers, or a full HTML document. Edit it in ",e.jsx("strong",{children:"HTML source"})," so nothing is stripped. Use placeholders on the left to insert fields safely."]})]}),e.jsxs(Vt,{value:"visual",className:"flex-1 flex flex-col gap-2 mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx("div",{className:Nt("email-quill rounded-md border border-slate-200 bg-white overflow-hidden flex flex-col flex-1","[&_.ql-toolbar]:border-slate-200 [&_.ql-toolbar]:bg-slate-50","[&_.ql-container]:border-0 [&_.ql-editor]:min-h-[380px] [&_.ql-editor]:text-sm [&_.ql-editor]:text-slate-900"),children:e.jsx(pG,{ref:o,theme:"snow",value:t||"",onChange:s,modules:xG,formats:gG})}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:["Use headings, lists, and links. Insert dynamic fields from ",e.jsx("strong",{children:"Available Placeholders"})," on the left."]})]}),e.jsxs(Vt,{value:"html",className:"flex-1 flex flex-col mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx(Ks,{ref:a,placeholder:"Raw HTML / Handlebars — use for partials {{> ...}} or full layouts",className:"flex-1 min-h-[420px] font-mono text-xs text-slate-900 bg-slate-900/5 focus:bg-white p-4 resize-y",value:t||"",onChange:m=>s(m.target.value),spellCheck:!1}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["Full control for ",e.jsx("code",{className:"font-mono",children:"{{> email_header}}"}),", styles, and edge cases. Backend still sanitizes on save."]})]})]})})});G_.displayName="EmailTemplateBodyEditor";function vG(t){const s=/\{\{\{[\s\S]*?\}\}\}|\{\{[\s\S]*?\}\}/g;return t.replace(s,n=>n.replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&"))}const yG=/\{\{\s*>\s*email_header\s*\}\}/i,bG=/\{\{\s*>\s*email_footer\s*\}\}/i,jG=/\{\{\s*>\s*primary_cta\s*\}\}/i,NG=/^[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_header\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*/i,wG=/[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_footer\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*$/i,SG=/(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*primary_cta\s*\}\}\s*(?:<\/(?:p|div)>)?/gi;function CG(t){const s=t||"",n=vG(s);if(!yG.test(n)||!bG.test(n))return{isShellTemplate:!1,editableHtml:s,includesCta:!1};const r=jG.test(n);let a=n.replace(NG,"").replace(wG,"").replace(SG,"");return a=a.trim(),{isShellTemplate:!0,editableHtml:a,includesCta:r}}function AG(t,s){return`{{> email_header}}
|
||
${(t||"").trim()}${s?`
|
||
{{> primary_cta}}
|
||
`:`
|
||
`}{{> email_footer}}`}const kG=({isOpen:t,onOpenChange:s,editingTemplate:n,setEditingTemplate:r,testDataInput:a,setTestDataInput:i,previewLoading:o,handlePreviewTemplate:d,previewContent:m,handleSaveTemplate:f})=>{var q;const p=Ct.useRef(null),h=Ct.useRef(null),[x,u]=Ct.useState("visual"),[N,v]=Ct.useState(""),[w,j]=Ct.useState(!1),[b,C]=Ct.useState(!1);Ct.useEffect(()=>{if(!t||!n)return;const O=CG(n.body||"");j(O.isShellTemplate),C(O.includesCta);const R=O.isShellTemplate?O.editableHtml:n.body||"";v(R);const P=Gm(R);u(P?"html":"visual")},[t,n==null?void 0:n.id,n==null?void 0:n.body]);const S=Ct.useCallback(()=>w?AG(N,b):(n==null?void 0:n.body)||"",[w,N,b,n==null?void 0:n.body]),D=O=>{var R;(R=h.current)==null||R.insertPlaceholder(O)},_=(n==null?void 0:n.placeholders)||[],A=w?N:(n==null?void 0:n.body)||"",E=O=>{w?(v(O),Gm(O)&&u("html")):(r({...n,body:O}),Gm(O)&&u("html"))};return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"sm:max-w-7xl w-full max-h-[95vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Edit Email Template"}),e.jsx(ws,{children:"Trigger codes are fixed by system seeding. Edit subject and message content below."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8",children:[e.jsx("div",{className:"lg:col-span-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-slate-50 p-4 rounded-lg border border-slate-200 space-y-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-slate-800 flex items-center gap-2",children:[e.jsx(Qc,{className:"w-4 h-4 text-re-red"}),"General Settings"]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Template Name"}),e.jsx(it,{placeholder:"e.g., Application Received",className:"mt-1.5 bg-white",value:(n==null?void 0:n.name)||"",onChange:O=>r({...n,name:O.target.value})})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Trigger Code"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 mb-1",children:"Defined when the template row is seeded; it cannot be changed here."}),e.jsx("div",{className:"mt-1.5 flex items-center",children:e.jsx(we,{variant:"outline",className:"bg-white font-mono text-xs px-3 py-1.5",children:(n==null?void 0:n.templateCode)||"—"})})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Description"}),e.jsx(it,{placeholder:"Brief purpose of this email",className:"mt-1.5 bg-white",value:(n==null?void 0:n.description)||"",onChange:O=>r({...n,description:O.target.value})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t mt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(yp,{id:"active",checked:(n==null?void 0:n.isActive)??!0,onCheckedChange:O=>r({...n,isActive:O})}),e.jsx(le,{htmlFor:"active",className:"text-sm cursor-pointer",children:"Active"})]}),e.jsx(we,{className:n!=null&&n.isActive?"bg-green-100 text-green-700":"bg-slate-100 text-slate-500",children:n!=null&&n.isActive?"Template Enabled":"Template Disabled"})]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-lg border border-red-100",children:[e.jsxs("h3",{className:"text-sm font-semibold text-red-900 flex items-center gap-2 mb-3",children:[e.jsx(qa,{className:"w-4 h-4"}),"Available Placeholders"]}),e.jsx("p",{className:"text-[10px] text-re-red-hover mb-4 leading-relaxed",children:"Click a placeholder to insert it at the cursor."}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.length>0?_.map(O=>e.jsx("button",{type:"button",onClick:()=>D(O),className:"px-2 py-1 bg-white border border-red-200 rounded text-[11px] font-mono text-red-800 hover:bg-re-red hover:text-white hover:border-re-red transition-all flex items-center gap-1 shadow-sm",children:`{{${O}}}`},O)):e.jsx("div",{className:"w-full py-4 text-center border-2 border-dashed border-red-200 rounded-lg",children:e.jsx("p",{className:"text-[10px] text-re-red",children:"No placeholders defined for this trigger"})})})]})]})}),e.jsxs("div",{className:"lg:col-span-4 space-y-4 flex flex-col h-full min-h-[600px]",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(gr,{className:"w-4 h-4 text-re-red"}),"Template Designer"]})}),e.jsxs("div",{className:"flex-1 flex flex-col space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-xs font-semibold",children:"Subject Line"}),e.jsx(it,{placeholder:"Subject line with {{variables}}",className:"mt-1.5 text-slate-900 font-medium",value:(n==null?void 0:n.subject)||"",onChange:O=>r({...n,subject:O.target.value})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-[480px]",children:[e.jsx(le,{className:"text-xs font-semibold mb-1.5",children:"Email Body"}),e.jsx(G_,{ref:h,tab:x,onTabChange:O=>u(O),textareaRef:p,value:A,onChange:E})]})]})]}),e.jsxs("div",{className:"lg:col-span-4 space-y-6 lg:border-l lg:pl-8 flex flex-col h-full",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-slate-900 flex items-center gap-2 mb-4",children:[e.jsx(pg,{className:"w-4 h-4 text-green-600"}),"Live Simulation"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx(le,{className:"text-xs font-semibold",children:"Mock Test Data (JSON)"}),e.jsx("button",{type:"button",onClick:()=>i('{"applicantName": "Rajesh Kumar", "location": "Mumbai South", "applicationId": "APP-2026-X12", "link": "https://example.com/app", "portalLink": "https://example.com/app"}'),className:"text-[10px] text-re-red hover:underline",children:"Reset to Sample"})]}),e.jsx(Ks,{placeholder:'{"applicant_name": "John Doe"}',className:"font-mono text-[11px] text-slate-900 bg-slate-50",rows:6,value:a,onChange:O=>i(O.target.value)})]}),e.jsxs(te,{variant:"default",type:"button",className:"w-full bg-green-600 hover:bg-green-700 shadow-md",onClick:()=>d(S()),disabled:o,children:[o?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(pg,{className:"w-4 h-4 mr-2"}),"Generate Mock Preview"]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx(le,{className:"text-xs font-semibold mb-2",children:"Simulated Output"}),e.jsx("div",{className:"flex-1 border rounded-xl overflow-hidden flex flex-col bg-slate-50 shadow-inner",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white p-3 border-b text-[11px] font-semibold text-slate-700 flex items-center justify-between",children:[e.jsxs("div",{className:"truncate shrink",children:[e.jsx("span",{className:"text-slate-400 mr-2",children:"Subject:"})," ",m.subject]}),e.jsxs(we,{variant:"outline",className:"bg-green-50 text-green-600 text-[9px] whitespace-nowrap ml-2",children:[e.jsx(Hn,{className:"w-3 h-3 mr-1"})," Compiled"]})]}),e.jsx("div",{className:"p-6 bg-white overflow-auto flex-1 shadow-sm",children:e.jsx("div",{className:"max-w-none text-sm text-slate-800 email-preview-container",dangerouslySetInnerHTML:{__html:m.html}})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center text-slate-400 space-y-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(pg,{className:"w-8 h-8 opacity-20"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Ready for Preview"}),e.jsx("p",{className:"text-[11px]",children:'Click "Generate Mock Preview" to see the rendered email.'})]})]})})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t mt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover",type:"button",onClick:()=>f(S()),disabled:!(n!=null&&n.id)||!((q=n==null?void 0:n.templateCode)!=null&&q.trim()),children:"Save Template"})]})]})})},DG=({isOpen:t,onOpenChange:s,editingLocationId:n,locationState:r,setLocationState:a,locationDistrict:i,setLocationDistrict:o,locationCity:d,setLocationCity:m,locationActiveFrom:f,setLocationActiveFrom:p,locationActiveTo:h,setLocationActiveTo:x,locationStatus:u,setLocationStatus:N,allStates:v,allDistricts:w,onSave:j})=>{const b=Ct.useMemo(()=>r?(w||[]).filter(C=>C.stateId===r):[],[w,r]);return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:n?"Edit Location":"Add Location"}),e.jsx(ws,{children:n?"Modify dealership location details":"Add a new dealership location (Area/City)"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"State"}),e.jsxs(Rt,{value:r,onValueChange:C=>{a(C),o("")},children:[e.jsx(_t,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(Et,{placeholder:"Select state"})}),e.jsx(Tt,{children:(v||[]).map(C=>e.jsx(Pe,{value:C.id,children:C.name||C.stateName},C.id))})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"City"}),e.jsx(it,{placeholder:"Enter city name",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-red-500/30 focus-visible:border-red-500",value:d,onChange:C=>m(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"District"}),e.jsxs(Rt,{value:i,onValueChange:o,disabled:!r,children:[e.jsx(_t,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(Et,{placeholder:r?"Select district":"Select state first"})}),e.jsx(Tt,{children:b.map(C=>e.jsx(Pe,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"border rounded-lg p-4 bg-gradient-to-br from-blue-50 to-cyan-50 border-blue-200",children:[e.jsx(le,{className:"items-center gap-2 text-sm leading-none font-medium text-blue-900 mb-3 block",children:"Active Period"}),e.jsx("p",{className:"text-xs text-blue-700 mb-3",children:"Define the time period when this location will be available for dealership applications"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(le,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Start Date"}),e.jsx(it,{type:"date",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-blue-500/30 focus-visible:border-blue-500",value:f,onChange:C=>p(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(le,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"End Date"}),e.jsx(it,{type:"date",className:"mt-2 text-slate-900 border-slate-200 focus-visible:ring-blue-500/30 focus-visible:border-blue-500",value:h,onChange:C=>x(C.target.value)})]})]})]}),e.jsxs("div",{children:[e.jsx(le,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Opportunity"}),e.jsxs(Rt,{value:u,onValueChange:N,children:[e.jsx(_t,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(Et,{placeholder:"Is this an active Opportunity?"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"active",children:"Yes"}),e.jsx(Pe,{value:"inactive",children:"No"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(te,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(te,{className:"flex-1 bg-re-red hover:bg-re-red-hover text-white shadow-md hover:shadow-lg transition-all",onClick:j,children:"Save Location"})]})]})]})})},RG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState(null),o=async()=>{try{r(!0);const f=await $s.getSystemConfigs({category:"SECURITY_DEPOSIT"});f.success&&s(f.data)}catch(f){console.error("Fetch error:",f),J.error("Failed to load deposit configurations")}finally{r(!1)}};g.useEffect(()=>{o()},[]);const d=(f,p)=>{s(h=>h.map(x=>x.id===f?{...x,value:{...x.value,amount:parseInt(p)||0}}:x))},m=async f=>{try{i(f.id),(await $s.saveSystemConfig(f)).success&&J.success(`Configuration for ${f.key} updated successfully`)}catch{J.error("Failed to save configuration")}finally{i(null)}};return n?e.jsxs("div",{className:"flex flex-col items-center justify-center p-20 space-y-4",children:[e.jsx("div",{className:"w-10 h-10 border-4 border-re-red border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-slate-600 animate-pulse",children:"Loading settings..."})]}):e.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500 max-w-4xl",children:[e.jsxs(_e,{className:"border-none shadow-lg bg-white/80 backdrop-blur-md",children:[e.jsx(Xe,{className:"py-4 border-b bg-slate-50/50",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-red-100 flex items-center justify-center",children:e.jsx(Qc,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(st,{className:"text-lg font-bold text-slate-900",children:"Global Payment Settings"}),e.jsx(es,{className:"text-xs",children:"Configure base Security Deposit amounts for onboarding workflows."})]})]})}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"grid gap-3",children:t.map(f=>{var p;return e.jsxs("div",{className:"p-3 border rounded-xl bg-white hover:shadow-sm transition-shadow flex items-center justify-between border-slate-100",children:[e.jsxs("div",{className:"space-y-0.5 max-w-md",children:[e.jsxs("h4",{className:"font-bold text-slate-800 text-sm flex items-center gap-2",children:[f.key.replace(/_/g," "),e.jsx("span",{className:"text-[9px] bg-slate-100 text-slate-500 px-1.5 py-0.5 rounded-full uppercase tracking-wider",children:"Master"})]}),e.jsx("p",{className:"text-xs text-slate-500 leading-tight",children:f.description})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(le,{htmlFor:`amount-${f.id}`,className:"text-[10px] font-semibold text-slate-400 uppercase tracking-wider block",children:"Amount (INR)"}),e.jsxs("div",{className:"relative w-40",children:[e.jsx(ya,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-slate-400 font-bold"}),e.jsx(it,{id:`amount-${f.id}`,type:"number",className:"pl-8 h-9 text-base font-bold bg-slate-50/50 border-slate-200 focus:ring-red-500 focus:border-red-500 rounded-lg",value:((p=f.value)==null?void 0:p.amount)||"",onChange:h=>d(f.id,h.target.value)})]})]}),e.jsx("div",{className:"pt-4",children:e.jsx(te,{onClick:()=>m(f),disabled:a===f.id,className:"h-9 px-4 bg-re-red hover:bg-re-red-hover text-white rounded-lg shadow-md shadow-re-red/10 active:scale-95 transition-all flex items-center gap-1.5 group",children:a===f.id?e.jsx(or,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(dl,{className:"w-4 h-4 group-hover:scale-110 transition-transform"}),e.jsx("span",{className:"font-bold text-sm",children:"Update"})]})})})]})]},f.id)})}),t.length===0&&e.jsxs("div",{className:"text-center py-12 bg-slate-50/50 rounded-xl border border-dashed border-slate-200",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(Qc,{className:"w-6 h-6 text-slate-400"})}),e.jsx("p",{className:"text-slate-500 text-sm font-medium",children:"No configurations found."}),e.jsxs(te,{variant:"outline",className:"mt-4 rounded-lg h-9 text-xs",onClick:o,children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1.5"})," Reload"]})]})]})]}),e.jsxs("div",{className:"bg-red-50/50 rounded-xl p-4 border border-red-100/50 flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-red-100 flex items-center justify-center flex-shrink-0",children:e.jsx(Qc,{className:"w-4 h-4 text-re-red-hover"})}),e.jsxs("div",{children:[e.jsx("h5",{className:"font-bold text-red-900 text-sm",children:"Super Admin Notice"}),e.jsx("p",{className:"text-[11px] text-red-800/80 leading-snug",children:"Updates made here take immediate effect. These values define the default expected amounts for all current and future onboarding payments."})]})]})]})},EG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState(!1),[o,d]=g.useState(!1),[m,f]=g.useState(null),[p,h]=g.useState([]),[x,u]=g.useState({}),[N,v]=g.useState(!0),[w,j]=g.useState(""),[b,C]=g.useState(1),[S]=g.useState(10),[D,_]=g.useState(""),[A,E]=g.useState({total:0,pages:1}),q=g.useRef(!0),[O,R]=g.useState({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:""}),P=["DD-ZM","RBM","DD","ZBH","DD Lead","DD Head","NBH","DD Admin","Legal Admin","Super Admin","DD AM","FDD","DDL","Finance","Finance Admin","Dealer","ARCHITECTURE"];g.useEffect(()=>{(async()=>{var z;try{const T=await ps.getDocumentConfigMetadata();T&&(h(T.modules||[]),u(T.stages||{}),((z=T.modules)==null?void 0:z.length)>0&&(_(T.modules[0]),R(F=>({...F,module:T.modules[0]}))))}catch{J.error("Failed to load system metadata")}finally{v(!1)}})()},[]);const L=g.useCallback(async()=>{if(D){q.current?r(!0):i(!0);try{const M=await ps.getDocumentConfigs({search:w,page:b,limit:S,module:D,isAdminView:!0});M&&M.pagination?(s(M.data||[]),E(M.pagination)):Array.isArray(M)&&(s(M),E({total:M.length,pages:1}))}catch(M){console.error("Fetch Configs Error:",M),q.current||J.error("Failed to sync configuration database")}finally{r(!1),i(!1),q.current=!1}}},[w,b,S,D]);g.useEffect(()=>{const M=setTimeout(()=>{L()},300);return()=>clearTimeout(M)},[L]);const $=async()=>{try{m?(await ps.updateDocumentConfig(m.id,O),J.success("Configuration updated")):(await ps.createDocumentConfig(O),J.success("Configuration created")),d(!1),L()}catch{J.error("Failed to save configuration")}},Z=async M=>{if(window.confirm("Are you sure you want to delete this configuration?"))try{await ps.deleteDocumentConfig(M),J.success("Configuration deleted"),L()}catch{J.error("Failed to delete configuration")}},Q=()=>{f(null),R({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:D}),d(!0)},W=M=>{f(M),R({documentType:M.documentType,stageCode:M.stageCode,allowedRoles:M.allowedRoles||[],isMandatory:M.isMandatory,isActive:M.isActive,module:M.module||"ONBOARDING"}),d(!0)},U=M=>{R(z=>({...z,allowedRoles:z.allowedRoles.includes(M)?z.allowedRoles.filter(T=>T!==M):[...z.allowedRoles,M]}))};return N?e.jsxs("div",{className:"h-96 flex flex-col items-center justify-center gap-4",children:[e.jsx(ty,{className:"w-10 h-10 text-re-red animate-bounce"}),e.jsx("p",{className:"text-slate-500 font-bold uppercase tracking-widest text-xs",children:"Connecting to Governance Engine..."})]}):e.jsxs(_e,{className:"border-slate-200 shadow-sm overflow-hidden bg-white",children:[e.jsxs(Xe,{className:"bg-slate-50/80 border-b border-slate-200 py-4 relative",children:[a&&e.jsxs("div",{className:"absolute top-0 left-0 right-0 h-1 bg-red-100 overflow-hidden",children:[e.jsx("div",{className:"h-full bg-re-red animate-[loading_1.5s_infinite_linear]",style:{width:"30%",transformOrigin:"left"}}),e.jsx("style",{children:`
|
||
@keyframes loading {
|
||
0% { left: -30%; }
|
||
100% { left: 100%; }
|
||
}
|
||
`})]}),e.jsxs("div",{className:"flex flex-row items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white rounded-xl shadow-sm ring-1 ring-slate-200 text-re-red",children:e.jsx(UI,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx(st,{className:"text-lg font-bold text-slate-800",children:"Governance Matrix"}),e.jsx("p",{className:"text-[11px] text-slate-500 font-bold uppercase tracking-wider",children:"Baseline Document Rules (Synced from Backend)"})]})]}),e.jsxs(te,{onClick:Q,className:"bg-slate-900 hover:bg-black text-white rounded-xl h-9 px-4 flex gap-2 font-bold transition-all active:scale-95 shadow-md uppercase text-[10px]",children:[e.jsx(bn,{className:"w-4 h-4"})," Add Policy"]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-64",children:e.jsxs(Rt,{value:D,onValueChange:M=>{_(M),C(1)},children:[e.jsx(_t,{className:"h-10 rounded-xl bg-white border-slate-200 focus:ring-red-500 font-bold text-slate-700 shadow-sm",children:e.jsx(Et,{placeholder:"Target Module"})}),e.jsx(Tt,{className:"rounded-xl shadow-2xl border-none",children:p.map(M=>e.jsx(Pe,{value:M,className:"font-bold text-xs py-2.5 uppercase",children:M.replace(/_/g," ")},M))})]})}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{placeholder:"Search policies, stages or documents...",value:w,onChange:M=>{j(M.target.value),C(1)},className:"pl-10 h-10 rounded-xl bg-white border-slate-200 focus:ring-red-500 shadow-sm font-medium"})]})]})]}),e.jsxs(Oe,{className:"p-0 min-h-[400px] relative",children:[n?e.jsxs("div",{className:"absolute inset-0 z-10 bg-white/60 backdrop-blur-[1px] flex flex-col items-center justify-center gap-3",children:[e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("span",{className:"text-slate-500 text-sm font-bold animate-pulse",children:"Syncing Policies..."})]}):null,e.jsxs(Ms,{children:[e.jsx(Fs,{className:"bg-slate-50/50",children:e.jsxs(lt,{className:"border-none",children:[e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Policy Detail"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Process Stage"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Module"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Stakeholders"}),e.jsx(me,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Compliance Rules"}),e.jsx(me,{className:"text-right font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Action"})]})}),e.jsx(Bs,{children:!n&&t.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"h-96 text-center text-slate-500",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 opacity-40",children:[e.jsx(wa,{className:"w-12 h-12 mb-2"}),e.jsxs("p",{className:"font-bold text-xl",children:["No policies found for ",D]}),e.jsx("p",{className:"text-sm font-medium",children:"Try adjusting your filters or search term"})]})})}):t.map(M=>{var z,T;return e.jsxs(lt,{className:"hover:bg-slate-50/80 transition-colors group h-14",children:[e.jsx(oe,{children:e.jsx("div",{className:"font-bold text-slate-900 group-hover:text-re-red-hover transition-colors uppercase text-[12px]",children:M.documentType})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"bg-blue-50/50 border-blue-100 text-blue-700 font-bold px-2 py-0.5 whitespace-nowrap text-[10px] rounded-md uppercase",children:M.stageCode})}),e.jsx(oe,{children:e.jsx("div",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-tighter",children:(z=M.module)==null?void 0:z.replace(/_/g," ")})}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:((T=M.allowedRoles)==null?void 0:T.length)>0?e.jsxs(e.Fragment,{children:[M.allowedRoles.slice(0,2).map(F=>e.jsx(we,{variant:"secondary",className:"bg-white text-slate-600 text-[9px] border-slate-200 font-bold uppercase",children:F},F)),M.allowedRoles.length>2&&e.jsxs(we,{variant:"outline",className:"text-[9px] text-slate-400 font-bold border-dashed",children:["+",M.allowedRoles.length-2]})]}):e.jsx(we,{variant:"secondary",className:"bg-slate-50 text-slate-400 text-[9px] border-slate-100 uppercase",children:"Inherited"})})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex gap-2",children:[M.isMandatory&&e.jsx(we,{className:"bg-re-red text-white border-transparent text-[10px] font-bold h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"BLOCKING"}),!M.isActive&&e.jsx(we,{className:"bg-slate-200 text-slate-500 border-transparent text-[10px] h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"DORMANT"}),M.isActive&&!M.isMandatory&&e.jsx(we,{className:"bg-emerald-100 text-emerald-700 border-emerald-200 text-[10px] h-5 px-1.5 rounded-sm font-black uppercase tracking-tighter",children:"OPTIONAL"})]})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(te,{variant:"ghost",size:"icon",onClick:()=>W(M),className:"h-8 w-8 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition-transform active:scale-90",children:e.jsx(gr,{className:"w-4 h-4"})}),e.jsx(te,{variant:"ghost",size:"icon",onClick:()=>Z(M.id),className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50 rounded-lg transition-transform active:scale-90",children:e.jsx(Zn,{className:"w-4 h-4"})})]})})]},M.id)})})]}),e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-slate-50/50 border-t border-slate-200 mt-auto",children:[e.jsxs("div",{className:"text-[11px] text-slate-500 font-bold uppercase tracking-tight",children:["Dataset Index ",e.jsxs("span",{className:"text-slate-900 border-b border-slate-300 mx-1",children:[t.length>0?(b-1)*S+1:0," - ",Math.min(b*S,A.total)]})," Total Found ",e.jsx("span",{className:"text-re-red-hover font-extrabold ml-1",children:A.total})]}),e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsxs(te,{variant:"outline",size:"sm",disabled:b===1,onClick:()=>{C(M=>Math.max(1,M-1)),window.scrollTo({top:0,behavior:"smooth"})},className:"h-9 px-3 rounded-xl border-slate-200 bg-white hover:bg-slate-50 transition-all font-bold shadow-sm disabled:opacity-30 uppercase text-[10px]",children:[e.jsx(io,{className:"w-4 h-4 mr-1 text-slate-600"})," Prev"]}),e.jsxs("div",{className:"flex items-center px-4 h-9 bg-white border border-slate-200 rounded-xl text-xs font-extrabold text-slate-800 shadow-inner",children:[e.jsx("span",{className:"text-re-red",children:b})," ",e.jsx("span",{className:"mx-2 text-slate-300",children:"/"})," ",A.pages]}),e.jsxs(te,{variant:"outline",size:"sm",disabled:b>=A.pages,onClick:()=>{C(M=>Math.min(A.pages,M+1)),window.scrollTo({top:0,behavior:"smooth"})},className:"h-9 px-3 rounded-xl border-slate-200 bg-white hover:bg-slate-50 transition-all font-bold shadow-sm disabled:opacity-30 uppercase text-[10px]",children:["Next ",e.jsx(mi,{className:"w-4 h-4 ml-1 text-slate-600"})]})]})]})]}),e.jsx(ms,{open:o,onOpenChange:d,children:e.jsxs(us,{className:"max-w-2xl rounded-2xl border-none shadow-2xl p-0 overflow-hidden ring-1 ring-black/5",children:[e.jsx(ys,{className:"bg-slate-900 text-white p-7",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 bg-white/10 rounded-2xl backdrop-blur-md ring-1 ring-white/20",children:e.jsx(Ff,{className:"w-7 h-7 text-red-400"})}),e.jsxs("div",{children:[e.jsx(gs,{className:"text-2xl font-black tracking-tight uppercase",children:m?"Modify Policy":"Publish Rule"}),e.jsxs("p",{className:"text-xs text-slate-400 font-bold tracking-widest uppercase mt-1",children:["Configuring ",O.module," Lifecycle"]})]})]})}),e.jsxs("div",{className:"p-7 space-y-6 bg-white overflow-y-auto max-h-[70vh]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Process Stream"}),e.jsxs(Rt,{value:O.module,onValueChange:M=>R(z=>({...z,module:M,stageCode:"General"})),children:[e.jsx(_t,{className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm bg-slate-50 font-black text-xs uppercase",children:e.jsx(Et,{placeholder:"Module"})}),e.jsx(Tt,{className:"rounded-xl border-none shadow-2xl",children:p.map(M=>e.jsx(Pe,{value:M,className:"py-3 px-4 rounded-lg focus:bg-red-50 font-black text-[10px] uppercase",children:M.replace(/_/g," ")},M))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Milestone Stage"}),e.jsxs(Rt,{value:O.stageCode,onValueChange:M=>R(z=>({...z,stageCode:M})),children:[e.jsx(_t,{className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm bg-white font-black text-xs uppercase",children:e.jsx(Et,{placeholder:"Select Stage"})}),e.jsx(Tt,{className:"rounded-xl border-none shadow-2xl",children:(x[O.module]||["General"]).map(M=>e.jsx(Pe,{value:M,className:"py-3 px-4 rounded-lg focus:bg-red-50 font-black text-[10px] uppercase",children:M},M))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Document Label Identifier"}),e.jsx(it,{value:O.documentType,onChange:M=>R(z=>({...z,documentType:M.target.value})),placeholder:"e.g., PAN Card, Blueprint",className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm font-black text-sm uppercase placeholder:font-bold placeholder:text-slate-300"})]}),e.jsxs("div",{className:"space-y-4 p-5 bg-slate-50 rounded-2xl border border-slate-100 shadow-inner",children:[e.jsxs(le,{className:"text-slate-900 font-black flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider",children:[e.jsx(so,{className:"w-4 h-4 text-re-red"})," Visibility Matrix"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:P.map(M=>e.jsxs("div",{className:`flex items-center space-x-2 p-3 rounded-xl border transition-all cursor-pointer group active:scale-95 ${O.allowedRoles.includes(M)?"bg-red-50 border-red-300 shadow-sm":"bg-white border-slate-200 hover:border-red-200 hover:shadow-sm"}`,onClick:()=>U(M),children:[e.jsx(Tn,{id:`role-${M}`,checked:O.allowedRoles.includes(M),onCheckedChange:()=>U(M),className:"w-4 h-4 data-[state=checked]:bg-re-red data-[state=checked]:border-re-red rounded"}),e.jsx(le,{htmlFor:`role-${M}`,className:`text-[10px] font-black cursor-pointer uppercase truncate ${O.allowedRoles.includes(M)?"text-red-800":"text-slate-500 group-hover:text-re-red-hover"}`,children:M})]},M))})]}),e.jsxs("div",{className:"flex gap-6 mt-4",children:[e.jsxs("div",{className:`flex items-center space-x-4 p-4 rounded-2xl border transition-all cursor-pointer flex-1 group ${O.isMandatory?"bg-red-50 border-red-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-red-50/30"}`,onClick:()=>R(M=>({...M,isMandatory:!M.isMandatory})),children:[e.jsx(Tn,{id:"mandatory",checked:O.isMandatory,onCheckedChange:M=>R(z=>({...z,isMandatory:!!M})),className:"w-5 h-5 border-slate-300 data-[state=checked]:bg-re-red data-[state=checked]:border-re-red rounded-md"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(le,{htmlFor:"mandatory",className:"text-xs font-black text-slate-800 cursor-pointer group-hover:text-red-900 transition-colors uppercase tracking-tight",children:"Mandatory Policy"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter",children:"Blocking Next Stage Action"})]})]}),e.jsxs("div",{className:`flex items-center space-x-4 p-4 rounded-2xl border transition-all cursor-pointer flex-1 group ${O.isActive?"bg-emerald-50 border-emerald-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-emerald-50/30"}`,onClick:()=>R(M=>({...M,isActive:!M.isActive})),children:[e.jsx(Tn,{id:"active",checked:O.isActive,onCheckedChange:M=>R(z=>({...z,isActive:!!M})),className:"w-5 h-5 border-slate-300 data-[state=checked]:bg-emerald-600 data-[state=checked]:border-emerald-600 rounded-md"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(le,{htmlFor:"active",className:"text-xs font-black text-slate-800 cursor-pointer group-hover:text-emerald-900 transition-colors uppercase tracking-tight",children:"Active Policy"}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter",children:"Visible To Active Streams"})]})]})]})]}),e.jsxs(mn,{className:"bg-slate-50 p-7 flex gap-4 border-t",children:[e.jsx(te,{variant:"ghost",onClick:()=>d(!1),className:"flex-1 h-12 rounded-xl font-black uppercase text-slate-400 hover:text-slate-600 hover:bg-slate-100 text-xs",children:"Discard"}),e.jsx(te,{onClick:$,className:"flex-1 h-12 rounded-xl bg-slate-900 hover:bg-black text-white font-black text-xs uppercase shadow-xl transition-all active:scale-95",children:m?"Update Policy Database":"Publish New Policy"})]})]})})]})},_G=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),a=async()=>{r(!0);try{const m=await $s.getSystemConfigs({category:"ASSIGNMENT"});m.success&&s(m.data)}catch{J.error("Failed to load assignment configurations")}finally{r(!1)}};g.useEffect(()=>{a()},[]);const i=(m,f)=>{s(p=>p.map(h=>h.key===m?{...h,value:{...h.value,enabled:f}}:h))},o=async m=>{try{(await $s.saveSystemConfig({key:m.key,value:m.value,category:m.category,description:m.description})).success&&J.success(`${m.key.replace("AUTO_ASSIGN_","")} setting updated`)}catch{J.error("Failed to save configuration")}},d=[{key:"AUTO_ASSIGN_ONBOARDING",label:"Onboarding",icon:sc,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RELOCATION",label:"Relocation",icon:nM,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_TERMINATION",label:"Termination",icon:FI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_CONSTITUTIONAL",label:"Constitutional",icon:$I,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RESIGNATION",label:"Resignation",icon:ks,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_FNF",label:"F&F Settlement",icon:TI,color:"text-slate-500",bg:"bg-slate-100"}];return n?e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 space-y-4",children:[e.jsx(cl,{className:"w-8 h-8 animate-spin text-re-red"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Loading governance controls..."})]}):e.jsx("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:e.jsxs(_e,{className:"border-none shadow-md overflow-hidden bg-white/50 backdrop-blur-sm",children:[e.jsx(Xe,{className:"bg-gradient-to-r from-slate-900 to-slate-800 text-white p-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:e.jsx(Ff,{className:"w-6 h-6 text-red-400"})}),e.jsxs("div",{children:[e.jsx(st,{className:"text-xl font-bold",children:"Auto-Assignment Governance"}),e.jsx(es,{className:"text-slate-300",children:"Control the automated mapping of participants across different business modules"})]})]})}),e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:d.map(m=>{var h;const f=t.find(x=>x.key===m.key),p=((h=f==null?void 0:f.value)==null?void 0:h.enabled)??!1;return e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-xl border bg-white transition-all group",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:Nt("w-12 h-12 flex items-center justify-center rounded-full transition-colors",m.bg,m.color),children:e.jsx(m.icon,{className:"w-6 h-6"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-slate-900",children:m.label}),e.jsx(xp,{children:e.jsxs(dj,{children:[e.jsx(uj,{children:e.jsx(qa,{className:"w-3.5 h-3.5 text-slate-400"})}),e.jsx(hj,{className:"max-w-xs",children:e.jsxs("p",{children:["When OFF, all participants for new ",m.label," requests must be assigned manually by authorized administrators."]})})]})})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(we,{variant:p?"default":"secondary",className:p?"bg-emerald-50 text-emerald-700 border-emerald-200 hover:bg-emerald-100":"bg-slate-50 text-slate-500 border-slate-200",children:p?"Auto-Assign ON":"Manual Mode"})})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsx(yp,{className:"data-[state=checked]:bg-re-red",checked:p,onCheckedChange:x=>{i(m.key,x);const u=t.find(N=>N.key===m.key);u&&o({...u,value:{enabled:x}})}})})]},m.key)})}),e.jsxs("div",{className:"mt-8 p-4 bg-red-50 border border-red-100 rounded-lg flex items-start gap-3",children:[e.jsx(qa,{className:"w-5 h-5 text-re-red shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-red-800",children:[e.jsx("p",{className:"font-semibold mb-1",children:"Impact of Manual Mode:"}),e.jsx("p",{children:'Turning OFF auto-assignment will ONLY affect new requests. Existing requests will retain their current participant mappings. You will need to use the "Add Participant" button in the worknotes or application details to grant access to stakeholders.'})]})]})]})]})})},an={DD:"DD",DD_ZM:"DD-ZM",RBM:"RBM",ZBH:"ZBH",DD_LEAD:"DD Lead",DD_HEAD:"DD Head",NBH:"NBH",DD_ADMIN:"DD Admin",LEGAL_ADMIN:"Legal Admin",SUPER_ADMIN:"Super Admin",DD_AM:"DD AM",ASM:"ASM",FINANCE:"Finance",DEALER:"Dealer",ARCHITECTURE:"ARCHITECTURE",FDD:"FDD",CCO:"CCO",CEO:"CEO"},S2={ONBOARDING:{General:an.DD_ADMIN,KYC:an.DD_ADMIN,"Level 1 Interview":an.RBM,"Level 2 Interview":an.ZBH,"Level 3 Interview":an.NBH,FDD:an.FDD,"LOI Approval":`${an.DD_HEAD},${an.NBH}`,"LOA Approval":an.NBH,"LOI Issue":an.DD_ADMIN,"Architecture Team Assigned":an.ARCHITECTURE,"Architecture Document Upload":an.ARCHITECTURE,"Architecture Team Completion":an.ARCHITECTURE,EOR:an.DD_ADMIN,Inauguration:an.DD_ADMIN},RESIGNATION:{Submission:an.DEALER,"Regional Review":an.RBM,"ZM Review":an.DD_ZM,"ZBH Review":an.ZBH,"Finance Review":an.FINANCE,"DDL Review":an.DD_LEAD,Approved:an.DD_HEAD},RELOCATION:{Initiated:an.DEALER,"ASM Review":an.ASM,"ZM Review":an.DD_ZM,"ZBH Review":an.ZBH,Completed:an.DD_HEAD},CONSTITUTIONAL_CHANGE:{Draft:an.DEALER,"Legal Review":an.LEGAL_ADMIN,Approved:an.DD_HEAD},TERMINATION:{Hearing:an.NBH,Review:an.DD_LEAD,Closed:an.DD_HEAD}},C2={async getPolicies(){var t,s;try{return(await Re.getApprovalPolicies()).data}catch(n){return J.error(((s=(t=n==null?void 0:n.response)==null?void 0:t.data)==null?void 0:s.message)||"Failed to fetch approval policies"),{success:!1,data:[]}}},async savePolicy(t,s){var n,r,a;try{const i=await Re.upsertApprovalPolicy(t,s);return(n=i==null?void 0:i.data)!=null&&n.success&&J.success("Approval policy updated"),i.data}catch(i){return J.error(((a=(r=i==null?void 0:i.response)==null?void 0:r.data)==null?void 0:a.message)||"Failed to update approval policy"),{success:!1}}}},TG=Object.values(an).sort(),PG=[{label:"Onboarding",stages:[{label:"General Info",value:"ONBOARDING_GENERAL"},{label:"KYC Verification",value:"ONBOARDING_KYC"},{label:"Level 1 Interview",value:"LEVEL_1_INTERVIEW"},{label:"Level 2 Interview",value:"LEVEL_2_INTERVIEW"},{label:"Level 3 Interview",value:"LEVEL_3_INTERVIEW"},{label:"FDD Verification",value:"FDD_VERIFICATION"},{label:"LOI Approval",value:"LOI_APPROVAL"},{label:"LOA Approval",value:"LOA_APPROVAL"},{label:"Architecture Team Assigned",value:"ARCHITECTURE_ASSIGNMENT"},{label:"Architecture Doc Upload",value:"ARCHITECTURE_DOCUMENT_UPLOAD"},{label:"Statutory Verification",value:"STATUTORY_CHECK"},{label:"EOR Verification",value:"EOR_VERIFICATION"}]},{label:"Offboarding (Resignation)",stages:[{label:"Regional Review",value:"RESIGNATION_REGIONAL_REVIEW"},{label:"ZM Review",value:"RESIGNATION_ZM_REVIEW"},{label:"ZBH Review",value:"RESIGNATION_ZBH_REVIEW"},{label:"Finance Clearance",value:"RESIGNATION_FINANCE_REVIEW"},{label:"DDL Review",value:"RESIGNATION_DDL_REVIEW"},{label:"Final Approval",value:"RESIGNATION_APPROVED"}]},{label:"Termination",stages:[{label:"RBM Review",value:"TERMINATION_HEARING"},{label:"DDL Evaluation",value:"TERMINATION_REVIEW"},{label:"Legal Verification",value:"TERMINATION_LEGAL_VERIFICATION"},{label:"Final NBH Approval",value:"TERMINATION_CLOSED"}]},{label:"Relocation & CC",stages:[{label:"Relocation ASM Review",value:"RELOCATION_ASM_REVIEW"},{label:"Relocation Head Approval",value:"RELOCATION_COMPLETED"},{label:"CC Legal Review",value:"CONSTITUTIONAL_LEGAL_REVIEW"},{label:"CC Head Approval",value:"CONSTITUTIONAL_APPROVED"}]}];function K_(){const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,i]=g.useState(!1),[o,d]=g.useState(!1),[m,f]=g.useState(!1),[p,h]=g.useState({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),x=g.useMemo(()=>[...n].sort((j,b)=>j.stageCode.localeCompare(b.stageCode)),[n]),u=async()=>{s(!0);try{const j=await C2.getPolicies();j!=null&&j.success&&r(j.data||[])}finally{s(!1)}};g.useEffect(()=>{u()},[]);const N=()=>{d(!1),f(!1),h({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),i(!0)},v=j=>{d(!0),f(!0),h({stageCode:j.stageCode,minApprovals:j.minApprovals||1,approvalMode:j.approvalMode||"MIN_N",requiredRoles:Array.isArray(j.requiredRoles)?[...j.requiredRoles]:[],isActive:j.isActive!==!1}),i(!0)},w=async()=>{if(!p.stageCode.trim())return;if(p.approvalMode==="ROLE_MANDATORY"&&p.requiredRoles.length>0&&p.minApprovals>p.requiredRoles.length){alert("In ROLE_MANDATORY mode, min approvals cannot exceed the number of required roles.");return}const j={minApprovals:Number(p.minApprovals)||1,approvalMode:p.approvalMode,requiredRoles:p.requiredRoles,isActive:p.isActive},b=p.stageCode.trim().toUpperCase().replace(/\s+/g,"_"),C=await C2.savePolicy(b,j);C!=null&&C.success&&(await u(),i(!1))};return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(Ff,{className:"w-6 h-6 text-re-red"}),"Approval Policies"]}),e.jsx("p",{className:"text-slate-500",children:"Configure stage-level approvers, mode, and minimum approvals."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(te,{variant:"outline",onClick:u,disabled:t,children:[e.jsx(or,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]}),e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover",onClick:N,children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add New Policy"]})]})]}),e.jsxs(_e,{className:"border-slate-200 overflow-hidden shadow-sm",children:[e.jsx(Xe,{className:"bg-slate-50 px-6 py-4 border-b",children:e.jsx(st,{className:"text-lg font-semibold text-slate-800",children:"Configured Stages"})}),e.jsx(Oe,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ms,{children:[e.jsx(Fs,{className:"bg-slate-50/50",children:e.jsxs(lt,{children:[e.jsx(me,{className:"w-[200px]",children:"Stage Code"}),e.jsx(me,{children:"Approval Mode"}),e.jsx(me,{children:"Min Appr."}),e.jsx(me,{className:"min-w-[300px]",children:"Required Roles"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:x.map(j=>e.jsxs(lt,{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx(oe,{className:"font-mono text-xs font-semibold text-slate-700",children:j.stageCode}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"font-medium px-2 py-0.5 text-slate-600 border-slate-300 uppercase",children:j.approvalMode})}),e.jsx(oe,{children:e.jsx("span",{className:"font-medium text-slate-700 bg-slate-100 px-2.5 py-1 rounded-full text-xs",children:j.minApprovals})}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-wrap gap-1.5 py-1",children:(j.requiredRoles||[]).map(b=>e.jsx(we,{variant:"secondary",className:"bg-slate-100 text-slate-600 border-transparent hover:bg-slate-200 text-[11px] font-normal",children:b},b))})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${j.isActive?"bg-green-500 shadow-[0_0_8px_rgba(34,197,94,0.4)]":"bg-slate-400"}`}),e.jsx("span",{className:`text-xs font-medium ${j.isActive?"text-green-700":"text-slate-500"}`,children:j.isActive?"Active":"Inactive"})]})}),e.jsx(oe,{className:"text-right",children:e.jsxs(te,{size:"sm",variant:"ghost",className:"text-re-red hover:text-re-red-hover hover:bg-red-50 h-8 px-2",onClick:()=>v(j),children:[e.jsx(gr,{className:"w-4 h-4 mr-1.5"}),"Edit"]})})]},j.stageCode))})]})})})]}),e.jsx(ms,{open:a,onOpenChange:i,children:e.jsxs(us,{className:"sm:max-w-[480px] overflow-visible",children:[e.jsxs(ys,{className:"gap-1 pb-2 border-b",children:[e.jsxs(gs,{className:"text-base flex items-center gap-2",children:[o?e.jsx(gr,{className:"w-4 h-4 text-re-red"}):e.jsx(bn,{className:"w-4 h-4 text-re-red"}),o?"Edit Policy":"Create New Policy"]}),e.jsx(ws,{className:"text-[11px]",children:o?`Update configuration for stage ${p.stageCode}.`:"Define approval requirements for a workflow stage."})]}),e.jsxs("div",{className:"grid gap-3 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-start gap-4",children:[e.jsx(le,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight pt-2",children:"Stage"}),e.jsx("div",{className:"col-span-3 space-y-2",children:!m&&!o?e.jsx("div",{className:"space-y-2",children:e.jsxs(Rt,{value:p.stageCode,onValueChange:j=>{j==="CUSTOM"?(f(!0),h({...p,stageCode:""})):h({...p,stageCode:j})},children:[e.jsx(_t,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(Et,{placeholder:"Select a workflow stage..."})}),e.jsxs(Tt,{className:"max-h-[300px]",children:[PG.map(j=>e.jsxs(pS,{children:[e.jsx(_$,{className:"text-[10px] uppercase text-slate-400 font-bold bg-slate-50 px-2 py-1",children:j.label}),j.stages.map(b=>e.jsxs(Pe,{value:b.value,className:"text-xs",children:[b.label," ",e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono ml-1",children:["(",b.value,")"]})]},b.value))]},j.label)),e.jsxs(pS,{children:[e.jsx(G8,{}),e.jsx(Pe,{value:"CUSTOM",className:"text-xs font-semibold text-re-red italic",children:"+ Enter Custom Stage Code"})]})]})]})}):e.jsxs("div",{className:"relative",children:[e.jsx(it,{className:"w-full font-mono text-xs h-8 pr-8",placeholder:"e.g. FNF_SETTLEMENT",disabled:o,value:p.stageCode,onChange:j=>h({...p,stageCode:j.target.value.toUpperCase()})}),!o&&e.jsx(id,{className:"w-3 h-3 absolute right-2.5 top-2.5 text-slate-400 cursor-pointer hover:text-slate-600",onClick:()=>{f(!1),h({...p,stageCode:""})}})]})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight",children:"Mode"}),e.jsx("div",{className:"col-span-3",children:e.jsxs(Rt,{value:p.approvalMode,onValueChange:j=>h({...p,approvalMode:j}),children:[e.jsx(_t,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(Et,{placeholder:"Select mode"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"ALL",className:"text-xs",children:"ALL (Everyone must approve)"}),e.jsx(Pe,{value:"MIN_N",className:"text-xs",children:"MIN_N (First N approvals count)"}),e.jsx(Pe,{value:"ROLE_MANDATORY",className:"text-xs",children:"ROLE_MANDATORY (Hierarchy base)"})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight",children:"Min Appr."}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{type:"number",min:1,value:p.minApprovals,onChange:j=>h({...p,minApprovals:Number(j.target.value||1)}),className:"w-20 h-8 text-xs border-slate-200"})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-start gap-4",children:[e.jsx(le,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight pt-2",children:"Roles"}),e.jsxs("div",{className:"col-span-3 space-y-2",children:[e.jsxs(bb,{children:[e.jsx(jb,{asChild:!0,children:e.jsxs(te,{variant:"outline",size:"sm",className:"w-full justify-between h-8 text-[11px] text-slate-500 font-normal border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(bn,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{children:"Add Roles..."})]}),e.jsx(we,{variant:"secondary",className:"bg-red-50 text-re-red-hover border-transparent text-[9px] px-1 h-4",children:p.requiredRoles.length})]})}),e.jsxs(Nb,{className:"w-[280px] max-h-[250px] overflow-y-auto shadow-xl",align:"start",children:[e.jsx(W8,{className:"text-[10px] uppercase tracking-wider text-slate-400 font-bold px-2 py-1 border-b",children:"Available Roles"}),TG.map(j=>e.jsx(H8,{className:"text-xs",checked:p.requiredRoles.includes(j),onCheckedChange:b=>{h(b?{...p,requiredRoles:[...p.requiredRoles,j]}:{...p,requiredRoles:p.requiredRoles.filter(C=>C!==j)})},children:j},j))]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 min-h-[32px] p-2 rounded-sm bg-slate-50/50 border border-slate-100",children:[p.requiredRoles.map(j=>e.jsxs(we,{variant:"secondary",className:"bg-white text-slate-600 border-slate-200 text-[10px] font-normal flex items-center gap-1 py-0 px-1.5 h-5 transition-all",children:[j,e.jsx(id,{className:"w-2.5 h-2.5 cursor-pointer text-slate-400 hover:text-red-500",onClick:()=>h({...p,requiredRoles:p.requiredRoles.filter(b=>b!==j)})})]},j)),p.requiredRoles.length===0&&e.jsx("span",{className:"text-slate-400 text-[10px] italic px-1 py-0.5",children:"No roles assigned."})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(le,{className:"text-right text-[11px] font-semibold text-slate-500 uppercase tracking-tight",children:"Status"}),e.jsx("div",{className:"col-span-3",children:e.jsxs(Rt,{value:p.isActive?"active":"inactive",onValueChange:j=>h({...p,isActive:j==="active"}),children:[e.jsx(_t,{className:"w-24 h-8 text-[11px] font-medium border-slate-200",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"active",className:"text-xs",children:"Active"}),e.jsx(Pe,{value:"inactive",className:"text-xs",children:"Inactive"})]})]})})]})]}),e.jsxs(mn,{className:"gap-2 pt-3 border-t",children:[e.jsx(te,{variant:"outline",size:"sm",className:"text-xs h-8",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover h-8 text-xs font-semibold",onClick:w,children:[e.jsx(dl,{className:"w-3 h-3 mr-1.5"}),o?"Save Changes":"Create Policy"]})]})]})})]})}const OG=()=>{const{fetchInitialData:t,fetchAreas:s}=RV(),{asms:n,zonalManagerMappings:r,allStates:a,allDistricts:i,users:o,roles:d,loading:m}=Pn(Ye=>Ye.master),[f,p]=g.useState("hierarchy"),[h,x]=g.useState("all"),[u,N]=g.useState(!1),[v,w]=g.useState(!1),[j,b]=g.useState(!1),[C,S]=g.useState(!1),[D,_]=g.useState(!1),[A,E]=g.useState(null),[q,O]=g.useState(""),[R,P]=g.useState("active"),[L,$]=g.useState(""),[Z,Q]=g.useState(""),[W,U]=g.useState([]),[M,z]=g.useState([]),[T,F]=g.useState("DD-AM"),[I,K]=g.useState(!1),[G,V]=g.useState(null),[Y,re]=g.useState(""),[ae,ue]=g.useState("active"),[ye,ce]=g.useState(""),[je,Me]=g.useState([]),[ut,jt]=g.useState(!1),[ft,X]=g.useState(null),[Ce,xe]=g.useState(!1),[We,Be]=g.useState(null),[rt,ht]=g.useState(""),[ge,Je]=g.useState(""),[mt,de]=g.useState(""),[at,ot]=g.useState("none"),[ke,Zt]=g.useState(null),[Bt,_s]=g.useState(""),[Us,fs]=g.useState(""),[Vs,Qs]=g.useState(""),[Xs,ie]=g.useState(""),[nt,fe]=g.useState([]),[Ae,Fe]=g.useState(null),[Ke,Le]=g.useState('{"applicant_name": "John Doe"}'),[Ue,et]=g.useState(!1),[dt,ss]=g.useState(null),[Wt,kt]=g.useState(null),[wt,Os]=g.useState(""),[as,Se]=g.useState(""),[be,pt]=g.useState(""),[Ve,bt]=g.useState(""),[gt,rs]=g.useState(""),[is,Ts]=g.useState("active"),[Ws,nn]=g.useState(""),[Ee,$t]=g.useState(1),[Xt,Cs]=g.useState("all"),[Mt,ze]=g.useState("all");g.useEffect(()=>{t()},[t]),g.useEffect(()=>{if(ft&&d.length>0){const Ye=d.find(qt=>qt.id===ft.id);Ye&&X(Ye)}},[d,ft==null?void 0:ft.id]);const xt=g.useMemo(()=>{const Ye={};return[...n,...r].forEach(qt=>{(qt.areasManaged||qt.districts||[]).forEach(Gt=>{const St=typeof Gt=="string"?Gt:Gt.id;Ye[St]||(Ye[St]=[]),Ye[St].includes(qt.name)||Ye[St].push(qt.name)})}),Ye},[n,r]),yt=g.useCallback((Ye,qt)=>i.filter(Ze=>{var Gt;return((Gt=Ze.stateName)==null?void 0:Gt.toUpperCase())===(Ye==null?void 0:Ye.toUpperCase())&&(!qt||Ze.regionId===qt)}).map(Ze=>({id:Ze.id,name:Ze.name})),[i]),Ot=async()=>{var Ye,qt;if(!q){J.error("Please select a DD-AM user");return}try{const Ze={userId:q,roleCode:T,districts:M,status:R},Gt=await $s.saveASM(Ze);Gt.success?(J.success(`DD Area Manager ${A?"updated":"assigned"} successfully`),N(!1),t()):J.error(Gt.message||"Failed to save ASM")}catch(Ze){const Gt=((qt=(Ye=Ze==null?void 0:Ze.response)==null?void 0:Ye.data)==null?void 0:qt.message)||(Ze==null?void 0:Ze.message)||"Failed to save ASM";J.error(Gt)}},Pt=Ye=>{var qt;E(Ye.id),O(Ye.id),P(Ye.status.toLowerCase()),$(Ye.zoneId),Q(Ye.regionId),U(Ye.stateNames||[]),z(((qt=Ye.areasManaged)==null?void 0:qt.map(Ze=>Ze.id))||[]),F("DD-AM"),N(!0)},Jt=Ye=>{var qt;V(Ye.id),re(Ye.id),ue(((qt=Ye.status)==null?void 0:qt.toLowerCase())==="active"?"active":"inactive"),ce(Ye.zoneId||""),Me(Ye.assignedRegionIds||[]),K(!0)},bs=async()=>{var Ye,qt;if(!Y||!ye){J.error("Manager and Zone are required");return}try{const Ze={userId:Y,zoneId:ye,regionIds:je,status:ae},Gt=await $s.saveZonalManager(Ze);Gt.success?(J.success(`Zonal Manager ${G?"updated":"assigned"} successfully`),K(!1),t()):J.error(Gt.message||"Failed to save Zonal Manager")}catch(Ze){const Gt=((qt=(Ye=Ze==null?void 0:Ze.response)==null?void 0:Ye.data)==null?void 0:qt.message)||(Ze==null?void 0:Ze.message)||"Failed to save Zonal Manager";J.error(Gt)}},ns=async()=>{var Ye,qt;try{const Ze={id:We,name:rt,code:ge,description:mt,managerId:at==="none"?null:at},Gt=await $s.saveZone(Ze);Gt.success?(J.success("Zone saved successfully"),w(!1),t()):J.error(Gt.message||"Error saving zone")}catch(Ze){const Gt=((qt=(Ye=Ze==null?void 0:Ze.response)==null?void 0:Ye.data)==null?void 0:qt.message)||(Ze==null?void 0:Ze.message)||"Error saving zone";J.error(Gt)}},Ds=async()=>{var Ye,qt;try{const Ze={...ke?{id:ke}:{},name:Bt,description:Us,parentId:Vs,managerId:Xs,districts:nt,status:"Active"},Gt=await $s.saveRegion(Ze);Gt.success?(J.success("Region saved successfully"),b(!1),t()):J.error(Gt.message||"Error saving region")}catch(Ze){const Gt=((qt=(Ye=Ze==null?void 0:Ze.response)==null?void 0:Ye.data)==null?void 0:qt.message)||(Ze==null?void 0:Ze.message)||"Error saving region";J.error(Gt)}},ts=async Ye=>{var qt,Ze;try{if(!(Ae!=null&&Ae.id)){J.error("Open a template from the list to edit.");return}const Gt=await $s.updateEmailTemplate(Ae.id,{...Ae,body:Ye});Gt.success?(J.success("Template saved"),S(!1),t()):J.error(Gt.message||"Error saving template")}catch(Gt){const St=((Ze=(qt=Gt==null?void 0:Gt.response)==null?void 0:qt.data)==null?void 0:Ze.message)||(Gt==null?void 0:Gt.message)||"Error saving template";J.error(St)}},js=async Ye=>{var qt;et(!0);try{let Ze;try{Ze=JSON.parse(Ke)}catch{J.error("Mock test data must be valid JSON");return}const Gt=await $s.previewEmailTemplate({subject:Ae==null?void 0:Ae.subject,body:Ye,data:Ze});Gt.success?ss(Gt.data):J.error(Gt.message||"Preview failed")}catch(Ze){const Gt=(qt=Ze==null?void 0:Ze.response)==null?void 0:qt.data,St=(Gt==null?void 0:Gt.error)||(Gt==null?void 0:Gt.message);J.error(St||(Ze==null?void 0:Ze.message)||"Preview failed")}finally{et(!1)}},tn=async(Ye,qt)=>{var Ze,Gt;try{const St=await $s.updateRole(Ye,{permissions:qt});St.success?(J.success("Role permissions updated successfully"),jt(!1),t()):J.error(St.message||"Error saving role permissions")}catch(St){const qn=((Gt=(Ze=St==null?void 0:St.response)==null?void 0:Ze.data)==null?void 0:Gt.message)||(St==null?void 0:St.message)||"Error saving role permissions";J.error(qn)}},vn=Ye=>{X(Ye),jt(!0)},jn=async Ye=>{var qt,Ze;try{const Gt={...Ye,permissionIds:[]},St=await $s.createRole(Gt);if(St!=null&&St.success){J.success("Role created successfully"),t();return}throw new Error((St==null?void 0:St.message)||"Failed to create role")}catch(Gt){const St=((Ze=(qt=Gt==null?void 0:Gt.response)==null?void 0:qt.data)==null?void 0:Ze.message)||(Gt==null?void 0:Gt.message)||"Failed to create role";throw J.error(St),Gt}},xn=Ye=>{const qt=i.find(Ze=>Ze.id===Ye.districtId);kt(Ye.id),Os((qt==null?void 0:qt.stateId)||Ye.stateId||""),pt(Ye.city||""),Se(Ye.districtId||""),bt(Ye.openFrom?new Date(Ye.openFrom).toISOString().split("T")[0]:""),rs(Ye.openTo?new Date(Ye.openTo).toISOString().split("T")[0]:""),Ts(Ye.isOpportunity?"active":"inactive"),_(!0)},gn=async()=>{try{if(!wt){J.error("Please select a state");return}if(!as){J.error("Please select a district");return}const Ye=a.find(St=>St.id===wt),qt=i.find(St=>St.id===as),Ze={id:Wt,stateId:wt,stateName:(Ye==null?void 0:Ye.name)||(Ye==null?void 0:Ye.stateName)||"",districtId:as,name:be||(qt==null?void 0:qt.name)||"New Location",city:be,status:is,openFrom:Ve,openTo:gt,isOpportunity:is==="active"};(await(Wt?$s.updateArea(Wt,Ze):$s.createArea(Ze))).success&&(J.success("Location saved"),_(!1),s({search:Ws,page:Ee}))}catch{J.error("Error saving location")}};return g.useEffect(()=>{const Ye=setTimeout(()=>{s({search:Ws,page:Ee,stateId:Xt==="all"?void 0:Xt,isOpportunity:Mt==="all"?void 0:Mt==="active"?"true":"false"})},500);return()=>clearTimeout(Ye)},[Ws,Ee,Xt,Mt,s]),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2 font-bold text-2xl",children:"Master Configuration"}),e.jsx("p",{className:"text-slate-600",children:"Centralized governance for locations, roles, and operational policies"})]})}),m?e.jsxs("div",{className:"flex flex-col items-center justify-center p-20 space-y-4",children:[e.jsx("div",{className:"w-12 h-12 border-4 border-re-red border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-slate-600 font-medium animate-pulse",children:"Synchronizing Global Settings..."})]}):e.jsxs(In,{value:f,onValueChange:p,className:"space-y-6",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-8 h-auto sticky top-0 z-10 bg-white/80 backdrop-blur-sm border shadow-sm rounded-xl p-1",children:[e.jsxs(Ht,{value:"hierarchy",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(ku,{className:"w-4 h-4"})," Organisation"]}),e.jsxs(Ht,{value:"roles",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(dc,{className:"w-4 h-4"})," Roles"]}),e.jsxs(Ht,{value:"templates",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(Gr,{className:"w-4 h-4"})," Emails"]}),e.jsxs(Ht,{value:"locations",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white",children:[e.jsx(Mr,{className:"w-4 h-4"})," Locations"]}),e.jsxs(Ht,{value:"approvals",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(QI,{className:"w-4 h-4"})," Approvals"]}),e.jsxs(Ht,{value:"documents",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(ks,{className:"w-4 h-4"})," Docs Config"]}),e.jsxs(Ht,{value:"governance",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Ff,{className:"w-4 h-4"})," Governance"]}),e.jsxs(Ht,{value:"settings",className:"flex items-center gap-2 py-3 rounded-lg data-[state=active]:bg-re-red data-[state=active]:text-white transition-all transform hover:scale-[1.02]",children:[e.jsx(Qc,{className:"w-4 h-4"})," App Settings"]})]}),e.jsxs(Vt,{value:"hierarchy",className:"space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e.jsx(EV,{selectedZone:h,onZoneClick:Ye=>x(h===Ye?"all":Ye)}),e.jsx(_V,{selectedZone:h,onAddZone:()=>{Be(null),ht(""),Je(""),de(""),ot("none"),w(!0)},onEditZone:Ye=>{var qt;Be(Ye.id),ht(Ye.name),Je(Ye.code),de(Ye.description),ot(((qt=Ye.zonalBusinessHead)==null?void 0:qt.id)||"none"),w(!0)}}),e.jsx(TV,{selectedZone:h,onAddRegion:()=>{Zt(null),_s(""),Qs(h==="all"?"":h),ie(""),fe([]),b(!0)},onEditRegion:Ye=>{var qt,Ze;Zt(Ye.id),_s(Ye.name),Qs(Ye.zoneId),ie(((qt=Ye.regionalManager)==null?void 0:qt.id)||""),fe(((Ze=Ye.districts)==null?void 0:Ze.map(Gt=>Gt.id))||[]),b(!0)},onDeleteRegion:()=>J.error("Regional office deletion is restricted via portal")}),e.jsx(OV,{selectedZone:h,onAddZM:()=>{V(null),re(""),ue("active"),ce(h==="all"?"":h),Me([]),K(!0)},onEditZM:Jt,onDeleteZM:()=>J.error("ZM deletion restricted")}),e.jsx(PV,{selectedZone:h,onAddASM:()=>{E(null),O(""),$(h==="all"?"":h),Q(""),U([]),z([]),F("DD-AM"),N(!0)},onEditASM:Pt,onDeleteASM:()=>J.error("ASM deletion restricted")}),e.jsx(qH,{}),e.jsx(LV,{userAssignedData:o.length>0?o:n})]}),e.jsx(Vt,{value:"roles",className:"animate-in fade-in duration-300",children:e.jsx(IV,{onAddRole:()=>xe(!0),onEditRole:vn})}),e.jsx(Vt,{value:"templates",className:"animate-in fade-in duration-300",children:e.jsx(BV,{onEditTemplate:Ye=>{if(Fe(Ye),Ye.placeholders&&Array.isArray(Ye.placeholders)){const qt=Ye.placeholders.reduce((Ze,Gt)=>(Ze[Gt]=`[${Gt}]`,Ze),{});Le(JSON.stringify(qt,null,2))}else Le("{}");S(!0)},onDeleteTemplate:()=>J.error("Delete Template restricted")})}),e.jsx(Vt,{value:"locations",className:"animate-in fade-in duration-300",children:e.jsx($V,{states:a,stateFilter:Xt,onStateFilterChange:Ye=>{Cs(Ye),$t(1)},statusFilter:Mt,onStatusFilterChange:Ye=>{ze(Ye),$t(1)},onAddLocation:()=>{kt(null),Os(""),pt(""),Se(""),bt(""),rs(""),Ts("active"),_(!0)},onEditLocation:xn,onDeleteLocation:Ye=>{window.confirm("Are you sure you want to delete this location?")&&$s.deleteArea(Ye).then(qt=>{qt.success&&(J.success("Location deleted"),s({search:Ws,page:Ee,stateId:Xt==="all"?void 0:Xt}))})},onSearch:Ye=>{nn(Ye),$t(1)},onPageChange:$t,searchTerm:Ws})}),e.jsx(Vt,{value:"approvals",className:"animate-in fade-in duration-300",children:e.jsx(K_,{})}),e.jsx(Vt,{value:"documents",className:"animate-in fade-in duration-300",children:e.jsx(EG,{})}),e.jsx(Vt,{value:"governance",className:"animate-in fade-in duration-300",children:e.jsx(_G,{})}),e.jsx(Vt,{value:"settings",className:"animate-in fade-in duration-300",children:e.jsx(RG,{})})]}),e.jsx(UH,{isOpen:v,onOpenChange:w,editingZoneId:We,zoneName:rt,setZoneName:ht,zoneCode:ge,setZoneCode:Je,zoneDescription:mt,setZoneDescription:de,zonalBusinessHeadId:at,setZonalBusinessHeadId:ot,onSave:ns,userAssignedData:o.length>0?o.map(Ye=>{var qt,Ze;return{...Ye,name:Ye.fullName||Ye.name,role:(qt=Ye.role)==null?void 0:qt.roleName,roleCode:(Ze=Ye.role)==null?void 0:Ze.roleCode,allRoles:Ye.allRoles}}):n}),e.jsx(VH,{isOpen:j,onOpenChange:b,editingRegionId:ke,regionName:Bt,setRegionName:_s,regionDescription:Us,setRegionDescription:fs,selectedRegionZone:Vs,setSelectedRegionZone:Qs,regionalManagerId:Xs,setRegionalManagerId:ie,selectedRegionStates:nt,setSelectedRegionStates:fe,onSave:Ds,userAssignedData:o.length>0?o.map(Ye=>{var qt,Ze;return{...Ye,name:Ye.fullName||Ye.name,role:(qt=Ye.role)==null?void 0:qt.roleName,roleCode:(Ze=Ye.role)==null?void 0:Ze.roleCode,allRoles:Ye.allRoles}}):n}),e.jsx(dH,{isOpen:u,onOpenChange:N,editingASMId:A,asmManagerId:q,setAsmManagerId:O,asmStatus:R,setAsmStatus:P,selectedASMZone:L,setSelectedASMZone:$,selectedASMRegion:Z,setSelectedASMRegion:Q,selectedASMStates:W,setSelectedASMStates:U,selectedASMDistricts:M,setSelectedASMDistricts:z,onSave:Ot,asmRoleCode:T,setAsmRoleCode:F,userAssignedData:o.length>0?o.map(Ye=>{var qt,Ze;return{...Ye,name:Ye.fullName||Ye.name,role:(qt=Ye.role)==null?void 0:qt.roleName,roleCode:(Ze=Ye.role)==null?void 0:Ze.roleCode,allRoles:Ye.allRoles}}):n,districtsAssignedToOthers:xt,getDistrictsForSelectedState:Ye=>yt(Ye,Z||void 0)}),e.jsx(zH,{isOpen:I,onOpenChange:K,editingZMId:G,zmManagerId:Y,setZmManagerId:re,zmStatus:ae,setZmStatus:ue,selectedZone:ye,setSelectedZone:ce,selectedRegions:je,setSelectedRegions:Me,onSave:bs,userAssignedData:o.length>0?o.map(Ye=>{var qt,Ze;return{...Ye,name:Ye.fullName||Ye.name,role:(qt=Ye.role)==null?void 0:qt.roleName,roleCode:(Ze=Ye.role)==null?void 0:Ze.roleCode,allRoles:Ye.allRoles}}):n}),e.jsx(kG,{isOpen:C,onOpenChange:S,editingTemplate:Ae,setEditingTemplate:Fe,testDataInput:Ke,setTestDataInput:Le,previewLoading:Ue,handlePreviewTemplate:js,previewContent:dt,handleSaveTemplate:ts}),e.jsx(DG,{isOpen:D,onOpenChange:_,editingLocationId:Wt,locationState:wt,setLocationState:Os,locationDistrict:as,setLocationDistrict:Se,locationCity:be,setLocationCity:pt,locationActiveFrom:Ve,setLocationActiveFrom:bt,locationActiveTo:gt,setLocationActiveTo:rs,locationStatus:is,setLocationStatus:Ts,allStates:a,allDistricts:i,onSave:gn}),e.jsx(MV,{isOpen:ut,onOpenChange:jt,role:ft,onSave:tn}),e.jsx(FV,{isOpen:Ce,onOpenChange:xe,onSave:jn})]})},km={extractErrorMessage(t,s){var n,r,a;return((r=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:r.message)||((a=t==null?void 0:t.data)==null?void 0:a.message)||(t==null?void 0:t.message)||s},async getAllUsers(t){var s,n;try{return(await Re.getUsers(t)).data}catch(r){return console.error("Error fetching users:",r),J.error(((n=(s=r.response)==null?void 0:s.data)==null?void 0:n.message)||"Failed to fetch users"),{success:!1,data:[]}}},async createUser(t){var s;try{const n=await Re.createUser(t);return n.ok&&((s=n.data)!=null&&s.success),n.data}catch(n){console.error("Error creating user:",n);const r=this.extractErrorMessage(n,"Failed to create user");return J.error(r),{success:!1,message:r}}},async updateUser(t,s){var n,r,a;try{const i=await Re.updateUser(t,s);return i.ok&&((n=i.data)!=null&&n.success)&&J.success(i.data.message||"User updated successfully"),i.data}catch(i){return console.error("Error updating user:",i),J.error(((a=(r=i.response)==null?void 0:r.data)==null?void 0:a.message)||"Failed to update user"),{success:!1}}},async updateUserStatus(t,s,n){var r,a,i;try{const o=await Re.updateUserStatus(t,{status:s,isActive:n});return o.ok&&((r=o.data)!=null&&r.success)&&J.success(o.data.message||"User status updated"),o.data}catch(o){return console.error("Error updating status:",o),J.error(((i=(a=o.response)==null?void 0:a.data)==null?void 0:i.message)||"Failed to update status"),{success:!1}}}};function LG(){const t=(W,U)=>{if(!(W!=null&&W.parents)||!Array.isArray(W.parents))return"";const M=W.parents.find(z=>(z==null?void 0:z.type)===U);return(M==null?void 0:M.id)||""},s=(W,U)=>W?Array.isArray(W[U])?W[U]:Array.isArray(W.data)?W.data:[]:[],[n,r]=g.useState([]),[a,i]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[p,h]=g.useState([]),[x,u]=g.useState([]),[N,v]=g.useState(!0),[w,j]=g.useState(""),[b,C]=g.useState("all"),[S,D]=g.useState("all"),[_,A]=g.useState(!1),[E,q]=g.useState(null),[O,R]=g.useState({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""});g.useEffect(()=>{P()},[]);const P=async()=>{v(!0);try{const[W,U,M,z]=await Promise.all([km.getAllUsers(),$s.getRoles(),$s.getZones(),$s.getRegions()]);W.success&&r(W.data),U.success&&i(U.data),M.success&&d(M.data),z.success&&f(z.data)}catch{J.error("Failed to load user management data")}finally{v(!1)}};g.useEffect(()=>{O.zoneId?$s.getStates(O.zoneId).then(W=>{W&&W.success&&h(s(W,"states"))}):h([])},[O.zoneId]),g.useEffect(()=>{O.stateId?$s.getDistricts(O.stateId).then(W=>{W&&W.success&&u(s(W,"districts"))}):u([])},[O.stateId]),g.useEffect(()=>{},[O.districtId]);const L=W=>{const U=W.location,M=U==null?void 0:U.type,z=W.zoneId||(M==="zone"?U==null?void 0:U.id:t(U,"zone")),T=W.regionId||(M==="region"?U==null?void 0:U.id:t(U,"region")),F=W.stateId||(M==="state"?U==null?void 0:U.id:t(U,"state")),I=W.districtId||(M==="district"?U==null?void 0:U.id:t(U,"district"));q(W),R({fullName:W.fullName||"",email:W.email||"",roleCode:W.roleCode||"",status:W.status||"active",isActive:W.isActive??!0,mobileNumber:W.mobileNumber||"",department:W.department||"",designation:W.designation||"",employeeId:W.employeeId||"",zoneId:z||"",regionId:T||"",stateId:F||"",districtId:I||""}),A(!0)},$=async()=>{var W,U;if(!O.fullName||!O.email||!O.roleCode){J.error("Please fill in all required fields");return}try{const M=O.districtId||O.stateId||O.regionId||O.zoneId||null,z={...O,locationId:M};if(E)(await km.updateUser(E.id,z)).success&&(A(!1),P());else{const T=await km.createUser(z);T.success?(J.success("User created successfully"),R({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!1),P()):J.error(T.message||"Failed to create user")}}catch(M){const z=((U=(W=M==null?void 0:M.response)==null?void 0:W.data)==null?void 0:U.message)||(M==null?void 0:M.message)||"Operation failed";J.error(z)}},Z=async W=>{const U=W.status==="active"?"inactive":"active",M=!W.isActive;(await km.updateUserStatus(W.id,U,M)).success&&P()},Q=n.filter(W=>{var T,F,I;const U=((T=W.fullName)==null?void 0:T.toLowerCase().includes(w.toLowerCase()))||((F=W.email)==null?void 0:F.toLowerCase().includes(w.toLowerCase()))||((I=W.employeeId)==null?void 0:I.toLowerCase().includes(w.toLowerCase())),M=b==="all"||W.roleCode===b,z=S==="all"||W.status===S;return U&&M&&z});return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(ja,{className:"w-6 h-6 text-re-red"}),"User Management"]}),e.jsx("p",{className:"text-slate-500",children:"Manage system users, roles, and access permissions."})]}),e.jsxs(te,{onClick:()=>{q(null),R({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!0)},className:"bg-re-red hover:bg-re-red-hover text-white shrink-0",children:[e.jsx(nb,{className:"w-4 h-4 mr-2"}),"Add New User"]})]}),e.jsx(_e,{className:"border-slate-200",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(it,{placeholder:"Search by name, email, ID...",className:"pl-10",value:w,onChange:W=>j(W.target.value)})]}),e.jsxs(Rt,{value:b,onValueChange:C,children:[e.jsxs(_t,{children:[e.jsx(eb,{className:"w-4 h-4 mr-2 text-slate-400"}),e.jsx(Et,{placeholder:"Filter by Role"})]}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Roles"}),a.map(W=>e.jsx(Pe,{value:W.roleCode,children:W.roleName},W.id))]})]}),e.jsxs(Rt,{value:S,onValueChange:D,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Filter by Status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"all",children:"All Status"}),e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{value:"inactive",children:"Inactive"})]})]}),e.jsxs(te,{variant:"outline",onClick:P,disabled:N,children:[e.jsx(or,{className:`w-4 h-4 mr-2 ${N?"animate-spin":""}`}),"Refresh"]})]})})}),e.jsx(_e,{className:"border-slate-200 overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ms,{children:[e.jsx(Fs,{className:"bg-slate-50",children:e.jsxs(lt,{children:[e.jsx(me,{children:"User Information"}),e.jsx(me,{children:"Geographical Mapping"}),e.jsx(me,{children:"Account Details"}),e.jsx(me,{children:"Role & Department"}),e.jsx(me,{children:"Status"}),e.jsx(me,{className:"text-right",children:"Actions"})]})}),e.jsx(Bs,{children:N?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"h-40 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-2 text-slate-500",children:[e.jsx(or,{className:"w-8 h-8 animate-spin"}),e.jsx("p",{children:"Loading users..."})]})})}):Q.length===0?e.jsx(lt,{children:e.jsxs(oe,{colSpan:5,className:"h-40 text-center text-slate-500",children:[e.jsx(ja,{className:"w-12 h-12 mx-auto mb-2 opacity-20"}),"No users found matching your criteria."]})}):Q.map(W=>{var U,M,z,T;return e.jsxs(lt,{className:"hover:bg-slate-50/50",children:[e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 text-re-red-hover flex items-center justify-center font-bold",children:((U=W.fullName)==null?void 0:U.charAt(0))||((M=W.email)==null?void 0:M.charAt(0))}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-900",children:W.fullName}),e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(Gr,{className:"w-3 h-3"}),W.email]})]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(we,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:["Location: ",((z=W.location)==null?void 0:z.name)||"N/A"]})}),e.jsxs("div",{className:"text-xs text-slate-500",children:["Type: ",(T=W.location)!=null&&T.type?W.location.type.toUpperCase():"N/A"]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:["ID: ",W.employeeId||"N/A"]}),e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(tb,{className:"w-3 h-3"}),W.mobileNumber||"No phone"]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(we,{variant:"outline",className:"bg-purple-50 text-purple-700 border-purple-200",children:[e.jsx(dc,{className:"w-3 h-3 mr-1"}),W.roleCode]}),e.jsx("div",{className:"text-xs text-slate-500",children:W.department||"No department"})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex flex-col items-start gap-1",children:e.jsxs(we,{variant:W.status==="active"?"default":"destructive",className:`text-xs ${W.status==="active"?"bg-green-600 hover:bg-green-700":""}`,children:[W.status==="active"?e.jsx(ln,{className:"w-3 h-3 mr-1"}):e.jsx(ai,{className:"w-3 h-3 mr-1"}),W.status]})}),e.jsx(yp,{checked:W.isActive,onCheckedChange:()=>Z(W)})]})}),e.jsx(oe,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(te,{variant:"ghost",size:"icon",onClick:()=>L(W),children:e.jsx(gr,{className:"w-4 h-4 text-slate-400 hover:text-re-red"})}),e.jsx(te,{variant:"ghost",size:"icon",children:e.jsx(Zn,{className:"w-4 h-4 text-slate-400 hover:text-red-600"})})]})})]},W.id)})})]})})}),e.jsx(ms,{open:_,onOpenChange:A,children:e.jsxs(us,{className:"max-w-2xl bg-white",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:E?"Edit User":"Add New User"}),e.jsx(ws,{children:"Modify user profiles and system access settings."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(it,{id:"fullName",value:O.fullName,onChange:W=>R({...O,fullName:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"email",children:"Email Address *"}),e.jsx(it,{id:"email",type:"email",value:O.email,onChange:W=>R({...O,email:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"employeeId",children:"Employee ID"}),e.jsx(it,{id:"employeeId",value:O.employeeId,onChange:W=>R({...O,employeeId:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"roleCode",children:"Role *"}),e.jsxs(Rt,{value:O.roleCode,onValueChange:W=>R({...O,roleCode:W}),children:[e.jsx(_t,{id:"roleCode",children:e.jsx(Et,{placeholder:"Select a role"})}),e.jsx(Tt,{children:a.map(W=>e.jsx(Pe,{value:W.roleCode,children:W.roleName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"department",children:"Department"}),e.jsx(it,{id:"department",value:O.department,onChange:W=>R({...O,department:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"designation",children:"Designation"}),e.jsx(it,{id:"designation",value:O.designation,onChange:W=>R({...O,designation:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"mobileNumber",children:"Mobile Number"}),e.jsx(it,{id:"mobileNumber",value:O.mobileNumber,onChange:W=>R({...O,mobileNumber:W.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"status",children:"Account Status"}),e.jsxs(Rt,{value:O.status,onValueChange:W=>R({...O,status:W}),children:[e.jsx(_t,{id:"status",children:e.jsx(Et,{placeholder:"Select status"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"active",children:"Active"}),e.jsx(Pe,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"col-span-2 border-t pt-4 mt-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-900 mb-1",children:"Geographical Assignments"}),e.jsx("p",{className:"text-xs text-slate-500 mb-4",children:"Optional: you can create users without territory mapping and assign later."}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"zoneId",children:"Zone (Top Level)"}),e.jsxs(Rt,{value:O.zoneId,onValueChange:W=>R({...O,zoneId:W,regionId:"",stateId:"",districtId:""}),children:[e.jsx(_t,{id:"zoneId",children:e.jsx(Et,{placeholder:"Select Zone"})}),e.jsx(Tt,{children:o.map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.zoneName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"regionId",children:"Region"}),e.jsxs(Rt,{value:O.regionId,onValueChange:W=>R({...O,regionId:W}),disabled:!O.zoneId,children:[e.jsx(_t,{id:"regionId",children:e.jsx(Et,{placeholder:"Select Region"})}),e.jsx(Tt,{children:m.filter(W=>W.parents&&W.parents.some(U=>U.id===O.zoneId)||W.zoneId===O.zoneId).map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.regionName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"stateId",children:"State"}),e.jsxs(Rt,{value:O.stateId,onValueChange:W=>R({...O,stateId:W,districtId:""}),disabled:!O.zoneId,children:[e.jsx(_t,{id:"stateId",children:e.jsx(Et,{placeholder:"Select State"})}),e.jsx(Tt,{children:p.filter(W=>W.parents&&W.parents.some(U=>U.id===O.zoneId)||W.zoneId===O.zoneId).map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.stateName},W.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(le,{htmlFor:"districtId",children:"District"}),e.jsxs(Rt,{value:O.districtId,onValueChange:W=>R({...O,districtId:W}),disabled:!O.stateId,children:[e.jsx(_t,{id:"districtId",children:e.jsx(Et,{placeholder:"Select District"})}),e.jsx(Tt,{children:x.filter(W=>W.parents&&W.parents.some(U=>U.id===O.stateId)||W.stateId===O.stateId).map(W=>e.jsx(Pe,{value:W.id,children:W.name||W.districtName},W.id))})]})]})]})]})]}),e.jsxs(mn,{className:"bg-slate-50 -mx-6 -mb-6 p-4 rounded-b-lg",children:[e.jsx(te,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover text-white",onClick:$,children:E?"Save Changes":"Create User"})]})]})})]})}const Ty={healthy:"0–25% elapsed",warning:"26–75% elapsed",critical:"76–99% elapsed",breached:"Breached"},Y_={healthy:"bg-emerald-100 text-emerald-800 border-emerald-200",warning:"bg-red-50 text-red-800 border-red-200",critical:"bg-orange-100 text-orange-800 border-orange-200",breached:"bg-red-100 text-red-800 border-red-200"},IG=["ALL","ONBOARDING","TERMINATION","RESIGNATION","RELOCATION","CONSTITUTIONAL","FNF"];function MG({bucket:t}){return e.jsx(we,{variant:"outline",className:`text-[10px] font-semibold ${Y_[t]}`,children:Ty[t]})}function FG({percent:t,bucket:s}){const n=s==="breached"?"bg-red-500":s==="critical"?"bg-orange-500":s==="warning"?"bg-red-500":"bg-emerald-500",r=Math.min(t,100);return e.jsxs("div",{className:"min-w-[100px]",children:[e.jsx("div",{className:"h-1.5 w-full bg-slate-100 rounded-full overflow-hidden mb-1",children:e.jsx("div",{className:`h-full rounded-full ${n}`,style:{width:`${r}%`}})}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[t,"% of TAT"]}),e.jsx("div",{className:"mt-1",children:e.jsx(MG,{bucket:s})})]})}function Tv({items:t,emptyMessage:s}){return t.length===0?e.jsx("p",{className:"text-sm text-slate-500 py-8 text-center",children:s}):e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Case"}),e.jsx(me,{children:"Module"}),e.jsx(me,{children:"Stage"}),e.jsx(me,{children:"Owner"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Time"}),e.jsx(me,{className:"w-10"})]})}),e.jsx(Bs,{children:t.map(n=>e.jsxs(lt,{className:n.bucket==="breached"?"bg-red-50/40":void 0,children:[e.jsx(oe,{className:"font-medium text-slate-900",children:n.caseRef}),e.jsx(oe,{children:e.jsx(we,{variant:"secondary",className:"text-[10px]",children:n.module})}),e.jsx(oe,{className:"text-slate-700 max-w-[200px] truncate",title:n.stageName,children:n.stageName}),e.jsx(oe,{className:"text-slate-600 text-xs",children:n.ownerRole}),e.jsx(oe,{children:e.jsx(FG,{percent:n.percentUsed,bucket:n.bucket})}),e.jsxs(oe,{className:"text-xs text-slate-600",children:[e.jsx("div",{children:n.remainingLabel}),e.jsxs("span",{className:"text-[10px] text-slate-400 block",children:["Due ",new Date(n.deadline).toLocaleString()]})]}),e.jsx(oe,{children:e.jsx("a",{href:n.link,target:"_blank",rel:"noopener noreferrer",className:"text-re-red hover:text-red-800",title:"Open case",children:e.jsx(ik,{className:"w-4 h-4"})})})]},n.trackingId))})]})}const BG=()=>{var A,E,q,O,R,P,L,$,Z;const[t,s]=g.useState(null),[n,r]=g.useState(!0),[a,i]=g.useState("ALL"),[o,d]=g.useState("queue"),[m,f]=g.useState(!1),[p,h]=g.useState(null),[x,u]=g.useState({}),[N,v]=g.useState(!1),w=g.useCallback(async()=>{r(!0);try{const Q=await Yl.getOperationsDashboard({module:a==="ALL"?void 0:a,mineOnly:m});Q!=null&&Q.success?s(Q.data):J.error("Failed to load SLA monitor")}catch{J.error("Failed to load SLA monitor")}finally{r(!1)}},[a,o,m]);g.useEffect(()=>{w()},[w]),g.useEffect(()=>{Yl.getQuestionnaireReminderSettings().then(Q=>{Q!=null&&Q.success&&Q.data&&(h(Q.data),u(Q.data))}).catch(()=>{})},[]);const j=async()=>{v(!0);try{const Q=await Yl.updateQuestionnaireReminderSettings(x);Q!=null&&Q.success&&(h(Q.data),u(Q.data),J.success("Questionnaire reminder settings saved"))}catch{J.error("Failed to save settings")}finally{v(!1)}},b=t==null?void 0:t.summary,C=t==null?void 0:t.analytics,S=(t==null?void 0:t.activeQueue)??[],D=S.filter(Q=>Q.bucket==="breached"),_=S.filter(Q=>Q.bucket==="warning"||Q.bucket==="critical");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(rd,{className:"w-5 h-5 text-re-red"}),"SLA Operations Monitor"]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["Live queue, aging buckets, breaches, and scheduler health",(t==null?void 0:t.generatedAt)&&e.jsxs("span",{className:"ml-2 text-slate-400",children:["· Updated ",new Date(t.generatedAt).toLocaleTimeString()]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[e.jsx(Tn,{id:"sla-mine-only",checked:m,onCheckedChange:Q=>f(!!Q)}),e.jsx(le,{htmlFor:"sla-mine-only",className:"text-sm cursor-pointer",children:"My queue only"})]}),e.jsxs(Rt,{value:a,onValueChange:i,children:[e.jsx(_t,{className:"w-[180px] h-9",children:e.jsx(Et,{placeholder:"Module"})}),e.jsx(Tt,{children:IG.map(Q=>e.jsx(Pe,{value:Q,children:Q==="ALL"?"All modules":Q},Q))})]}),e.jsxs(te,{variant:"outline",size:"sm",onClick:()=>Yl.exportOperationsCsv({module:a==="ALL"?void 0:a,mineOnly:m}).catch(()=>J.error("Export failed")),children:[e.jsx(fi,{className:"w-4 h-4 mr-1"}),"Export CSV"]}),e.jsxs(te,{variant:"outline",size:"sm",onClick:w,disabled:n,children:[e.jsx(or,{className:`w-4 h-4 mr-1 ${n?"animate-spin":""}`}),"Refresh"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-3",children:[e.jsx(du,{label:"In queue",value:(b==null?void 0:b.activeCount)??"—",icon:e.jsx(dn,{className:"w-4 h-4 text-blue-600"})}),e.jsx(du,{label:"Breached",value:(b==null?void 0:b.breachedCount)??"—",icon:e.jsx(Ba,{className:"w-4 h-4 text-red-600"}),highlight:"red"}),e.jsx(du,{label:"Due soon",value:(b==null?void 0:b.dueSoonCount)??"—",icon:e.jsx(sM,{className:"w-4 h-4 text-re-red"})}),e.jsx(du,{label:"On track",value:(b==null?void 0:b.onTrackCount)??"—",icon:e.jsx(Hn,{className:"w-4 h-4 text-emerald-600"})}),e.jsx(du,{label:"Open breaches",value:(b==null?void 0:b.openBreachesCount)??"—",icon:e.jsx(Ba,{className:"w-4 h-4 text-re-red"})})]}),C&&e.jsxs(_e,{className:"border-slate-200",children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsxs(st,{className:"text-sm flex items-center gap-2",children:[e.jsx(PI,{className:"w-4 h-4 text-re-red"}),"Analytics (last ",C.periodDays," days)"]}),e.jsx(es,{children:"Breach rate, resolution time, and top delayed stages"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(Dm,{label:"Tracks started",value:C.tracksStarted}),e.jsx(Dm,{label:"Breach rate",value:`${C.breachRatePercent}%`,highlight:!0}),e.jsx(Dm,{label:"Avg resolution",value:C.avgResolutionHours!=null?`${C.avgResolutionHours}h`:"—"}),e.jsx(Dm,{label:"Completed tracks",value:C.completedTracks})]}),C.topDelayedStages.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase mb-2",children:"Top delayed stages"}),e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Stage"}),e.jsx(me,{children:"Breaches (30d)"}),e.jsx(me,{children:"Active breached"})]})}),e.jsx(Bs,{children:C.topDelayedStages.map(Q=>e.jsxs(lt,{children:[e.jsx(oe,{className:"font-medium",children:Q.stageName}),e.jsx(oe,{children:Q.breachCount}),e.jsx(oe,{children:Q.currentlyBreached})]},Q.stageName))})]})]}),Object.keys(C.breachesByModule).length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(C.breachesByModule).map(([Q,W])=>e.jsxs(we,{variant:"outline",children:[Q,": ",W," breaches"]},Q))})]})]}),b&&e.jsxs(_e,{className:"border-slate-200",children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(st,{className:"text-sm",children:"Aging buckets"}),e.jsx(es,{children:"Percent of configured TAT elapsed"})]}),e.jsxs(Oe,{className:"flex flex-wrap gap-2",children:[Object.keys(Ty).map(Q=>e.jsxs(we,{variant:"outline",className:`px-3 py-1 ${Y_[Q]}`,children:[Ty[Q],": ",b.buckets[Q]??0]},Q)),b.tracksWithoutConfig>0&&e.jsxs(we,{variant:"outline",className:"bg-slate-100 text-slate-600",children:["No config match: ",b.tracksWithoutConfig]})]})]}),e.jsxs(In,{value:o,onValueChange:d,children:[e.jsxs(Mn,{className:"bg-slate-100",children:[e.jsxs(Ht,{value:"queue",children:["Active queue (",S.length,")"]}),e.jsxs(Ht,{value:"breached",children:["Breached (",D.length,")"]}),e.jsxs(Ht,{value:"due",children:["Due soon (",_.length,")"]}),e.jsxs(Ht,{value:"breach-log",children:["Open breaches (",((A=t==null?void 0:t.breaches)==null?void 0:A.length)??0,")"]}),e.jsx(Ht,{value:"schedulers",children:"Schedulers"})]}),e.jsx(Vt,{value:"queue",className:"mt-4",children:e.jsx(_e,{children:e.jsx(Oe,{className:"pt-4",children:e.jsx(Tv,{items:S,emptyMessage:"No active SLA timers in queue."})})})}),e.jsx(Vt,{value:"breached",className:"mt-4",children:e.jsx(_e,{children:e.jsx(Oe,{className:"pt-4",children:e.jsx(Tv,{items:D,emptyMessage:"No breached items — all active SLAs are within TAT."})})})}),e.jsx(Vt,{value:"due",className:"mt-4",children:e.jsx(_e,{children:e.jsx(Oe,{className:"pt-4",children:e.jsx(Tv,{items:_,emptyMessage:"Nothing in the 26–99% window right now."})})})}),e.jsx(Vt,{value:"breach-log",className:"mt-4",children:e.jsx(_e,{children:e.jsx(Oe,{className:"pt-4",children:(E=t==null?void 0:t.breaches)!=null&&E.length?e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Case"}),e.jsx(me,{children:"Module"}),e.jsx(me,{children:"Stage"}),e.jsx(me,{children:"Breached at"}),e.jsx(me,{children:"Status"}),e.jsx(me,{})]})}),e.jsx(Bs,{children:t.breaches.map(Q=>e.jsxs(lt,{children:[e.jsx(oe,{className:"font-medium",children:Q.caseRef}),e.jsx(oe,{children:e.jsx(we,{variant:"secondary",className:"text-[10px]",children:Q.module})}),e.jsx(oe,{className:"truncate max-w-[200px]",children:Q.stageName}),e.jsx(oe,{className:"text-xs",children:new Date(Q.breachedAt).toLocaleString()}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:Q.status})}),e.jsx(oe,{children:e.jsx("a",{href:Q.link,target:"_blank",rel:"noopener noreferrer",className:"text-re-red",children:e.jsx(ik,{className:"w-4 h-4"})})})]},Q.id))})]}):e.jsx("p",{className:"text-sm text-slate-500 py-8 text-center",children:"No open breach records."})})})}),e.jsx(Vt,{value:"schedulers",className:"mt-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"text-sm flex items-center gap-2",children:[e.jsx(Gr,{className:"w-4 h-4"}),"Prospect questionnaire reminders"]}),e.jsxs(es,{children:["Email/WhatsApp to applicants in Questionnaire Pending (not internal SLA)",(p==null?void 0:p.source)&&e.jsxs("span",{className:"block text-slate-400",children:["Source: ",p.source]})]})]}),e.jsxs(Oe,{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{id:"q-enabled",checked:!!x.enabled,onCheckedChange:Q=>u(W=>({...W,enabled:!!Q}))}),e.jsx(le,{htmlFor:"q-enabled",children:"Scheduler enabled"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(le,{className:"text-xs",children:"First after (days)"}),e.jsx(it,{type:"number",min:1,value:x.firstAfterDays??"",onChange:Q=>u(W=>({...W,firstAfterDays:Number(Q.target.value)}))})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-xs",children:"Interval (days)"}),e.jsx(it,{type:"number",min:1,value:x.intervalDays??"",onChange:Q=>u(W=>({...W,intervalDays:Number(Q.target.value)}))})]}),e.jsxs("div",{children:[e.jsx(le,{className:"text-xs",children:"Max reminders"}),e.jsx(it,{type:"number",min:1,value:x.maxCount??"",onChange:Q=>u(W=>({...W,maxCount:Number(Q.target.value)}))})]})]}),e.jsx(te,{size:"sm",onClick:j,disabled:N,children:N?"Saving…":"Save reminder settings"})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"text-sm flex items-center gap-2",children:[e.jsx(YI,{className:"w-4 h-4"}),"Infrastructure"]})}),e.jsxs(Oe,{className:"space-y-2 text-sm",children:[e.jsx(Pv,{label:"Redis",value:(q=t==null?void 0:t.scheduler)!=null&&q.redisEnabled?"Enabled":"Disabled",ok:(O=t==null?void 0:t.scheduler)==null?void 0:O.redisEnabled}),e.jsx(Pv,{label:"SLA fast mode",value:(R=t==null?void 0:t.scheduler)!=null&&R.slaFastMode?"On":"Off",ok:!((P=t==null?void 0:t.scheduler)!=null&&P.slaFastMode)}),e.jsx(Pv,{label:"Questionnaire fast mode",value:(L=t==null?void 0:t.scheduler)!=null&&L.questionnaireFastMode?"On":"Off",ok:!(($=t==null?void 0:t.scheduler)!=null&&$.questionnaireFastMode)})]})]}),(((Z=t==null?void 0:t.scheduler)==null?void 0:Z.queues)??[]).map(Q=>{var W;return e.jsxs(_e,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(st,{className:"text-sm",children:Q.name}),Q.key&&e.jsx(es,{children:Q.key})]}),e.jsx(Oe,{className:"text-sm",children:Q.error?e.jsx("p",{className:"text-red-600",children:Q.error}):e.jsxs(e.Fragment,{children:[Q.counts&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Object.entries(Q.counts).map(([U,M])=>e.jsxs(we,{variant:"outline",children:[U,": ",M]},U))}),(W=Q.repeatable)!=null&&W.length?e.jsx("ul",{className:"text-xs text-slate-600 space-y-1",children:Q.repeatable.map((U,M)=>e.jsxs("li",{children:[U.name||U.pattern,U.next?` · next ${new Date(U.next).toLocaleString()}`:""]},M))}):e.jsx("p",{className:"text-slate-400 text-xs",children:"No repeatable jobs registered"})]})})]},Q.name)})]})})]})]})};function Dm({label:t,value:s,highlight:n}){return e.jsxs("div",{className:`rounded-lg border p-3 ${n?"border-red-200 bg-red-50/40":"border-slate-200 bg-slate-50/50"}`,children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:t}),e.jsx("p",{className:"text-xl font-bold text-slate-900",children:s})]})}function du({label:t,value:s,icon:n,highlight:r}){return e.jsx(_e,{className:r==="red"?"border-red-200 bg-red-50/30":"border-slate-200",children:e.jsx(Oe,{className:"pt-4 pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500 uppercase tracking-wide",children:t}),e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:s})]}),n]})})})}function Pv({label:t,value:s,ok:n}){return e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-600",children:t}),e.jsx("span",{className:n===!1?"text-re-red-hover font-medium":"text-slate-900",children:s})]})}const $G=({isOpen:t,onClose:s,sla:n,onSave:r})=>{const[a,i]=g.useState({activityName:"",tatHours:24,tatUnit:"hours",isActive:!0,reminders:[],escalationConfigs:[]}),[o,d]=g.useState(!1);g.useEffect(()=>{n&&i({...n,reminders:n.reminders||[],escalationConfigs:n.escalationConfigs||[]})},[n]);const m=()=>{i({...a,reminders:[...a.reminders,{timeValue:1,timeUnit:"days",isEnabled:!0}]})},f=u=>{const N=[...a.reminders];N.splice(u,1),i({...a,reminders:N})},p=()=>{i({...a,escalationConfigs:[...a.escalationConfigs,{level:a.escalationConfigs.length+1,timeValue:1,timeUnit:"days",notifyEmail:""}]})},h=u=>{const N=[...a.escalationConfigs];N.splice(u,1);const v=N.map((w,j)=>({...w,level:j+1}));i({...a,escalationConfigs:v})},x=async u=>{if(u.preventDefault(),!a.activityName||!a.ownerRole){J.error("Activity Name and Owner Role are required");return}try{d(!0),await $s.saveSlaConfig(a),J.success(n!=null&&n.id?"SLA Configuration updated":"New SLA Configuration created"),r(),s()}catch(N){console.error("Save SLA error:",N),J.error("Failed to save SLA configuration")}finally{d(!1)}};return e.jsx(ms,{open:t,onOpenChange:s,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsxs(gs,{children:[n!=null&&n.id?"Configure SLA":"Add New SLA",": ",a.activityName||"New Activity"]}),e.jsx(ws,{children:"Define the Turn Around Time and notification rules for this stage."})]}),e.jsxs("form",{onSubmit:x,className:"space-y-6 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"activityName",children:"Activity Name (Workflow Stage)"}),e.jsxs(Rt,{value:a.activityName,onValueChange:u=>{let N=a.ownerRole;for(const v of Object.values(S2))if(v[u]){N=v[u];break}i({...a,activityName:u,ownerRole:N})},disabled:!!(n!=null&&n.id),children:[e.jsx(_t,{id:"activityName",children:e.jsx(Et,{placeholder:"Select Stage"})}),e.jsx(Tt,{children:Object.entries(S2).map(([u,N])=>e.jsxs(Ct.Fragment,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-slate-500 bg-slate-50",children:u}),Object.keys(N).map(v=>e.jsx(Pe,{value:v,children:v},v))]},u))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"ownerRole",children:"Owner Role (Auto-resolved)"}),e.jsxs(Rt,{value:a.ownerRole,onValueChange:u=>i({...a,ownerRole:u}),disabled:!!(n!=null&&n.id),children:[e.jsx(_t,{id:"ownerRole",children:e.jsx(Et,{placeholder:"Select Role"})}),e.jsx(Tt,{children:Object.values(an).map(u=>e.jsx(Pe,{value:u,children:u},u))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"tatHours",children:"Target TAT"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(it,{id:"tatHours",type:"number",value:a.tatHours,onChange:u=>i({...a,tatHours:parseInt(u.target.value)})}),e.jsxs(Rt,{value:a.tatUnit,onValueChange:u=>i({...a,tatUnit:u}),children:[e.jsx(_t,{className:"w-32",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"hours",children:"Hours"}),e.jsx(Pe,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-8",children:[e.jsx(yp,{id:"isActive",className:"data-[state=checked]:bg-re-red",checked:a.isActive,onCheckedChange:u=>i({...a,isActive:u})}),e.jsx(le,{htmlFor:"isActive",children:"Active SLA Tracking"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Au,{className:"w-4 h-4 text-blue-600"}),e.jsx("h4",{className:"font-medium text-sm",children:"Reminders"})]}),e.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7 text-xs",children:[e.jsx(bn,{className:"w-3 h-3 mr-1"})," Add Reminder"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.reminders.map((u,N)=>e.jsxs("div",{className:"flex items-center gap-3 bg-slate-50 p-2 rounded-lg border border-slate-100",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500 w-12 text-center",children:"Before"}),e.jsx(it,{type:"number",className:"w-20 h-8",value:u.timeValue,onChange:v=>{const w=[...a.reminders];w[N].timeValue=parseInt(v.target.value),i({...a,reminders:w})}}),e.jsxs(Rt,{value:u.timeUnit,onValueChange:v=>{const w=[...a.reminders];w[N].timeUnit=v,i({...a,reminders:w})},children:[e.jsx(_t,{className:"w-24 h-8 text-xs",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"hours",children:"Hours"}),e.jsx(Pe,{value:"days",children:"Days"})]})]}),e.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(N),className:"h-8 w-8 p-0 text-slate-400 hover:text-red-500",children:e.jsx(Zn,{className:"w-4 h-4"})})]},N)),a.reminders.length===0&&e.jsx("p",{className:"text-center text-xs text-slate-400 py-2",children:"No reminders set"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ba,{className:"w-4 h-4 text-re-red"}),e.jsx("h4",{className:"font-medium text-sm",children:"Escalation Levels"})]}),e.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7 text-xs",children:[e.jsx(bn,{className:"w-3 h-3 mr-1"})," Add Level"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.escalationConfigs.map((u,N)=>e.jsxs("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(we,{variant:"outline",className:"bg-red-50 text-re-red-hover border-red-100",children:["Level ",u.level]}),e.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(N),className:"h-7 w-7 p-0 text-slate-400 hover:text-red-500",children:e.jsx(Zn,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(le,{className:"text-[10px] uppercase text-slate-500",children:"Escalate After Breaching By"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(it,{type:"number",className:"h-8",value:u.timeValue,onChange:v=>{const w=[...a.escalationConfigs];w[N].timeValue=parseInt(v.target.value),i({...a,escalationConfigs:w})}}),e.jsxs(Rt,{value:u.timeUnit,onValueChange:v=>{const w=[...a.escalationConfigs];w[N].timeUnit=v,i({...a,escalationConfigs:w})},children:[e.jsx(_t,{className:"w-24 h-8 text-xs",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"hours",children:"Hours"}),e.jsx(Pe,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(le,{className:"text-[10px] uppercase text-slate-500",children:"Notification Recipient (Role)"}),e.jsxs(Rt,{value:u.notifyRole||"",onValueChange:v=>{const w=[...a.escalationConfigs];w[N].notifyRole=v,w[N].notifyEmail="",i({...a,escalationConfigs:w})},children:[e.jsx(_t,{className:"h-8 text-xs",children:e.jsx(Et,{placeholder:"Select Recipient Role"})}),e.jsx(Tt,{children:Object.values(an).map(v=>e.jsx(Pe,{value:v,children:v},v))})]})]})]})]},N)),a.escalationConfigs.length===0&&e.jsx("p",{className:"text-center text-xs text-slate-400 py-2",children:"No escalation levels defined"})]})]}),e.jsxs(mn,{className:"pt-4 border-t",children:[e.jsx(te,{type:"button",variant:"outline",onClick:s,disabled:o,children:"Cancel"}),e.jsx(te,{type:"submit",disabled:o,className:"bg-re-red hover:bg-re-red-hover text-white",children:o?"Saving...":"Save Configuration"})]})]})]})})},qG=()=>{const t=Lu(),{slaConfigs:s,loading:n}=Pn(v=>v.master),[r,a]=g.useState(!1),[i,o]=g.useState(null),[d,m]=g.useState(!1),[f,p]=g.useState("monitor"),h=async()=>{try{const v=await $s.getSlaConfigs();v&&v.success&&t(AA({slaConfigs:v.data}))}catch{J.error("Failed to fetch SLA configurations")}};g.useEffect(()=>{h()},[]);const x=async()=>{try{m(!0);const v=await $s.initializeDefaultSlas();v&&v.success&&(J.success("Default SLAs initialized successfully"),h())}catch{J.error("Failed to initialize default SLAs")}finally{m(!1)}},u=v=>{o(v),a(!0)},N=()=>{o(null),a(!0)};return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(dn,{className:"w-6 h-6 text-re-red"}),"SLA & Escalation"]}),e.jsx("p",{className:"text-slate-500",children:"Configure TAT rules and monitor live queue, breaches, and schedulers"})]}),e.jsxs(In,{value:f,onValueChange:p,children:[e.jsxs(Mn,{className:"bg-slate-100",children:[e.jsxs(Ht,{value:"monitor",className:"flex items-center gap-1.5",children:[e.jsx(rd,{className:"w-4 h-4"}),"Operations monitor"]}),e.jsx(Ht,{value:"config",children:"Configuration matrix"})]}),e.jsx(Vt,{value:"monitor",className:"mt-6",children:e.jsx(BG,{})}),e.jsxs(Vt,{value:"config",className:"mt-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsxs(te,{variant:"outline",onClick:x,disabled:n||d,children:[e.jsx(or,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Initialize Defaults"]}),e.jsxs(te,{onClick:N,disabled:n,className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"Add Manual SLA"]}),e.jsx(te,{variant:"ghost",size:"icon",onClick:h,disabled:n,children:e.jsx(or,{className:`w-4 h-4 ${n?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.map(v=>{var w,j;return e.jsxs(_e,{className:"border-slate-200 hover:shadow-md transition-shadow group overflow-hidden",children:[e.jsx(Xe,{className:"pb-3 bg-gradient-to-br from-white to-slate-50/50",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-50 border border-red-100 flex items-center justify-center",children:e.jsx(dn,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(st,{className:"text-lg",children:v.activityName}),e.jsx(es,{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"font-semibold text-re-red-hover",children:["Target TAT: ",v.tatHours," ",v.tatUnit]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{variant:v.isActive?"default":"secondary",className:v.isActive?"bg-emerald-600":"bg-slate-400",children:v.isActive?e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"w-3 h-3 mr-1"})," Active"]}):"Disabled"}),e.jsx(te,{variant:"ghost",size:"icon",onClick:()=>u(v),className:"h-8 w-8 text-slate-400 hover:text-re-red",children:e.jsx(gr,{className:"w-4 h-4"})})]})]})}),e.jsxs(Oe,{className:"pt-4 grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border-l-2 border-blue-400 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Au,{className:"w-4 h-4 text-blue-600"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Reminders (",((w=v.reminders)==null?void 0:w.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[(v.reminders||[]).map((b,C)=>e.jsxs("div",{className:"text-xs text-slate-600 flex items-center gap-1",children:[e.jsxs(we,{variant:"outline",className:"text-[10px] h-4.5 bg-blue-50 border-blue-200",children:[b.timeValue," ",b.timeUnit]}),e.jsx("span",{children:"before SLA"})]},C)),(!v.reminders||v.reminders.length===0)&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"None configured"})]})]}),e.jsxs("div",{className:"border-l-2 border-red-400 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ba,{className:"w-4 h-4 text-re-red"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Escalations (",((j=v.escalationConfigs)==null?void 0:j.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-2",children:[(v.escalationConfigs||[]).map((b,C)=>e.jsxs("div",{className:"text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-slate-900 font-medium",children:[e.jsxs(we,{variant:"outline",className:"text-[9px] h-4 px-1 bg-red-50 border-red-200 text-re-red-hover",children:["L",b.level]}),e.jsxs("span",{children:["after ",b.timeValue," ",b.timeUnit]})]}),e.jsx("p",{className:"text-slate-500 ml-8 font-mono truncate",children:b.notifyEmail})]},C)),(!v.escalationConfigs||v.escalationConfigs.length===0)&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"None configured"})]})]})]})]},v.id)}),s.length===0&&!n&&e.jsxs("div",{className:"lg:col-span-2 py-20 text-center border-2 border-dashed rounded-2xl bg-slate-50/50",children:[e.jsx(dn,{className:"w-12 h-12 text-slate-200 mx-auto mb-4"}),e.jsx("h3",{className:"text-slate-600 font-medium",children:"No SLA Workflows found"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Please initialize default configurations from the admin tools"})]})]})]})]}),e.jsx($G,{isOpen:r,onClose:()=>a(!1),sla:i,onSave:h})]})},Z_="Private Limited",Q_="LLP",X_="Partnership",gj="Proprietorship",J_=[gj,X_,Q_,Z_];function zG(t){return J_.includes(t)}function UG(t){const s=String(t||"").trim();if(!s)return null;if(zG(s))return s;const n=s.toLowerCase().replace(/\./g,"").replace(/\s+/g," ").trim();return n.includes("private")&&(n.includes("ltd")||n.includes("limited"))||n==="pvt ltd"||n==="pvtltd"?Z_:n.includes("llp")?Q_:n.includes("partnership")?X_:n.includes("proprietorship")||n==="sole proprietorship"?gj:J_.find(a=>a.toLowerCase()===s.toLowerCase())||null}function eT(t){return UG(t)||gj}const VG={Partnership:[1,2,3,4,8,9,10,16],LLP:[1,2,3,7,8,10,11,16],"Private Limited":[1,2,3,5,6,7,8,10,16],Proprietorship:[1,2,3,10,16]},HG=99,WG={1:"GST",2:"Firm Pan Copy",3:"Self attested KYC's",4:"Partnership Agreement (Notarised)",5:"MOA (Applicable for Only Pvt.Ltd)",6:"AOA (Applicable for Only Pvt.Ltd)",7:"COI (Applicable for Only Pvt.Ltd & LLP)",8:"BPA - Business Purchase Agreement",9:"Firm Registration Certificate (Partnership)",10:"Cancelled Cheque",11:"LLP Agreement (Notarised)",12:"ZBH Approval",13:"NBH Approval",14:"RBM Approval",15:"DD-Lead Approval",16:"Declaration / Authorization Letter",[HG]:"Other"},A2=(t,s)=>Qb(t,s),rl=t=>{switch(t){case"Proprietorship":return"bg-purple-100 text-purple-700 border-purple-300";case"Partnership":return"bg-blue-100 text-blue-700 border-blue-300";case"LLP":return"bg-indigo-100 text-indigo-700 border-indigo-300";case"Private Limited":return"bg-cyan-100 text-cyan-700 border-cyan-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}};function GG({onViewDetails:t}){var Me,ut,jt,ft;const[s,n]=g.useState(!1),[r,a]=g.useState([]),[i,o]=g.useState([]),[d,m]=g.useState([]),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState([]),[v,w]=g.useState(null),[j,b]=g.useState(""),[C,S]=g.useState(""),[D,_]=g.useState([]),[A,E]=g.useState([]),[q,O]=g.useState(!0),[R,P]=g.useState(1),[L,$]=g.useState(null),[Z,Q]=g.useState("all"),W=10,U=A.map(X=>({entityType:"constitutional",entityId:X.id||X.requestId})),{get:M}=mc(U,A.length>0),[z,T]=g.useState(!1),[F,I]=g.useState(!1),K=X=>X.status==="Completed"||X.status==="Closed"||X.currentStage==="Completed",G=X=>X.status==="Rejected"||X.status==="Revoked"||X.currentStage==="Rejected"||X.currentStage==="Revoked",V=X=>!K(X)&&!G(X)&&X.status!=="Submitted",Y=X=>X.status==="Submitted"||X.currentStage==="Submitted",re=X=>{Q(X),P(1)};g.useEffect(()=>{ae()},[R,Z]),g.useEffect(()=>{if(!s)return;let X=!1;return(async()=>{var Ce,xe,We,Be;try{I(!0);const[rt,ht,ge]=await Promise.all([Re.getConstitutionalChangeMeta(),Re.getDealers({onboarded:"true"}),Re.getOutlets()]);if(X)return;(Ce=rt.data)!=null&&Ce.success&&Array.isArray(rt.data.structureTargets)&&a(rt.data.structureTargets);const Je=((xe=ht.data)==null?void 0:xe.data)??((We=ht.data)==null?void 0:We.dealers)??[];o(Array.isArray(Je)?Je:[]);const mt=((Be=ge.data)==null?void 0:Be.outlets)??[];m(Array.isArray(mt)?mt:[])}catch(rt){console.error(rt),J.error("Failed to load dealers or form options")}finally{X||I(!1)}})(),()=>{X=!0}},[s]);const ae=async()=>{try{O(!0);const X=await Re.getConstitutionalChanges({page:R,limit:W,status:Z==="all"?void 0:Z});X.data.success&&(E(X.data.requests||[]),$(X.meta))}catch(X){console.error("Fetch requests error:",X),J.error("Failed to fetch requests")}finally{O(!1)}},ue=X=>{var Be,rt,ht;if(p(X),x(""),b(""),_([]),!X){w(null),N([]);return}const Ce=i.find(ge=>{var Je;return((Je=ge.user)==null?void 0:Je.id)===X});if(!((Be=Ce==null?void 0:Ce.user)!=null&&Be.id)){w(null),N([]);return}const xe=eT(Ce.constitutionType),We=d.filter(ge=>String(ge.dealerId)===String(X));N(We),We.length===1&&x(We[0].id),w({dealerUserId:Ce.user.id,dealerName:Ce.businessName,dealershipName:Ce.legalName||Ce.businessName,address:Ce.registeredAddress||((rt=Ce.application)==null?void 0:rt.preferredLocation)||"—",gst:Ce.gstNumber||"N/A",currentType:xe,dealerCode:((ht=Ce.dealerCode)==null?void 0:ht.dealerCode)||"—",region:"—",zone:"—"})},ye=X=>{b(X),_(VG[X]||[])},ce=async X=>{var Ce,xe;if(X.preventDefault(),!(v!=null&&v.dealerUserId)){J.error("Please select a dealer");return}if(u.length>1&&!h){J.error("Please select an outlet for this dealer");return}if(!j){J.error("Please select proposed constitution type");return}if(!C.trim()){J.error("Please provide a reason for constitutional change");return}if(v.currentType===j){J.error("Proposed type cannot be the same as the current constitution");return}try{T(!0);const We={forDealerUserId:v.dealerUserId,outletId:h||void 0,changeType:j,reason:C.trim(),currentConstitution:v.currentType};(await Re.createConstitutionalChange(We)).data.success&&(J.success("Constitutional change request submitted successfully"),n(!1),ae(),p(""),x(""),N([]),w(null),b(""),S(""),_([]))}catch(We){console.error("Submit request error:",We);const Be=((xe=(Ce=We==null?void 0:We.response)==null?void 0:Ce.data)==null?void 0:xe.message)||"Failed to submit request";J.error(Be)}finally{T(!1)}},je=[{title:"Total Requests",value:((Me=L==null?void 0:L.stats)==null?void 0:Me.total)||0,icon:ks,color:"bg-blue-500"},{title:"Submitted / Review",value:((ut=L==null?void 0:L.stats)==null?void 0:ut.pending)||0,icon:er,color:"bg-re-red"},{title:"Completed",value:((jt=L==null?void 0:L.stats)==null?void 0:jt.completed)||0,icon:dc,color:"bg-green-500"},{title:"Rejected / Revoked",value:((ft=L==null?void 0:L.stats)==null?void 0:ft.rejected)||0,icon:ad,color:"bg-red-500"}];return e.jsxs("div",{className:"space-y-6",children:[q&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/20 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Constitutional Change Management"}),e.jsx("p",{className:"text-slate-600",children:"Manage dealership constitutional change requests - Adding/Removing partners or changing business structure"})]}),e.jsxs(ms,{open:s,onOpenChange:n,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"New Request"]})}),e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Create Constitutional Change Request"}),e.jsx(ws,{children:"Submit a request for dealership constitutional change. All fields are mandatory."})]}),e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[F&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 py-2",children:[e.jsx(cs,{className:"h-4 w-4 animate-spin"}),"Loading dealers and options…"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"dealerUser",children:"Dealer *"}),e.jsxs(Rt,{value:f,onValueChange:ue,disabled:F,required:!0,children:[e.jsx(_t,{id:"dealerUser",children:e.jsx(Et,{placeholder:"Select dealer account"})}),e.jsx(Tt,{className:"max-h-72",children:i.filter(X=>{var Ce;return(Ce=X.user)==null?void 0:Ce.id}).map(X=>{var Ce;return e.jsx(Pe,{value:X.user.id,children:(((Ce=X.dealerCode)==null?void 0:Ce.dealerCode)||"No code")+" — "+(X.businessName||X.legalName||"Dealer")},X.user.id)})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Internal users create the request on behalf of the selected dealer; the workflow uses the same endpoint as dealer-initiated requests."})]}),u.length>1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"outletPick",children:"Outlet *"}),e.jsxs(Rt,{value:h,onValueChange:x,required:!0,children:[e.jsx(_t,{id:"outletPick",children:e.jsx(Et,{placeholder:"Select outlet"})}),e.jsx(Tt,{children:u.map(X=>e.jsxs(Pe,{value:X.id,children:[X.code," — ",X.name]},X.id))})]})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-3",children:[e.jsx("h3",{className:"text-slate-900",children:"Dealer Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Code:"}),e.jsx("p",{className:"text-slate-900",children:v.dealerCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Name:"}),e.jsx("p",{className:"text-slate-900",children:v.dealerName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Legal / display name:"}),e.jsx("p",{className:"text-slate-900",children:v.dealershipName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Address:"}),e.jsx("p",{className:"text-slate-900",children:v.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"GST:"}),e.jsx("p",{className:"text-slate-900",children:v.gst})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Current constitution (from profile):"}),e.jsx(we,{className:rl(v.currentType),children:v.currentType})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"targetType",children:"Proposed constitution *"}),e.jsxs(Rt,{value:j,onValueChange:ye,required:!0,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select proposed constitution"})}),e.jsx(Tt,{children:r.filter(X=>X.value!==(v==null?void 0:v.currentType)).map(X=>e.jsx(Pe,{value:X.value,children:X.label},X.value))})]}),v&&j&&v.currentType===j&&e.jsx("p",{className:"text-red-600 text-sm",children:"Target type cannot be same as current type"})]}),j&&D.length>0&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 space-y-2",children:[e.jsxs("h4",{className:"text-blue-900",children:["Required Documents for ",j]}),e.jsx("div",{className:"grid grid-cols-1 gap-2",children:D.map(X=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"text-blue-600 font-medium",children:[X,"."]}),e.jsx("span",{className:"text-blue-800",children:WG[X]})]},X))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Reason for Constitutional Change *"}),e.jsx(Ks,{id:"reason",placeholder:"Provide detailed reason for the constitutional change request...",value:C,onChange:X=>S(X.target.value),rows:4,required:!0})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-re-red hover:bg-re-red-hover",disabled:!v||!j||v&&v.currentType===j||u.length>1&&!h||F||z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:je.map((X,Ce)=>{const xe=X.icon;return e.jsx(_e,{children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:X.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:X.value})]}),e.jsx("div",{className:`${X.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(xe,{className:"w-6 h-6 text-white"})})]})})},Ce)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Constitutional Change Requests"}),e.jsx(es,{children:"Track and manage all constitutional change requests across all stages"})]}),e.jsxs(Oe,{children:[e.jsxs(In,{value:Z,onValueChange:re,className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-4",children:[e.jsx(Ht,{value:"all",children:"All Requests"}),e.jsx(Ht,{value:"pending",children:"Submitted / Review"}),e.jsx(Ht,{value:"rejected",children:"Rejected / Revoked"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:A.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No constitutional change requests found"})}):A.map(X=>{var Ce,xe,We,Be,rt,ht,ge,Je,mt,de,at,ot,ke,Zt,Bt,_s;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:X.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((We=(xe=(Ce=X.dealer)==null?void 0:Ce.dealerProfile)==null?void 0:xe.dealerCode)==null?void 0:We.dealerCode)||((Be=X.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(rt=X.dealer)==null?void 0:rt.dealerProfile)==null?void 0:ht.businessName)||((ge=X.outlet)==null?void 0:ge.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((mt=(Je=X.dealer)==null?void 0:Je.dealerProfile)==null?void 0:mt.registeredAddress)||((de=X.outlet)!=null&&de.city&&((at=X.outlet)!=null&&at.state)?`${X.outlet.city}, ${X.outlet.state}`:((Zt=(ke=(ot=X.dealer)==null?void 0:ot.dealerProfile)==null?void 0:ke.application)==null?void 0:Zt.city)||((Bt=X.outlet)==null?void 0:Bt.address)||"N/A")})]}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:rl(X.currentConstitution||"Proprietorship"),children:X.currentConstitution||"—"}),e.jsx(Wo,{className:"w-4 h-4 text-slate-400"}),e.jsx(we,{className:rl(X.changeType),children:X.changeType})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(we,{className:Jl(X.currentStage,X.status),children:X.currentStage}),e.jsx(br,{status:M("constitutional",X.id||X.requestId),compact:!0})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${fl(X.status,X.currentStage)}`,style:{width:`${X.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[X.progressPercentage||0,"%"]})]})}),e.jsxs(oe,{children:[e.jsx("div",{className:"text-slate-900",children:Qt(X.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((_s=X.dealer)==null?void 0:_s.fullName)||"Dealer"]})]}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(X.requestId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},X.requestId)})})]})})}),e.jsx(Vt,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsxs(Bs,{children:[A.filter(X=>Y(X)||V(X)).map(X=>{var Ce,xe,We,Be,rt,ht,ge,Je,mt,de,at,ot;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:X.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((We=(xe=(Ce=X.dealer)==null?void 0:Ce.dealerProfile)==null?void 0:xe.dealerCode)==null?void 0:We.dealerCode)||((Be=X.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(rt=X.dealer)==null?void 0:rt.dealerProfile)==null?void 0:ht.businessName)||((ge=X.outlet)==null?void 0:ge.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((mt=(Je=X.dealer)==null?void 0:Je.dealerProfile)==null?void 0:mt.registeredAddress)||((de=X.outlet)!=null&&de.city&&((at=X.outlet)!=null&&at.state)?`${X.outlet.city}, ${X.outlet.state}`:((ot=X.outlet)==null?void 0:ot.address)||"N/A")})]}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:rl(X.currentConstitution||"Proprietorship"),children:X.currentConstitution||"—"}),e.jsx(Wo,{className:"w-4 h-4 text-slate-400"}),e.jsx(we,{className:rl(X.changeType),children:X.changeType})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(we,{className:Jl(X.currentStage,X.status),children:X.currentStage}),e.jsx(br,{status:M("constitutional",X.id||X.requestId),compact:!0})]})}),e.jsx(oe,{children:e.jsx(we,{className:A2(X.status,X.currentStage),children:X.status})}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(X.requestId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},X.requestId)}),A.filter(X=>Y(X)||V(X)).length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No pending requests found"})})]})]})})}),e.jsx(Vt,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Actions"})]})}),e.jsxs(Bs,{children:[A.filter(X=>G(X)).map(X=>{var Ce,xe,We,Be,rt,ht,ge,Je,mt,de,at,ot,ke,Zt,Bt;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:X.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((We=(xe=(Ce=X.dealer)==null?void 0:Ce.dealerProfile)==null?void 0:xe.dealerCode)==null?void 0:We.dealerCode)||((Be=X.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(rt=X.dealer)==null?void 0:rt.dealerProfile)==null?void 0:ht.businessName)||((ge=X.outlet)==null?void 0:ge.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((mt=(Je=X.dealer)==null?void 0:Je.dealerProfile)==null?void 0:mt.registeredAddress)||((de=X.outlet)!=null&&de.city&&((at=X.outlet)!=null&&at.state)?`${X.outlet.city}, ${X.outlet.state}`:((Zt=(ke=(ot=X.dealer)==null?void 0:ot.dealerProfile)==null?void 0:ke.application)==null?void 0:Zt.city)||((Bt=X.outlet)==null?void 0:Bt.address)||"N/A")})]}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:rl(X.currentConstitution||"Proprietorship"),children:X.currentConstitution||"—"}),e.jsx(Wo,{className:"w-4 h-4 text-slate-400"}),e.jsx(we,{className:rl(X.changeType),children:X.changeType})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${fl(X.status,X.currentStage)}`,style:{width:`${X.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[X.progressPercentage||0,"%"]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(we,{className:Jl(X.currentStage,X.status),children:X.currentStage}),e.jsx(br,{status:M("constitutional",X.id||X.requestId),compact:!0})]})}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(X.requestId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},X.requestId)}),A.filter(X=>G(X)).length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No in-progress requests found"})})]})]})})}),e.jsx(Vt,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Constitutional Change"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsxs(Bs,{children:[A.filter(X=>K(X)).map(X=>{var Ce,xe,We,Be,rt,ht,ge,Je,mt,de,at,ot;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:X.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((We=(xe=(Ce=X.dealer)==null?void 0:Ce.dealerProfile)==null?void 0:xe.dealerCode)==null?void 0:We.dealerCode)||((Be=X.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(rt=X.dealer)==null?void 0:rt.dealerProfile)==null?void 0:ht.businessName)||((ge=X.outlet)==null?void 0:ge.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((mt=(Je=X.dealer)==null?void 0:Je.dealerProfile)==null?void 0:mt.registeredAddress)||((de=X.outlet)!=null&&de.city&&((at=X.outlet)!=null&&at.state)?`${X.outlet.city}, ${X.outlet.state}`:((ot=X.outlet)==null?void 0:ot.address)||"N/A")})]}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:rl(X.currentConstitution||"Proprietorship"),children:X.currentConstitution||"—"}),e.jsx(Wo,{className:"w-4 h-4 text-slate-400"}),e.jsx(we,{className:rl(X.changeType),children:X.changeType})]})}),e.jsx(oe,{children:e.jsx(we,{className:A2(X.status,X.currentStage),children:X.status})}),e.jsx(oe,{children:e.jsx("div",{className:"text-slate-900",children:Qt(X.createdAt)})}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>t(X.requestId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},X.requestId)}),A.filter(X=>K(X)).length===0&&e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No completed requests found"})})]})]})})})]}),L&&L.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>P(X=>Math.max(1,X-1)),className:R===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(L.totalPages)].map((X,Ce)=>{const xe=Ce+1;return xe===1||xe===L.totalPages||xe>=R-1&&xe<=R+1?e.jsx(pn,{children:e.jsx($i,{isActive:R===xe,onClick:()=>P(xe),className:"cursor-pointer",children:xe})},xe):xe===2&&R>3||xe===L.totalPages-1&&R<L.totalPages-2?e.jsx(pn,{children:e.jsx(go,{})},xe):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>P(X=>Math.min(L.totalPages,X+1)),className:R===L.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Rm={APPROVE:"approve",SEND_BACK:"sendBack",REVOKE:"revoke",REJECT:"reject",WITHDRAWAL:"withdrawal",ASSIGN:"assign",PUSH_FNF:"pushfnf",RECONSIDER:"reconsider",ISSUE_SCN:"issueSCN",SCN_RESPONSE:"scnResponse"},Em=[{id:2,name:"ASM Review",key:"asm-review",role:"ASM"},{id:3,name:"ZM/RBM Review",key:"zm-rbm-review",role:"ZM/RBM"},{id:4,name:"ZBH Review",key:"zbh-review",role:"ZBH"},{id:5,name:"DD Lead Review",key:"lead-review",role:"DD Lead"},{id:6,name:"DD Head Review",key:"head-review",role:"DD Head"},{id:7,name:"NBH Approval",key:"nbh-approval",role:"NBH"},{id:8,name:"Legal Review",key:"legal-review",role:"Legal Team"},{id:9,name:"Completed",key:"completed",role:"System"}],k2=t=>t==="ZM/RBM Review"?"ZM+RBM Review":t,D2=t=>t==="ZM/RBM"?"ZM+RBM":t,R2={Partnership:[1,2,3,4,8,9,10,16],LLP:[1,2,3,7,8,10,11,16],"Private Limited":[1,2,3,5,6,7,8,10,16],"Pvt Ltd":[1,2,3,5,6,7,8,10,16],Proprietorship:[1,2,3,10,16]},Uo=99,Hc={1:"GST Certificate",2:"Firm PAN Copy",3:"Self attested KYC's",4:"Partnership Agreement (Notarised)",5:"MOA (Applicable for Only Pvt.Ltd)",6:"AOA (Applicable for Only Pvt.Ltd)",7:"COI (Applicable for Only Pvt.Ltd & LLP)",8:"BPA - Business Purchase Agreement",9:"Firm Registration Certificate (Partnership)",10:"Cancelled Cheque",11:"LLP Agreement (Notarised)",12:"ZBH Approval",13:"NBH Approval",14:"RBM Approval",15:"DD-Lead Approval",16:"Declaration / Authorization Letter",[Uo]:"Other"},E2=t=>{switch(t){case"Proprietorship":return"bg-purple-100 text-purple-700 border-purple-300";case"Partnership":return"bg-blue-100 text-blue-700 border-blue-300";case"LLP":return"bg-indigo-100 text-indigo-700 border-indigo-300";case"Private Limited":case"Pvt Ltd":return"bg-cyan-100 text-cyan-700 border-cyan-300";default:return"bg-slate-100 text-slate-700 border-slate-300"}},Ov=t=>zE(t),KG=t=>t?"h-8 px-2 text-red-700 hover:bg-red-50 hover:text-red-800":"h-8 px-2 text-slate-700 hover:bg-slate-50",YG=t=>{const s=String(t.action||"").toUpperCase(),n=String(t.description||"").toUpperCase(),r=String(t.remarks||"").toUpperCase(),a=t.details||t.newData||{},i=String(a.targetStage||"").toUpperCase(),o=String(a.action||"").toUpperCase(),d=`${s} ${n} ${r} ${o}`.toUpperCase();return d.includes("REJECT")?{variant:"danger",badge:s.replace(/_/g," ")||"REJECTED"}:d.includes("REVOK")?{variant:"danger",badge:s.replace(/_/g," ")||"REVOKED"}:d.includes("SENT BACK")||d.includes("SEND BACK")||d.includes("RECONSIDER")?{variant:"pending",badge:s.replace(/_/g," ")||"SENT BACK"}:d.includes("APPROV")||d.includes("INITI")||d.includes("CREATE")||d.includes("VERIF")||d.includes("UPLOAD")?{variant:"success",badge:s.replace(/_/g," ")||"APPROVED"}:i==="COMPLETED"||d.includes("COMPLET")?{variant:"success",badge:"COMPLETED"}:i?{variant:"success",badge:"APPROVED"}:{variant:"neutral",badge:s.replace(/_/g," ")||"EVENT"}},_2=t=>{const s=String(t||"").trim().toLowerCase();return s?s.includes("proprietor")?"Proprietorship":s.includes("partner")?"Partnership":s.includes("llp")?"LLP":s.includes("private")||s.includes("pvt")?"Private Limited":t:""};function ZG({requestId:t,onBack:s,currentUser:n}){var fs,Vs,Qs,Xs,ie,nt,fe,Ae,Fe,Ke,Le,Ue,et,dt,ss,Wt,kt,wt,Os,as,Se,be,pt,Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt,Cs,Mt;const{get:r}=mc(t?[{entityType:"constitutional",entityId:t}]:[],!!t),a=tr(),[i,o]=g.useState(!1),[d,m]=g.useState("approve"),[f,p]=g.useState(""),[h,x]=g.useState(!1),[u,N]=g.useState(null),[v,w]=g.useState(null),[j,b]=g.useState(!1),[C,S]=g.useState("workflow"),[D,_]=g.useState("required"),[A,E]=g.useState(null),[q,O]=g.useState([]),[R,P]=g.useState(!0),[L,$]=g.useState(!1),[Z,Q]=g.useState(null),[W,U]=g.useState(!1),[M,z]=g.useState(!1),[T,F]=g.useState(null),[I,K]=g.useState(""),[G,V]=g.useState(!1),Y=async ze=>{if(ze)try{const xt=await Re.getAuditLogs("constitutional_change",ze);xt.data&&xt.data.success&&O(xt.data.data||[])}catch(xt){console.error("Error fetching audit logs:",xt)}},re=async ze=>{try{ze!=null&&ze.silent||P(!0);const xt=await Re.getConstitutionalChangeById(t);if(xt.data.success){const yt=xt.data.request;E(yt),await Y((yt==null?void 0:yt.id)||t)}else J.error("Failed to fetch request details")}catch(xt){console.error("Fetch request details error:",xt),J.error("Error loading request details")}finally{ze!=null&&ze.silent||P(!1)}};g.useEffect(()=>{re()},[t]);const ae=g.useMemo(()=>q.length>0?q:((A==null?void 0:A.timeline)||[]).map((xt,yt)=>({id:`timeline-${yt}`,action:String(xt.action||"UPDATED"),description:xt.remarks||xt.action||"Updated",stage:xt.stage||null,userName:xt.user||xt.userName||"System",remarks:xt.remarks,timestamp:xt.timestamp||xt.createdAt})),[q,A==null?void 0:A.timeline]),ue=g.useMemo(()=>{const ze=_2(String((A==null?void 0:A.changeType)||"")),yt=[...R2[ze]||[]];return yt.includes(Uo)||yt.push(Uo),yt.sort((Ot,Pt)=>Ot===Uo?1:Pt===Uo?-1:Ot-Pt)},[A==null?void 0:A.changeType]);if(R)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading request details..."})]});if(!A)return e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"Request Not Found"}),e.jsx("p",{className:"text-slate-600 mb-4",children:"The constitutional change request you're looking for doesn't exist."}),e.jsx(te,{onClick:s,children:"Go Back"})]});const ye=_2(A.changeType),ce=R2[ye]||[],je=ze=>{const xt=A.documents||[],yt=Hc[ze];return xt.find(Ot=>{const Pt=Number(Ot==null?void 0:Ot.docNumber);return!!(!Number.isNaN(Pt)&&Pt===ze||yt&&typeof(Ot==null?void 0:Ot.name)=="string"&&Ot.name.includes(yt))})},Me=ze=>{const xt=je(ze);return!!xt&&String(xt.status||"")!=="Rejected"},jt=(()=>{let ze=A.currentStage||"";if(["Rejected","Revoked","Withdrawn"].includes(A.status)&&(ze==="Rejected"||ze==="Revoked"||!ze)){const Ot=[...A.timeline||[]].reverse().find(Pt=>Pt.stage&&!["Rejected","Revoked","REJECTED","REVOKED"].includes(Pt.stage));Ot&&(ze=Ot.stage)}const xt={"ASM Review":1,"ZM/RBM Review":2,"ZM+RBM Review":2,"ZBH Review":3,"DD Lead Review":4,"DD Head Review":5,"NBH Approval":6,"Legal Review":7,Completed:8};if(xt[ze])return xt[ze];const yt=ze.trim().toLowerCase();for(const[Ot,Pt]of Object.entries(xt))if(Ot.toLowerCase()===yt||Ot.toLowerCase().includes(yt)||yt.includes(Ot.toLowerCase()))return Pt;return 1})(),ft=A.currentStage==="Completed"||String(A.status||"")==="Completed"&&!["Rejected","Revoked"].includes(String(A.currentStage||"")),X=Ad(A.status,A.currentStage),Ce=fl(A.status,A.currentStage),xe=Xb(A.status,A.currentStage),We=ze=>{const yt={Submitted:["Submitted","Draft"],"ASM Review":["ASM Review"],"ZM/RBM Review":["ZM/RBM Review","ZM+RBM Review","ZM Review","RBM Review"],"ZBH Review":["ZBH Review"],"DD Lead Review":["DD Lead Review","Lead Review"],"DD Head Review":["DD Head Review","Head Review"],"NBH Approval":["NBH Approval"],"Legal Review":["Legal Review"],Completed:["Completed"]}[ze]||[ze],Ot=(A.timeline||[]).filter(Pt=>{const Jt=String(Pt.stage||Pt.targetStage||"").trim();return yt.includes(Jt)});return Ot.length?Ot[Ot.length-1]:null},rt=(()=>{var gn,Ye;if(!A||!n)return{canApprove:!1,canReject:!1,canSendBack:!1,canRevoke:!1,isFinalState:!1,hasCurrentUserApprovedZmRbm:!1};const ze=A.currentStage,xt=A.status,yt=n.role||n.roleCode,Ot=String(n.roleCode||n.role||"").trim().toUpperCase(),Pt=["Completed","Rejected","Revoked"].includes(String(xt||""))||["Rejected","Revoked","Completed"].includes(String(ze||"")),Jt=Em.find(qt=>qt.name===ze||qt.key===ze),bs=ze==="Submitted",ns=n.roleCode==="SUPER_ADMIN"||bs&&(yt==="ASM"||n.roleCode==="ASM")||!bs&&((Jt==null?void 0:Jt.role)==="ASM"&&yt==="ASM"||((Jt==null?void 0:Jt.role)==="ZM/RBM"||(Jt==null?void 0:Jt.role)==="ZM+RBM")&&(yt==="DD-ZM"||yt==="RBM")||(Jt==null?void 0:Jt.role)==="ZBH"&&yt==="ZBH"||(Jt==null?void 0:Jt.role)==="DD Lead"&&yt==="DD Lead"||(Jt==null?void 0:Jt.role)==="DD Head"&&yt==="DD Head"||(Jt==null?void 0:Jt.role)==="NBH"&&yt==="NBH"||(Jt==null?void 0:Jt.role)==="Legal Team"&&yt==="Legal Admin"),Ds=["ZBH","DD Lead","DD Head","NBH"],ts=ns&&!Pt&&(n.roleCode==="SUPER_ADMIN"||Ds.includes(yt))&&ze!=="Legal Review"&&ze!=="Submitted";let js=A.metadata||{};if(typeof js=="string")try{js=JSON.parse(js)}catch(qt){console.error("Failed to parse metadata",qt),js={}}const tn=((gn=js==null?void 0:js.jointApprovals)==null?void 0:gn.zmRbm)||{},vn=ze==="ZM/RBM Review"||ze==="ZM+RBM Review",jn=Ot==="RBM"?"RBM":Ot==="DD-ZM"||Ot==="DD ZM"||Ot==="ZM"?"DD-ZM":null,xn=vn&&jn&&!!((Ye=tn==null?void 0:tn[jn])!=null&&Ye.approvedByUserId);return{canApprove:ns&&!Pt&&!xn,canReject:ns&&!Pt&&!xn,canSendBack:ts,canRevoke:ts,isFinalState:Pt,hasCurrentUserApprovedZmRbm:xn}})(),ht=(fs=A.dealer)==null?void 0:fs.dealerProfile,ge=ht==null?void 0:ht.application,Je=((ge==null?void 0:ge.loiRequests)||[]).find(ze=>/approved/i.test(String((ze==null?void 0:ze.status)||""))),mt=((ge==null?void 0:ge.loaRequests)||[]).find(ze=>/approved/i.test(String((ze==null?void 0:ze.status)||""))),de=(ht==null?void 0:ht.loiDate)??(Je==null?void 0:Je.approvedAt),at=(ht==null?void 0:ht.loaDate)??(mt==null?void 0:mt.approvedAt),ot=ze=>{m(ze),Q(null),o(!0)},ke=async ze=>{var Ot,Pt,Jt;ze.preventDefault();const xt=String(f||"").trim();if((d==="sendBack"||d==="revoke")&&xt.length<5){J.error("Detailed remarks (minimum 5 characters) are required for Send Back and Revoke actions.");return}if(!xt&&d!=="approve"){J.error("Remarks are required for this action.");return}try{$(!0),Q(null);const bs=d==="approve"?Rm.APPROVE:d==="reject"?Rm.REJECT:d==="sendBack"?Rm.SEND_BACK:Rm.REVOKE,ns=await Re.updateConstitutionalChange(t,bs,{comments:f}),Ds=ns==null?void 0:ns.data;if(ns!=null&&ns.ok&&(Ds!=null&&Ds.success)){const tn=d==="approve"?"approved":d==="reject"?"rejected":d==="sendBack"?"sent back":"revoked";J.success(`Request ${tn} successfully`),o(!1),p(""),Q(null),await re();return}const ts=(Ds==null?void 0:Ds.message)||((Ot=ns==null?void 0:ns.data)==null?void 0:Ot.error)||"Failed to submit action";Q(ts);const js=/mandatory documents/i.test(ts);J.error(ts,{duration:js?14e3:8e3})}catch(bs){console.error("Submit action error:",bs);const ns=((Jt=(Pt=bs==null?void 0:bs.response)==null?void 0:Pt.data)==null?void 0:Jt.message)||(bs==null?void 0:bs.message)||"Failed to submit action";Q(ns),J.error(ns,{duration:/mandatory documents/i.test(ns)?14e3:8e3})}finally{$(!1)}},Zt=async()=>{var ze,xt,yt;if(!u||!v){J.error("Please select document type and file");return}try{U(!0);const Ot=Array.isArray(A.documents)?[...A.documents]:[],Jt=u!==Uo?Ot.findIndex(Ds=>Number(Ds==null?void 0:Ds.docNumber)===u):-1,bs={id:((xt=(ze=globalThis.crypto)==null?void 0:ze.randomUUID)==null?void 0:xt.call(ze))??`doc-${Date.now()}-${u}`,docNumber:u,name:Hc[u]||"Other",fileName:v.name,status:"Pending Verification",uploadedOn:new Date().toISOString(),uploadedBy:(n==null?void 0:n.name)||"Dealer"};Jt>=0?Ot[Jt]={...Ot[Jt],...bs}:Ot.push(bs),(yt=(await Re.uploadConstitutionalDocuments(t,Ot)).data)!=null&&yt.success?(J.success("Document uploaded successfully"),x(!1),N(null),w(null),await re({silent:!0})):J.error("Failed to upload document")}catch(Ot){console.error("Upload document error:",Ot),J.error("Failed to upload document")}finally{U(!1)}},Bt=(ze,xt)=>(ze==null?void 0:ze.id)!=null?String(ze.id):String(xt),_s=async(ze,xt)=>{var yt,Ot;try{const Pt=Bt(ze,xt),Jt=await Re.verifyConstitutionalDocument(t,Pt);(yt=Jt.data)!=null&&yt.success?(J.success("Document verified successfully"),await re({silent:!0}),A!=null&&A.id&&await Y(A.id)):J.error(((Ot=Jt.data)==null?void 0:Ot.message)||"Failed to verify document")}catch(Pt){console.error("Verify document error:",Pt),J.error("Failed to verify document")}},Us=async()=>{var xt,yt;if(T==null||!String(I).trim()){J.error("Please enter a rejection reason.");return}const ze=((A==null?void 0:A.documents)||[])[T];if(!ze){J.error("Document not found");return}try{V(!0);const Ot=Bt(ze,T),Pt=await Re.rejectConstitutionalDocument(t,Ot,{remarks:I.trim()});(xt=Pt.data)!=null&&xt.success?(J.success("Document marked as rejected"),z(!1),F(null),K(""),await re({silent:!0}),A!=null&&A.id&&await Y(A.id)):J.error(((yt=Pt.data)==null?void 0:yt.message)||"Failed to reject document")}catch(Ot){console.error("Reject document error:",Ot),J.error("Failed to reject document")}finally{V(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(te,{variant:"outline",onClick:s,className:"flex items-center gap-2",children:[e.jsx(Wr,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[A.requestId," - Constitutional Change Details"]}),e.jsxs("p",{className:"text-slate-600",children:[((Qs=(Vs=A.dealer)==null?void 0:Vs.dealerProfile)==null?void 0:Qs.businessName)||((Xs=A.outlet)==null?void 0:Xs.name)||"N/A"," (",((fe=(nt=(ie=A.dealer)==null?void 0:ie.dealerProfile)==null?void 0:nt.dealerCode)==null?void 0:fe.dealerCode)||((Ae=A.outlet)==null?void 0:Ae.code)||"N/A",")"]})]})]}),e.jsx(we,{className:xe,children:A.status}),e.jsx(br,{status:r("constitutional",t)})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Request Overview"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Dealer Details"}),e.jsx("p",{className:"text-slate-900",children:((Ke=(Fe=A.dealer)==null?void 0:Fe.dealerProfile)==null?void 0:Ke.businessName)||((Le=A.outlet)==null?void 0:Le.name)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((dt=(et=(Ue=A.dealer)==null?void 0:Ue.dealerProfile)==null?void 0:et.dealerCode)==null?void 0:dt.dealerCode)||((ss=A.outlet)==null?void 0:ss.code)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((kt=(Wt=A.dealer)==null?void 0:Wt.dealerProfile)==null?void 0:kt.registeredAddress)||((wt=A.outlet)==null?void 0:wt.city)||((Os=A.outlet)==null?void 0:Os.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Constitutional Change"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:E2(A.oldValue||A.currentConstitution||((as=A.outlet)==null?void 0:as.type)||"Proprietorship"),children:A.oldValue||A.currentConstitution||((Se=A.outlet)==null?void 0:Se.type)||"Proprietorship"}),e.jsx(Wo,{className:"w-4 h-4 text-slate-400"}),e.jsx(we,{className:E2(A.newValue||A.changeType),children:A.newValue||A.changeType})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Request Information"}),e.jsxs("p",{className:"text-slate-900 text-sm",children:["Submitted: ",Qt(A.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",((be=A.dealer)==null?void 0:be.fullName)||"Dealer"]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-slate-600 text-sm",children:"Current Stage:"}),e.jsx(we,{className:Jl(A.currentStage,A.status),children:A.currentStage})]})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Reason for Change"}),e.jsx("p",{className:"text-slate-900",children:A.description})]})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Establishment & Dealer Codes"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:((bt=(Ve=(pt=A.dealer)==null?void 0:pt.dealerProfile)==null?void 0:Ve.dealerCode)==null?void 0:bt.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:((is=(rs=(gt=A.dealer)==null?void 0:gt.dealerProfile)==null?void 0:rs.dealerCode)==null?void 0:is.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:((nn=(Ws=(Ts=A.dealer)==null?void 0:Ts.dealerProfile)==null?void 0:Ws.dealerCode)==null?void 0:nn.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:((Xt=($t=(Ee=A.dealer)==null?void 0:Ee.dealerProfile)==null?void 0:$t.dealerCode)==null?void 0:Xt.gearCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Inauguration Date"}),e.jsx("p",{className:"text-slate-900",children:(Mt=(Cs=A.dealer)==null?void 0:Cs.dealerProfile)!=null&&Mt.onboardedAt?Qt(A.dealer.dealerProfile.onboardedAt,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"LOI Date"}),e.jsx("p",{className:"text-slate-900",children:de?Qt(de,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"LOA Date"}),e.jsx("p",{className:"text-slate-900",children:at?Qt(at,"date"):"N/A"})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsx(_e,{children:e.jsxs(In,{value:C,onValueChange:S,className:"w-full",children:[e.jsx(Xe,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-6 px-6",children:e.jsxs(Mn,{className:"w-max min-w-full justify-start",children:[e.jsx(Ht,{value:"workflow",children:"Workflow Progress"}),e.jsx(Ht,{value:"documents",children:"Documents"}),e.jsx(Ht,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Oe,{children:[e.jsxs(Vt,{value:"workflow",className:"mt-0 status-progress-ui",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-900",children:"Overall Progress"}),e.jsxs(we,{className:`${Ce} text-white border-transparent hover:opacity-90`,children:[A.progressPercentage,"% Complete"]})]}),e.jsx("div",{className:"h-3 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-500 ${Ce}`,style:{width:`${A.progressPercentage}%`}})})]}),X&&e.jsxs("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800",children:["This request is closed as ",e.jsx("strong",{children:String(A.status)}),". The approval path below is for reference only."]}),e.jsx("div",{className:"space-y-4",children:X?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:Em.map(ze=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:k2(ze.name)})," — ",D2(ze.role)]},ze.id))}):Em.map((ze,xt)=>{var jn;const yt=ft||xt<jt-1,Ot=!ft&&xt===jt-1,Pt=We(ze.name),Jt=(Pt==null?void 0:Pt.comments)||(Pt==null?void 0:Pt.feedback)||(Pt==null?void 0:Pt.remarks),bs=ze.name==="ZM/RBM Review";let ns=A.metadata||{};if(typeof ns=="string")try{ns=JSON.parse(ns)}catch{ns={}}const Ds=((jn=ns==null?void 0:ns.jointApprovals)==null?void 0:jn.zmRbm)||{},ts=Ds==null?void 0:Ds.RBM,js=Ds==null?void 0:Ds["DD-ZM"],tn=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").toUpperCase(),vn=tn==="RBM"?ts:tn==="DD-ZM"||tn==="DD ZM"||tn==="ZM"?js:null;return e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${yt?"bg-green-100":Ot?Ei.icon:"bg-slate-100"}`,children:yt?e.jsx(Hn,{className:"w-5 h-5 text-green-600"}):Ot?e.jsx(dn,{className:"w-5 h-5 text-re-red"}):e.jsx(sn,{className:"w-5 h-5 text-slate-400"})}),xt<Em.length-1&&e.jsx("div",{className:`w-0.5 h-12 ${yt?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${Ot?Ei.panel:""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:`${Ot?Ei.title:"text-slate-900"}`,children:k2(ze.name)}),e.jsx("p",{className:`text-sm ${Ot?Ei.subtitle:"text-slate-600"}`,children:`Responsible: ${D2(ze.role)}`})]}),e.jsx(we,{className:yt?"bg-green-100 text-green-700 border-green-300":Ot?Ei.stageBadge:"bg-slate-100 text-slate-500 border-slate-300",children:yt?"Completed":Ot?"In Progress":"Pending"})]}),Pt&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600",children:[e.jsxs(we,{variant:"outline",className:"text-[11px] normal-case",children:["Last updated by: ",Pt.user||Pt.userName||"System"]}),e.jsx("span",{children:Qt(Pt.timestamp||Pt.createdAt)})]}),Jt&&e.jsx("div",{className:"p-2 rounded border border-slate-200 bg-slate-50 text-sm text-slate-700",children:Jt})]}),bs&&e.jsxs("div",{className:"mt-3 rounded-md border border-slate-200 bg-slate-50 p-3",children:[e.jsx("p",{className:"text-xs text-slate-600 mb-2",children:"Joint approval status"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(we,{className:ts!=null&&ts.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["RBM: ",ts!=null&&ts.approvedByUserId?"Approved":"Pending"]}),e.jsxs(we,{className:js!=null&&js.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["DD-ZM: ",js!=null&&js.approvedByUserId?"Approved":"Pending"]}),(vn==null?void 0:vn.approvedByUserId)&&e.jsx(we,{className:"bg-blue-100 text-blue-700 border-blue-300",children:"Approved by you"})]}),((ts==null?void 0:ts.remarks)||(js==null?void 0:js.remarks))&&e.jsxs("div",{className:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded border border-slate-200 bg-white p-2",children:[e.jsx("p",{className:"text-[11px] text-slate-500 mb-1",children:"RBM Comment"}),e.jsx("p",{className:"text-sm text-slate-700",children:(ts==null?void 0:ts.remarks)||"-"})]}),e.jsxs("div",{className:"rounded border border-slate-200 bg-white p-2",children:[e.jsx("p",{className:"text-[11px] text-slate-500 mb-1",children:"DD-ZM Comment"}),e.jsx("p",{className:"text-sm text-slate-700",children:(js==null?void 0:js.remarks)||"-"})]})]})]})]})]},ze.id)})})]}),e.jsx(Vt,{value:"documents",className:"mt-0",children:e.jsxs(In,{value:D,onValueChange:_,className:"w-full",children:[e.jsxs(Mn,{className:"w-full justify-start mb-4",children:[e.jsx(Ht,{value:"required",children:"Required for Process"}),e.jsx(Ht,{value:"existing",children:"Existing Documents"})]}),e.jsx(Vt,{value:"required",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("h4",{className:"text-slate-900",children:"Document Checklist"}),e.jsxs(ms,{open:h,onOpenChange:ze=>{x(ze),ze||(b(!1),w(null))},children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{b(!1),N(null),w(null)},children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Upload Document"}),e.jsx(ws,{children:j?"Pick a file for the selected document.":"Select the document type and upload the file."})]}),e.jsxs("div",{className:"space-y-4",children:[j&&u!=null?e.jsxs("div",{children:[e.jsx(le,{children:"Document"}),e.jsx("div",{className:"mt-1 flex items-center gap-2 bg-red-50 border border-red-200 rounded-md px-3 h-10",children:e.jsx(we,{className:"bg-re-red text-white border-transparent",children:Hc[u]||`Document ${u}`})})]}):e.jsxs("div",{children:[e.jsx(le,{children:"Document Type"}),e.jsxs("select",{className:"mt-1 flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-re-red focus-visible:ring-offset-2",value:u!=null?String(u):"",onChange:ze=>{const xt=ze.target.value;N(xt?Number(xt):null)},children:[e.jsx("option",{value:"",children:"Select document type"}),ue.map(ze=>e.jsxs("option",{value:String(ze),children:[ze!==Uo&&Me(ze)?"✓ ":"",Hc[ze]||`Document ${ze}`]},ze))]})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Upload File"}),e.jsx(it,{type:"file",className:"mt-1",onChange:ze=>{var xt;return w(((xt=ze.target.files)==null?void 0:xt[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover",onClick:Zt,disabled:W,children:W?"Uploading...":"Upload"})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:ce.map(ze=>{const xt=je(ze),yt=xt&&String(xt.status)==="Rejected",Ot=xt&&!yt;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${yt?"bg-red-50 border-red-200":Ot?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[yt?e.jsx(sn,{className:"w-5 h-5 text-red-600"}):Ot?e.jsx(Hn,{className:"w-5 h-5 text-green-600"}):e.jsx(sn,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:yt?"text-red-900":Ot?"text-green-900":"text-slate-900",children:Hc[ze]}),xt&&e.jsxs("p",{className:yt?"text-red-700 text-sm":Ot?"text-green-700 text-sm":"text-slate-600 text-sm",children:[xt.fileName||xt.name,yt&&(xt.rejectionReason||xt.rejectionRemarks)?` — ${xt.rejectionReason||xt.rejectionRemarks}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[xt?e.jsx(we,{className:Ov(xt.status),children:xt.status}):e.jsx(we,{className:"bg-slate-100 text-slate-600 border-slate-300",children:"Not Uploaded"}),!Ot&&e.jsxs(te,{size:"sm",variant:"ghost",className:KG(!!yt),onClick:()=>{N(ze),w(null),b(!0),x(!0)},children:[e.jsx(vr,{className:"w-3.5 h-3.5 mr-1"}),yt?"Re-upload":"Upload"]})]})]},ze)})})]})}),e.jsx(Vt,{value:"existing",className:"mt-0",children:(A.documents||[]).length>0?e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900 mb-3",children:"All Uploaded Documents"}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"File Name"}),e.jsx(me,{children:"Uploaded On"}),e.jsx(me,{children:"Uploaded By"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:(A.documents||[]).map((ze,xt)=>{var yt;return e.jsxs(lt,{className:String(ze.status)==="Rejected"?"bg-red-50/80":void 0,children:[e.jsx(oe,{className:"text-slate-900",children:ze.docNumber?Hc[ze.docNumber]:ze.name}),e.jsx(oe,{className:"text-slate-600",children:ze.fileName||ze.name}),e.jsx(oe,{className:"text-slate-600",children:Qt(ze.uploadedOn||ze.createdAt)}),e.jsx(oe,{className:"text-slate-600",children:typeof ze.uploadedBy=="string"?ze.uploadedBy:((yt=ze.uploadedBy)==null?void 0:yt.fullName)||"Dealer"}),e.jsx(oe,{children:e.jsx(we,{className:Ov(ze.status),children:ze.status})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{size:"sm",variant:"outline",className:"h-8 w-8 p-0",title:"View document",children:e.jsx(un,{className:"w-4 h-4"})}),e.jsx(te,{size:"sm",variant:"outline",className:"h-8 w-8 p-0",title:"Download document",children:e.jsx(fi,{className:"w-4 h-4"})}),ze.status!=="Verified"&&ze.status!=="Rejected"&&(()=>{const Ot=(n==null?void 0:n.role)||(n==null?void 0:n.roleCode)||"";return["DD Lead","DD Head","NBH","Legal Admin","DD Admin","Super Admin","SUPER_ADMIN","DD_ADMIN"].includes(Ot)})()&&e.jsxs(e.Fragment,{children:[e.jsx(te,{size:"sm",className:"bg-green-600 hover:bg-green-700",onClick:()=>_s(ze,xt),children:"Verify"}),e.jsx(te,{size:"sm",variant:"outline",className:"border-red-300 text-red-700 hover:bg-red-50",onClick:()=>{F(xt),K(""),z(!0)},children:"Reject"})]})]})})]},xt)})})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(Vt,{value:"history",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[ae.map((ze,xt)=>{var xn;const yt=YG(ze),Pt=(((xn=ze.actor)==null?void 0:xn.name)||ze.userName||"System").split("·").map(gn=>gn.trim()),Jt=[...new Set(Pt)].join(", "),Ds=String(ze.stage||ze.action||"").trim().replace(/\[Master data\]\s*/i,"").replace(/Constitutional change [A-Z0-9-]+ (completed|updated):/i,"$1:").replace(/dealer constitution updated from "(.*)" to "(.*)"\.?/i,'"$1" → "$2"').trim()||yt.badge||"Action",ts=String(ze.remarks||"").trim(),js=String(ze.description||"").trim(),vn=[/^Approval\s*-\s*Stage:/i,/^Record (created|updated)/i,/^Document (uploaded|verified|rejected)/i].some(gn=>gn.test(js)),jn=ts||(vn?"":js)||null;return e.jsxs("div",{className:"flex items-start gap-4 pb-4 border-b border-slate-200 last:border-0",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 ${yt.variant==="success"?"bg-green-100":yt.variant==="danger"?"bg-red-100":yt.variant==="pending"?"bg-red-50":"bg-slate-100"}`,children:yt.variant==="success"?e.jsx(Hn,{className:"w-5 h-5 text-green-600"}):yt.variant==="danger"?e.jsx(sn,{className:"w-5 h-5 text-red-600"}):yt.variant==="pending"?e.jsx(dn,{className:"w-5 h-5 text-re-red"}):e.jsx(dn,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900 capitalize",children:Ds}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["by ",e.jsx("span",{className:"font-medium text-slate-700",children:Jt})]})]}),e.jsx(we,{className:Ov(yt.badge),children:yt.badge.replace(/_/g," ")})]}),jn&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 rounded border border-slate-100 text-slate-700 text-sm",children:jn}),e.jsx("p",{className:"text-slate-400 text-xs mt-2 font-medium uppercase tracking-wider",children:Qt(ze.timestamp||ze.createdAt)})]})]},ze.id||xt)}),ae.length===0&&e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No history found"})]})})]})]})})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Current Status"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx(we,{className:Jl(A.currentStage,A.status),children:A.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${Ce}`,style:{width:`${A.progressPercentage??0}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[A.progressPercentage??0,"%"]})]})]})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[rt.canApprove&&e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>ot("approve"),disabled:L,children:[L&&d==="approve"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!rt.canApprove&&rt.hasCurrentUserApprovedZmRbm&&e.jsxs(te,{variant:"outline",className:"w-full border-green-300 text-green-700 bg-green-50 cursor-not-allowed",disabled:!0,children:[e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approved by you"]}),rt.canReject&&e.jsxs(te,{variant:"destructive",className:"w-full",onClick:()=>ot("reject"),disabled:L,children:[L&&d==="reject"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sn,{className:"w-4 h-4 mr-2"}),"Reject proposal"]}),rt.canSendBack&&e.jsxs(te,{variant:"outline",className:"w-full border-red-300 text-red-900 hover:bg-red-50",onClick:()=>ot("sendBack"),disabled:L,children:[L&&d==="sendBack"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(rM,{className:"w-4 h-4 mr-2"}),"Send back"]}),rt.canRevoke&&e.jsxs(te,{variant:"outline",className:"w-full border-red-300 text-re-red-hover hover:bg-red-50",onClick:()=>ot("revoke"),disabled:L,children:[L&&d==="revoke"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke request"]}),!rt.canApprove&&!rt.canReject&&!rt.canSendBack&&!rt.canRevoke&&e.jsx("div",{className:"text-center py-4 bg-slate-50 rounded-lg border border-dashed border-slate-200",children:e.jsx("p",{className:"text-slate-500 text-xs px-4",children:rt.isFinalState?"This request is finalized.":"No actions available for your role at this stage."})}),e.jsx("div",{className:"border-t border-slate-200 pt-3 mt-3",children:e.jsxs(te,{variant:"outline",className:"w-full border-blue-700 text-blue-800 hover:bg-blue-50",onClick:()=>{var ze;return a(`/worknotes/constitutional/${(A==null?void 0:A.id)||t}`,{state:{requestType:"constitutional",applicationName:((ze=A==null?void 0:A.outlet)==null?void 0:ze.name)||"Constitutional Change",registrationNumber:(A==null?void 0:A.requestId)||t||"",participants:(A==null?void 0:A.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"Worknotes (",((A==null?void 0:A.worknotes)||[]).length,")"]})})]})]})]})]}),e.jsx(ms,{open:i,onOpenChange:ze=>{o(ze),ze||Q(null)},children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:d==="approve"?"Approve request":d==="reject"?"Reject proposal":d==="sendBack"?"Send back to previous stage":"Revoke request"}),e.jsx(ws,{children:d==="sendBack"||d==="revoke"?"SRS §12.2.3: remarks are mandatory and will be posted to Work Notes for Send Back / Revoke.":"Comments will be recorded in the audit trail and work notes where applicable."})]}),e.jsxs("form",{onSubmit:ke,className:"space-y-4",children:[Z&&e.jsxs("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-900 flex gap-2",children:[e.jsx(sn,{className:"w-5 h-5 shrink-0 text-red-600","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:"This action was not completed"}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words",children:Z}),/mandatory documents/i.test(Z)&&e.jsxs("p",{className:"mt-2 text-red-800",children:["Use the ",e.jsx("strong",{children:"Documents"})," tab to upload every required file for this constitution type, then approve again."]})]})]}),e.jsx("div",{children:e.jsx(le,{htmlFor:"comments",children:d==="sendBack"||d==="revoke"?"Remarks (required) *":"Comments *"})}),e.jsx(Ks,{id:"comments",value:f,onChange:ze=>p(ze.target.value),placeholder:d==="sendBack"||d==="revoke"?"Enter mandatory remarks for Work Notes…":"Enter your comments…",rows:4,required:d!=="approve"}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:d==="approve"?"bg-green-600 hover:bg-green-700":"bg-re-red hover:bg-re-red-hover",disabled:L,children:L?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):d==="approve"?"Approve":d==="reject"?"Reject":d==="sendBack"?"Send back":"Revoke"})]})]})]})}),e.jsx(ms,{open:M,onOpenChange:z,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Reject document"}),e.jsx(ws,{children:"Mark this upload as rejected and provide a reason. The action is recorded in the audit trail."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(le,{htmlFor:"rejectReason",children:"Rejection reason *"}),e.jsx(Ks,{id:"rejectReason",rows:4,value:I,onChange:ze=>K(ze.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>z(!1),children:"Cancel"}),e.jsx(te,{type:"button",variant:"destructive",disabled:G,onClick:()=>void Us(),children:G?e.jsx(cs,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})})]})}const QG=(t,s)=>{var n,r,a;return((r=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:r.message)||((a=t==null?void 0:t.data)==null?void 0:a.message)||(t==null?void 0:t.message)||s},Lv=(t,s)=>Jl(t,s);function XG({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,i]=g.useState(!0),[o,d]=g.useState(1),[m,f]=g.useState(null),[p,h]=g.useState("all"),x=10,[u,N]=g.useState(!1),[v,w]=g.useState([]),[j,b]=g.useState(null),[C,S]=g.useState(""),[D,_]=g.useState(""),[A,E]=g.useState(""),[q,O]=g.useState(""),[R,P]=g.useState(""),[L,$]=g.useState(""),[Z,Q]=g.useState(""),[W,U]=g.useState(""),[M,z]=g.useState(""),[T,F]=g.useState(!1),[I,K]=g.useState([]),[G,V]=g.useState([]),[Y,re]=g.useState(""),[ae,ue]=g.useState(""),[ye,ce]=g.useState(!1),je=(t==null?void 0:t.role)==="Super Admin"||(t==null?void 0:t.roleCode)==="Super Admin",Me=n.map(de=>({entityType:"relocation",entityId:de.id||de.requestId})),{get:ut}=mc(Me,n.length>0),jt=de=>de.status==="Completed"||de.status==="Closed"||de.currentStage==="Completed",ft=de=>de.status==="Rejected"||de.status==="Revoked"||de.currentStage==="Rejected",X=de=>!jt(de)&&!ft(de)&&String(de.status||"").startsWith("Pending");g.useEffect(()=>{Je()},[o,p]),g.useEffect(()=>{je&&(xe(),We())},[je]);const Ce=de=>{h(de),d(1)},xe=async()=>{var de;try{const at=await Re.getOutlets();at.data.success&&w(at.data.outlets||((de=at.data.data)==null?void 0:de.outlets)||at.data.data||[])}catch(at){console.error("Fetch outlets error:",at)}},We=async()=>{var de,at,ot,ke;try{ce(!0);const[Zt,Bt]=await Promise.all([Re.getStates().catch(()=>({success:!1})),Re.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),_s=(de=Zt==null?void 0:Zt.data)!=null&&de.success?((at=Zt.data.data)==null?void 0:at.states)||Zt.data.data||[]:[],Us=(ot=Bt==null?void 0:Bt.data)!=null&&ot.success?((ke=Bt.data.data)==null?void 0:ke.districts)||Bt.data.data||[]:[];K(_s),V(Us)}catch(Zt){console.error("Fetch master data error:",Zt)}finally{ce(!1)}},Be=de=>{re(de),ue("");const at=I.find(ot=>ot.id===de);at&&_(at.name)},rt=de=>{ue(de);const at=G.find(ot=>ot.id===de);at&&S(at.name)},ht=async de=>{if(de.preventDefault(),!j||!C||!D||!A||!q||!R||!L||!Z){J.error("Please fill all mandatory fields");return}try{F(!0);const at={outletId:j.id,relocationType:"Intercity",currentAddress:j.address||"",currentCity:j.city||"",currentState:j.state||"",newAddress:A,newCity:C,newState:D,newDistrictId:ae||null,newStateId:Y||null,reason:q,distance:R,propertyType:L,proposedDate:Z,newLatitude:W?parseFloat(W):null,newLongitude:M?parseFloat(M):null,currentLatitude:j.latitude||null,currentLongitude:j.longitude||null};(await Re.createRelocationRequest(at)).data.success&&(J.success(`Relocation request submitted successfully for ${j.name}`),N(!1),Je(),b(null),S(""),_(""),E(""),O(""),P(""),$(""),Q(""),U(""),z(""))}catch(at){console.error("Submit relocation error:",at),J.error(QG(at,"Failed to submit relocation request"))}finally{F(!1)}},ge=Y?G.filter(de=>de.stateId===Y):G,Je=async()=>{try{i(!0);const de=await Re.getRelocationRequests({page:o,limit:x,status:p==="all"?void 0:p});de.data.success&&(r(de.data.requests),f(de.meta))}catch(de){console.error("Fetch relocation requests error:",de),J.error("Failed to fetch relocation requests")}finally{i(!1)}},mt=[{title:"Total Requests",value:n.length,icon:ks,color:"bg-blue-500"},{title:"Pending Review",value:n.filter(de=>X(de)).length,icon:er,color:"bg-re-red"},{title:"Completed",value:n.filter(de=>jt(de)).length,icon:Mr,color:"bg-green-500"},{title:"Rejected / Revoked",value:n.filter(de=>ft(de)).length,icon:ad,color:"bg-red-500"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Relocation Request Management"}),e.jsx("p",{className:"text-slate-600",children:"Manage dealer relocation requests - Moving dealership to a new location"}),e.jsx("span",{className:"block mt-1 text-slate-500 text-sm",children:"• Note: Relocation requests are initiated by the dealer."})]}),je&&e.jsxs(ms,{open:u,onOpenChange:N,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Submit Relocation Request"}),e.jsx(ws,{children:"Create a new relocation request on behalf of a dealer"})]}),e.jsxs("form",{onSubmit:ht,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(Rt,{value:j==null?void 0:j.id,onValueChange:de=>b(v.find(at=>at.id===de)),required:!0,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select an outlet"})}),e.jsx(Tt,{children:v.map(de=>e.jsxs(Pe,{value:de.id,children:[de.name," (",de.code,")"]},de.id))})]})]}),j&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2 text-sm",children:[e.jsx("h3",{className:"text-slate-900 font-medium",children:"Current Location"}),e.jsxs("p",{className:"text-slate-600",children:[j.address,", ",j.city,", ",j.state," - ",j.pincode]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(Rt,{value:Y,onValueChange:Be,required:!0,disabled:ye,children:[e.jsx(_t,{id:"newState",children:e.jsx(Et,{placeholder:ye?"Loading...":"Select state"})}),e.jsx(Tt,{children:I.map(de=>e.jsx(Pe,{value:de.id,children:de.name},de.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(Rt,{value:ae,onValueChange:rt,required:!0,disabled:!Y||ye,children:[e.jsx(_t,{id:"newCity",children:e.jsx(Et,{placeholder:Y?ye?"Loading...":"Select district":"Select state first"})}),e.jsx(Tt,{children:ge.map(de=>e.jsx(Pe,{value:de.id,children:de.name},de.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Ks,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:A,onChange:de=>E(de.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(it,{id:"distance",type:"text",placeholder:"e.g. 5.5 km",value:R,onChange:de=>P(de.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(Rt,{value:L,onValueChange:$,required:!0,children:[e.jsx(_t,{id:"propertyType",children:e.jsx(Et,{placeholder:"Select type"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Owned",children:"Owned"}),e.jsx(Pe,{value:"Leased",children:"Leased"}),e.jsx(Pe,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(it,{id:"expectedDate",type:"date",value:Z,onChange:de=>Q(de.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Ks,{id:"reason",placeholder:"Why is this relocation requested?",value:q,onChange:de=>O(de.target.value),rows:4,required:!0})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-re-red hover:bg-re-red-hover text-white",disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Relocation Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:mt.map((de,at)=>{const ot=de.icon;return e.jsx(_e,{children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:de.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:de.value})]}),e.jsx("div",{className:`${de.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(ot,{className:"w-6 h-6 text-white"})})]})})},at)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"Relocation Requests"}),e.jsx(es,{children:"Track and manage all dealership relocation requests across all stages"})]}),e.jsxs(Oe,{children:[e.jsxs(In,{value:p,onValueChange:Ce,className:"w-full",children:[e.jsxs(Mn,{className:"grid w-full grid-cols-4",children:[e.jsx(Ht,{value:"all",children:"All Requests"}),e.jsx(Ht,{value:"pending",children:"Pending Review"}),e.jsx(Ht,{value:"rejected",children:"Rejected / Revoked"}),e.jsx(Ht,{value:"completed",children:"Completed"})]}),e.jsx(Vt,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Distance"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a?e.jsx(lt,{children:e.jsx(oe,{colSpan:8,className:"h-32 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-2",children:[e.jsx(cs,{className:"w-6 h-6 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Loading requests..."})]})})}):n.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:8,className:"h-32 text-center text-slate-500",children:"No relocation requests found"})}):n.map(de=>{var at,ot,ke;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:de.requestId||de.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((at=de.outlet)==null?void 0:at.code)||de.dealerCode})]}),e.jsx(oe,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ot=de.outlet)==null?void 0:ot.name)||de.dealerName})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-slate-600 text-sm",children:[e.jsx("span",{className:"text-slate-500",children:"From:"}),e.jsx("span",{children:de.currentLocation})]}),e.jsxs("div",{className:"flex items-center gap-1 text-slate-900 text-sm",children:[e.jsx(hk,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-slate-500",children:"To:"}),e.jsx("span",{children:de.proposedLocation})]})]})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"border-slate-300 text-slate-700",children:de.distance})}),e.jsxs(oe,{children:[e.jsx(br,{status:ut("relocation",de.id||de.requestId),compact:!0}),e.jsx(we,{className:Lv(de.currentStage,de.status),children:de.currentStage})]}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${fl(de.status,de.currentStage)}`,style:{width:`${de.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[de.progressPercentage||0,"%"]})]})}),e.jsxs(oe,{children:[e.jsx("div",{className:"text-slate-900",children:Qt(de.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((ke=de.dealer)==null?void 0:ke.fullName)||"Dealer"]})]}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(de.id),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},de.id)})})]})})}),e.jsx(Vt,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"h-32 text-center",children:e.jsx(cs,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(de=>X(de)).map(de=>{var at,ot;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:de.requestId||de.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((at=de.outlet)==null?void 0:at.code)||de.dealerCode})]}),e.jsx(oe,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ot=de.outlet)==null?void 0:ot.name)||de.dealerName})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",de.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",de.proposedLocation]})]})}),e.jsxs(oe,{children:[e.jsx(br,{status:ut("relocation",de.id||de.requestId),compact:!0}),e.jsx(we,{className:Lv(de.currentStage,de.status),children:de.currentStage})]}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(de.id),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},de.id)})})]})})}),e.jsx(Vt,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Current Stage"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a?e.jsx(lt,{children:e.jsx(oe,{colSpan:6,className:"h-32 text-center",children:e.jsx(cs,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(de=>ft(de)).map(de=>{var at,ot;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:de.requestId||de.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((at=de.outlet)==null?void 0:at.code)||de.dealerCode})]}),e.jsx(oe,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ot=de.outlet)==null?void 0:ot.name)||de.dealerName})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",de.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",de.proposedLocation]})]})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${fl(de.status,de.currentStage)}`,style:{width:`${de.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[de.progressPercentage||0,"%"]})]})}),e.jsxs(oe,{children:[e.jsx(br,{status:ut("relocation",de.id||de.requestId),compact:!0}),e.jsx(we,{className:Lv(de.currentStage,de.status),children:de.currentStage})]}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(de.id),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},de.id)})})]})})}),e.jsx(Vt,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Dealer Details"}),e.jsx(me,{children:"Relocation Details"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:a?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"h-32 text-center",children:e.jsx(cs,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(de=>jt(de)).map(de=>{var at,ot;return e.jsxs(lt,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:de.requestId||de.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((at=de.outlet)==null?void 0:at.code)||de.dealerCode})]}),e.jsx(oe,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((ot=de.outlet)==null?void 0:ot.name)||de.dealerName})}),e.jsx(oe,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",de.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",de.proposedLocation]})]})}),e.jsx(oe,{children:e.jsx("div",{className:"text-slate-900",children:Qt(de.createdAt)})}),e.jsx(oe,{children:e.jsxs(te,{size:"sm",variant:"outline",onClick:()=>s(de.id),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},de.id)})})]})})})]}),m&&m.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(mo,{children:e.jsxs(fo,{children:[e.jsx(pn,{children:e.jsx(po,{onClick:()=>d(de=>Math.max(1,de-1)),className:o===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(m.totalPages)].map((de,at)=>{const ot=at+1;return ot===1||ot===m.totalPages||ot>=o-1&&ot<=o+1?e.jsx(pn,{children:e.jsx($i,{isActive:o===ot,onClick:()=>d(ot),className:"cursor-pointer",children:ot})},ot):ot===2&&o>3||ot===m.totalPages-1&&o<m.totalPages-2?e.jsx(pn,{children:e.jsx(go,{})},ot):null}),e.jsx(pn,{children:e.jsx(xo,{onClick:()=>d(de=>Math.min(m.totalPages,de+1)),className:o===m.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const pa=[{id:1,name:"ASM Review",key:"ASM_REVIEW",role:"ASM"},{id:2,name:"RBM Review",key:"RBM_REVIEW",role:"RBM"},{id:3,name:"DD ZM Review",key:"DD_ZM_REVIEW",role:"DD-ZM"},{id:4,name:"ZBH Review",key:"ZBH_REVIEW",role:"ZBH"},{id:5,name:"DD Lead Review",key:"DD_LEAD_REVIEW",role:"DD Lead"},{id:6,name:"NBH Approval",key:"NBH_APPROVAL",role:"NBH"},{id:7,name:"Legal Clearance",key:"LEGAL_CLEARANCE",role:"Legal Admin"},{id:8,name:"Relocation Complete",key:"COMPLETED",role:"System"}];function Py(t){const s=String(t||"").trim().replace(/\u00a0/g," ");if(!s||s==="Submitted")return 0;const n=s.toLowerCase();if(["completed","relocation complete","closed"].includes(n))return pa.length+1;const r=s.match(/^pending\s+(.+)$/i),a=(r?r[1]:s).trim();let i=pa.findIndex(o=>o.name===a||o.name===s||o.key===a||o.key===s);return i<0&&(i=pa.findIndex(o=>a.toLowerCase().includes(o.name.toLowerCase())||o.name.toLowerCase().includes(a.toLowerCase()))),i>=0?i+1:0}function JG(t){const s=String(t||"").toLowerCase();return!!(s.includes("sent back")||s.includes("send")&&s.includes("back"))}function eK(t){const s=String((t==null?void 0:t.action)||"");return!!(/document\s*verified/i.test(s)||/document/i.test(s)&&/upload/i.test(s))}function tT(t,s){if(eK(s))return t;const n=String((s==null?void 0:s.action)||"");if(JG(n)){const a=Py(String((s==null?void 0:s.targetStage)||""));return a>0?a:t}let r=t;for(const a of[s==null?void 0:s.targetStage,s==null?void 0:s.stage].filter(Boolean)){const i=Py(String(a));i>r&&(r=i)}return r}function tK(t){const s=[...t||[]].filter(Boolean).sort((r,a)=>new Date((r==null?void 0:r.timestamp)||(r==null?void 0:r.createdAt)||0).getTime()-new Date((a==null?void 0:a.timestamp)||(a==null?void 0:a.createdAt)||0).getTime());let n=0;for(const r of s)n=tT(n,r);return n}function sK(t){const s=[...t||[]].filter(Boolean).sort((r,a)=>new Date((r==null?void 0:r.createdAt)||(r==null?void 0:r.timestamp)||0).getTime()-new Date((a==null?void 0:a.createdAt)||(a==null?void 0:a.timestamp)||0).getTime());let n=0;for(const r of s){const a=String((r==null?void 0:r.action)||"");if(a==="DOCUMENT_UPLOADED"||a==="DOCUMENT_VERIFIED")continue;const i=(r==null?void 0:r.details)||(r==null?void 0:r.newData)||{},o=[a,i==null?void 0:i.action,String((i==null?void 0:i.type)||"")].filter(Boolean).join(" ");n=tT(n,{action:o,stage:(i==null?void 0:i.stage)!==void 0?String(i.stage):(r==null?void 0:r.stage)!==void 0?String(r.stage):void 0,targetStage:(i==null?void 0:i.targetStage)!==void 0?String(i.targetStage):void 0})}return n}function nK(t,s,n){const a=(Array.isArray(t)?[...t]:[]).filter(i=>{const o=String((i==null?void 0:i.stage)||"").trim();return o===s.name||o===s.key||n===0&&(o==="Submitted"||o==="Request submitted")});return a.sort((i,o)=>{const d=new Date((i==null?void 0:i.timestamp)||(i==null?void 0:i.createdAt)||0).getTime(),m=new Date((o==null?void 0:o.timestamp)||(o==null?void 0:o.createdAt)||0).getTime();return d-m}),a}const Wc=["Property documents for new location","Lease/Rental agreement for new location","NOC from current landlord","Municipal approvals","Fire safety certificate","Pollution clearance","Layout/Floor plan of new location","Photos of new location","Locality map","Building plan approval","Electricity connection documents","Water supply documents"],T2=t=>zE(t),rK=t=>t?"h-7 px-2 text-red-700 hover:bg-red-50 hover:text-red-800 flex-shrink-0":"h-7 px-2 text-slate-700 hover:bg-slate-50 flex-shrink-0",qo=(t,s)=>{var r,a,i;const n=((r=t==null?void 0:t.response)==null?void 0:r.data)||(t==null?void 0:t.data);if(n!=null&&n.readiness){const o=((a=n.readiness)==null?void 0:a.missingUploads)||[],d=((i=n.readiness)==null?void 0:i.pendingVerification)||[],m=[o.length?`Missing: ${o.join(", ")}`:"",d.length?`Pending verification: ${d.join(", ")}`:""].filter(Boolean).join(" | ");return m?`${n.message||s} (${m})`:n.message||s}return(n==null?void 0:n.message)||(t==null?void 0:t.message)||s};function aK({requestId:t,onBack:s,currentUser:n}){var Le,Ue,et,dt,ss,Wt,kt,wt,Os,as;const{get:r}=mc(t?[{entityType:"relocation",entityId:t}]:[],!!t),a=tr(),[i,o]=g.useState(null),[d,m]=g.useState([]),[f,p]=g.useState(!0),[h,x]=g.useState(!1),[u,N]=g.useState(!1),[v,w]=g.useState("approve"),[j,b]=g.useState(""),[C,S]=g.useState(!1),[D,_]=g.useState(null),[A,E]=g.useState(!1),[q,O]=g.useState(!1),[R,P]=g.useState(null),[L,$]=g.useState(Wc[0]),[Z,Q]=g.useState(!1),[W,U]=g.useState(!1),[M,z]=g.useState("workflow"),[T,F]=g.useState(!1),[I,K]=g.useState(null),[G,V]=g.useState(!1),[Y,re]=g.useState(null),[ae,ue]=g.useState(""),[ye,ce]=g.useState(!1);g.useEffect(()=>{ft(),je()},[t]);const je=async()=>{try{const Se=await Re.getAuditLogs("relocation",t);Se.data&&Se.data.success&&m(Se.data.data||[])}catch(Se){console.error("Error fetching audit logs:",Se)}},Me=async Se=>{try{E(!0);const be=Se||(i==null?void 0:i.id)||t,pt=await Re.getEorChecklistForRelocation(be);pt.data.success&&_(pt.data.data)}catch(be){console.error("Fetch EOR checklist error:",be)}finally{E(!1)}},ut=async(Se,be,pt)=>{if(D)try{(await Re.updateEorChecklistItem(D.id,{description:Se,isCompliant:be,itemType:pt,remarks:""})).data.success&&Me()}catch(Ve){console.error("Update EOR item error:",Ve),J.error(qo(Ve,"Failed to update item"))}},jt=async()=>{if(D)try{O(!0),(await Re.submitEorAudit(D.id,{status:"Completed",overallComments:"Relocation EOR Audit Completed"})).data.success&&(J.success("EOR Audit submitted successfully"),ft(),Me())}catch(Se){console.error("Submit EOR audit error:",Se),J.error(qo(Se,"Failed to submit EOR audit"))}finally{O(!1)}},ft=async(Se=!1)=>{try{Se||p(!0);const be=await Re.getRelocationRequestById(t);if(be.data.success){const pt=be.data.request;o(pt)}}catch(be){console.error("Fetch relocation request details error:",be),J.error(qo(be,"Failed to fetch request details"))}finally{p(!1)}},X=()=>{if(!i)return 1;if(i.status==="Completed"||i.currentStage==="Completed")return pa.length+1;if(i.status==="Rejected"||i.status==="Revoked"||i.status==="Withdrawn"){const Ve=[...i.timeline||[]].filter(Boolean).reverse();for(const bt of Ve){const gt=String(bt.stage||"").trim(),rs=String(bt.targetStage||"").trim(),is=pa.findIndex(Ts=>Ts.name===gt||Ts.key===rs||Ts.key===gt||Ts.name===rs);if(is>=0)return is+1}return 1}const Se=i.currentStage,be=pa.findIndex(Ve=>Ve.name===Se||Ve.key===Se||Ve.name.replace(/\s+/g," ")===String(Se||"").replace(/\s+/g," "));if(be>=0)return be+1;const pt=Py(String(i.status||""));return pt>0?pt:1},Ce=Array.isArray(i==null?void 0:i.timeline)?i.timeline:[],xe=tK(Ce),We=sK(d),Be=i?X():1,rt=!!i&&Math.max(xe,We)>Be&&(Ce.length>0||d.length>0),ht=i?pa[Math.min(Math.max(Be,1),pa.length)-1]:void 0,ge=(i==null?void 0:i.status)==="Completed"||(i==null?void 0:i.currentStage)==="Completed"||Be>=pa.length+1,Je=ge?100:Math.min(100,Math.round(Be/pa.length*100)),mt=ge?100:Je,de=i?Ad(i.status,i.currentStage):!1,at=i?fl(i.status,i.currentStage):"bg-status-progress",ot=i?Xb(i.status,i.currentStage):"bg-re-red hover:bg-re-red-hover text-white border-transparent",ke=i?Wc.filter(Se=>{var be;return!((be=i.documents)!=null&&be.some(pt=>pt.type===Se||pt.name&&pt.name.toLowerCase().includes(Se.toLowerCase().split(" ")[0])))}):[],Zt=i?Wc.filter(Se=>{var pt;const be=((pt=i.documents)==null?void 0:pt.filter(Ve=>Ve.type===Se||Ve.name&&Ve.name.toLowerCase().includes(Se.toLowerCase().split(" ")[0])))||[];return be.length>0&&!be.some(Ve=>Ve.status==="Verified")}):[],Bt=Se=>{var pt,Ve,bt;if(!i||!i.participants||i.participants.length===0)return null;const be=i.participants.find(gt=>{var rs,is;return((rs=gt.metadata)==null?void 0:rs.stage)===Se||((is=gt.metadata)==null?void 0:is.stage)===Se.toUpperCase().replace(/ /g,"_")});return be&&(((pt=be.user)==null?void 0:pt.fullName)||((Ve=be.user)==null?void 0:Ve.name)||((bt=be.user)==null?void 0:bt.role))||null},Us=(!i||!n?!1:(n==null?void 0:n.role)==="Super Admin"||n.role==="Super Admin"?!0:!!(ht!=null&&ht.role&&n.role===ht.role))&&i.status!=="Completed"&&i.status!=="Rejected"&&i.status!=="Revoked",fs=Us&&i.currentStage&&i.currentStage!=="ASM Review"&&i.currentStage!=="Rejected",Vs=Us&&["ZBH","DD Lead","NBH","Legal Admin","Super Admin"].includes((n==null?void 0:n.role)||""),Qs=(i==null?void 0:i.currentStage)==="NBH Approval"||(i==null?void 0:i.currentStage)==="Legal Clearance",Xs=Us&&(!Qs||ke.length===0&&Zt.length===0),ie=Se=>{w(Se),N(!0)},nt=async Se=>{Se.preventDefault();const be=String(j||"").trim();if((v==="sendBack"||v==="revoke")&&be.length<5){J.error(`Remarks are required for ${v==="sendBack"?"Send Back":"Revoke"} (minimum 5 characters).`);return}try{x(!0);const gt={approve:"approve",reject:"reject",hold:"hold",sendBack:"sendBack",revoke:"revoke"}[v]||"approve";if((await Re.updateRelocationRequest(t,gt,{remarks:be})).data.success){const is=v==="sendBack"?"sent back":v==="revoke"?"revoked":`${v}ed`;J.success(`Request ${is} successfully`),N(!1),b(""),ft(),je(),v==="approve"&&(ht==null?void 0:ht.key)==="LEGAL_CLEARANCE"&&(i!=null&&i.id)&&Me(i.id)}}catch(bt){console.error("Submit action error:",bt),J.error(qo(bt,"Failed to submit action"))}finally{x(!1)}},fe=async()=>{if(!R||!L){J.error("Please select both a document type and a file");return}try{U(!0);const Se=new FormData;Se.append("file",R),Se.append("documentType",L),Se.append("stage",i.currentStage),(await Re.uploadRelocationDocument(t,Se)).data.success&&(J.success("Document uploaded successfully"),S(!1),P(null),ft(!0),je())}catch(Se){console.error("Upload document error:",Se),J.error(qo(Se,"Failed to upload document"))}finally{U(!1)}},Ae=async Se=>{try{(await Re.verifyRelocationDocument(t,Se)).data.success&&(J.success("Document verified successfully"),ft(!0),je())}catch(be){console.error("Verify document error:",be),J.error(qo(be,"Failed to verify document"))}},Fe=async()=>{var Se,be;if(!Y||!String(ae).trim()){J.error("Please enter a rejection reason.");return}try{ce(!0);const pt=await Re.rejectRelocationDocument(t,Y,{remarks:ae.trim()});(Se=pt.data)!=null&&Se.success?(J.success("Document rejected successfully"),V(!1),re(null),ue(""),ft(!0),je()):J.error(((be=pt.data)==null?void 0:be.message)||"Failed to reject document")}catch(pt){console.error("Reject document error:",pt),J.error(qo(pt,"Failed to reject document"))}finally{ce(!1)}},Ke=Se=>{K({fileName:Se.name,filePath:Se.url,documentType:Se.type,createdAt:Se.uploadedOn,mimeType:Se.mimeType}),F(!0)};return f?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(cs,{className:"w-10 h-10 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Loading request details..."})]}):i?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(te,{variant:"outline",onClick:s,className:"flex items-center gap-2",children:[e.jsx(Wr,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[i.requestId," - Relocation Request Details"]}),e.jsxs("p",{className:"text-slate-600",children:[(Le=i.outlet)==null?void 0:Le.name," (",(Ue=i.outlet)==null?void 0:Ue.code,")"]}),e.jsx("div",{className:"mt-1",children:e.jsx(br,{status:r("relocation",t)})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(te,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:()=>{var Se;return a(`/worknotes/relocation/${t}`,{state:{applicationName:((Se=i==null?void 0:i.outlet)==null?void 0:Se.name)||"Relocation",registrationNumber:(i==null?void 0:i.requestId)||"",participants:(i==null?void 0:i.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"View Work Notes",((et=i==null?void 0:i.worknotes)==null?void 0:et.length)>0&&e.jsx(we,{className:"ml-2 bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:i.worknotes.length})]}),e.jsx(we,{className:ot,children:i.status})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Relocation Overview"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Dealer Details"}),e.jsx("p",{className:"text-slate-900",children:(dt=i.outlet)==null?void 0:dt.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:(ss=i.outlet)==null?void 0:ss.code}),e.jsx("p",{className:"text-slate-600 text-xs mt-1",children:(Wt=i.dealer)==null?void 0:Wt.fullName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Relocation Route"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{className:"w-4 h-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-xs",children:"From (Current)"}),e.jsx("p",{className:"text-slate-900 text-sm",children:i.currentLocation||(i.outlet?`${i.outlet.address}, ${i.outlet.city}`:"N/A")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hk,{className:"w-4 h-4 text-re-red"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-xs",children:"To (Proposed)"}),e.jsx("p",{className:"text-slate-900 text-sm",children:i.proposedLocation||`${i.newAddress}, ${i.newCity}`})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(we,{variant:"outline",className:"border-slate-300 text-slate-700",children:["Type: ",i.relocationType]}),i.distance&&e.jsxs(we,{variant:"outline",className:"border-red-200 bg-red-50 text-re-red-hover",children:["Distance: ",i.distance]}),i.propertyType&&e.jsxs(we,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700",children:["Property: ",i.propertyType]}),i.expectedRelocationDate&&e.jsxs(we,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:["Expected Date: ",i.expectedRelocationDate]})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:"Request Information"}),e.jsxs("p",{className:"text-slate-900 text-sm",children:["Submitted: ",Qt(i.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",(kt=i.dealer)==null?void 0:kt.fullName]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-slate-600 text-sm",children:"Current Stage:"}),e.jsx(we,{className:Jl(i.currentStage,i.status),children:String(i.currentStage||"").replace(/_/g," ")})]})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"text-slate-600 text-sm mb-2",children:"Reason for Relocation"}),e.jsx("p",{className:"text-slate-900",children:i.reason})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2 space-y-6",children:e.jsx(_e,{children:e.jsxs(In,{value:M,onValueChange:z,className:"w-full",children:[e.jsx(Xe,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-6 px-6",children:e.jsxs(Mn,{className:"w-max min-w-full justify-start",children:[e.jsx(Ht,{value:"workflow",children:"Workflow Progress"}),e.jsx(Ht,{value:"documents",children:"Documents"}),e.jsx(Ht,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Oe,{children:[e.jsxs(Vt,{value:"workflow",className:"mt-0 status-progress-ui",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-slate-900",children:"Overall Progress"}),e.jsxs(we,{className:`${at} text-white border-transparent hover:opacity-90`,children:[mt,"% Complete"]})]}),e.jsx("div",{className:"h-3 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-500 ${at}`,style:{width:`${mt}%`}})})]}),de&&e.jsxs("div",{className:"mb-6 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800",children:["This request is closed as ",e.jsx("strong",{children:String(i.status)}),". The approval path below is for reference only."]}),rt&&!de&&e.jsxs("div",{className:"mb-6 rounded-lg border border-red-300 bg-red-50 px-4 py-3 text-sm text-red-900",children:[e.jsx("span",{className:"font-medium",children:"Activity ahead of current stage:"})," Some timeline or audit entries reference steps after the official current stage (",String(i.currentStage),"). Per-step history below may include future steps; the highlighted step and approvals follow the server current stage only."]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:"Progress Timeline"}),e.jsx(es,{className:"mt-1",children:"Track the relocation approval process — activity recorded at each stage appears below that step."})]}),e.jsx("div",{className:"space-y-4",children:de?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:pa.map(Se=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:Se.name})," — ",Se.role]},Se.id))}):pa.map((Se,be)=>{const pt=ge||be<Be-1,Ve=!ge&&be===Be-1,bt=nK(Ce,Se,be),gt=bt.length>0?bt[bt.length-1]:null;return e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${pt?"bg-green-100 text-green-600":Ve?Ei.icon:"bg-slate-100 text-slate-400"}`,children:pt?e.jsx(Hn,{className:"w-5 h-5"}):Ve?e.jsx(dn,{className:"w-5 h-5"}):e.jsx("span",{className:"text-xs font-semibold",children:Se.id})}),be<pa.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${pt?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${Ve?Ei.panel:""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 gap-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:pt?"text-green-700":Ve?Ei.title:"text-slate-900",children:Se.name}),e.jsxs("p",{className:`text-sm ${Ve?Ei.subtitle:"text-slate-600"}`,children:["Responsible: ",Se.role]}),Bt(Se.name)&&e.jsxs("p",{className:"text-xs text-blue-600 font-medium mt-1",children:["Assigned: ",Bt(Se.name)]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(we,{className:pt?"bg-green-100 text-green-700 border-green-300":Ve?Ei.stageBadge:"bg-slate-100 text-slate-500 border-slate-300",children:pt?"Completed":Ve?"In Progress":"Pending"}),gt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[e.jsx(er,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:Qt(gt.timestamp||gt.createdAt)})]})]})]}),gt&&e.jsxs("div",{className:"space-y-2 mt-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:gt.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:gt.action||"Update"}),gt.targetStage&>.targetStage!==gt.stage&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["→ ",String(gt.targetStage).replace(/_/g," ")]})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:gt.remarks||gt.comments||"No remarks provided."}),bt.length>1&&e.jsxs("p",{className:"text-[10px] text-slate-500",children:[bt.length," events at this stage; showing the latest."]})]})]})]},Se.id)})})]}),e.jsx(Vt,{value:"documents",className:"mt-0",children:e.jsxs(In,{defaultValue:"required",className:"w-full",children:[e.jsxs(Mn,{className:"w-full justify-start mb-4",children:[e.jsx(Ht,{value:"required",children:"Required for Process"}),e.jsx(Ht,{value:"existing",children:"Existing Documents"})]}),e.jsx(Vt,{value:"required",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-slate-900",children:"Required Documents"}),e.jsxs(ms,{open:C,onOpenChange:Se=>{S(Se),Se||(Q(!1),P(null))},children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{Q(!1),$(Wc[0]),P(null)},children:[e.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Upload Document"}),e.jsx(ws,{children:Z?"Pick a file for the selected document.":"Select the document type and upload the file."})]}),e.jsxs("div",{className:"space-y-4",children:[Z?e.jsxs("div",{children:[e.jsx(le,{children:"Document"}),e.jsx("div",{className:"mt-1 flex items-center gap-2 bg-red-50 border border-red-200 rounded-md px-3 h-10",children:e.jsx(we,{className:"bg-re-red text-white border-transparent",children:L})})]}):e.jsxs("div",{children:[e.jsx(le,{children:"Document Type"}),e.jsx("select",{className:"w-full mt-1 px-3 py-2 border border-slate-300 rounded-md",value:L,onChange:Se=>$(Se.target.value),children:Wc.map((Se,be)=>{var Ve;const pt=(Ve=i.documents)==null?void 0:Ve.some(bt=>bt.type===Se||bt.name.toLowerCase().includes(Se.toLowerCase().split(" ")[0]));return e.jsx("option",{value:Se,children:pt?`✅ ${Se}`:Se},be)})})]}),e.jsxs("div",{children:[e.jsx(le,{children:"Upload File"}),e.jsx(it,{type:"file",className:"mt-1",onChange:Se=>{var be;return P(((be=Se.target.files)==null?void 0:be[0])||null)}})]})]}),e.jsxs(mn,{children:[e.jsx(te,{variant:"outline",onClick:()=>S(!1),disabled:W,children:"Cancel"}),e.jsx(te,{className:"bg-re-red hover:bg-re-red-hover",onClick:fe,disabled:W,children:W?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):"Upload"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Wc.map((Se,be)=>{var gt;const pt=(gt=i.documents)==null?void 0:gt.find(rs=>rs.type===Se||rs.name.toLowerCase().includes(Se.toLowerCase().split(" ")[0])),Ve=pt&&String(pt.status)==="Rejected",bt=pt&&!Ve;return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2 rounded border text-sm ${Ve?"bg-red-50 border-red-200":bt?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Ve?e.jsx(sn,{className:"w-4 h-4 text-red-600 flex-shrink-0"}):bt?e.jsx(Hn,{className:"w-4 h-4 text-green-600 flex-shrink-0"}):e.jsx(sn,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:`truncate ${Ve?"text-red-900":bt?"text-green-900":"text-slate-700"}`,children:Se})]}),!bt&&e.jsxs(te,{size:"sm",variant:"ghost",className:rK(!!Ve),onClick:()=>{$(Se),P(null),Q(!0),S(!0)},children:[e.jsx(vr,{className:"w-3.5 h-3.5 mr-1"}),Ve?"Re-upload":"Upload"]})]},be)})})]})}),e.jsx(Vt,{value:"existing",className:"mt-0",children:i.documents&&i.documents.length>0?e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900 mb-3",children:"All Uploaded Documents"}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{children:"Document Name"}),e.jsx(me,{children:"Category"}),e.jsx(me,{children:"Uploaded On"}),e.jsx(me,{children:"Uploaded By"}),e.jsx(me,{children:"Status"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:i.documents.map(Se=>e.jsxs(lt,{className:String(Se.status)==="Rejected"?"bg-red-50/80":void 0,children:[e.jsx(oe,{className:"text-slate-900",children:Se.name}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"border-slate-300",children:Se.category||"General"})}),e.jsx(oe,{className:"text-slate-600",children:Qt(Se.uploadedOn)}),e.jsx(oe,{className:"text-slate-600",children:Se.uploadedBy}),e.jsx(oe,{children:e.jsx(we,{className:T2(Se.status),children:Se.status})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Se.url&&Ke(Se),disabled:!Se.url,title:Se.url?"View Document":"File path not available",children:e.jsx(un,{className:"w-4 h-4"})}),e.jsx(te,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Se.url&&window.open(`http://localhost:5000/${Se.url}`,"_blank"),disabled:!Se.url,title:Se.url?"Download Document":"File path not available",children:e.jsx(fi,{className:"w-4 h-4"})}),Se.status==="Pending Verification"&&(()=>{const be=(n==null?void 0:n.role)||(n==null?void 0:n.roleCode)||"";return["DD Lead","NBH","Legal Admin","DD Admin","Super Admin","SUPER_ADMIN","DD_ADMIN"].includes(be)})()&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{size:"sm",className:"h-8 bg-green-600 hover:bg-green-700 text-white gap-1",onClick:()=>Ae(Se.id),title:"Verify Document",children:[e.jsx(Hn,{className:"w-4 h-4"}),"Verify"]}),e.jsxs(te,{size:"sm",variant:"destructive",className:"h-8 gap-1",onClick:()=>{re(Se.id),ue(""),V(!0)},title:"Reject Document",children:[e.jsx(sn,{className:"w-4 h-4"}),"Reject"]})]})]})})]},Se.id))})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(Vt,{value:"eor",className:"mt-0",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-slate-900",children:"EOR Readiness Checklist"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Verify new location infrastructure and statutory compliances"}),e.jsx("p",{className:"text-slate-500 text-xs mt-1 max-w-2xl",children:"When document types match a checklist line, proofs from the Documents tab are linked here automatically (same files; no separate EOR upload required)."})]}),D&&e.jsx(we,{className:T2(D.status),children:D.status})]}),D?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(me,{className:"w-[50px]"}),e.jsx(me,{children:"Category"}),e.jsx(me,{children:"Checklist Item"}),e.jsx(me,{children:"Proof & Documents"})]})}),e.jsx(Bs,{children:!D.items||D.items.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:4,className:"text-center text-slate-500 py-8 text-sm",children:'No checklist rows returned. Use "Try Refreshing" above or reload the page.'})}):D.items.map(Se=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsx("input",{type:"checkbox",checked:Se.isCompliant,onChange:be=>ut(Se.description,be.target.checked,Se.itemType),disabled:D.status==="Completed"||(n==null?void 0:n.role)!=="NBH"&&(n==null?void 0:n.role)!=="Super Admin",className:"w-4 h-4 rounded border-slate-300 text-re-red"})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",className:"border-slate-300 capitalize text-xs",children:Se.itemType})}),e.jsx(oe,{className:"text-slate-900 font-medium text-sm",children:Se.description}),e.jsx(oe,{children:e.jsx("div",{className:"flex flex-col items-start gap-1",children:Se.proofDocumentId&&Se.proofDocument?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-slate-600 truncate max-w-[220px]",title:Se.proofDocument.fileName,children:Se.proofDocument.fileName}),e.jsxs(te,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-blue-600 px-0",onClick:()=>Ke({name:Se.proofDocument.fileName,url:Se.proofDocument.filePath,type:Se.proofDocument.documentType,uploadedOn:Se.proofDocument.updatedAt||Se.proofDocument.createdAt,mimeType:Se.proofDocument.mimeType}),children:[e.jsx(un,{className:"w-3.5 h-3.5 mr-1"}),"View"]})]}):Se.proofDocumentId?e.jsx("span",{className:"text-xs text-re-red-hover",children:"Proof linked (refresh if file details are missing)"}):e.jsxs(te,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-slate-400",disabled:D.status==="Completed",children:[e.jsx(vr,{className:"w-3.5 h-3.5 mr-1"}),"Upload"]})})})]},Se.id))})]})}),((n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="Super Admin")&&D.status!=="Completed"&&e.jsx("div",{className:"flex justify-end pt-4 border-t border-slate-200",children:e.jsxs(te,{className:"bg-green-600 hover:bg-green-700",onClick:jt,disabled:q||!((wt=D.items)!=null&&wt.length)||!D.items.every(Se=>Se.isCompliant),children:[q?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Finalize EOR & Complete Relocation"]})}),!((Os=D.items)!=null&&Os.every(Se=>Se.isCompliant))&&e.jsx("p",{className:"text-right text-xs text-re-red italic",children:"All items must be marked as compliant before final submission."})]}):e.jsx("div",{className:"bg-slate-50 border border-dashed border-slate-300 rounded-lg p-12 text-center",children:A?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500",children:"Fetching checklist..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(sn,{className:"w-12 h-12 text-slate-300 mx-auto mb-4"}),e.jsx("h5",{className:"text-slate-900 mb-1",children:"No Checklist Found"}),e.jsx("p",{className:"text-slate-500 text-sm mb-4",children:"The EOR checklist will be automatically initiated once the request reaches the final clearance stage."}),e.jsx(te,{variant:"outline",onClick:()=>Me(i==null?void 0:i.id),children:"Try Refreshing"})]})})]})}),e.jsx(Vt,{value:"history",className:"mt-0",children:e.jsx("div",{className:"space-y-4",children:d.length>0?d.map((Se,be)=>{var pt,Ve,bt,gt,rs,is,Ts,Ws,nn,Ee,$t,Xt;return e.jsxs("div",{className:"flex gap-4 pb-6 border-b border-slate-100 last:border-0 relative",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-slate-300 mt-2 z-10"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:`
|
||
${(Se.description||Se.action||((pt=Se.details)==null?void 0:pt.action)||"").toLowerCase().includes("reject")||(Se.description||Se.action||((Ve=Se.details)==null?void 0:Ve.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Se.description||Se.action||((bt=Se.details)==null?void 0:bt.action)||"").toLowerCase().includes("sent back")||(Se.description||Se.action||((gt=Se.details)==null?void 0:gt.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(Se.description||Se.action||((rs=Se.details)==null?void 0:rs.action)||"").toLowerCase().includes("approv")||(Se.description||Se.action||((is=Se.details)==null?void 0:is.action)||"").toLowerCase().includes("initi")||(Se.action||"").toLowerCase().includes("complete")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
|
||
`,children:Se.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Ts=Se.actor)==null?void 0:Ts.name)||Se.userName||"System"]}),((Ws=Se.details)==null?void 0:Ws.stage)&&e.jsxs("span",{className:"text-[10px] text-slate-400 font-normal",children:["at ",Se.details.stage]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Qt(Se.timestamp||Se.createdAt)})]}),(Se.remarks||Se.description||((nn=Se.newData)==null?void 0:nn.remarks)||((Ee=Se.details)==null?void 0:Ee.remarks))&&e.jsx("div",{className:"p-3 bg-slate-50 border border-slate-100 rounded-lg text-sm text-slate-700 shadow-sm ml-1",children:Se.remarks||Se.description||(($t=Se.newData)==null?void 0:$t.remarks)||((Xt=Se.details)==null?void 0:Xt.remarks)})]})]},be)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No history found"})})})]})]})})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Current Status"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx(we,{className:Jl(i.currentStage,i.status),children:i.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Progress"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"flex-1 h-2 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-300 ${at}`,style:{width:`${mt}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[mt,"%"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Distance"}),e.jsx("p",{className:"text-slate-900",children:i.distance})]})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsx(st,{children:"Actions"})}),e.jsxs(Oe,{className:"space-y-3",children:[Us&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>ie("approve"),disabled:h||!Xs,children:[h&&v==="approve"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!Xs&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-800",children:"Approval is blocked until mandatory documents are uploaded and verified for this stage."}),e.jsxs(te,{variant:"destructive",className:"w-full",onClick:()=>ie("reject"),disabled:h,children:[h&&v==="reject"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(sn,{className:"w-4 h-4 mr-2"}),"Reject Request"]}),fs&&e.jsxs(te,{variant:"outline",className:"w-full border-red-300 text-red-900 hover:bg-red-50",onClick:()=>ie("sendBack"),disabled:h,children:[h&&v==="sendBack"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(KI,{className:"w-4 h-4 mr-2"}),"Send Back"]}),Vs&&e.jsxs(te,{variant:"outline",className:"w-full border-red-300 text-red-800 hover:bg-red-50",onClick:()=>ie("revoke"),disabled:h,children:[h&&v==="revoke"?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Jy,{className:"w-4 h-4 mr-2"}),"Revoke Request"]}),e.jsx("div",{className:"border-t border-slate-200 pt-3 mt-3"})]}),e.jsxs(te,{variant:"outline",className:"w-full border-blue-300 text-blue-700 hover:bg-blue-50",onClick:()=>{var Se;return a(`/worknotes/relocation/${t}`,{state:{applicationName:((Se=i==null?void 0:i.outlet)==null?void 0:Se.name)||"Relocation",registrationNumber:(i==null?void 0:i.requestId)||"",participants:(i==null?void 0:i.participants)||[]}})},children:[e.jsx(li,{className:"w-4 h-4 mr-2"}),"Worknotes (",((as=i==null?void 0:i.worknotes)==null?void 0:as.length)||0,")"]})]})]})]})]}),e.jsx(ms,{open:u,onOpenChange:N,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:v==="approve"?"Approve Request":v==="reject"?"Reject Request":v==="sendBack"?"Send Back Request":v==="revoke"?"Revoke Request":"Put Request on Hold"}),e.jsx(ws,{children:v==="sendBack"||v==="revoke"?"Remarks are required and will be recorded in Work Notes and the audit trail.":"Please provide comments for this action. This will be recorded in the audit trail."})]}),e.jsxs("form",{onSubmit:nt,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(le,{htmlFor:"comments",children:v==="sendBack"||v==="revoke"?"Remarks *":"Comments *"}),e.jsx("div",{className:"space-y-2"})]}),e.jsx(Ks,{id:"comments",value:j,onChange:Se=>b(Se.target.value),placeholder:v==="sendBack"?"Explain what needs to be corrected at the previous stage…":v==="revoke"?"Document why this relocation request is being revoked…":"Enter your comments...",rows:4,required:!0}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>N(!1),disabled:h,children:"Cancel"}),e.jsxs(te,{type:"submit",className:v==="approve"?"bg-green-600 hover:bg-green-700":"bg-re-red hover:bg-re-red-hover",disabled:h,children:[h?e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}):null,v==="approve"?"Approve":v==="reject"?"Reject":v==="sendBack"?"Send Back":v==="revoke"?"Revoke":"Put on Hold"]})]})]})]})}),e.jsx(ms,{open:G,onOpenChange:V,children:e.jsxs(us,{children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Reject document"}),e.jsx(ws,{children:"Mark this upload as rejected and provide a reason. The action is recorded in the audit trail."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(le,{htmlFor:"rejectDocReason",children:"Rejection reason *"}),e.jsx(Ks,{id:"rejectDocReason",rows:4,value:ae,onChange:Se=>ue(Se.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>V(!1),children:"Cancel"}),e.jsx(te,{type:"button",variant:"destructive",disabled:ye,onClick:()=>void Fe(),children:ye?e.jsx(cs,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})}),e.jsx(ho,{isOpen:T,onClose:()=>F(!1),document:I})]}):e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"Request Not Found"}),e.jsx("p",{className:"text-slate-600 mb-4",children:"The relocation request you're looking for doesn't exist."}),e.jsx(te,{onClick:s,children:"Go Back"})]})}function iK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(null),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState([]),[j,b]=g.useState([]),[C,S]=g.useState(!0),[D,_]=g.useState(!1),[A,E]=g.useState(null);g.useEffect(()=>{q()},[]);const q=async()=>{try{S(!0);const L=await Xl.getDashboardData(),$=await Jo.getResignations();w(L.outlets||[]),E(L.profile),b($.resignations||[])}catch(L){console.error("Fetch resignation data error:",L),J.error("Failed to load outlets and requests")}finally{S(!1)}},O=L=>{a(L),n(!0)},R=async L=>{if(L.preventDefault(),!i){J.error("Please select resignation type");return}if(!d||!f){J.error("Please enter last operational dates");return}if(!h.trim()){J.error("Please provide a reason for resignation");return}try{_(!0);const $={outletId:r==null?void 0:r.id,resignationType:i,lastOperationalDateSales:d,lastOperationalDateServices:f,reason:h,additionalInfo:u};await Jo.createResignation($),J.success(`Resignation request submitted successfully for ${r==null?void 0:r.name}`),n(!1),q(),a(null),o(""),m(""),p(""),x(""),N("")}catch($){console.error("Submit resignation error:",$),J.error("Failed to submit resignation request")}finally{_(!1)}},P=[{title:"Total Outlets",value:v.length,icon:to,color:"bg-blue-500"},{title:"Active Outlets",value:v.filter(L=>L.status==="Active").length,icon:ln,color:"bg-green-500"},{title:"Pending Resignations",value:v.filter(L=>L.status==="Pending Resignation").length,icon:dn,color:"bg-re-red"}];return e.jsxs("div",{className:"space-y-6",children:[C&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"})}),!C&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Dealership Resignation Management"}),e.jsx("p",{className:"text-slate-600",children:"Manage resignation requests for your dealerships and studios"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:P.map((L,$)=>{const Z=L.icon;return e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(st,{className:"text-sm",children:L.title}),e.jsx("div",{className:`${L.color} p-2 rounded-lg`,children:e.jsx(Z,{className:"h-4 w-4 text-white"})})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:L.value})})]},$)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"My Outlets"}),e.jsx(es,{children:"Select an outlet to request resignation"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:v.map(L=>{const $=L.type==="Dealership"?to:tM,Z=L.status==="Pending Resignation",Q=j.find(W=>W.outletId===L.id&&W.status!=="Completed"&&W.status!=="Rejected");return e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`${L.type==="Dealership"?"bg-blue-100":"bg-purple-100"} p-2 rounded-lg`,children:e.jsx($,{className:`w-5 h-5 ${L.type==="Dealership"?"text-blue-600":"text-purple-600"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:L.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:L.code})]})]}),e.jsx(we,{className:`border ${L.status==="Active"?"bg-green-100 text-green-700 border-green-300":L.status==="Pending Resignation"?"bg-red-50 text-re-red border-red-200":"bg-slate-100 text-slate-700 border-slate-300"}`,children:L.status})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Mr,{className:"w-4 h-4 text-slate-400 mt-0.5 flex-shrink-0"}),e.jsx("div",{children:e.jsx("p",{className:"text-slate-600",children:L.location})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(er,{className:"w-4 h-4 text-slate-400"}),e.jsxs("span",{className:"text-slate-600",children:["Outlet Code: ",L.code]})]})]}),Z?e.jsx("div",{className:"bg-red-50 border border-red-200 rounded p-3 text-sm",children:e.jsxs("p",{className:"text-slate-800",children:["Resignation in progress - ",e.jsx("span",{className:"underline cursor-pointer",onClick:()=>t&&(Q==null?void 0:Q.resignationId)&&t(Q.resignationId),children:"View Request"})]})}):e.jsxs(te,{className:"w-full bg-red-600 hover:bg-red-700",onClick:()=>O(L),children:[e.jsx(ks,{className:"w-4 h-4 mr-2"}),"Request Resignation"]})]},L.id)})})})]}),e.jsx(ms,{open:s,onOpenChange:n,children:e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Submit Resignation Request"}),e.jsx(ws,{children:"Fill in the details for your resignation request. All fields are mandatory."})]}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2",children:[e.jsx("h3",{className:"text-slate-900",children:"Outlet Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Outlet Code:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.code})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Outlet Name:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Code:"}),e.jsx("p",{className:"text-slate-900",children:(A==null?void 0:A.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"City:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.location})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-slate-600",children:"Location:"}),e.jsx("p",{className:"text-slate-900",children:r==null?void 0:r.location})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"resignationType",children:"Resignation Type *"}),e.jsxs(Rt,{value:i,onValueChange:o,required:!0,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select resignation type"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Voluntary",children:"Voluntary"}),e.jsx(Pe,{value:"Retirement",children:"Retirement"}),e.jsx(Pe,{value:"Health Issues",children:"Health Issues"}),e.jsx(Pe,{value:"Business Closure",children:"Business Closure"}),e.jsx(Pe,{value:"Other",children:"Other"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"lastOpDateSales",children:"Last Operational Date - Sales *"}),e.jsx(it,{id:"lastOpDateSales",type:"date",value:d,onChange:L=>m(L.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"lastOpDateServices",children:"Last Operational Date - Services *"}),e.jsx(it,{id:"lastOpDateServices",type:"date",value:f,onChange:L=>p(L.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Reason for Resignation *"}),e.jsx(Ks,{id:"reason",placeholder:"Please provide detailed reason for resignation...",value:h,onChange:L=>x(L.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"additionalInfo",children:"Additional Information (Optional)"}),e.jsx(Ks,{id:"additionalInfo",placeholder:"Any additional details...",value:u,onChange:L=>N(L.target.value),rows:3})]}),e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-re-red mb-2 font-semibold",children:"Important Information"}),e.jsxs("ul",{className:"text-slate-700 text-sm space-y-1",children:[e.jsx("li",{children:"• F&F settlement process will be initiated after submission"}),e.jsx("li",{children:"• All department clearances must be obtained"}),e.jsx("li",{children:"• Final settlement will be processed after closure"}),e.jsx("li",{children:"• Please ensure all documents are ready for submission"})]})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>{n(!1),a(null)},children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-red-600 hover:bg-red-700",disabled:D,children:D?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Resignation Request"})]})]})]})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"My Resignation Requests"}),e.jsx(es,{children:"View your submitted resignation requests"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Outlet"}),e.jsx(me,{children:"Type"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:j.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No resignation requests found"})}):j.map(L=>{var $;return e.jsxs(lt,{children:[e.jsx(oe,{className:"font-medium text-slate-900",children:L.resignationId}),e.jsx(oe,{children:($=L.outlet)==null?void 0:$.name}),e.jsx(oe,{children:L.resignationType}),e.jsx(oe,{children:Qt(L.submittedOn)}),e.jsx(oe,{children:e.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>t&&t(L.resignationId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},L.id)})})]})})]})]})]})}var lK=Symbol("radix.slottable");function oK(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=lK,s}var sT="AlertDialog",[cK]=oa(sT,[ER]),yl=ER(),nT=t=>{const{__scopeAlertDialog:s,...n}=t,r=yl(s);return e.jsx(qb,{...r,...n,modal:!0})};nT.displayName=sT;var dK="AlertDialogTrigger",uK=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=yl(n);return e.jsx(WR,{...a,...r,ref:s})});uK.displayName=dK;var hK="AlertDialogPortal",rT=t=>{const{__scopeAlertDialog:s,...n}=t,r=yl(s);return e.jsx(zb,{...r,...n})};rT.displayName=hK;var mK="AlertDialogOverlay",aT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=yl(n);return e.jsx(ip,{...a,...r,ref:s})});aT.displayName=mK;var ed="AlertDialogContent",[fK,pK]=cK(ed),xK=oK("AlertDialogContent"),iT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,children:r,...a}=t,i=yl(n),o=g.useRef(null),d=Ys(s,o),m=g.useRef(null);return e.jsx($7,{contentName:ed,titleName:lT,docsSlug:"alert-dialog",children:e.jsx(fK,{scope:n,cancelRef:m,children:e.jsxs(lp,{role:"alertdialog",...i,...a,ref:d,onOpenAutoFocus:Yt(a.onOpenAutoFocus,f=>{var p;f.preventDefault(),(p=m.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[e.jsx(xK,{children:r}),e.jsx(vK,{contentRef:o})]})})})});iT.displayName=ed;var lT="AlertDialogTitle",oT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=yl(n);return e.jsx(GR,{...a,...r,ref:s})});oT.displayName=lT;var cT="AlertDialogDescription",dT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=yl(n);return e.jsx(KR,{...a,...r,ref:s})});dT.displayName=cT;var gK="AlertDialogAction",uT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=yl(n);return e.jsx(Ub,{...a,...r,ref:s})});uT.displayName=gK;var hT="AlertDialogCancel",mT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,{cancelRef:a}=pK(hT,n),i=yl(n),o=Ys(s,a);return e.jsx(Ub,{...i,...r,ref:o})});mT.displayName=hT;var vK=({contentRef:t})=>{const s=`\`${ed}\` requires a description for the component to be accessible for screen reader users.
|
||
|
||
You can add a description to the \`${ed}\` by passing a \`${cT}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
||
|
||
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ed}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
||
|
||
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return g.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},yK=nT,bK=rT,jK=aT,NK=iT,wK=uT,SK=mT,CK=oT,AK=dT;function kK({...t}){return e.jsx(yK,{"data-slot":"alert-dialog",...t})}function DK({...t}){return e.jsx(bK,{"data-slot":"alert-dialog-portal",...t})}function RK({className:t,...s}){return e.jsx(jK,{"data-slot":"alert-dialog-overlay",className:Nt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...s})}function EK({className:t,...s}){return e.jsxs(DK,{children:[e.jsx(RK,{}),e.jsx(NK,{"data-slot":"alert-dialog-content",className:Nt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...s})]})}function _K({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:Nt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function TK({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:Nt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function PK({className:t,...s}){return e.jsx(CK,{"data-slot":"alert-dialog-title",className:Nt("text-lg font-semibold",t),...s})}function OK({className:t,...s}){return e.jsx(AK,{"data-slot":"alert-dialog-description",className:Nt("text-muted-foreground text-sm",t),...s})}function LK({className:t,...s}){return e.jsx(wK,{className:Nt(nd(),t),...s})}function IK({className:t,...s}){return e.jsx(SK,{className:Nt(nd({variant:"outline"}),t),...s})}function MK({resignationId:t,onBack:s}){var N,v,w;const[n,r]=g.useState(!0),[a,i]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(!1),[p,h]=g.useState("User requested withdrawal");g.useEffect(()=>{t&&(async()=>{try{r(!0);const b=await Jo.getResignationById(t);i(b)}catch(b){console.error("Failed to fetch resignation details:",b),J.error("Unable to load resignation details")}finally{r(!1)}})()},[t]);const x=async()=>{try{const j=await Jo.getResignationById(t);i(j)}catch{J.error("Unable to refresh resignation details")}},u=async()=>{var j,b;try{d(!0),await Jo.withdraw(t,p),J.success("Resignation request withdrawn successfully"),f(!1),await x()}catch(C){J.error(((b=(j=C==null?void 0:C.response)==null?void 0:j.data)==null?void 0:b.message)||"Failed to withdraw resignation")}finally{d(!1)}};return n?e.jsx("div",{className:"min-h-[320px] flex items-center justify-center",children:e.jsx(dn,{className:"w-8 h-8 animate-spin text-re-red"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(te,{variant:"outline",onClick:s,children:[e.jsx(Wr,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-slate-900",children:"Resignation Request Details"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"Review your resignation request details"})]}),a.status!=="Withdrawn"&&a.status!=="Completed"&&a.status!=="Rejected"&&!["NBH","DD Admin","Legal","Awaiting F&F","F&F Initiated"].includes(a.currentStage)&&e.jsxs(te,{variant:"destructive",className:"bg-red-600 hover:bg-red-700",onClick:()=>f(!0),disabled:o,children:[e.jsx(ai,{className:"w-4 h-4 mr-2"}),o?"Withdrawing...":"Withdraw Request"]})]}),e.jsx(kK,{open:m,onOpenChange:f,children:e.jsxs(EK,{children:[e.jsxs(_K,{children:[e.jsx(PK,{children:"Are you absolutely sure?"}),e.jsx(OK,{children:"This action will withdraw your resignation request. This action cannot be undone and you will need to submit a new request if you change your mind."}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx(le,{htmlFor:"withdrawal-reason",children:"Reason for withdrawal"}),e.jsx(it,{id:"withdrawal-reason",placeholder:"Please enter a reason...",value:p,onChange:j=>h(j.target.value)})]})]}),e.jsxs(TK,{children:[e.jsx(IK,{disabled:o,children:"Cancel"}),e.jsx(LK,{onClick:j=>{j.preventDefault(),u()},className:"bg-red-600 hover:bg-red-700 text-white",disabled:o,children:o?"Withdrawing...":"Yes, Withdraw Request"})]})]})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"w-5 h-5 text-re-red"}),"Request Summary"]}),e.jsx(es,{children:"Key details about your resignation request"})]}),e.jsxs(Oe,{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Request ID"}),e.jsx("p",{className:"text-slate-900",children:a.resignationId||a.id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Submitted On"}),e.jsx("p",{className:"text-slate-900",children:Qt(a.submittedOn||a.createdAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Resignation Type"}),e.jsx("p",{className:"text-slate-900",children:a.resignationType||"N/A"})]})]})]}),e.jsxs(_e,{children:[e.jsx(Xe,{children:e.jsxs(st,{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"w-5 h-5 text-blue-600"}),"Outlet and Dates"]})}),e.jsxs(Oe,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Outlet"}),e.jsx("p",{className:"text-slate-900",children:((N=a.outlet)==null?void 0:N.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Outlet Code"}),e.jsx("p",{className:"text-slate-900",children:((v=a.outlet)==null?void 0:v.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Last Operational Date (Sales)"}),e.jsx("p",{className:"text-slate-900",children:a.lastOperationalDateSales?Qt(a.lastOperationalDateSales):"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Last Operational Date (Services)"}),e.jsx("p",{className:"text-slate-900",children:a.lastOperationalDateServices?Qt(a.lastOperationalDateServices):"N/A"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Reason"}),e.jsx("p",{className:"text-slate-900",children:a.reason||"-"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(Mr,{className:"w-3 h-3"}),"Outlet Address"]}),e.jsx("p",{className:"text-slate-900",children:((w=a.outlet)==null?void 0:w.address)||"-"})]})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(te,{variant:"outline",onClick:s,children:[e.jsx(Wr,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsx(_e,{children:e.jsx(Oe,{className:"py-8 text-center text-slate-600",children:"Resignation details not found."})})]})}const FK=(t,s)=>Qb(t,s);function BK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(""),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState([]),[v,w]=g.useState(!0),[j,b]=g.useState(!1),[C,S]=g.useState(null),[D,_]=g.useState([]);g.useEffect(()=>{A()},[]);const A=async()=>{var O,R;try{w(!0);const[P,L,$]=await Promise.all([Xl.getDashboardData(),Xl.getConstitutionalChanges(),Re.getConstitutionalChangeMeta()]);S(P.profile);const Z=eT((O=P.profile)==null?void 0:O.constitutionType);a(Z),N(L.requests||[]),(R=$.data)!=null&&R.success&&Array.isArray($.data.structureTargets)&&_($.data.structureTargets)}catch(P){console.error("Fetch constitutional data error:",P),J.error("Failed to load requests")}finally{w(!1)}},E=async O=>{var R,P;if(O.preventDefault(),!i){J.error("Please select proposed constitution type");return}if(r===i){J.error("Proposed constitution must be different from current");return}if(!d.trim()){J.error("Please provide a reason for constitutional change");return}try{b(!0);const L={currentConstitution:r,changeType:i,reason:d.trim(),newPartnersDetails:f,shareholdingPattern:h};await Xl.submitConstitutionalChange(L),J.success("Constitutional change request submitted successfully"),n(!1),A(),o(""),m(""),p(""),x("")}catch(L){console.error("Submit constitutional change error:",L);const $=((P=(R=L==null?void 0:L.response)==null?void 0:R.data)==null?void 0:P.message)||"Failed to submit constitutional change request";J.error($)}finally{b(!1)}},q=[{title:"Total Requests",value:u.length,icon:cl,color:"bg-blue-500"},{title:"Pending",value:u.filter(O=>O.status!=="Completed"&&O.status!=="Rejected").length,icon:er,color:"bg-re-red"},{title:"Completed",value:u.filter(O=>O.status==="Completed").length,icon:ks,color:"bg-green-500"}];return e.jsxs("div",{className:"space-y-6",children:[v&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(cs,{className:"w-8 h-8 text-blue-600 animate-spin"})}),!v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"My Constitutional Change Requests"}),e.jsx("p",{className:"text-slate-600",children:"Submit and track requests for changing your business constitution"})]}),e.jsxs(ms,{open:s,onOpenChange:n,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"New Constitutional Change"]})}),e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Submit Constitutional Change Request"}),e.jsx(ws,{children:"Request to change your dealership's business constitution structure"})]}),e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2",children:[e.jsx("h3",{className:"text-slate-900",children:"Current Dealership Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Code:"}),e.jsx("p",{className:"text-slate-900",children:(C==null?void 0:C.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-600",children:"Dealer Name:"}),e.jsx("p",{className:"text-slate-900",children:(C==null?void 0:C.businessName)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-slate-600",children:"Current Constitution:"}),e.jsx("p",{className:"text-slate-900",children:r})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"currentConstitution",children:"Current Constitution *"}),e.jsx(it,{id:"currentConstitution",value:r,disabled:!0,className:"bg-slate-100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"proposedConstitution",children:"Proposed Constitution *"}),e.jsxs(Rt,{value:i,onValueChange:o,required:!0,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select new constitution"})}),e.jsx(Tt,{children:D.filter(O=>O.value!==r).map(O=>e.jsx(Pe,{value:O.value,children:O.label},O.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Reason for Change *"}),e.jsx(Ks,{id:"reason",placeholder:"Please provide detailed reason for constitutional change...",value:d,onChange:O=>m(O.target.value),rows:4,required:!0})]}),(i==="Partnership"||i==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newPartners",children:"Details of New Partners/Members"}),e.jsx(Ks,{id:"newPartners",placeholder:"Name, relationship, and experience of new partners...",value:f,onChange:O=>p(O.target.value),rows:3})]}),(i==="Private Limited"||i==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"shareholdingPattern",children:"Proposed Shareholding Pattern"}),e.jsx(Ks,{id:"shareholdingPattern",placeholder:"Details of share distribution among partners/directors...",value:h,onChange:O=>x(O.target.value),rows:3})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-blue-900 mb-2",children:"Documents Required (to be uploaded later)"}),e.jsxs("ul",{className:"text-blue-800 text-sm space-y-1",children:[e.jsx("li",{children:"• GST Registration Certificate"}),e.jsx("li",{children:"• Firm PAN Copy"}),e.jsx("li",{children:"• Self-attested KYC documents"}),e.jsx("li",{children:"• Business Purchase Agreement (BPA)"}),e.jsx("li",{children:"• Partnership Agreement / Firm Registration (if target is Partnership)"}),e.jsx("li",{children:"• LLP Agreement / COI (if target is LLP)"}),e.jsx("li",{children:"• MOA, AOA, COI (if target is Private Limited)"}),e.jsx("li",{children:"• Cancelled Cheque"}),e.jsx("li",{children:"• Declaration / Authorization Letter"})]})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-blue-600 hover:bg-blue-700",disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:q.map((O,R)=>{const P=O.icon;return e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(st,{className:"text-sm",children:O.title}),e.jsx("div",{className:`${O.color} p-2 rounded-lg`,children:e.jsx(P,{className:"h-4 w-4 text-white"})})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:O.value})})]},R)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"My Constitutional Change Requests"}),e.jsx(es,{children:"View and track all your constitutional change requests"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Current"}),e.jsx(me,{children:"Proposed"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Current Status"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:u.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No constitutional change requests found"})}):u.map(O=>e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900",children:O.requestId})}),e.jsx(oe,{children:e.jsx(we,{variant:"outline",children:O.currentConstitution})}),e.jsx(oe,{children:e.jsx(we,{className:"bg-blue-100 text-blue-700 border-blue-300",children:O.changeType})}),e.jsx(oe,{className:"text-slate-600",children:Qt(O.createdAt)}),e.jsx(oe,{children:e.jsx(we,{className:`border ${FK(O.status)}`,children:O.status})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-2 min-w-[60px]",children:e.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${O.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[O.progressPercentage||0,"%"]})]})}),e.jsx(oe,{children:e.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>t&&t(O.requestId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},O.id))})]})})]})]})]})}const $K=(t,s)=>Qb(t,s),Iv=(t,s)=>{var n,r,a;return((r=(n=t==null?void 0:t.response)==null?void 0:n.data)==null?void 0:r.message)||((a=t==null?void 0:t.data)==null?void 0:a.message)||(t==null?void 0:t.message)||s};function qK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(null),[i,o]=g.useState(""),[d,m]=g.useState(""),[f,p]=g.useState(""),[h,x]=g.useState(""),[u,N]=g.useState(""),[v,w]=g.useState(""),[j,b]=g.useState(""),[C,S]=g.useState(""),[D,_]=g.useState(""),[A,E]=g.useState([]),[q,O]=g.useState([]),[R,P]=g.useState(""),[L,$]=g.useState(""),[Z,Q]=g.useState(!1),[W,U]=g.useState([]),[M,z]=g.useState([]),[T,F]=g.useState(!0),[I,K]=g.useState(!1);g.useEffect(()=>{V(),Y()},[]);const G=R?q.filter(ce=>ce.stateId===R):q,V=async()=>{try{F(!0);const ce=await Xl.getDashboardData(),je=await Xl.getRelocationRequests();U(ce.outlets||[]),z(je.requests||[])}catch(ce){console.error("Fetch relocation data error:",ce),J.error(Iv(ce,"Failed to load outlets and requests"))}finally{F(!1)}},Y=async()=>{var ce,je;try{Q(!0);const[Me,ut]=await Promise.all([$s.getStates().catch(()=>({success:!1})),$s.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),jt=Me!=null&&Me.success?((ce=Me.data)==null?void 0:ce.states)||Me.data||[]:[],ft=ut!=null&&ut.success?((je=ut.data)==null?void 0:je.districts)||ut.data||[]:[];E(jt),O(ft)}catch(Me){console.error("Fetch master data error:",Me),J.error(Iv(Me,"Failed to load master data"))}finally{Q(!1)}},re=ce=>{P(ce),$("");const je=A.find(Me=>Me.id===ce);je&&m(je.name)},ae=ce=>{$(ce);const je=q.find(Me=>Me.id===ce);je&&o(je.name)},ue=async ce=>{if(ce.preventDefault(),!r){J.error("Please select an outlet");return}if(!i.trim()||!d.trim()||!f.trim()){J.error("Please provide complete relocation details");return}if(!h.trim()){J.error("Please provide a reason for relocation");return}if(!u.trim()||!v||!j){J.error("Please fill all mandatory fields (Distance, Property Type, Date)");return}try{K(!0);const je={outletId:r.id,relocationType:"Intercity",currentAddress:r.address||"",currentCity:r.city||"",currentState:r.state||"",newAddress:f,newCity:i,newState:d,newDistrictId:L||null,newStateId:R||null,distance:u,reason:h,propertyType:v,proposedDate:j,proposedLatitude:C?parseFloat(C):null,proposedLongitude:D?parseFloat(D):null,currentLatitude:r.latitude||null,currentLongitude:r.longitude||null};await Xl.submitRelocationRequest(je),J.success(`Relocation request submitted successfully for ${r.name}`),n(!1),V(),a(null),o(""),m(""),p(""),x(""),N(""),w(""),b(""),S(""),_(""),t&&V()}catch(je){console.error("Submit relocation error:",je),J.error(Iv(je,"Failed to submit relocation request"))}finally{K(!1)}},ye=[{title:"Total Requests",value:M.length,icon:Mr,color:"bg-blue-500"},{title:"Pending",value:M.filter(ce=>ce.status!=="Completed"&&ce.status!=="Rejected").length,icon:er,color:"bg-re-red"},{title:"Approved",value:M.filter(ce=>ce.status==="Completed").length,icon:to,color:"bg-green-500"}];return e.jsxs("div",{className:"space-y-6",children:[T&&e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsx(cs,{className:"w-8 h-8 text-re-red animate-spin"})}),!T&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-slate-900 mb-2",children:"Relocation Requests"}),e.jsx("p",{className:"text-slate-600",children:"Request to relocate your existing dealership or studio to a new location"})]}),e.jsxs(ms,{open:s,onOpenChange:n,children:[e.jsx(oo,{asChild:!0,children:e.jsxs(te,{className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(us,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ys,{children:[e.jsx(gs,{children:"Submit Relocation Request"}),e.jsx(ws,{children:"Provide details about the outlet you want to relocate and its proposed new location"})]}),e.jsxs("form",{onSubmit:ue,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(Rt,{value:r==null?void 0:r.id,onValueChange:ce=>a(W.find(je=>je.id===ce)),required:!0,children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"Select an outlet"})}),e.jsx(Tt,{children:W.map(ce=>e.jsxs(Pe,{value:ce.id,children:[ce.name," (",ce.code,")"]},ce.id))})]})]}),r&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-2",children:[e.jsx("h3",{className:"text-slate-900 text-sm font-medium",children:"Current Location"}),e.jsx("p",{className:"text-slate-600 text-sm",children:r.location})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(Rt,{value:R,onValueChange:re,required:!0,disabled:Z,children:[e.jsx(_t,{id:"newState",children:e.jsx(Et,{placeholder:Z?"Loading...":"Select state"})}),e.jsx(Tt,{children:A.map(ce=>e.jsx(Pe,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(Rt,{value:L,onValueChange:ae,required:!0,disabled:!R||Z,children:[e.jsx(_t,{id:"newCity",children:e.jsx(Et,{placeholder:R?Z?"Loading...":"Select district":"Select state first"})}),e.jsx(Tt,{children:G.map(ce=>e.jsx(Pe,{value:ce.id,children:ce.name},ce.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Ks,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:f,onChange:ce=>p(ce.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(it,{id:"distance",placeholder:"e.g. 5.5 km",value:u,onChange:ce=>N(ce.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(Rt,{value:v,onValueChange:w,required:!0,children:[e.jsx(_t,{id:"propertyType",children:e.jsx(Et,{placeholder:"Select type"})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"Owned",children:"Owned"}),e.jsx(Pe,{value:"Leased",children:"Leased"}),e.jsx(Pe,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(it,{id:"expectedDate",type:"date",value:j,onChange:ce=>b(ce.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Ks,{id:"reason",placeholder:"Why do you want to relocate this outlet?",value:h,onChange:ce=>x(ce.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[e.jsx("h4",{className:"text-blue-900 mb-2 font-medium",children:"Policy Notes"}),e.jsxs("ul",{className:"text-blue-800 text-xs space-y-1",children:[e.jsx("li",{children:"• Relocation is subject to feasibility study of the new location"}),e.jsx("li",{children:"• Maximum allowed distance and other policy criteria apply"}),e.jsx("li",{children:"• Site visit will be conducted by RBM/ASM"}),e.jsx("li",{children:"• New outlet code might be generated upon approval"})]})]}),e.jsxs(mn,{children:[e.jsx(te,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(te,{type:"submit",className:"bg-re-red hover:bg-re-red-hover text-white",disabled:I,children:I?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Relocation Request"})]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:ye.map((ce,je)=>{const Me=ce.icon;return e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(st,{className:"text-sm",children:ce.title}),e.jsx("div",{className:`${ce.color} p-2 rounded-lg`,children:e.jsx(Me,{className:"h-4 w-4 text-white"})})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:ce.value})})]},je)})}),e.jsxs(_e,{children:[e.jsxs(Xe,{children:[e.jsx(st,{children:"My Relocation Requests"}),e.jsx(es,{children:"Track the status of your relocation applications"})]}),e.jsx(Oe,{children:e.jsxs(Ms,{children:[e.jsx(Fs,{children:e.jsxs(lt,{children:[e.jsx(me,{children:"Request ID"}),e.jsx(me,{children:"Outlet"}),e.jsx(me,{children:"Target Location"}),e.jsx(me,{children:"Submitted On"}),e.jsx(me,{children:"Current Status"}),e.jsx(me,{children:"Progress"}),e.jsx(me,{children:"Actions"})]})}),e.jsx(Bs,{children:M.length===0?e.jsx(lt,{children:e.jsx(oe,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No relocation requests found"})}):M.map(ce=>{var je;return e.jsxs(lt,{children:[e.jsx(oe,{children:e.jsx("span",{className:"text-slate-900 font-medium",children:ce.requestId})}),e.jsx(oe,{children:(je=ce.outlet)==null?void 0:je.name}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx("span",{className:"text-slate-500",children:ce.currentCity}),e.jsx(Wo,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:ce.newCity})]})}),e.jsx(oe,{className:"text-slate-600",children:Qt(ce.createdAt)}),e.jsx(oe,{children:e.jsx(we,{className:`border ${$K(ce.status)}`,children:ce.status})}),e.jsx(oe,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-slate-200 rounded-full h-2 min-w-[60px]",children:e.jsx("div",{className:"bg-re-red h-2 rounded-full",style:{width:`${ce.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[ce.progressPercentage||0,"%"]})]})}),e.jsx(oe,{children:e.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>t&&t(ce.requestId),children:[e.jsx(un,{className:"w-4 h-4 mr-1"}),"View"]})})]},ce.id)})})]})})]})]})]})}const zK=["Personal Information","Financial Information","Location & Background","Motivation","Business Structure","Professional Background","Infrastructure","Financial Planning","Growth & Expansion","Brand Affinity","Vision & Strategy"],P2=()=>{const{id:t}=gd(),s=tr(),[n,r]=g.useState(`v${new Date().toISOString().split("T")[0]}`),[a,i]=g.useState([{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:1,isMandatory:!0}]),[o,d]=g.useState(!1),[m,f]=g.useState(!!t);g.useEffect(()=>{t&&p(t)},[t]);const p=async C=>{var S;try{f(!0);const D=await Re.getQuestionnaireById(C);if((S=D.data)!=null&&S.success){const _=D.data.data;r(`${_.version} (Copy)`),_.questions&&_.questions.length>0&&i(_.questions.map(A=>{var O,R;let E=(O=A.inputType)==null?void 0:O.toLowerCase().trim();return E==="mcq"&&(E="select"),["text","number","file","yesno","select","radio","textarea","email","mcq"].includes(E)||(E="text"),{...A,inputType:E,weight:parseFloat(A.weight),options:((R=A.questionOptions)==null?void 0:R.map(P=>({text:P.optionText,score:P.score})))||[]}}))}else J.error("Failed to load questionnaire"),s("/questionnaires")}catch(D){console.error(D),J.error("Error fetching questionnaire")}finally{f(!1)}},h=a.reduce((C,S)=>C+(S.weight||0),0),x=()=>{i([...a,{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:a.length+1,isMandatory:!0}])},u=C=>{const D=a.filter((_,A)=>A!==C).map((_,A)=>({..._,order:A+1}));i(D)},N=(C,S,D)=>{var A;const _=[...a];if(S==="weight"){const E=parseFloat(D)||0;_[C].options&&(_[C].options=_[C].options.map(q=>({...q,score:Math.min(q.score,E)})))}S==="inputType"&&D==="yesno"&&(!_[C].options||((A=_[C].options)==null?void 0:A.length)===0)?_[C].options=[{text:"Yes",score:_[C].weight||5},{text:"No",score:0}]:S==="inputType"&&D==="select"&&!_[C].options&&(_[C].options=[]),_[C]={..._[C],[S]:D},i(_)},v=C=>{const S=[...a];S[C].options||(S[C].options=[]),S[C].options.push({text:"",score:0}),i(S)},w=(C,S,D,_)=>{const A=[...a];if(A[C].options){let E=_;if(D==="score"){const q=A[C].weight||0;E=Math.min(parseFloat(_)||0,q)}A[C].options[S]={...A[C].options[S],[D]:E},i(A)}},j=(C,S)=>{const D=[...a];D[C].options&&(D[C].options=D[C].options.filter((_,A)=>A!==S),i(D))},b=async()=>{var C;if(a.some(S=>!S.questionText)){J.error("All questions must have text");return}for(let S=0;S<a.length;S++){const D=a[S];if(D.inputType==="select"||D.inputType==="yesno"){const _=(C=D.options)==null?void 0:C.find(A=>A.score>D.weight);if(_){J.error(`Question ${S+1}: Option "${_.text}" score (${_.score}) exceeds question weightage (${D.weight})`);return}}}if(h!==100){J.error(`Total weightage must be exactly 100. Current total: ${h}`);return}try{d(!0),await Re.createQuestionnaireVersion({version:n,questions:a}),J.success("Questionnaire version created successfully"),s("/questionnaires")}catch(S){console.error(S),J.error("Failed to create questionnaire")}finally{d(!1)}};return m?e.jsx("div",{className:"flex justify-center p-12",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-re-red"})}):e.jsxs("div",{className:"p-6 bg-white rounded-lg shadow-md max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4 border-b border-gray-100 pb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>s("/questionnaires"),className:"p-2 hover:bg-slate-100 rounded-full transition-colors text-slate-500",children:e.jsx(Wr,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-900",children:t?"Edit Questionnaire Version":"Create New Version"}),e.jsx("p",{className:"text-slate-500 text-sm mt-1",children:t?"Modify existing template and save as new version":"Define questions, logic and weightage"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 w-full md:w-auto",children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg border ${h===100?"bg-green-50 border-green-200 text-green-700":"bg-red-50 border-red-200 text-re-red-hover"}`,children:[h!==100&&e.jsx(sn,{size:16}),e.jsxs("span",{className:"text-sm font-semibold",children:["Total Score: ",h,"/100"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-initial",children:[e.jsx("input",{type:"text",value:n,onChange:C=>r(C.target.value),className:"border border-slate-300 p-2 rounded-lg w-full md:w-48 text-sm focus:ring-2 focus:ring-red-500 outline-none",placeholder:"Version Name (e.g. v2.0)"}),e.jsxs("button",{onClick:b,disabled:o,className:"bg-re-red text-white px-6 py-2 rounded-lg flex items-center gap-2 hover:bg-re-red-hover disabled:bg-slate-300 disabled:cursor-not-allowed transition shadow-sm font-medium whitespace-nowrap",children:[e.jsx(dl,{size:18})," ",o?"Saving...":"Publish"]})]})]})]}),e.jsx("div",{className:"space-y-4",children:a.map((C,S)=>{var D;return e.jsxs("div",{className:"group border border-slate-200 p-5 rounded-xl bg-slate-50/50 hover:bg-white hover:shadow-md transition-all duration-200 flex gap-4 items-start relative",children:[e.jsx("div",{className:"pt-2.5",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-200 flex items-center justify-center text-slate-600 font-semibold text-sm",children:S+1})}),e.jsxs("div",{className:"flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-5",children:[e.jsxs("div",{className:"md:col-span-6 lg:col-span-5",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Question Text"}),e.jsx("input",{type:"text",value:C.questionText,onChange:_=>N(S,"questionText",_.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none transition-shadow",placeholder:"Enter your question here..."})]}),e.jsxs("div",{className:"md:col-span-6 lg:col-span-3",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Section"}),e.jsx("select",{value:C.sectionName,onChange:_=>N(S,"sectionName",_.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none bg-white",children:zK.map(_=>e.jsx("option",{value:_,children:_},_))})]}),e.jsxs("div",{className:"md:col-span-4 lg:col-span-2",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Input Type"}),e.jsxs("select",{value:C.inputType,onChange:_=>N(S,"inputType",_.target.value),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none bg-white",children:[e.jsx("option",{value:"text",children:"One Liner"}),e.jsx("option",{value:"email",children:"Email Address"}),e.jsx("option",{value:"textarea",children:"Paragraph"}),e.jsx("option",{value:"number",children:"Numeric"}),e.jsx("option",{value:"file",children:"File Upload"}),e.jsx("option",{value:"yesno",children:"Yes / No"}),e.jsx("option",{value:"select",children:"Options (Dropdown)"}),e.jsx("option",{value:"radio",children:"Options (Radio)"})]})]}),e.jsx("div",{className:"md:col-span-4 lg:col-span-2",children:e.jsx("div",{className:"flex items-center gap-3 h-full pt-6",children:e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"number",value:isNaN(C.weight)?0:C.weight,onChange:_=>N(S,"weight",parseFloat(_.target.value)||0),className:"w-full border border-slate-300 p-2.5 rounded-lg focus:ring-2 focus:ring-red-500 outline-none pl-3 pr-8",title:"Weightage"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 text-xs font-bold",children:"%"})]})})})})]}),(C.inputType==="select"||C.inputType==="yesno"||C.inputType==="radio"||C.inputType==="mcq")&&e.jsxs("div",{className:"w-full mt-4 pl-4 md:pl-16 border-t border-slate-100 pt-4",children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2",children:"Answer Options & Scores"}),e.jsx("div",{className:"space-y-2",children:(D=C.options)==null?void 0:D.map((_,A)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:_.text,onChange:E=>w(S,A,"text",E.target.value),className:"flex-1 border border-slate-300 p-2 rounded-md text-sm focus:ring-1 focus:ring-red-500 outline-none",placeholder:`Option ${A+1}`}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:"Score:"}),e.jsx("input",{type:"number",value:isNaN(_.score)?0:_.score,max:isNaN(C.weight)?0:C.weight,min:0,onChange:E=>w(S,A,"score",E.target.value),className:`w-20 border ${_.score>C.weight||isNaN(_.score)?"border-red-500 text-red-600":"border-slate-300"} p-2 rounded-md text-sm focus:ring-1 focus:ring-red-500 outline-none`})]}),e.jsx("button",{onClick:()=>j(S,A),className:"p-1.5 text-slate-400 hover:text-red-500 transition-colors",title:"Remove Option",children:e.jsx(Zn,{size:16})})]},A))}),e.jsxs("button",{onClick:()=>v(S),className:"mt-3 text-sm flex items-center gap-1 text-re-red hover:text-re-red-hover font-medium",children:[e.jsx(bn,{size:16})," Add Option"]})]})]}),e.jsx("button",{onClick:()=>u(S),className:"absolute -right-3 -top-3 md:static md:mt-8 md:mr-2 w-8 h-8 flex items-center justify-center rounded-full bg-white md:bg-transparent text-slate-400 hover:text-red-600 hover:bg-red-50 border border-slate-200 md:border-transparent shadow-sm md:shadow-none transition-all",title:"Remove Question",children:e.jsx(Zn,{size:18})})]},S)})}),e.jsxs("button",{onClick:x,className:"mt-8 w-full border-2 border-dashed border-slate-300 p-4 rounded-xl text-slate-500 hover:border-red-500 hover:text-re-red hover:bg-red-50/30 flex justify-center items-center gap-2 transition-all font-medium",children:[e.jsx(bn,{size:20})," Add Another Question"]})]})},O2=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),a=tr();g.useEffect(()=>{i()},[]);const i=async()=>{var o;try{r(!0);const d=await Re.getAllQuestionnaires();(o=d.data)!=null&&o.success?s(d.data.data):J.error("Failed to load questionnaire versions")}catch(d){console.error(d),J.error("Error fetching versions")}finally{r(!1)}};return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-900",children:"Questionnaire Versions"}),e.jsx("p",{className:"text-slate-500",children:"Manage your questionnaire templates and versions"})]}),e.jsxs("button",{onClick:()=>a("/questionnaire-builder"),className:"bg-re-red text-white px-4 py-2 rounded-lg flex items-center gap-2 hover:bg-re-red-hover transition",children:[e.jsx(bn,{size:20})," Create New Version"]})]}),n?e.jsx("div",{className:"flex justify-center p-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-re-red"})}):t.length===0?e.jsxs("div",{className:"text-center p-12 bg-white rounded-lg shadow-sm border border-slate-200",children:[e.jsx("p",{className:"text-slate-500 mb-4",children:"No questionnaire versions found."}),e.jsx("button",{onClick:()=>a("/questionnaire-builder"),className:"text-re-red font-medium hover:underline",children:"Create your first version"})]}):e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-slate-200 overflow-hidden",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4 font-medium text-slate-600",children:"Version Name"}),e.jsx("th",{className:"p-4 font-medium text-slate-600",children:"Status"}),e.jsx("th",{className:"p-4 font-medium text-slate-600",children:"Created At"}),e.jsx("th",{className:"p-4 font-medium text-slate-600 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:t.map(o=>e.jsxs("tr",{className:"hover:bg-slate-50 transition",children:[e.jsx("td",{className:"p-4 font-medium text-slate-900",children:o.version}),e.jsx("td",{className:"p-4",children:o.isActive?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-200",children:[e.jsx(ln,{size:12})," Active"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600 border border-slate-200",children:[e.jsx(ai,{size:12})," Inactive"]})}),e.jsx("td",{className:"p-4 text-slate-600 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(er,{size:14,className:"text-slate-400"}),za(new Date(o.createdAt),"MMM dd, yyyy HH:mm")]})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs("button",{onClick:()=>a(`/questionnaire-builder/${o.id}`),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded text-sm font-medium text-slate-600 hover:text-re-red hover:bg-red-50 transition border border-slate-200 hover:border-red-200",children:[e.jsx(gr,{size:14})," Edit / Clone"]})})]},o.id))})]})})]})},Mv=[{value:"KT_MATRIX",label:"KT Matrix (Level 1)",description:"Scored criteria for Level 1 interview assessment"},{value:"LEVEL2_FEEDBACK",label:"Level 2 Feedback",description:"Qualitative feedback fields for Level 2 interview"},{value:"LEVEL3_FEEDBACK",label:"Level 3 Feedback",description:"Qualitative feedback fields for Level 3 interview"}],UK=()=>{const[t,s]=g.useState([]),[,n]=g.useState(!1),[r,a]=g.useState("KT_MATRIX"),[i,o]=g.useState(!1),[d,m]=g.useState(null),[f,p]=g.useState(!1),[h,x]=g.useState(!1),u=g.useCallback(async()=>{var R;try{n(!0);const P=await Re.getInterviewConfigs();(R=P.data)!=null&&R.success&&s(P.data.data||[])}catch(P){console.error("Fetch configs error:",P),J.error("Failed to load interview configurations")}finally{n(!1)}},[]);g.useEffect(()=>{u()},[u]);const N=R=>t.find(P=>P.configType===R&&P.isActive),v=R=>{var L;const P={KT_MATRIX:[{itemKey:"example_criterion",label:"Example Criterion",type:"select",order:1,isRequired:!0,weight:5,maxScore:10,options:[{optionLabel:"Excellent",optionValue:"excellent",score:10,order:1},{optionLabel:"Good",optionValue:"good",score:5,order:2}]}],LEVEL2_FEEDBACK:[{itemKey:"strategicVision",label:"Strategic Vision",type:"textarea",order:1,isRequired:!0,weight:null,maxScore:null},{itemKey:"managementCapabilities",label:"Management Capabilities",type:"textarea",order:2,isRequired:!0,weight:null,maxScore:null},{itemKey:"additionalComments",label:"Additional Comments",type:"textarea",order:3,isRequired:!1,weight:null,maxScore:null}],LEVEL3_FEEDBACK:[{itemKey:"businessVision",label:"Business Vision & Strategy",type:"textarea",order:1,isRequired:!0,weight:null,maxScore:null},{itemKey:"leadership",label:"Leadership & Decision Making",type:"textarea",order:2,isRequired:!0,weight:null,maxScore:null},{itemKey:"additionalComments",label:"Additional Comments",type:"textarea",order:3,isRequired:!1,weight:null,maxScore:null}]};m({configType:R,name:`${((L=Mv.find($=>$.value===R))==null?void 0:L.label)||"New Config"}`,version:`v${new Date().toISOString().split("T")[0]}`,isActive:!0,items:P[R]||[]}),o(!0)},w=async R=>{var P;try{n(!0);const L=await Re.getInterviewConfigById(R);(P=L.data)!=null&&P.success&&(m(L.data.data),o(!0))}catch{J.error("Failed to load configuration for editing")}finally{n(!1)}},j=async()=>{var R,P;if(d){if(!d.name||!d.version){J.error("Name and version are required");return}if(!d.items||d.items.length===0){J.error("Add at least one item");return}if(d.configType==="KT_MATRIX"){const L=d.items.reduce(($,Z)=>$+(Number(Z.weight)||0),0);if(Math.abs(L-100)>.01){J.error(`KT Matrix total weight must be 100. Current: ${L}`);return}for(const $ of d.items)if($.type==="select"&&(!$.options||$.options.length===0)){J.error(`Select item "${$.label}" must have options`);return}}try{p(!0);const L={configType:d.configType,name:d.name,version:d.version,items:d.items.map(($,Z)=>{var Q;return{...$,order:$.order||Z+1,options:(Q=$.options)==null?void 0:Q.map((W,U)=>({...W,order:W.order||U+1}))}})};d.id?(await Re.updateInterviewConfig(d.id,L),J.success("Configuration updated successfully")):(await Re.createInterviewConfig(L),J.success("New configuration published successfully")),o(!1),m(null),await u()}catch(L){console.error("Save error:",L),J.error(((P=(R=L==null?void 0:L.response)==null?void 0:R.data)==null?void 0:P.message)||"Failed to save configuration")}finally{p(!1)}}},b=async R=>{if(confirm("Are you sure you want to delete this configuration?"))try{await Re.deleteInterviewConfig(R),J.success("Configuration deleted"),await u()}catch{J.error("Failed to delete configuration")}},C=async()=>{if(confirm("This will reset all interview configurations to system defaults. Continue?"))try{x(!0),await Re.initializeDefaultInterviewConfigs(),J.success("Default configurations initialized"),await u()}catch{J.error("Failed to initialize defaults")}finally{x(!1)}},S=()=>{var P,L;if(!d)return;const R={itemKey:`field_${(((P=d.items)==null?void 0:P.length)||0)+1}`,label:"",type:d.configType==="KT_MATRIX"?"select":"textarea",order:(((L=d.items)==null?void 0:L.length)||0)+1,isRequired:!0,weight:d.configType==="KT_MATRIX"?5:null,maxScore:d.configType==="KT_MATRIX"?10:null,options:d.configType==="KT_MATRIX"?[{optionLabel:"Option 1",optionValue:"opt1",score:10,order:1},{optionLabel:"Option 2",optionValue:"opt2",score:5,order:2}]:void 0};m({...d,items:[...d.items||[],R]})},D=R=>{var $;if(!d)return;const L=((($=d.items)==null?void 0:$.filter((Z,Q)=>Q!==R))||[]).map((Z,Q)=>({...Z,order:Q+1}));m({...d,items:L})},_=(R,P,L)=>{if(!d)return;const $=[...d.items||[]];$[R]={...$[R],[P]:L},m({...d,items:$})},A=R=>{if(!d)return;const P=[...d.items||[]],L=P[R];L.options||(L.options=[]),L.options.push({optionLabel:"",optionValue:"",score:0,order:L.options.length+1}),m({...d,items:P})},E=(R,P,L,$)=>{if(!d)return;const Z=[...d.items||[]];Z[R].options&&(Z[R].options[P]={...Z[R].options[P],[L]:$},m({...d,items:Z}))},q=(R,P)=>{if(!d)return;const L=[...d.items||[]];L[R].options&&(L[R].options=L[R].options.filter(($,Z)=>Z!==P),m({...d,items:L}))},O=(d==null?void 0:d.configType)==="KT_MATRIX"?(d.items||[]).reduce((R,P)=>R+(Number(P.weight)||0),0):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-900",children:"Interview Configuration"}),e.jsx("p",{className:"text-slate-500 text-sm mt-1",children:"Manage KT Matrix criteria and feedback fields for all interview levels"})]}),e.jsxs(te,{variant:"outline",onClick:C,disabled:h,className:"gap-2",children:[e.jsx(sb,{size:16})," ",h?"Initializing...":"Reset to Defaults"]})]}),e.jsxs(In,{value:r,onValueChange:a,children:[e.jsx(Mn,{className:"grid w-full grid-cols-3",children:Mv.map(R=>e.jsx(Ht,{value:R.value,children:R.label},R.value))}),Mv.map(R=>{var $;const P=N(R.value),L=t.filter(Z=>Z.configType===R.value);return e.jsx(Vt,{value:R.value,children:e.jsxs(_e,{children:[e.jsxs(Xe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{className:"text-lg",children:R.label}),e.jsx("p",{className:"text-sm text-slate-500",children:R.description})]}),e.jsxs(te,{onClick:()=>v(R.value),className:"gap-2",children:[e.jsx(bn,{size:16})," Publish New Version"]})]}),e.jsxs(Oe,{children:[P?e.jsx("div",{className:"mb-6 p-4 bg-green-50 border border-green-200 rounded-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-green-800",children:["Active: ",P.name]}),e.jsxs("p",{className:"text-sm text-green-700",children:["Version ",P.version," • ",(($=P.items)==null?void 0:$.length)||0," items"]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>P.id&&w(P.id),children:e.jsx(k1,{size:16})})})]})}):e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg text-red-800",children:'No active configuration found. Click "Publish New Version" to create one, or "Reset to Defaults" to initialize system defaults.'}),e.jsx("h3",{className:"text-sm font-semibold text-slate-700 mb-3",children:"Version History"}),L.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No versions found."}):e.jsx("div",{className:"space-y-2",children:L.map(Z=>{var Q;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${Z.isActive?"bg-green-50 border-green-200":"bg-white border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[Z.isActive&&e.jsx(we,{className:"bg-green-600",children:"Active"}),e.jsx("span",{className:"font-medium text-sm",children:Z.name}),e.jsx("span",{className:"text-xs text-slate-500",children:Z.version}),e.jsxs("span",{className:"text-xs text-slate-400",children:[((Q=Z.items)==null?void 0:Q.length)||0," items"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(te,{variant:"ghost",size:"sm",onClick:()=>Z.id&&w(Z.id),children:e.jsx(k1,{size:14})}),e.jsx(te,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover",onClick:()=>Z.id&&b(Z.id),children:e.jsx(Zn,{size:14})})]})]},Z.id)})})]})]})},R.value)})]})," ",e.jsx(ms,{open:i,onOpenChange:o,children:e.jsxs(us,{className:"max-w-[95vw] w-full lg:max-w-7xl p-0 overflow-hidden border-none shadow-2xl rounded-2xl flex flex-col max-h-[95vh]",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100 bg-white flex shrink-0 items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{children:[e.jsx(gs,{className:"text-lg font-bold text-slate-900 leading-none",children:d!=null&&d.id?"Edit Configuration":"New Configuration"}),e.jsxs(ws,{className:"text-[11px] text-slate-500 mt-1 uppercase tracking-wider font-semibold",children:[d==null?void 0:d.configType.replace(/_/g," ")," · ",(d==null?void 0:d.version)||"v1.0"]})]}),(d==null?void 0:d.configType)==="KT_MATRIX"&&e.jsxs("div",{className:`px-3 py-1.5 rounded-md text-[10px] font-black uppercase tracking-tight ${O===100?"bg-emerald-50 text-emerald-700 border border-emerald-100":"bg-red-50 text-re-red-hover border border-red-100"}`,children:["Weight: ",O,"% / 100%"]})]}),e.jsx("div",{className:"flex items-center gap-2"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 bg-white space-y-6 custom-scrollbar",children:d&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 items-end bg-slate-50/40 p-4 rounded-xl border border-slate-100",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(le,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Name"}),e.jsx(it,{value:d.name,onChange:R=>m({...d,name:R.target.value}),className:"h-9 border-slate-200 bg-white shadow-none text-sm font-normal"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(le,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Version"}),e.jsx(it,{value:d.version,onChange:R=>m({...d,version:R.target.value}),className:"h-9 border-slate-200 bg-white shadow-none text-sm font-normal"})]}),e.jsx("div",{className:"flex items-center justify-end h-9",children:e.jsxs(te,{variant:"outline",onClick:S,className:"h-full border-dashed border-slate-300 text-slate-500 hover:text-slate-900 text-xs font-bold px-4",children:[e.jsx(bn,{size:14,className:"mr-2"})," Add Criteria"]})})]}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim pb-4 -mx-1 px-1",children:e.jsx("div",{className:"min-w-[900px] border border-slate-100 rounded-xl",children:e.jsxs("table",{className:"w-full text-left border-collapse table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/50 border-b border-slate-100 text-[10px] uppercase font-black text-slate-400 tracking-[0.1em]",children:[e.jsx("th",{className:"px-4 py-2 w-12 text-center",children:"#"}),e.jsx("th",{className:"px-4 py-2 w-[35%]",children:"Label"}),e.jsx("th",{className:"px-4 py-2 w-[20%]",children:"Data Key"}),e.jsx("th",{className:"px-4 py-2 w-32",children:"Type"}),d.configType==="KT_MATRIX"&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"px-4 py-2 w-24",children:"Weight"}),e.jsx("th",{className:"px-4 py-2 w-20",children:"Max"})]}),e.jsx("th",{className:"px-4 py-2 w-16 text-center",children:"Req."}),e.jsx("th",{className:"px-4 py-2 w-10"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:(d.items||[]).map((R,P)=>e.jsxs(Ct.Fragment,{children:[e.jsxs("tr",{className:"group hover:bg-slate-50/10 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-slate-300 font-bold text-[11px] align-top pt-5 text-center",children:String(P+1).padStart(2,"0")}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsx(it,{value:R.label,onChange:L=>_(P,"label",L.target.value),className:"h-10 border-slate-100 hover:border-slate-300 focus:bg-white bg-slate-50/30 text-sm font-normal transition-all",placeholder:"Age/Qualification etc."})}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsx(it,{value:R.itemKey,onChange:L=>_(P,"itemKey",L.target.value),className:"h-10 border-slate-100 hover:border-slate-300 focus:bg-white bg-slate-50/30 font-mono text-[11px] text-slate-500"})}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsxs(Rt,{value:R.type,onValueChange:L=>_(P,"type",L),children:[e.jsx(_t,{className:"h-10 border-slate-100 hover:border-slate-300 bg-slate-50/30 text-xs focus:ring-0",children:e.jsx(Et,{})}),e.jsxs(Tt,{children:[e.jsx(Pe,{value:"select",children:"Options"}),e.jsx(Pe,{value:"text",children:"One Liner"}),e.jsx(Pe,{value:"textarea",children:"Paragraph"}),e.jsx(Pe,{value:"number",children:"Numeric"})]})]})}),d.configType==="KT_MATRIX"&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsxs("div",{className:"relative group/num",children:[e.jsx(it,{type:"number",value:R.weight||"",onChange:L=>_(P,"weight",parseFloat(L.target.value)||0),className:"h-10 w-full border-slate-100 bg-slate-50/30 text-sm font-normal text-right pr-8 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0.5 top-0.5 bottom-0.5 flex flex-col border-l border-slate-200/50 bg-white/40 rounded-r-md overflow-hidden opacity-40 group-hover/num:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>_(P,"weight",(R.weight||0)+1),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center border-b border-slate-200/50",children:e.jsx(yu,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>_(P,"weight",Math.max(0,(R.weight||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(va,{size:10,className:"text-slate-600"})})]}),e.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-[9px] text-slate-300 font-bold",children:"%"})]})}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsxs("div",{className:"relative group/num",children:[e.jsx(it,{type:"number",value:R.maxScore||"",onChange:L=>_(P,"maxScore",parseFloat(L.target.value)||0),className:"h-10 border-slate-100 bg-slate-50/30 text-sm font-normal text-right pr-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0.5 top-0.5 bottom-0.5 flex flex-col border-l border-slate-200/50 bg-white/40 rounded-r-md overflow-hidden opacity-40 group-hover/num:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>_(P,"maxScore",(R.maxScore||0)+1),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center border-b border-slate-200/50",children:e.jsx(yu,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>_(P,"maxScore",Math.max(0,(R.maxScore||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(va,{size:10,className:"text-slate-600"})})]})]})})]}),e.jsx("td",{className:"px-4 py-3 align-top text-center pt-5",children:e.jsx("input",{type:"checkbox",checked:R.isRequired,onChange:L=>_(P,"isRequired",L.target.checked),className:"w-4 h-4 accent-slate-900 border-slate-300"})}),e.jsx("td",{className:"px-4 py-3 align-top pt-4",children:e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-200 hover:text-red-500 hover:bg-red-50",onClick:()=>D(P),children:e.jsx(Zn,{size:16})})})]}),R.type==="select"&&e.jsxs("tr",{className:"bg-slate-50/30",children:[e.jsx("td",{colSpan:1}),e.jsx("td",{colSpan:d.configType==="KT_MATRIX"?7:5,className:"px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200/50 pb-2 mb-2",children:[e.jsxs("p",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest flex items-center gap-2",children:[e.jsx("div",{className:"w-1 h-3 bg-red-400 rounded-full"})," Options"]}),e.jsxs(te,{variant:"ghost",size:"sm",className:"h-7 px-3 text-[10px] font-bold uppercase text-slate-600 hover:bg-white border border-transparent hover:border-slate-200",onClick:()=>A(P),children:[e.jsx(bn,{className:"w-3 h-3 mr-1.5"})," Append Option"]})]}),e.jsxs("div",{className:"grid grid-cols-12 gap-3 mb-2 px-1",children:[e.jsx("div",{className:"col-span-6 text-[9px] font-black uppercase text-slate-300 tracking-tighter",children:"Display Label"}),e.jsx("div",{className:"col-span-3 text-[9px] font-black uppercase text-slate-300 tracking-tighter",children:"API Value"}),e.jsx("div",{className:"col-span-2 text-[9px] font-black uppercase text-slate-300 tracking-tighter",children:"Score"})]}),e.jsx("div",{className:"space-y-2",children:(R.options||[]).map((L,$)=>e.jsxs("div",{className:"grid grid-cols-12 gap-3 items-center group/opt",children:[e.jsx("div",{className:"col-span-6",children:e.jsx(it,{placeholder:"Label",value:L.optionLabel,onChange:Z=>E(P,$,"optionLabel",Z.target.value),className:"h-9 border-slate-200 bg-white text-xs font-normal"})}),e.jsx("div",{className:"col-span-3",children:e.jsx(it,{placeholder:"Value",value:L.optionValue,onChange:Z=>E(P,$,"optionValue",Z.target.value),className:"h-9 border-slate-200 bg-white text-xs font-mono"})}),e.jsx("div",{className:"col-span-2",children:e.jsxs("div",{className:"relative group/optnum",children:[e.jsx(it,{type:"number",placeholder:"0",value:L.score,onChange:Z=>E(P,$,"score",parseFloat(Z.target.value)||0),className:"h-9 border-slate-200 bg-white text-xs font-normal text-right pr-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("div",{className:"absolute right-0.5 top-0.5 bottom-0.5 flex flex-col border-l border-slate-100 bg-slate-50/50 rounded-r-md overflow-hidden opacity-0 group-hover/optnum:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>E(P,$,"score",(L.score||0)+1),className:"flex-1 px-1 hover:bg-slate-200 flex items-center justify-center border-b border-slate-100",children:e.jsx(yu,{size:8})}),e.jsx("button",{onClick:()=>E(P,$,"score",(L.score||0)-1),className:"flex-1 px-1 hover:bg-slate-200 flex items-center justify-center",children:e.jsx(va,{size:8})})]})]})}),e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-300 hover:text-red-500 opacity-0 group-hover/opt:opacity-100",onClick:()=>q(P,$),children:e.jsx(Zn,{size:13})})})]},$))})]})})]})]},P))})]})})})]})}),e.jsxs("div",{className:"px-6 py-4 bg-slate-50 border-t border-slate-100 flex shrink-0 justify-end gap-3",children:[e.jsx(te,{variant:"ghost",className:"px-6 h-10 text-xs font-bold text-slate-500 hover:bg-slate-200 transition-colors",onClick:()=>o(!1),children:"Dismiss"}),e.jsxs(te,{className:"bg-slate-900 hover:bg-slate-950 text-white px-8 h-10 rounded-lg text-xs font-black uppercase tracking-widest shadow-xl shadow-slate-200 transition-all active:scale-95",onClick:j,disabled:f,children:[f?e.jsx(cs,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(dl,{className:"w-4 h-4 mr-2"}),"Commit Changes"]})]})]})})]})},VK=[{value:"__all__",label:"All Modules"},{value:"QUESTIONNAIRE",label:"Questionnaire"},{value:"INTERVIEW_CONFIG",label:"Interview Configuration"},{value:"SYSTEM_CONFIG",label:"System Configuration"},{value:"SLA_CONFIG",label:"SLA Configuration"},{value:"EMAIL_TEMPLATE",label:"Email Template"},{value:"MASTER_HIERARCHY",label:"Master Hierarchy"},{value:"ROLE_ASSIGNMENT",label:"Role Assignment"},{value:"USER_ADMIN",label:"User Administration"},{value:"DEALER_MAPPING",label:"Dealer Mapping"}],HK=[{value:"__all__",label:"All Actions"},{value:"CREATED",label:"Created"},{value:"UPDATED",label:"Updated"},{value:"DELETED",label:"Deleted"},{value:"ACTIVATED",label:"Activated"},{value:"DEACTIVATED",label:"Deactivated"},{value:"INITIALIZED",label:"Initialized"},{value:"SUBMITTED",label:"Submitted"},{value:"ASSIGNED",label:"Assigned"},{value:"UNASSIGNED",label:"Unassigned"},{value:"REORDERED",label:"Reordered"}],WK={CREATED:"bg-emerald-100 text-emerald-700 border-emerald-200",UPDATED:"bg-blue-100 text-blue-700 border-blue-200",DELETED:"bg-rose-100 text-rose-700 border-rose-200",ACTIVATED:"bg-emerald-100 text-emerald-700 border-emerald-200",DEACTIVATED:"bg-slate-200 text-slate-700 border-slate-300",INITIALIZED:"bg-red-50 text-re-red-hover border-red-200",SUBMITTED:"bg-indigo-100 text-indigo-700 border-indigo-200",ASSIGNED:"bg-violet-100 text-violet-700 border-violet-200",UNASSIGNED:"bg-slate-200 text-slate-700 border-slate-300",REORDERED:"bg-sky-100 text-sky-700 border-sky-200"},L2=t=>{try{return new Date(t).toLocaleString("en-IN",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return t}},Fv=({value:t})=>t==null?e.jsx("p",{className:"text-xs italic text-slate-400",children:"—"}):e.jsx("pre",{className:"text-xs bg-slate-900 text-slate-100 rounded-lg p-3 overflow-auto max-h-72 whitespace-pre-wrap break-words",children:JSON.stringify(t,null,2)}),GK=()=>{var Q,W,U;const[t,s]=g.useState([]),[n,r]=g.useState(null),[a,i]=g.useState(!1),[o,d]=g.useState(1),[m]=g.useState(25),[f,p]=g.useState(1),[h,x]=g.useState(0),[u,N]=g.useState("__all__"),[v,w]=g.useState("__all__"),[j,b]=g.useState(""),[C,S]=g.useState(""),[D,_]=g.useState(""),[A,E]=g.useState(""),[q,O]=g.useState(null),R=g.useMemo(()=>({module:u!=="__all__"?u:void 0,action:v!=="__all__"?v:void 0,search:A||void 0,dateFrom:C||void 0,dateTo:D||void 0,page:o,limit:m}),[u,v,A,C,D,o,m]),P=g.useCallback(async()=>{var M,z;i(!0);try{const T=await Re.getSystemAuditLogs(R),F=T==null?void 0:T.data;T!=null&&T.ok&&(F!=null&&F.success)?(s(F.data||[]),p(((M=F.pagination)==null?void 0:M.totalPages)||1),x(((z=F.pagination)==null?void 0:z.total)||0)):(J.error((F==null?void 0:F.message)||"Unable to load system logs"),s([]))}catch(T){console.error("[SystemLogsPage] fetchLogs error:",T),J.error("Failed to load system logs"),s([])}finally{i(!1)}},[R]),L=g.useCallback(async()=>{try{const M=await Re.getSystemAuditSummary(),z=M==null?void 0:M.data;M!=null&&M.ok&&(z!=null&&z.success)&&r(z.data||null)}catch(M){console.error("[SystemLogsPage] fetchSummary error:",M)}},[]);g.useEffect(()=>{P()},[P]),g.useEffect(()=>{L()},[L]);const $=()=>{d(1),E(j.trim())},Z=()=>{N("__all__"),w("__all__"),b(""),E(""),S(""),_(""),d(1)};return e.jsxs("div",{className:"space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(rd,{className:"w-6 h-6 text-re-red"}),"System Activity Logs"]}),e.jsx("p",{className:"text-slate-500",children:"Configuration-level changes across questionnaires, interview configs, master hierarchy, system / SLA configs, and role assignments."})]}),e.jsxs(te,{variant:"outline",onClick:()=>{P(),L()},disabled:a,children:[e.jsx(or,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsxs(_e,{className:"border-slate-200",children:[e.jsx(Xe,{className:"pb-2",children:e.jsx(st,{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Total Events"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:(n==null?void 0:n.totalEntries)??"—"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Lifetime"})]})]}),((n==null?void 0:n.byModule)||[]).slice(0,4).map(M=>e.jsxs(_e,{className:"border-slate-200",children:[e.jsx(Xe,{className:"pb-2",children:e.jsx(st,{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:M.moduleLabel})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:M.total}),e.jsx("button",{onClick:()=>{N(M.module),d(1)},className:"text-[11px] text-re-red hover:underline mt-1",children:"View module →"})]})]},M.module))]}),e.jsx(_e,{className:"border-slate-200",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-3 items-end",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-600 mb-1 block flex items-center gap-1",children:[e.jsx(wa,{className:"w-3 h-3"})," Search"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(it,{placeholder:"Entity name, description, or actor…",value:j,onChange:M=>b(M.target.value),onKeyDown:M=>{M.key==="Enter"&&$()}}),e.jsx(te,{variant:"outline",onClick:$,children:"Go"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"Module"}),e.jsxs(Rt,{value:u,onValueChange:M=>{N(M),d(1)},children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"All Modules"})}),e.jsx(Tt,{children:VK.map(M=>e.jsx(Pe,{value:M.value,children:M.label},M.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"Action"}),e.jsxs(Rt,{value:v,onValueChange:M=>{w(M),d(1)},children:[e.jsx(_t,{children:e.jsx(Et,{placeholder:"All Actions"})}),e.jsx(Tt,{children:HK.map(M=>e.jsx(Pe,{value:M.value,children:M.label},M.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"From"}),e.jsx(it,{type:"date",value:C,onChange:M=>{S(M.target.value),d(1)}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"To"}),e.jsx(it,{type:"date",value:D,onChange:M=>{_(M.target.value),d(1)}})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-2",children:[e.jsx(eb,{className:"w-3 h-3"}),"Showing ",t.length," of ",h," matching event(s)"]}),e.jsx(te,{variant:"ghost",size:"sm",onClick:Z,children:"Reset filters"})]})]})}),e.jsxs(_e,{className:"border-slate-200 overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50 text-slate-600",children:e.jsxs("tr",{className:"text-left",children:[e.jsx("th",{className:"px-4 py-3 font-semibold",children:"When"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Module"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Action"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Entity"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Actor"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Description"}),e.jsx("th",{className:"px-4 py-3 font-semibold w-10"})]})}),e.jsxs("tbody",{className:"divide-y divide-slate-100",children:[a&&e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-4 py-10 text-center text-slate-400",children:[e.jsx(or,{className:"w-5 h-5 inline-block mr-2 animate-spin"}),"Loading system logs…"]})}),!a&&t.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-10 text-center text-slate-400",children:"No events match the current filters."})}),!a&&t.map(M=>{var z,T,F;return e.jsxs("tr",{className:"hover:bg-slate-50/70 cursor-pointer",onClick:()=>O(M),children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-slate-700",children:L2(M.timestamp)}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(we,{variant:"outline",className:"border-slate-300 text-slate-700",children:M.moduleLabel})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(we,{variant:"outline",className:WK[M.action]||"bg-slate-100 text-slate-700 border-slate-200",children:M.actionLabel})}),e.jsxs("td",{className:"px-4 py-3 text-slate-800",children:[e.jsx("div",{className:"font-medium truncate max-w-[260px]",title:M.entityLabel||"",children:M.entityLabel||`${M.entityType}`}),M.entityId&&e.jsx("div",{className:"text-[10px] font-mono text-slate-400 truncate max-w-[260px]",children:M.entityId})]}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-slate-100 text-slate-600 flex items-center justify-center text-xs font-semibold",children:(((z=M.actor)==null?void 0:z.name)||"S").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-800 leading-tight",children:((T=M.actor)==null?void 0:T.name)||"System"}),((F=M.actor)==null?void 0:F.role)&&e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:M.actor.role})]})]})}),e.jsx("td",{className:"px-4 py-3 text-slate-600",children:e.jsx("div",{className:"truncate max-w-[360px]",title:M.description,children:M.description})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(te,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),O(M)},title:"View details",children:e.jsx(un,{className:"w-4 h-4 text-slate-500"})})})]},M.id)})]})]})}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-slate-100 bg-slate-50/50",children:[e.jsxs("div",{className:"text-xs text-slate-500",children:["Page ",o," of ",f]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(te,{size:"sm",variant:"outline",disabled:a||o<=1,onClick:()=>d(M=>Math.max(1,M-1)),children:[e.jsx(io,{className:"w-4 h-4 mr-1"}),"Prev"]}),e.jsxs(te,{size:"sm",variant:"outline",disabled:a||o>=f,onClick:()=>d(M=>Math.min(f,M+1)),children:["Next",e.jsx(mi,{className:"w-4 h-4 ml-1"})]})]})]})]}),e.jsx(ms,{open:!!q,onOpenChange:M=>!M&&O(null),children:e.jsx(us,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:q&&e.jsxs(e.Fragment,{children:[e.jsxs(ys,{children:[e.jsxs(gs,{className:"flex items-center gap-2",children:[e.jsx(rd,{className:"w-5 h-5 text-re-red"}),q.moduleLabel," · ",q.actionLabel]}),e.jsx(ws,{className:"text-slate-600",children:q.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm mt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"Entity"}),e.jsx("p",{className:"text-slate-800",children:q.entityLabel||q.entityType}),q.entityId&&e.jsx("p",{className:"text-[11px] font-mono text-slate-400 mt-0.5",children:q.entityId})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"Actor"}),e.jsxs("p",{className:"text-slate-800 flex items-center gap-2",children:[e.jsx(Rr,{className:"w-4 h-4 text-slate-400"}),((Q=q.actor)==null?void 0:Q.name)||"System"]}),((W=q.actor)==null?void 0:W.role)&&e.jsx("p",{className:"text-[11px] text-slate-500 uppercase tracking-wider mt-0.5",children:q.actor.role}),((U=q.actor)==null?void 0:U.email)&&e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:q.actor.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"When"}),e.jsx("p",{className:"text-slate-800",children:L2(q.timestamp)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:"Source"}),e.jsx("p",{className:"text-slate-800",children:q.ipAddress||"—"}),e.jsx("p",{className:"text-[11px] text-slate-500 truncate",title:q.userAgent||"",children:q.userAgent||""})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-2",children:"Previous values"}),e.jsx(Fv,{value:q.oldData})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-2",children:"New values"}),e.jsx(Fv,{value:q.newData})]})]}),q.metadata&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider mb-2",children:"Metadata"}),e.jsx(Fv,{value:q.metadata})]})]})})})]})},KK=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,i]=g.useState(1),[o,d]=g.useState(1),m=15,f=tr(),p=async N=>{try{r(!0);const v=await Ko.getNotifications(N,m);v.success&&(s(v.data),v.pagination&&d(v.pagination.totalPages))}catch(v){console.error("Failed to fetch notifications",v)}finally{r(!1)}};g.useEffect(()=>{p(a)},[a]);const h=async(N,v)=>{v.stopPropagation(),await Ko.markAsRead(N),p(a)},x=async()=>{await Ko.markAllAsRead(),p(a)},u=async N=>{if(N.isRead||await Ko.markAsRead(N.id),N.link){const v=N.link;try{const w=new URL(v);w.origin===window.location.origin?f(w.pathname+w.search+w.hash):window.open(v,"_blank")}catch{f(v)}}else p(a)};return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Au,{className:"w-6 h-6 text-blue-600"}),"Notifications Center"]}),e.jsx("p",{className:"text-gray-500 text-sm mt-1",children:"View and manage all your alerts"})]}),e.jsxs(te,{variant:"outline",onClick:x,disabled:n||!t.some(N=>!N.isRead),children:[e.jsx($n,{className:"w-4 h-4 mr-2"}),"Mark all as read"]})]}),e.jsx(_e,{className:"shadow-sm border-gray-200",children:e.jsx(Oe,{className:"p-0",children:n?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[e.jsx(Au,{className:"w-12 h-12 text-gray-300 mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"No notifications yet"}),e.jsx("p",{className:"text-sm",children:"When you get updates, they'll show up here."})]}):e.jsx("div",{className:"divide-y divide-gray-100",children:t.map(N=>e.jsxs("div",{className:`p-4 hover:bg-gray-50 transition-colors flex items-start gap-4 cursor-pointer ${N.isRead?"":"bg-blue-50/50"}`,onClick:()=>u(N),children:[e.jsx("div",{className:"mt-1 flex-shrink-0 cursor-pointer",onClick:v=>h(N.id,v),children:N.isRead?e.jsx("div",{className:"w-3 h-3 border-2 border-gray-300 rounded-full"}):e.jsx("div",{className:"w-3 h-3 bg-blue-600 rounded-full shadow-sm"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1",children:[e.jsx("h4",{className:`text-sm font-semibold ${N.isRead?"text-gray-700":"text-gray-900"}`,children:N.title}),e.jsxs("div",{className:"flex items-center text-xs text-gray-500 whitespace-nowrap ml-4",children:[e.jsx(dn,{className:"w-3 h-3 mr-1"}),rR(new Date(N.createdAt),{addSuffix:!0})]})]}),e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2",children:N.message})]})]},N.id))})})}),!n&&o>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6 px-4",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Showing page ",e.jsx("span",{className:"font-medium text-gray-900",children:a})," of"," ",e.jsx("span",{className:"font-medium text-gray-900",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(te,{variant:"outline",size:"sm",disabled:a===1,onClick:()=>i(N=>Math.max(1,N-1)),children:[e.jsx(io,{className:"w-4 h-4"}),"Previous"]}),e.jsxs(te,{variant:"outline",size:"sm",disabled:a===o,onClick:()=>i(N=>Math.min(o,N+1)),children:["Next",e.jsx(mi,{className:"w-4 h-4"})]})]})]})]})},I2=({...t})=>e.jsx(PM,{theme:"light",className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t}),YK=({onLogout:t,title:s,subtitle:n})=>e.jsxs("div",{className:"flex h-screen bg-slate-50 overflow-hidden",children:[e.jsx(UM,{onLogout:t}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(a7,{title:s,subtitle:n,onRefresh:()=>window.location.reload()}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsx(bL,{})})]})]});function ZK(){const t=Lu(),{user:s,isAuthenticated:n,loading:r}=Pn(b=>b.auth),[a,i]=g.useState(!1),o=tr(),d=xl(),m=(s==null?void 0:s.role)||(s==null?void 0:s.roleCode)||"",f=b=>{const C=b.map(_=>_.toLowerCase()),S=String((s==null?void 0:s.role)||"").toLowerCase(),D=String((s==null?void 0:s.roleCode)||"").toLowerCase();return C.includes(S)||C.includes(D)},p=["DD Admin","DD_ADMIN","ASM","RBM","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","ZBH","NBH","Legal","Legal Admin","LEGAL_ADMIN","Super Admin","SUPER_ADMIN"],h=["ASM","RBM","DD-ZM","DD_ZM","ZBH","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Legal Admin","LEGAL_ADMIN","Legal","DD Admin","DD_ADMIN","CCO","CEO","Super Admin","SUPER_ADMIN"],x=["DD Admin","DD_ADMIN","DD-ZM","DD_ZM","DD Lead","DD_LEAD","DD Head","DD_HEAD","NBH","Finance","Finance Admin","FINANCE_ADMIN","Super Admin","SUPER_ADMIN"],u=["Finance","Finance Admin"];g.useEffect(()=>{t(Im())},[t]);const N=async(b,C)=>{var S;try{const D=await Re.login({email:b,password:C});if(D.ok&&D.data){const{token:_,user:A}=D.data;localStorage.setItem("token",_);const E={id:A.id,name:A.fullName||b.split("@")[0],email:A.email,password:C,role:typeof A.role=="string"?A.role:A.roleCode||"User"};t(wA({user:E,token:_})),J.success(`Welcome back, ${E.name}!`),i(!1)}else{const _=((S=D.data)==null?void 0:S.message)||"Invalid credentials";J.error(_)}}catch(D){console.error("Login error:",D),J.error("Something went wrong. Please try again.")}},v=()=>{t(SA()),i(!1),J.info("Logged out successfully"),o("/")};g.useEffect(()=>{const b=()=>{v(),J.error("Session expired. Please login again.")};return window.addEventListener("auth:logout",b),()=>window.removeEventListener("auth:logout",b)},[t,o]);const w=b=>b.startsWith("/applications/")&&b.length>14?"Application Details":b.startsWith("/resignation/")&&!b.startsWith("/dealer-resignation")?"Resignation Details":b.startsWith("/dealer-resignation/")?"Resignation Request Details":b.startsWith("/termination/")?"Termination Details":b.startsWith("/fnf/")?"F&F Request Details":b.startsWith("/constitutional-change/")?"Constitutional Change Details":b.startsWith("/relocation-requests/")?"Relocation Request Details":b.startsWith("/finance-onboarding/")?"Payment Details":b.startsWith("/finance-audit/")?"Finance Audit":b.startsWith("/finance-fnf/")?"F&F Settlement Details":b.startsWith("/fdd-details/")?"FDD Audit Workspace":b.startsWith("/questionnaire-builder/")?"Questionnaire Builder":b.startsWith("/worknotes/")?"Work Notes":{"/dashboard":"Dashboard","/applications":"Dealership Requests","/all-applications":"All Applications","/opportunity-requests":"Opportunity Requests","/non-opportunities":"Non-opportunities","/tasks":"My Tasks","/reports":"Reports & Analytics","/settings":"Settings","/users":"User Management","/resignation":"Resignation Management","/termination":"Termination Management","/fnf":"Full & Final Settlement","/finance-onboarding":"Payment Verification","/finance-fnf":"F&F Financial Settlement","/master":"Master Configuration","/constitutional-change":"Constitutional Change","/relocation-requests":"Relocation Requests","/dealer-resignation":"Dealer Resignation Management","/dealer-constitutional":"Dealer Constitutional Change","/dealer-relocation":"Dealer Relocation Requests","/questionnaire-builder":"Questionnaire Builder","/approval-policies":"Approval Policies","/fdd-dashboard":"FDD Dashboard","/fdd-details":"Audit Workspace","/questions":"Questionnaires","/questionnaires":"Questionnaire Templates","/interview-configs":"Interview Configuration","/system-logs":"System Logs","/sla-configurations":"SLA Matrix","/notifications":"Notifications"}[b]||"Dashboard",j=(b,C)=>{const S=(C||"").toLowerCase(),D=S==="dealer"||S.includes("dealer"),_=S.includes("finance");if(b.startsWith("/worknotes/"))return"Collaborative notes and clarifications linked to this onboarding or offboarding record.";if(b.startsWith("/applications/")&&b!=="/applications")return"Review stages, documents, interviews, and decisions for this single dealership onboarding application.";if(b==="/applications")return"Search, filter, and open dealership applications your role can work on.";if(b==="/all-applications")return"Cross-team view of every dealership application in the pipeline.";if(b==="/opportunity-requests")return"Applications tied to an opportunity location for DD prioritisation.";if(b==="/non-opportunities")return"Applications without a mapped opportunity; track for future reference or follow-up.";if(b==="/dashboard")return D?"Your home for outlet actions: constitutional change (how your business is legally registered), relocation, and resignation requests.":_?"Payment verification, finance audits, and F&F settlement work for dealership accounts.":"Operational snapshot for dealership onboarding: workloads, alerts, and shortcuts for your role.";if(b.startsWith("/dealer-resignation/"))return"Read-only summary of the resignation you submitted for this outlet.";if(b==="/dealer-resignation")return"Start a new outlet resignation or open a request you already submitted.";if(b==="/dealer-constitutional")return"Constitutional change updates your outlet’s registered legal structure (for example sole proprietorship to private limited). Submit one request per outlet; Royal Enfield teams review documents and approve before records change.";if(b==="/dealer-relocation")return"Request a move of your dealership to a new address or territory, and track requests in progress.";if(b.startsWith("/constitutional-change/"))return"Review evidence, comments, and workflow for this constitutional change case.";if(b==="/constitutional-change")return"Process dealer requests to change registered legal constitution, supporting documents, and approvals.";if(b.startsWith("/relocation-requests/"))return"Assess feasibility, documents, and approvals for this relocation request.";if(b==="/relocation-requests")return"Manage dealer relocation proposals: new sites, handovers, and compliance checks.";if(b.startsWith("/resignation/")&&!b.startsWith("/dealer-resignation"))return"HR workflow: clearances, handovers, and settlement steps for this resignation.";if(b==="/resignation")return"Queue of dealership resignation cases across your authorised outlets.";if(b.startsWith("/termination/"))return"Contractual exit details, evidence, and approvals for this termination case.";if(b==="/termination")return"Monitor dealership terminations, disputes, and mandated approvals.";if(b.startsWith("/fnf/"))return"Line items, deductions, and payout status for this full & final settlement.";if(b==="/fnf")return"Track F&F batches from clearance through finance payout.";if(b.startsWith("/finance-onboarding/"))return"Payment schedule, proofs, and audit notes for this onboarding application.";if(b==="/finance-onboarding")return"Validate Security Deposit, first fills, and related onboarding payments.";if(b.startsWith("/finance-audit/"))return"Finance audit trail and checklist for this application.";if(b.startsWith("/finance-fnf/"))return"Settlement calculations and release steps for this F&F record.";if(b==="/finance-fnf")return"Finance queue for F&F approvals and disbursements.";if(b.startsWith("/fdd-details/"))return"Field Development Director audit workspace for this application.";if(b==="/fdd-dashboard")return"FDD workload: audits due, flags raised, and follow-up actions.";if(b.startsWith("/questionnaire-builder/")||b==="/questionnaire-builder")return"Author and publish questionnaire versions used in dealership assessments.";if(b==="/questionnaires"||b==="/questions")return"List of published questionnaire templates and versions.";if(b==="/master")return"Hierarchy, geography, templates, and reference data shared across onboarding.";if(b==="/users")return"Create and maintain internal users, roles, and access for this portal.";if(b==="/approval-policies")return"Configure who must approve each onboarding stage or document type.";if(b==="/sla-configurations")return"Define turnaround targets and escalations for onboarding milestones.";if(b==="/interview-configs")return"Set up interview templates, panels, and scoring used during selection.";if(b==="/system-logs")return"Immutable record of configuration and administrative actions for compliance.";if(b==="/notifications")return"System and workflow alerts for your account.";if(b==="/tasks")return"Tasks assigned to you (placeholder module).";if(b==="/reports")return"Analytics and exports for onboarding performance (placeholder module).";if(b==="/settings")return"Profile, notifications, and security preferences for your account.";const A=w(b);return A==="Dashboard"?"Operational snapshot for dealership onboarding: workloads, alerts, and shortcuts for your role.":`You are viewing: ${A}.`};return r?e.jsx("div",{className:"flex items-center justify-center h-screen bg-slate-50",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-red-600"})}):n?e.jsxs(zB,{children:[e.jsxs(Xv,{children:[e.jsx(Ps,{path:"/prospective-dashboard/*",element:e.jsx(v1,{allowedRoles:["Prospective Dealer"],children:e.jsx(M$,{})})}),e.jsxs(Ps,{element:e.jsx(v1,{excludeRoles:["Prospective Dealer"],redirectTo:"/prospective-dashboard",children:e.jsx(YK,{onLogout:v,title:w(d.pathname),subtitle:j(d.pathname,m)})}),children:[e.jsx(Ps,{path:"/",element:e.jsx(Vn,{to:"/dashboard",replace:!0})}),e.jsx(Ps,{path:"/dashboard",element:f(u)?e.jsx(O$,{currentUser:s,onNavigate:b=>o(`/${b}`),onViewPaymentDetails:b=>o(`/finance-onboarding/${b}`),onViewAuditDetails:b=>o(`/finance-audit/${b}`),onViewFnFDetails:b=>o(`/finance-fnf/${b}`)}):f(["Dealer"])?e.jsx(L$,{currentUser:s,onNavigate:b=>o(`/${b}`)}):e.jsx(j7,{onNavigate:b=>o(`/${b}`)})}),e.jsx(Ps,{path:"/applications",element:e.jsx(Aq,{onViewDetails:b=>o(`/applications/${b}`),initialFilter:"all"})}),e.jsx(Ps,{path:"/applications/:id",element:e.jsx(RS,{})}),e.jsx(Ps,{path:"/worknotes/:type/:id",element:e.jsx(LE,{onBack:()=>window.history.back()})}),e.jsx(Ps,{path:"/all-applications",element:f(["DD","DD Admin","Super Admin"])?e.jsx(kq,{onViewDetails:b=>o(`/applications/${b}`),initialFilter:"all"}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/fdd-dashboard",element:e.jsx($$,{})}),e.jsx(Ps,{path:"/fdd-details/:id",element:e.jsx(lq,{})}),e.jsx(Ps,{path:"/opportunity-requests",element:e.jsx(AU,{onViewDetails:b=>o(`/applications/${b}`)})}),e.jsx(Ps,{path:"/non-opportunities",element:e.jsx(kU,{onViewDetails:b=>o(`/applications/${b}`)})}),e.jsx(Ps,{path:"/users",element:e.jsx(LG,{})}),e.jsx(Ps,{path:"/notifications",element:e.jsx(KK,{})}),e.jsx(Ps,{path:"/approval-policies",element:f(["Super Admin","DD Admin"])?e.jsx(K_,{}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/sla-configurations",element:f(["Super Admin","DD Admin","DD Lead"])?e.jsx(qG,{}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/master",element:e.jsx(OG,{})}),e.jsx(Ps,{path:"/questions",element:e.jsx(O2,{})}),e.jsx(Ps,{path:"/questionnaire-builder",element:e.jsx(P2,{})}),e.jsx(Ps,{path:"/questionnaire-builder/:id",element:e.jsx(P2,{})}),e.jsx(Ps,{path:"/questionnaires",element:e.jsx(O2,{})}),e.jsx(Ps,{path:"/interview-configs",element:f(["Super Admin","DD Admin","DD Head"])?e.jsx(UK,{}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/system-logs",element:f(["Super Admin"])?e.jsx(GK,{}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/resignation",element:f(p)?e.jsx(lV,{currentUser:s,onViewDetails:b=>o(`/resignation/${b}`)}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/resignation/:id",element:f(p)?e.jsx(fV,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/resignation"),currentUser:s}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/termination",element:f(h)?e.jsx(cV,{currentUser:s,onViewDetails:b=>o(`/termination/${b}`)}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/termination/:id",element:f(h)?e.jsx(jV,{terminationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/termination"),currentUser:s}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/fnf",element:f(x)?e.jsx(dV,{currentUser:s,onViewDetails:b=>o(`/fnf/${b}`)}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/fnf/:id",element:f(x)?e.jsx(SV,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/fnf"),currentUser:s}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/finance-onboarding",element:f(u)?e.jsx(CV,{onViewPaymentDetails:b=>o(`/finance-onboarding/${b}`),onViewAuditDetails:b=>o(`/finance-audit/${b}`)}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/finance-onboarding/:id",element:f(u)?e.jsx(kV,{applicationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/finance-onboarding")}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/finance-audit/:id",element:e.jsx(RS,{})}),e.jsx(Ps,{path:"/finance-fnf",element:f(u)?e.jsx(AV,{onViewFnFDetails:b=>o(`/finance-fnf/${b}`)}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/finance-fnf/:id",element:f(u)?e.jsx(DV,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/finance-fnf")}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/constitutional-change",element:e.jsx(GG,{currentUser:s,onViewDetails:b=>o(`/constitutional-change/${b}`)})}),e.jsx(Ps,{path:"/constitutional-change/:id",element:e.jsx(ZG,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/constitutional-change"),currentUser:s})}),e.jsx(Ps,{path:"/relocation-requests",element:e.jsx(XG,{currentUser:s,onViewDetails:b=>o(`/relocation-requests/${b}`)})}),e.jsx(Ps,{path:"/relocation-requests/:id",element:e.jsx(aK,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/relocation-requests"),currentUser:s})}),e.jsx(Ps,{path:"/dealer-resignation",element:e.jsx(iK,{currentUser:s,onViewDetails:b=>o(`/dealer-resignation/${b}`)})}),e.jsx(Ps,{path:"/dealer-resignation/:id",element:f(["Dealer"])?e.jsx(MK,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/dealer-resignation")}):e.jsx(Vn,{to:"/dashboard"})}),e.jsx(Ps,{path:"/dealer-constitutional",element:e.jsx(BK,{currentUser:s,onViewDetails:b=>o(`/constitutional-change/${b}`)})}),e.jsx(Ps,{path:"/dealer-relocation",element:e.jsx(qK,{currentUser:s,onViewDetails:b=>o(`/relocation-requests/${b}`)})}),e.jsx(Ps,{path:"/tasks",element:e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"My Tasks"}),e.jsx("p",{className:"text-slate-600",children:"Task management interface would be displayed here"}),e.jsx("p",{className:"text-slate-500 mt-4",children:"Shows applications assigned to the current user"})]})}),e.jsx(Ps,{path:"/reports",element:e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8 text-center",children:[e.jsx("h2",{className:"text-slate-900 mb-2",children:"Reports & Analytics"}),e.jsx("p",{className:"text-slate-600",children:"Advanced reporting and analytics dashboard"}),e.jsx("p",{className:"text-slate-500 mt-4",children:"Charts, export capabilities, and custom filters"})]})}),e.jsx(Ps,{path:"/settings",element:e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200 p-8",children:[e.jsx("h2",{className:"text-slate-900 mb-4",children:"Settings"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-2",children:"Profile Settings"}),e.jsx("p",{className:"text-slate-600",children:"Update your profile information and preferences"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-2",children:"Notification Preferences"}),e.jsx("p",{className:"text-slate-600",children:"Configure email and system notifications"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900 mb-2",children:"Security"}),e.jsx("p",{className:"text-slate-600",children:"Change password and manage security settings"})]})]})]})}),e.jsx(Ps,{path:"*",element:e.jsx(Vn,{to:"/dashboard",replace:!0})})]})]}),e.jsx(I2,{})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Xv,{children:[e.jsx(Ps,{path:"/admin-login",element:e.jsx(_1,{onLogin:N})}),e.jsx(Ps,{path:"/prospective-login",element:e.jsx(zM,{})}),e.jsx(Ps,{path:"/questionnaire/:applicationId",element:e.jsx(LM,{})}),e.jsx(Ps,{path:"*",element:a?e.jsx(_1,{onLogin:N}):e.jsx(OM,{onAdminLogin:()=>i(!0)})})]}),e.jsx(I2,{})]})}wP.createRoot(document.getElementById("root")).render(e.jsx(Ct.StrictMode,{children:e.jsx(FP,{store:D5,children:e.jsx(SL,{children:e.jsx(ZK,{})})})}));
|