794 lines
1.9 MiB
794 lines
1.9 MiB
var f4=Object.defineProperty;var p4=(t,s,n)=>s in t?f4(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Qx=(t,s,n)=>p4(t,typeof s!="symbol"?s+"":s,n);function x4(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 l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(t,a,l.get?l:{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 l of a)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();var Go=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xx={exports:{}},Jd={},Jx={exports:{}},rn={};/**
|
||
* @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 xw;function g4(){if(xw)return rn;xw=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"),l=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"),x=Symbol.for("react.lazy"),h=Symbol.iterator;function p(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(){}},w=Object.assign,v={};function N(T,F,B){this.props=T,this.context=F,this.refs=v,this.updater=B||u}N.prototype.isReactComponent={},N.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")},N.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function j(){}j.prototype=N.prototype;function y(T,F,B){this.props=T,this.context=F,this.refs=v,this.updater=B||u}var C=y.prototype=new j;C.constructor=y,w(C,N.prototype),C.isPureReactComponent=!0;var S=Array.isArray,D=Object.prototype.hasOwnProperty,R={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function L(T,F,B){var K,W={},H=null,X=null;if(F!=null)for(K in F.ref!==void 0&&(X=F.ref),F.key!==void 0&&(H=""+F.key),F)D.call(F,K)&&!A.hasOwnProperty(K)&&(W[K]=F[K]);var J=arguments.length-2;if(J===1)W.children=B;else if(1<J){for(var ie=Array(J),ae=0;ae<J;ae++)ie[ae]=arguments[ae+2];W.children=ie}if(T&&T.defaultProps)for(K in J=T.defaultProps,J)W[K]===void 0&&(W[K]=J[K]);return{$$typeof:t,type:T,key:H,ref:X,props:W,_owner:R.current}}function $(T,F){return{$$typeof:t,type:T.type,key:F,ref:T.ref,props:T.props,_owner:T._owner}}function P(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function E(T){var F={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(B){return F[B]})}var O=/\/+/g;function I(T,F){return typeof T=="object"&&T!==null&&T.key!=null?E(""+T.key):F.toString(36)}function q(T,F,B,K,W){var H=typeof T;(H==="undefined"||H==="boolean")&&(T=null);var X=!1;if(T===null)X=!0;else switch(H){case"string":case"number":X=!0;break;case"object":switch(T.$$typeof){case t:case s:X=!0}}if(X)return X=T,W=W(X),T=K===""?"."+I(X,0):K,S(W)?(B="",T!=null&&(B=T.replace(O,"$&/")+"/"),q(W,F,B,"",function(ae){return ae})):W!=null&&(P(W)&&(W=$(W,B+(!W.key||X&&X.key===W.key?"":(""+W.key).replace(O,"$&/")+"/")+T)),F.push(W)),1;if(X=0,K=K===""?".":K+":",S(T))for(var J=0;J<T.length;J++){H=T[J];var ie=K+I(H,J);X+=q(H,F,B,ie,W)}else if(ie=p(T),typeof ie=="function")for(T=ie.call(T),J=0;!(H=T.next()).done;)H=H.value,ie=K+I(H,J++),X+=q(H,F,B,ie,W);else if(H==="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 X}function G(T,F,B){if(T==null)return T;var K=[],W=0;return q(T,K,"","",function(H){return F.call(B,H,W++)}),K}function Y(T){if(T._status===-1){var F=T._result;F=F(),F.then(function(B){(T._status===0||T._status===-1)&&(T._status=1,T._result=B)},function(B){(T._status===0||T._status===-1)&&(T._status=2,T._result=B)}),T._status===-1&&(T._status=0,T._result=F)}if(T._status===1)return T._result.default;throw T._result}var V={current:null},Q={transition:null},_={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:Q,ReactCurrentOwner:R};function z(){throw Error("act(...) is not supported in production builds of React.")}return rn.Children={map:G,forEach:function(T,F,B){G(T,function(){F.apply(this,arguments)},B)},count:function(T){var F=0;return G(T,function(){F++}),F},toArray:function(T){return G(T,function(F){return F})||[]},only:function(T){if(!P(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},rn.Component=N,rn.Fragment=n,rn.Profiler=a,rn.PureComponent=y,rn.StrictMode=r,rn.Suspense=m,rn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_,rn.act=z,rn.cloneElement=function(T,F,B){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var K=w({},T.props),W=T.key,H=T.ref,X=T._owner;if(F!=null){if(F.ref!==void 0&&(H=F.ref,X=R.current),F.key!==void 0&&(W=""+F.key),T.type&&T.type.defaultProps)var J=T.type.defaultProps;for(ie in F)D.call(F,ie)&&!A.hasOwnProperty(ie)&&(K[ie]=F[ie]===void 0&&J!==void 0?J[ie]:F[ie])}var ie=arguments.length-2;if(ie===1)K.children=B;else if(1<ie){J=Array(ie);for(var ae=0;ae<ie;ae++)J[ae]=arguments[ae+2];K.children=J}return{$$typeof:t,type:T.type,key:W,ref:H,props:K,_owner:X}},rn.createContext=function(T){return T={$$typeof:o,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:l,_context:T},T.Consumer=T},rn.createElement=L,rn.createFactory=function(T){var F=L.bind(null,T);return F.type=T,F},rn.createRef=function(){return{current:null}},rn.forwardRef=function(T){return{$$typeof:d,render:T}},rn.isValidElement=P,rn.lazy=function(T){return{$$typeof:x,_payload:{_status:-1,_result:T},_init:Y}},rn.memo=function(T,F){return{$$typeof:f,type:T,compare:F===void 0?null:F}},rn.startTransition=function(T){var F=Q.transition;Q.transition={};try{T()}finally{Q.transition=F}},rn.unstable_act=z,rn.useCallback=function(T,F){return V.current.useCallback(T,F)},rn.useContext=function(T){return V.current.useContext(T)},rn.useDebugValue=function(){},rn.useDeferredValue=function(T){return V.current.useDeferredValue(T)},rn.useEffect=function(T,F){return V.current.useEffect(T,F)},rn.useId=function(){return V.current.useId()},rn.useImperativeHandle=function(T,F,B){return V.current.useImperativeHandle(T,F,B)},rn.useInsertionEffect=function(T,F){return V.current.useInsertionEffect(T,F)},rn.useLayoutEffect=function(T,F){return V.current.useLayoutEffect(T,F)},rn.useMemo=function(T,F){return V.current.useMemo(T,F)},rn.useReducer=function(T,F,B){return V.current.useReducer(T,F,B)},rn.useRef=function(T){return V.current.useRef(T)},rn.useState=function(T){return V.current.useState(T)},rn.useSyncExternalStore=function(T,F,B){return V.current.useSyncExternalStore(T,F,B)},rn.useTransition=function(){return V.current.useTransition()},rn.version="18.3.1",rn}var gw;function fd(){return gw||(gw=1,Jx.exports=g4()),Jx.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 vw;function v4(){if(vw)return Jd;vw=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,l={key:!0,ref:!0,__self:!0,__source:!0};function o(d,m,f){var x,h={},p=null,u=null;f!==void 0&&(p=""+f),m.key!==void 0&&(p=""+m.key),m.ref!==void 0&&(u=m.ref);for(x in m)r.call(m,x)&&!l.hasOwnProperty(x)&&(h[x]=m[x]);if(d&&d.defaultProps)for(x in m=d.defaultProps,m)h[x]===void 0&&(h[x]=m[x]);return{$$typeof:s,type:d,key:p,ref:u,props:h,_owner:a.current}}return Jd.Fragment=n,Jd.jsx=o,Jd.jsxs=o,Jd}var yw;function y4(){return yw||(yw=1,Xx.exports=v4()),Xx.exports}var e=y4(),g=fd();const wt=wf(g),Sf=x4({__proto__:null,default:wt},[g]);var rm={},eg={exports:{}},ca={},tg={exports:{}},sg={};/**
|
||
* @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 bw;function b4(){return bw||(bw=1,(function(t){function s(Q,_){var z=Q.length;Q.push(_);e:for(;0<z;){var T=z-1>>>1,F=Q[T];if(0<a(F,_))Q[T]=_,Q[z]=F,z=T;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var _=Q[0],z=Q.pop();if(z!==_){Q[0]=z;e:for(var T=0,F=Q.length,B=F>>>1;T<B;){var K=2*(T+1)-1,W=Q[K],H=K+1,X=Q[H];if(0>a(W,z))H<F&&0>a(X,W)?(Q[T]=X,Q[H]=z,T=H):(Q[T]=W,Q[K]=z,T=K);else if(H<F&&0>a(X,z))Q[T]=X,Q[H]=z,T=H;else break e}}return _}function a(Q,_){var z=Q.sortIndex-_.sortIndex;return z!==0?z:Q.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var o=Date,d=o.now();t.unstable_now=function(){return o.now()-d}}var m=[],f=[],x=1,h=null,p=3,u=!1,w=!1,v=!1,N=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,y=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(Q){for(var _=n(f);_!==null;){if(_.callback===null)r(f);else if(_.startTime<=Q)r(f),_.sortIndex=_.expirationTime,s(m,_);else break;_=n(f)}}function S(Q){if(v=!1,C(Q),!w)if(n(m)!==null)w=!0,Y(D);else{var _=n(f);_!==null&&V(S,_.startTime-Q)}}function D(Q,_){w=!1,v&&(v=!1,j(L),L=-1),u=!0;var z=p;try{for(C(_),h=n(m);h!==null&&(!(h.expirationTime>_)||Q&&!E());){var T=h.callback;if(typeof T=="function"){h.callback=null,p=h.priorityLevel;var F=T(h.expirationTime<=_);_=t.unstable_now(),typeof F=="function"?h.callback=F:h===n(m)&&r(m),C(_)}else r(m);h=n(m)}if(h!==null)var B=!0;else{var K=n(f);K!==null&&V(S,K.startTime-_),B=!1}return B}finally{h=null,p=z,u=!1}}var R=!1,A=null,L=-1,$=5,P=-1;function E(){return!(t.unstable_now()-P<$)}function O(){if(A!==null){var Q=t.unstable_now();P=Q;var _=!0;try{_=A(!0,Q)}finally{_?I():(R=!1,A=null)}}else R=!1}var I;if(typeof y=="function")I=function(){y(O)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,G=q.port2;q.port1.onmessage=O,I=function(){G.postMessage(null)}}else I=function(){N(O,0)};function Y(Q){A=Q,R||(R=!0,I())}function V(Q,_){L=N(function(){Q(t.unstable_now())},_)}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(Q){Q.callback=null},t.unstable_continueExecution=function(){w||u||(w=!0,Y(D))},t.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<Q?Math.floor(1e3/Q):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_getFirstCallbackNode=function(){return n(m)},t.unstable_next=function(Q){switch(p){case 1:case 2:case 3:var _=3;break;default:_=p}var z=p;p=_;try{return Q()}finally{p=z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(Q,_){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var z=p;p=Q;try{return _()}finally{p=z}},t.unstable_scheduleCallback=function(Q,_,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,Q){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,Q={id:x++,callback:_,priorityLevel:Q,startTime:z,expirationTime:F,sortIndex:-1},z>T?(Q.sortIndex=z,s(f,Q),n(m)===null&&Q===n(f)&&(v?(j(L),L=-1):v=!0,V(S,z-T))):(Q.sortIndex=F,s(m,Q),w||u||(w=!0,Y(D))),Q},t.unstable_shouldYield=E,t.unstable_wrapCallback=function(Q){var _=p;return function(){var z=p;p=_;try{return Q.apply(this,arguments)}finally{p=z}}}})(sg)),sg}var jw;function j4(){return jw||(jw=1,tg.exports=b4()),tg.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 Nw;function N4(){if(Nw)return ca;Nw=1;var t=fd(),s=j4();function n(i){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+i,b=1;b<arguments.length;b++)c+="&args[]="+encodeURIComponent(arguments[b]);return"Minified React error #"+i+"; 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 l(i,c){o(i,c),o(i+"Capture",c)}function o(i,c){for(a[i]=c,i=0;i<c.length;i++)r.add(c[i])}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]*$/,x={},h={};function p(i){return m.call(h,i)?!0:m.call(x,i)?!1:f.test(i)?h[i]=!0:(x[i]=!0,!1)}function u(i,c,b,k){if(b!==null&&b.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return k?!1:b!==null?!b.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function w(i,c,b,k){if(c===null||typeof c>"u"||u(i,c,b,k))return!0;if(k)return!1;if(b!==null)switch(b.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(i,c,b,k,M,U,le){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=k,this.attributeNamespace=M,this.mustUseProperty=b,this.propertyName=i,this.type=c,this.sanitizeURL=U,this.removeEmptyString=le}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){N[i]=new v(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var c=i[0];N[c]=new v(c,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){N[i]=new v(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){N[i]=new v(i,2,!1,i,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(i){N[i]=new v(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){N[i]=new v(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){N[i]=new v(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){N[i]=new v(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){N[i]=new v(i,5,!1,i.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function y(i){return i[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(i){var c=i.replace(j,y);N[c]=new v(c,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var c=i.replace(j,y);N[c]=new v(c,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var c=i.replace(j,y);N[c]=new v(c,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){N[i]=new v(i,1,!1,i.toLowerCase(),null,!1,!1)}),N.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){N[i]=new v(i,1,!1,i.toLowerCase(),null,!0,!0)});function C(i,c,b,k){var M=N.hasOwnProperty(c)?N[c]:null;(M!==null?M.type!==0:k||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(w(c,b,M,k)&&(b=null),k||M===null?p(c)&&(b===null?i.removeAttribute(c):i.setAttribute(c,""+b)):M.mustUseProperty?i[M.propertyName]=b===null?M.type===3?!1:"":b:(c=M.attributeName,k=M.attributeNamespace,b===null?i.removeAttribute(c):(M=M.type,b=M===3||M===4&&b===!0?"":""+b,k?i.setAttributeNS(k,c,b):i.setAttribute(c,b))))}var S=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),R=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),E=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),G=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),Q=Symbol.iterator;function _(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var z=Object.assign,T;function F(i){if(T===void 0)try{throw Error()}catch(b){var c=b.stack.trim().match(/\n( *(at )?)/);T=c&&c[1]||""}return`
|
||
`+T+i}var B=!1;function K(i,c){if(!i||B)return"";B=!0;var b=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(Ze){var k=Ze}Reflect.construct(i,[],c)}else{try{c.call()}catch(Ze){k=Ze}i.call(c.prototype)}else{try{throw Error()}catch(Ze){k=Ze}i()}}catch(Ze){if(Ze&&k&&typeof Ze.stack=="string"){for(var M=Ze.stack.split(`
|
||
`),U=k.stack.split(`
|
||
`),le=M.length-1,be=U.length-1;1<=le&&0<=be&&M[le]!==U[be];)be--;for(;1<=le&&0<=be;le--,be--)if(M[le]!==U[be]){if(le!==1||be!==1)do if(le--,be--,0>be||M[le]!==U[be]){var Re=`
|
||
`+M[le].replace(" at new "," at ");return i.displayName&&Re.includes("<anonymous>")&&(Re=Re.replace("<anonymous>",i.displayName)),Re}while(1<=le&&0<=be);break}}}finally{B=!1,Error.prepareStackTrace=b}return(i=i?i.displayName||i.name:"")?F(i):""}function W(i){switch(i.tag){case 5:return F(i.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return i=K(i.type,!1),i;case 11:return i=K(i.type.render,!1),i;case 1:return i=K(i.type,!0),i;default:return""}}function H(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case A:return"Fragment";case R:return"Portal";case $:return"Profiler";case L:return"StrictMode";case I:return"Suspense";case q:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case E:return(i.displayName||"Context")+".Consumer";case P:return(i._context.displayName||"Context")+".Provider";case O:var c=i.render;return i=i.displayName,i||(i=c.displayName||c.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case G:return c=i.displayName||null,c!==null?c:H(i.type)||"Memo";case Y:c=i._payload,i=i._init;try{return H(i(c))}catch{}}return null}function X(i){var c=i.type;switch(i.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 i=c.render,i=i.displayName||i.name||"",c.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return H(c);case 8:return c===L?"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 J(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ie(i){var c=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ae(i){var c=ie(i)?"checked":"value",b=Object.getOwnPropertyDescriptor(i.constructor.prototype,c),k=""+i[c];if(!i.hasOwnProperty(c)&&typeof b<"u"&&typeof b.get=="function"&&typeof b.set=="function"){var M=b.get,U=b.set;return Object.defineProperty(i,c,{configurable:!0,get:function(){return M.call(this)},set:function(le){k=""+le,U.call(this,le)}}),Object.defineProperty(i,c,{enumerable:b.enumerable}),{getValue:function(){return k},setValue:function(le){k=""+le},stopTracking:function(){i._valueTracker=null,delete i[c]}}}}function xe(i){i._valueTracker||(i._valueTracker=ae(i))}function ce(i){if(!i)return!1;var c=i._valueTracker;if(!c)return!0;var b=c.getValue(),k="";return i&&(k=ie(i)?i.checked?"true":"false":i.value),i=k,i!==b?(c.setValue(i),!0):!1}function we(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function ke(i,c){var b=c.checked;return z({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:b??i._wrapperState.initialChecked})}function Xe(i,c){var b=c.defaultValue==null?"":c.defaultValue,k=c.checked!=null?c.checked:c.defaultChecked;b=J(c.value!=null?c.value:b),i._wrapperState={initialChecked:k,initialValue:b,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Ot(i,c){c=c.checked,c!=null&&C(i,"checked",c,!1)}function bt(i,c){Ot(i,c);var b=J(c.value),k=c.type;if(b!=null)k==="number"?(b===0&&i.value===""||i.value!=b)&&(i.value=""+b):i.value!==""+b&&(i.value=""+b);else if(k==="submit"||k==="reset"){i.removeAttribute("value");return}c.hasOwnProperty("value")?ve(i,c.type,b):c.hasOwnProperty("defaultValue")&&ve(i,c.type,J(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(i.defaultChecked=!!c.defaultChecked)}function te(i,c,b){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=""+i._wrapperState.initialValue,b||c===i.value||(i.value=c),i.defaultValue=c}b=i.name,b!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,b!==""&&(i.name=b)}function ve(i,c,b){(c!=="number"||we(i.ownerDocument)!==i)&&(b==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+b&&(i.defaultValue=""+b))}var qe=Array.isArray;function ge(i,c,b,k){if(i=i.options,c){c={};for(var M=0;M<b.length;M++)c["$"+b[M]]=!0;for(b=0;b<i.length;b++)M=c.hasOwnProperty("$"+i[b].value),i[b].selected!==M&&(i[b].selected=M),M&&k&&(i[b].defaultSelected=!0)}else{for(b=""+J(b),c=null,M=0;M<i.length;M++){if(i[M].value===b){i[M].selected=!0,k&&(i[M].defaultSelected=!0);return}c!==null||i[M].disabled||(c=i[M])}c!==null&&(c.selected=!0)}}function Be(i,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return z({},c,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function ut(i,c){var b=c.value;if(b==null){if(b=c.children,c=c.defaultValue,b!=null){if(c!=null)throw Error(n(92));if(qe(b)){if(1<b.length)throw Error(n(93));b=b[0]}c=b}c==null&&(c=""),b=c}i._wrapperState={initialValue:J(b)}}function ht(i,c){var b=J(c.value),k=J(c.defaultValue);b!=null&&(b=""+b,b!==i.value&&(i.value=b),c.defaultValue==null&&i.defaultValue!==b&&(i.defaultValue=b)),k!=null&&(i.defaultValue=""+k)}function it(i){var c=i.textContent;c===i._wrapperState.initialValue&&c!==""&&c!==null&&(i.value=c)}function Tt(i){switch(i){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 It(i,c){return i==null||i==="http://www.w3.org/1999/xhtml"?Tt(c):i==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var he,vt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,b,k,M){MSApp.execUnsafeLocalFunction(function(){return i(c,b,k,M)})}:i})(function(i,c){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=c;else{for(he=he||document.createElement("div"),he.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=he.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;c.firstChild;)i.appendChild(c.firstChild)}});function mt(i,c){if(c){var b=i.firstChild;if(b&&b===i.lastChild&&b.nodeType===3){b.nodeValue=c;return}}i.textContent=c}var _e={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},Vt=["Webkit","ms","Moz","O"];Object.keys(_e).forEach(function(i){Vt.forEach(function(c){c=c+i.charAt(0).toUpperCase()+i.substring(1),_e[c]=_e[i]})});function Et(i,c,b){return c==null||typeof c=="boolean"||c===""?"":b||typeof c!="number"||c===0||_e.hasOwnProperty(i)&&_e[i]?(""+c).trim():c+"px"}function Ds(i,c){i=i.style;for(var b in c)if(c.hasOwnProperty(b)){var k=b.indexOf("--")===0,M=Et(b,c[b],k);b==="float"&&(b="cssFloat"),k?i.setProperty(b,M):i[b]=M}}var ln=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 Bs(i,c){if(c){if(ln[i]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,i));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 Ys(i,c){if(i.indexOf("-")===-1)return typeof c.is=="string";switch(i){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 Xs=null;function Js(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ws=null,Z=null,oe=null;function Ne(i){if(i=Fd(i)){if(typeof Ws!="function")throw Error(n(280));var c=i.stateNode;c&&(c=yh(c),Ws(i.stateNode,i.type,c))}}function Oe(i){Z?oe?oe.push(i):oe=[i]:Z=i}function De(){if(Z){var i=Z,c=oe;if(oe=Z=null,Ne(i),c)for(i=0;i<c.length;i++)Ne(c[i])}}function ye(i,c){return i(c)}function Ve(){}var Ge=!1;function st(i,c,b){if(Ge)return i(c,b);Ge=!0;try{return ye(i,c,b)}finally{Ge=!1,(Z!==null||oe!==null)&&(Ve(),De())}}function Kt(i,c){var b=i.stateNode;if(b===null)return null;var k=yh(b);if(k===null)return null;b=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)||(i=i.type,k=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!k;break e;default:i=!1}if(i)return null;if(b&&typeof b!="function")throw Error(n(231,c,typeof b));return b}var Xt=!1;if(d)try{var ot={};Object.defineProperty(ot,"passive",{get:function(){Xt=!0}}),window.addEventListener("test",ot,ot),window.removeEventListener("test",ot,ot)}catch{Xt=!1}function ft(i,c,b,k,M,U,le,be,Re){var Ze=Array.prototype.slice.call(arguments,3);try{c.apply(b,Ze)}catch(Ct){this.onError(Ct)}}var Es=!1,ts=null,vs=!1,Te=null,je={onError:function(i){Es=!0,ts=i}};function nt(i,c,b,k,M,U,le,be,Re){Es=!1,ts=null,ft.apply(je,arguments)}function Ye(i,c,b,k,M,U,le,be,Re){if(nt.apply(this,arguments),Es){if(Es){var Ze=ts;Es=!1,ts=null}else throw Error(n(198));vs||(vs=!0,Te=Ze)}}function pt(i){var c=i,b=i;if(i.alternate)for(;c.return;)c=c.return;else{i=c;do c=i,(c.flags&4098)!==0&&(b=c.return),i=c.return;while(i)}return c.tag===3?b:null}function yt(i){if(i.tag===13){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function Jt(i){if(pt(i)!==i)throw Error(n(188))}function ss(i){var c=i.alternate;if(!c){if(c=pt(i),c===null)throw Error(n(188));return c!==i?null:i}for(var b=i,k=c;;){var M=b.return;if(M===null)break;var U=M.alternate;if(U===null){if(k=M.return,k!==null){b=k;continue}break}if(M.child===U.child){for(U=M.child;U;){if(U===b)return Jt(M),i;if(U===k)return Jt(M),c;U=U.sibling}throw Error(n(188))}if(b.return!==k.return)b=M,k=U;else{for(var le=!1,be=M.child;be;){if(be===b){le=!0,b=M,k=U;break}if(be===k){le=!0,k=M,b=U;break}be=be.sibling}if(!le){for(be=U.child;be;){if(be===b){le=!0,b=U,k=M;break}if(be===k){le=!0,k=U,b=M;break}be=be.sibling}if(!le)throw Error(n(189))}}if(b.alternate!==k)throw Error(n(190))}if(b.tag!==3)throw Error(n(188));return b.stateNode.current===b?i:c}function Ss(i){return i=ss(i),i!==null?Zs(i):null}function Zs(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var c=Zs(i);if(c!==null)return c;i=i.sibling}return null}var on=s.unstable_scheduleCallback,en=s.unstable_cancelCallback,tn=s.unstable_shouldYield,cn=s.unstable_requestPaint,Ae=s.unstable_now,Ht=s.unstable_getCurrentPriorityLevel,Pe=s.unstable_ImmediatePriority,ct=s.unstable_UserBlockingPriority,tt=s.unstable_NormalPriority,Nt=s.unstable_LowPriority,Mt=s.unstable_IdlePriority,Pt=null,ys=null;function Yt(i){if(ys&&typeof ys.onCommitFiberRoot=="function")try{ys.onCommitFiberRoot(Pt,i,void 0,(i.current.flags&128)===128)}catch{}}var ps=Math.clz32?Math.clz32:gn,ks=Math.log,hs=Math.LN2;function gn(i){return i>>>=0,i===0?32:31-(ks(i)/hs|0)|0}var $s=64,dn=4194304;function sn(i){switch(i&-i){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 i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function We(i,c){var b=i.pendingLanes;if(b===0)return 0;var k=0,M=i.suspendedLanes,U=i.pingedLanes,le=b&268435455;if(le!==0){var be=le&~M;be!==0?k=sn(be):(U&=le,U!==0&&(k=sn(U)))}else le=b&~M,le!==0?k=sn(le):U!==0&&(k=sn(U));if(k===0)return 0;if(c!==0&&c!==k&&(c&M)===0&&(M=k&-k,U=c&-c,M>=U||M===16&&(U&4194240)!==0))return c;if((k&4)!==0&&(k|=b&16),c=i.entangledLanes,c!==0)for(i=i.entanglements,c&=k;0<c;)b=31-ps(c),M=1<<b,k|=i[b],c&=~M;return k}function Ft(i,c){switch(i){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 gt(i,c){for(var b=i.suspendedLanes,k=i.pingedLanes,M=i.expirationTimes,U=i.pendingLanes;0<U;){var le=31-ps(U),be=1<<le,Re=M[le];Re===-1?((be&b)===0||(be&k)!==0)&&(M[le]=Ft(be,c)):Re<=c&&(i.expiredLanes|=be),U&=~be}}function rt(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Is(){var i=$s;return $s<<=1,($s&4194240)===0&&($s=64),i}function xs(i){for(var c=[],b=0;31>b;b++)c.push(i);return c}function Nn(i,c,b){i.pendingLanes|=c,c!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,c=31-ps(c),i[c]=b}function kn(i,c){var b=i.pendingLanes&~c;i.pendingLanes=c,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=c,i.mutableReadLanes&=c,i.entangledLanes&=c,c=i.entanglements;var k=i.eventTimes;for(i=i.expirationTimes;0<b;){var M=31-ps(b),U=1<<M;c[M]=0,k[M]=-1,i[M]=-1,b&=~U}}function Cn(i,c){var b=i.entangledLanes|=c;for(i=i.entanglements;b;){var k=31-ps(b),M=1<<k;M&c|i[k]&c&&(i[k]|=c),b&=~M}}var Us=0;function Za(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Pa,Ms,un,ta,sa,na=!1,Mr=[],Xn=null,zn=null,Zt=null,Jn=new Map,Er=new Map,Gn=[],_r="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 On(i,c){switch(i){case"focusin":case"focusout":Xn=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Zt=null;break;case"pointerover":case"pointerout":Jn.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Er.delete(c.pointerId)}}function ur(i,c,b,k,M,U){return i===null||i.nativeEvent!==U?(i={blockedOn:c,domEventName:b,eventSystemFlags:k,nativeEvent:U,targetContainers:[M]},c!==null&&(c=Fd(c),c!==null&&Ms(c)),i):(i.eventSystemFlags|=k,c=i.targetContainers,M!==null&&c.indexOf(M)===-1&&c.push(M),i)}function ns(i,c,b,k,M){switch(c){case"focusin":return Xn=ur(Xn,i,c,b,k,M),!0;case"dragenter":return zn=ur(zn,i,c,b,k,M),!0;case"mouseover":return Zt=ur(Zt,i,c,b,k,M),!0;case"pointerover":var U=M.pointerId;return Jn.set(U,ur(Jn.get(U)||null,i,c,b,k,M)),!0;case"gotpointercapture":return U=M.pointerId,Er.set(U,ur(Er.get(U)||null,i,c,b,k,M)),!0}return!1}function nn(i){var c=Ro(i.target);if(c!==null){var b=pt(c);if(b!==null){if(c=b.tag,c===13){if(c=yt(b),c!==null){i.blockedOn=c,sa(i.priority,function(){un(b)});return}}else if(c===3&&b.stateNode.current.memoizedState.isDehydrated){i.blockedOn=b.tag===3?b.stateNode.containerInfo:null;return}}}i.blockedOn=null}function va(i){if(i.blockedOn!==null)return!1;for(var c=i.targetContainers;0<c.length;){var b=ba(i.domEventName,i.eventSystemFlags,c[0],i.nativeEvent);if(b===null){b=i.nativeEvent;var k=new b.constructor(b.type,b);Xs=k,b.target.dispatchEvent(k),Xs=null}else return c=Fd(b),c!==null&&Ms(c),i.blockedOn=b,!1;c.shift()}return!0}function Si(i,c,b){va(i)&&b.delete(c)}function Ci(){na=!1,Xn!==null&&va(Xn)&&(Xn=null),zn!==null&&va(zn)&&(zn=null),Zt!==null&&va(Zt)&&(Zt=null),Jn.forEach(Si),Er.forEach(Si)}function Fr(i,c){i.blockedOn===c&&(i.blockedOn=null,na||(na=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Ci)))}function Hr(i){function c(M){return Fr(M,i)}if(0<Mr.length){Fr(Mr[0],i);for(var b=1;b<Mr.length;b++){var k=Mr[b];k.blockedOn===i&&(k.blockedOn=null)}}for(Xn!==null&&Fr(Xn,i),zn!==null&&Fr(zn,i),Zt!==null&&Fr(Zt,i),Jn.forEach(c),Er.forEach(c),b=0;b<Gn.length;b++)k=Gn[b],k.blockedOn===i&&(k.blockedOn=null);for(;0<Gn.length&&(b=Gn[0],b.blockedOn===null);)nn(b),b.blockedOn===null&&Gn.shift()}var sr=S.ReactCurrentBatchConfig,ya=!0;function Gi(i,c,b,k){var M=Us,U=sr.transition;sr.transition=null;try{Us=1,Oa(i,c,b,k)}finally{Us=M,sr.transition=U}}function bo(i,c,b,k){var M=Us,U=sr.transition;sr.transition=null;try{Us=4,Oa(i,c,b,k)}finally{Us=M,sr.transition=U}}function Oa(i,c,b,k){if(ya){var M=ba(i,c,b,k);if(M===null)qp(i,c,k,An,b),On(i,k);else if(ns(M,i,c,b,k))k.stopPropagation();else if(On(i,k),c&4&&-1<_r.indexOf(i)){for(;M!==null;){var U=Fd(M);if(U!==null&&Pa(U),U=ba(i,c,b,k),U===null&&qp(i,c,k,An,b),U===M)break;M=U}M!==null&&k.stopPropagation()}else qp(i,c,k,null,b)}}var An=null;function ba(i,c,b,k){if(An=null,i=Js(k),i=Ro(i),i!==null)if(c=pt(i),c===null)i=null;else if(b=c.tag,b===13){if(i=yt(c),i!==null)return i;i=null}else if(b===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;i=null}else c!==i&&(i=null);return An=i,null}function Ki(i){switch(i){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(Ht()){case Pe:return 1;case ct:return 4;case tt:case Nt:return 16;case Mt:return 536870912;default:return 16}default:return 16}}var Wr=null,jo=null,Yi=null;function No(){if(Yi)return Yi;var i,c=jo,b=c.length,k,M="value"in Wr?Wr.value:Wr.textContent,U=M.length;for(i=0;i<b&&c[i]===M[i];i++);var le=b-i;for(k=1;k<=le&&c[b-k]===M[U-k];k++);return Yi=M.slice(i,1<k?1-k:void 0)}function Ai(i){var c=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&c===13&&(i=13)):i=c,i===10&&(i=13),32<=i||i===13?i:0}function wl(){return!0}function Sl(){return!1}function hn(i){function c(b,k,M,U,le){this._reactName=b,this._targetInst=M,this.type=k,this.nativeEvent=U,this.target=le,this.currentTarget=null;for(var be in i)i.hasOwnProperty(be)&&(b=i[be],this[be]=b?b(U):U[be]);return this.isDefaultPrevented=(U.defaultPrevented!=null?U.defaultPrevented:U.returnValue===!1)?wl:Sl,this.isPropagationStopped=Sl,this}return z(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var b=this.nativeEvent;b&&(b.preventDefault?b.preventDefault():typeof b.returnValue!="unknown"&&(b.returnValue=!1),this.isDefaultPrevented=wl)},stopPropagation:function(){var b=this.nativeEvent;b&&(b.stopPropagation?b.stopPropagation():typeof b.cancelBubble!="unknown"&&(b.cancelBubble=!0),this.isPropagationStopped=wl)},persist:function(){},isPersistent:wl}),c}var ne={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},re=hn(ne),me=z({},ne,{view:0,detail:0}),pe=hn(me),Se,ze,Ue,dt=z({},me,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:gr,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Ue&&(Ue&&i.type==="mousemove"?(Se=i.screenX-Ue.screenX,ze=i.screenY-Ue.screenY):ze=Se=0,Ue=i),Se)},movementY:function(i){return"movementY"in i?i.movementY:ze}}),is=hn(dt),Ut=z({},dt,{dataTransfer:0}),Lt=hn(Ut),Cs=z({},me,{relatedTarget:0}),vn=hn(Cs),nr=z({},ne,{animationName:0,elapsedTime:0,pseudoElement:0}),Bt=hn(nr),As=z({},ne,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),os=hn(As),En=z({},ne,{data:0}),Tr=hn(En),Kn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xr={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"},Gr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Qa(i){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(i):(i=Gr[i])?!!c[i]:!1}function gr(){return Qa}var wo=z({},me,{key:function(i){if(i.key){var c=Kn[i.key]||i.key;if(c!=="Unidentified")return c}return i.type==="keypress"?(i=Ai(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?xr[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:gr,charCode:function(i){return i.type==="keypress"?Ai(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Ai(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Cl=hn(wo),gc=z({},dt,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),So=hn(gc),Al=z({},me,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:gr}),Zi=hn(Al),Xa=z({},ne,{propertyName:0,elapsedTime:0,pseudoElement:0}),vc=hn(Xa),vr=z({},dt,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Co=hn(vr),La=[9,13,27,32],kl=d&&"CompositionEvent"in window,Qi=null;d&&"documentMode"in document&&(Qi=document.documentMode);var Ia=d&&"TextEvent"in window&&!Qi,Ja=d&&(!kl||Qi&&8<Qi&&11>=Qi),Dl=" ",Xi=!1;function Ao(i,c){switch(i){case"keyup":return La.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ch(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Rl=!1;function Dp(i,c){switch(i){case"compositionend":return ch(c);case"keypress":return c.which!==32?null:(Xi=!0,Dl);case"textInput":return i=c.data,i===Dl&&Xi?null:i;default:return null}}function Rp(i,c){if(Rl)return i==="compositionend"||!kl&&Ao(i,c)?(i=No(),Yi=jo=Wr=null,Rl=!1,i):null;switch(i){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 Ja&&c.locale!=="ko"?null:c.data;default:return null}}var Ep={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 dh(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c==="input"?!!Ep[i.type]:c==="textarea"}function uh(i,c,b,k){Oe(k),c=xh(c,"onChange"),0<c.length&&(b=new re("onChange","change",null,b,k),i.push({event:b,listeners:c}))}var ko=null,Do=null;function _p(i){Tj(i,0)}function yc(i){var c=Sc(i);if(ce(c))return i}function Tp(i,c){if(i==="change")return c}var hh=!1;if(d){var Rd;if(d){var Ed="oninput"in document;if(!Ed){var _d=document.createElement("div");_d.setAttribute("oninput","return;"),Ed=typeof _d.oninput=="function"}Rd=Ed}else Rd=!1;hh=Rd&&(!document.documentMode||9<document.documentMode)}function yr(){ko&&(ko.detachEvent("onpropertychange",El),Do=ko=null)}function El(i){if(i.propertyName==="value"&&yc(Do)){var c=[];uh(c,Do,i,Js(i)),st(_p,c)}}function Pp(i,c,b){i==="focusin"?(yr(),ko=c,Do=b,ko.attachEvent("onpropertychange",El)):i==="focusout"&&yr()}function gT(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return yc(Do)}function vT(i,c){if(i==="click")return yc(c)}function yT(i,c){if(i==="input"||i==="change")return yc(c)}function bT(i,c){return i===c&&(i!==0||1/i===1/c)||i!==i&&c!==c}var ei=typeof Object.is=="function"?Object.is:bT;function Td(i,c){if(ei(i,c))return!0;if(typeof i!="object"||i===null||typeof c!="object"||c===null)return!1;var b=Object.keys(i),k=Object.keys(c);if(b.length!==k.length)return!1;for(k=0;k<b.length;k++){var M=b[k];if(!m.call(c,M)||!ei(i[M],c[M]))return!1}return!0}function yj(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function bj(i,c){var b=yj(i);i=0;for(var k;b;){if(b.nodeType===3){if(k=i+b.textContent.length,i<=c&&k>=c)return{node:b,offset:c-i};i=k}e:{for(;b;){if(b.nextSibling){b=b.nextSibling;break e}b=b.parentNode}b=void 0}b=yj(b)}}function jj(i,c){return i&&c?i===c?!0:i&&i.nodeType===3?!1:c&&c.nodeType===3?jj(i,c.parentNode):"contains"in i?i.contains(c):i.compareDocumentPosition?!!(i.compareDocumentPosition(c)&16):!1:!1}function Nj(){for(var i=window,c=we();c instanceof i.HTMLIFrameElement;){try{var b=typeof c.contentWindow.location.href=="string"}catch{b=!1}if(b)i=c.contentWindow;else break;c=we(i.document)}return c}function Op(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c&&(c==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||c==="textarea"||i.contentEditable==="true")}function jT(i){var c=Nj(),b=i.focusedElem,k=i.selectionRange;if(c!==b&&b&&b.ownerDocument&&jj(b.ownerDocument.documentElement,b)){if(k!==null&&Op(b)){if(c=k.start,i=k.end,i===void 0&&(i=c),"selectionStart"in b)b.selectionStart=c,b.selectionEnd=Math.min(i,b.value.length);else if(i=(c=b.ownerDocument||document)&&c.defaultView||window,i.getSelection){i=i.getSelection();var M=b.textContent.length,U=Math.min(k.start,M);k=k.end===void 0?U:Math.min(k.end,M),!i.extend&&U>k&&(M=k,k=U,U=M),M=bj(b,U);var le=bj(b,k);M&&le&&(i.rangeCount!==1||i.anchorNode!==M.node||i.anchorOffset!==M.offset||i.focusNode!==le.node||i.focusOffset!==le.offset)&&(c=c.createRange(),c.setStart(M.node,M.offset),i.removeAllRanges(),U>k?(i.addRange(c),i.extend(le.node,le.offset)):(c.setEnd(le.node,le.offset),i.addRange(c)))}}for(c=[],i=b;i=i.parentNode;)i.nodeType===1&&c.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b<c.length;b++)i=c[b],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var NT=d&&"documentMode"in document&&11>=document.documentMode,bc=null,Lp=null,Pd=null,Ip=!1;function wj(i,c,b){var k=b.window===b?b.document:b.nodeType===9?b:b.ownerDocument;Ip||bc==null||bc!==we(k)||(k=bc,"selectionStart"in k&&Op(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}),Pd&&Td(Pd,k)||(Pd=k,k=xh(Lp,"onSelect"),0<k.length&&(c=new re("onSelect","select",null,c,b),i.push({event:c,listeners:k}),c.target=bc)))}function mh(i,c){var b={};return b[i.toLowerCase()]=c.toLowerCase(),b["Webkit"+i]="webkit"+c,b["Moz"+i]="moz"+c,b}var jc={animationend:mh("Animation","AnimationEnd"),animationiteration:mh("Animation","AnimationIteration"),animationstart:mh("Animation","AnimationStart"),transitionend:mh("Transition","TransitionEnd")},Mp={},Sj={};d&&(Sj=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(i){if(Mp[i])return Mp[i];if(!jc[i])return i;var c=jc[i],b;for(b in c)if(c.hasOwnProperty(b)&&b in Sj)return Mp[i]=c[b];return i}var Cj=fh("animationend"),Aj=fh("animationiteration"),kj=fh("animationstart"),Dj=fh("transitionend"),Rj=new Map,Ej="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 _l(i,c){Rj.set(i,c),l(c,[i])}for(var Fp=0;Fp<Ej.length;Fp++){var Bp=Ej[Fp],wT=Bp.toLowerCase(),ST=Bp[0].toUpperCase()+Bp.slice(1);_l(wT,"on"+ST)}_l(Cj,"onAnimationEnd"),_l(Aj,"onAnimationIteration"),_l(kj,"onAnimationStart"),_l("dblclick","onDoubleClick"),_l("focusin","onFocus"),_l("focusout","onBlur"),_l(Dj,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Od="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(" "),CT=new Set("cancel close invalid load scroll toggle".split(" ").concat(Od));function _j(i,c,b){var k=i.type||"unknown-event";i.currentTarget=b,Ye(k,c,void 0,i),i.currentTarget=null}function Tj(i,c){c=(c&4)!==0;for(var b=0;b<i.length;b++){var k=i[b],M=k.event;k=k.listeners;e:{var U=void 0;if(c)for(var le=k.length-1;0<=le;le--){var be=k[le],Re=be.instance,Ze=be.currentTarget;if(be=be.listener,Re!==U&&M.isPropagationStopped())break e;_j(M,be,Ze),U=Re}else for(le=0;le<k.length;le++){if(be=k[le],Re=be.instance,Ze=be.currentTarget,be=be.listener,Re!==U&&M.isPropagationStopped())break e;_j(M,be,Ze),U=Re}}}if(vs)throw i=Te,vs=!1,Te=null,i}function Ln(i,c){var b=c[Gp];b===void 0&&(b=c[Gp]=new Set);var k=i+"__bubble";b.has(k)||(Pj(c,i,2,!1),b.add(k))}function $p(i,c,b){var k=0;c&&(k|=4),Pj(b,i,k,c)}var ph="_reactListening"+Math.random().toString(36).slice(2);function Ld(i){if(!i[ph]){i[ph]=!0,r.forEach(function(b){b!=="selectionchange"&&(CT.has(b)||$p(b,!1,i),$p(b,!0,i))});var c=i.nodeType===9?i:i.ownerDocument;c===null||c[ph]||(c[ph]=!0,$p("selectionchange",!1,c))}}function Pj(i,c,b,k){switch(Ki(c)){case 1:var M=Gi;break;case 4:M=bo;break;default:M=Oa}b=M.bind(null,c,b,i),M=void 0,!Xt||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(M=!0),k?M!==void 0?i.addEventListener(c,b,{capture:!0,passive:M}):i.addEventListener(c,b,!0):M!==void 0?i.addEventListener(c,b,{passive:M}):i.addEventListener(c,b,!1)}function qp(i,c,b,k,M){var U=k;if((c&1)===0&&(c&2)===0&&k!==null)e:for(;;){if(k===null)return;var le=k.tag;if(le===3||le===4){var be=k.stateNode.containerInfo;if(be===M||be.nodeType===8&&be.parentNode===M)break;if(le===4)for(le=k.return;le!==null;){var Re=le.tag;if((Re===3||Re===4)&&(Re=le.stateNode.containerInfo,Re===M||Re.nodeType===8&&Re.parentNode===M))return;le=le.return}for(;be!==null;){if(le=Ro(be),le===null)return;if(Re=le.tag,Re===5||Re===6){k=U=le;continue e}be=be.parentNode}}k=k.return}st(function(){var Ze=U,Ct=Js(b),_t=[];e:{var St=Rj.get(i);if(St!==void 0){var rs=re,ms=i;switch(i){case"keypress":if(Ai(b)===0)break e;case"keydown":case"keyup":rs=Cl;break;case"focusin":ms="focus",rs=vn;break;case"focusout":ms="blur",rs=vn;break;case"beforeblur":case"afterblur":rs=vn;break;case"click":if(b.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":rs=is;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":rs=Lt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":rs=Zi;break;case Cj:case Aj:case kj:rs=Bt;break;case Dj:rs=vc;break;case"scroll":rs=pe;break;case"wheel":rs=Co;break;case"copy":case"cut":case"paste":rs=os;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":rs=So}var gs=(c&4)!==0,er=!gs&&i==="scroll",He=gs?St!==null?St+"Capture":null:St;gs=[];for(var Ie=Ze,Ke;Ie!==null;){Ke=Ie;var $t=Ke.stateNode;if(Ke.tag===5&&$t!==null&&(Ke=$t,He!==null&&($t=Kt(Ie,He),$t!=null&&gs.push(Id(Ie,$t,Ke)))),er)break;Ie=Ie.return}0<gs.length&&(St=new rs(St,ms,null,b,Ct),_t.push({event:St,listeners:gs}))}}if((c&7)===0){e:{if(St=i==="mouseover"||i==="pointerover",rs=i==="mouseout"||i==="pointerout",St&&b!==Xs&&(ms=b.relatedTarget||b.fromElement)&&(Ro(ms)||ms[Ji]))break e;if((rs||St)&&(St=Ct.window===Ct?Ct:(St=Ct.ownerDocument)?St.defaultView||St.parentWindow:window,rs?(ms=b.relatedTarget||b.toElement,rs=Ze,ms=ms?Ro(ms):null,ms!==null&&(er=pt(ms),ms!==er||ms.tag!==5&&ms.tag!==6)&&(ms=null)):(rs=null,ms=Ze),rs!==ms)){if(gs=is,$t="onMouseLeave",He="onMouseEnter",Ie="mouse",(i==="pointerout"||i==="pointerover")&&(gs=So,$t="onPointerLeave",He="onPointerEnter",Ie="pointer"),er=rs==null?St:Sc(rs),Ke=ms==null?St:Sc(ms),St=new gs($t,Ie+"leave",rs,b,Ct),St.target=er,St.relatedTarget=Ke,$t=null,Ro(Ct)===Ze&&(gs=new gs(He,Ie+"enter",ms,b,Ct),gs.target=Ke,gs.relatedTarget=er,$t=gs),er=$t,rs&&ms)t:{for(gs=rs,He=ms,Ie=0,Ke=gs;Ke;Ke=Nc(Ke))Ie++;for(Ke=0,$t=He;$t;$t=Nc($t))Ke++;for(;0<Ie-Ke;)gs=Nc(gs),Ie--;for(;0<Ke-Ie;)He=Nc(He),Ke--;for(;Ie--;){if(gs===He||He!==null&&gs===He.alternate)break t;gs=Nc(gs),He=Nc(He)}gs=null}else gs=null;rs!==null&&Oj(_t,St,rs,gs,!1),ms!==null&&er!==null&&Oj(_t,er,ms,gs,!0)}}e:{if(St=Ze?Sc(Ze):window,rs=St.nodeName&&St.nodeName.toLowerCase(),rs==="select"||rs==="input"&&St.type==="file")var js=Tp;else if(dh(St))if(hh)js=yT;else{js=gT;var _s=Pp}else(rs=St.nodeName)&&rs.toLowerCase()==="input"&&(St.type==="checkbox"||St.type==="radio")&&(js=vT);if(js&&(js=js(i,Ze))){uh(_t,js,b,Ct);break e}_s&&_s(i,St,Ze),i==="focusout"&&(_s=St._wrapperState)&&_s.controlled&&St.type==="number"&&ve(St,"number",St.value)}switch(_s=Ze?Sc(Ze):window,i){case"focusin":(dh(_s)||_s.contentEditable==="true")&&(bc=_s,Lp=Ze,Pd=null);break;case"focusout":Pd=Lp=bc=null;break;case"mousedown":Ip=!0;break;case"contextmenu":case"mouseup":case"dragend":Ip=!1,wj(_t,b,Ct);break;case"selectionchange":if(NT)break;case"keydown":case"keyup":wj(_t,b,Ct)}var Ts;if(kl)e:{switch(i){case"compositionstart":var Vs="onCompositionStart";break e;case"compositionend":Vs="onCompositionEnd";break e;case"compositionupdate":Vs="onCompositionUpdate";break e}Vs=void 0}else Rl?Ao(i,b)&&(Vs="onCompositionEnd"):i==="keydown"&&b.keyCode===229&&(Vs="onCompositionStart");Vs&&(Ja&&b.locale!=="ko"&&(Rl||Vs!=="onCompositionStart"?Vs==="onCompositionEnd"&&Rl&&(Ts=No()):(Wr=Ct,jo="value"in Wr?Wr.value:Wr.textContent,Rl=!0)),_s=xh(Ze,Vs),0<_s.length&&(Vs=new Tr(Vs,i,null,b,Ct),_t.push({event:Vs,listeners:_s}),Ts?Vs.data=Ts:(Ts=ch(b),Ts!==null&&(Vs.data=Ts)))),(Ts=Ia?Dp(i,b):Rp(i,b))&&(Ze=xh(Ze,"onBeforeInput"),0<Ze.length&&(Ct=new Tr("onBeforeInput","beforeinput",null,b,Ct),_t.push({event:Ct,listeners:Ze}),Ct.data=Ts))}Tj(_t,c)})}function Id(i,c,b){return{instance:i,listener:c,currentTarget:b}}function xh(i,c){for(var b=c+"Capture",k=[];i!==null;){var M=i,U=M.stateNode;M.tag===5&&U!==null&&(M=U,U=Kt(i,b),U!=null&&k.unshift(Id(i,U,M)),U=Kt(i,c),U!=null&&k.push(Id(i,U,M))),i=i.return}return k}function Nc(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Oj(i,c,b,k,M){for(var U=c._reactName,le=[];b!==null&&b!==k;){var be=b,Re=be.alternate,Ze=be.stateNode;if(Re!==null&&Re===k)break;be.tag===5&&Ze!==null&&(be=Ze,M?(Re=Kt(b,U),Re!=null&&le.unshift(Id(b,Re,be))):M||(Re=Kt(b,U),Re!=null&&le.push(Id(b,Re,be)))),b=b.return}le.length!==0&&i.push({event:c,listeners:le})}var AT=/\r\n?/g,kT=/\u0000|\uFFFD/g;function Lj(i){return(typeof i=="string"?i:""+i).replace(AT,`
|
||
`).replace(kT,"")}function gh(i,c,b){if(c=Lj(c),Lj(i)!==c&&b)throw Error(n(425))}function vh(){}var zp=null,Up=null;function Vp(i,c){return i==="textarea"||i==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Hp=typeof setTimeout=="function"?setTimeout:void 0,DT=typeof clearTimeout=="function"?clearTimeout:void 0,Ij=typeof Promise=="function"?Promise:void 0,RT=typeof queueMicrotask=="function"?queueMicrotask:typeof Ij<"u"?function(i){return Ij.resolve(null).then(i).catch(ET)}:Hp;function ET(i){setTimeout(function(){throw i})}function Wp(i,c){var b=c,k=0;do{var M=b.nextSibling;if(i.removeChild(b),M&&M.nodeType===8)if(b=M.data,b==="/$"){if(k===0){i.removeChild(M),Hr(c);return}k--}else b!=="$"&&b!=="$?"&&b!=="$!"||k++;b=M}while(b);Hr(c)}function Tl(i){for(;i!=null;i=i.nextSibling){var c=i.nodeType;if(c===1||c===3)break;if(c===8){if(c=i.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return i}function Mj(i){i=i.previousSibling;for(var c=0;i;){if(i.nodeType===8){var b=i.data;if(b==="$"||b==="$!"||b==="$?"){if(c===0)return i;c--}else b==="/$"&&c++}i=i.previousSibling}return null}var wc=Math.random().toString(36).slice(2),ki="__reactFiber$"+wc,Md="__reactProps$"+wc,Ji="__reactContainer$"+wc,Gp="__reactEvents$"+wc,_T="__reactListeners$"+wc,TT="__reactHandles$"+wc;function Ro(i){var c=i[ki];if(c)return c;for(var b=i.parentNode;b;){if(c=b[Ji]||b[ki]){if(b=c.alternate,c.child!==null||b!==null&&b.child!==null)for(i=Mj(i);i!==null;){if(b=i[ki])return b;i=Mj(i)}return c}i=b,b=i.parentNode}return null}function Fd(i){return i=i[ki]||i[Ji],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Sc(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function yh(i){return i[Md]||null}var Kp=[],Cc=-1;function Pl(i){return{current:i}}function In(i){0>Cc||(i.current=Kp[Cc],Kp[Cc]=null,Cc--)}function _n(i,c){Cc++,Kp[Cc]=i.current,i.current=c}var Ol={},Br=Pl(Ol),ra=Pl(!1),Eo=Ol;function Ac(i,c){var b=i.type.contextTypes;if(!b)return Ol;var k=i.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===c)return k.__reactInternalMemoizedMaskedChildContext;var M={},U;for(U in b)M[U]=c[U];return k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=c,i.__reactInternalMemoizedMaskedChildContext=M),M}function aa(i){return i=i.childContextTypes,i!=null}function bh(){In(ra),In(Br)}function Fj(i,c,b){if(Br.current!==Ol)throw Error(n(168));_n(Br,c),_n(ra,b)}function Bj(i,c,b){var k=i.stateNode;if(c=c.childContextTypes,typeof k.getChildContext!="function")return b;k=k.getChildContext();for(var M in k)if(!(M in c))throw Error(n(108,X(i)||"Unknown",M));return z({},b,k)}function jh(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ol,Eo=Br.current,_n(Br,i),_n(ra,ra.current),!0}function $j(i,c,b){var k=i.stateNode;if(!k)throw Error(n(169));b?(i=Bj(i,c,Eo),k.__reactInternalMemoizedMergedChildContext=i,In(ra),In(Br),_n(Br,i)):In(ra),_n(ra,b)}var el=null,Nh=!1,Yp=!1;function qj(i){el===null?el=[i]:el.push(i)}function PT(i){Nh=!0,qj(i)}function Ll(){if(!Yp&&el!==null){Yp=!0;var i=0,c=Us;try{var b=el;for(Us=1;i<b.length;i++){var k=b[i];do k=k(!0);while(k!==null)}el=null,Nh=!1}catch(M){throw el!==null&&(el=el.slice(i+1)),on(Pe,Ll),M}finally{Us=c,Yp=!1}}return null}var kc=[],Dc=0,wh=null,Sh=0,Ma=[],Fa=0,_o=null,tl=1,sl="";function To(i,c){kc[Dc++]=Sh,kc[Dc++]=wh,wh=i,Sh=c}function zj(i,c,b){Ma[Fa++]=tl,Ma[Fa++]=sl,Ma[Fa++]=_o,_o=i;var k=tl;i=sl;var M=32-ps(k)-1;k&=~(1<<M),b+=1;var U=32-ps(c)+M;if(30<U){var le=M-M%5;U=(k&(1<<le)-1).toString(32),k>>=le,M-=le,tl=1<<32-ps(c)+M|b<<M|k,sl=U+i}else tl=1<<U|b<<M|k,sl=i}function Zp(i){i.return!==null&&(To(i,1),zj(i,1,0))}function Qp(i){for(;i===wh;)wh=kc[--Dc],kc[Dc]=null,Sh=kc[--Dc],kc[Dc]=null;for(;i===_o;)_o=Ma[--Fa],Ma[Fa]=null,sl=Ma[--Fa],Ma[Fa]=null,tl=Ma[--Fa],Ma[Fa]=null}var ja=null,Na=null,Bn=!1,ti=null;function Uj(i,c){var b=za(5,null,null,0);b.elementType="DELETED",b.stateNode=c,b.return=i,c=i.deletions,c===null?(i.deletions=[b],i.flags|=16):c.push(b)}function Vj(i,c){switch(i.tag){case 5:var b=i.type;return c=c.nodeType!==1||b.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(i.stateNode=c,ja=i,Na=Tl(c.firstChild),!0):!1;case 6:return c=i.pendingProps===""||c.nodeType!==3?null:c,c!==null?(i.stateNode=c,ja=i,Na=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(b=_o!==null?{id:tl,overflow:sl}:null,i.memoizedState={dehydrated:c,treeContext:b,retryLane:1073741824},b=za(18,null,null,0),b.stateNode=c,b.return=i,i.child=b,ja=i,Na=null,!0):!1;default:return!1}}function Xp(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Jp(i){if(Bn){var c=Na;if(c){var b=c;if(!Vj(i,c)){if(Xp(i))throw Error(n(418));c=Tl(b.nextSibling);var k=ja;c&&Vj(i,c)?Uj(k,b):(i.flags=i.flags&-4097|2,Bn=!1,ja=i)}}else{if(Xp(i))throw Error(n(418));i.flags=i.flags&-4097|2,Bn=!1,ja=i}}}function Hj(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;ja=i}function Ch(i){if(i!==ja)return!1;if(!Bn)return Hj(i),Bn=!0,!1;var c;if((c=i.tag!==3)&&!(c=i.tag!==5)&&(c=i.type,c=c!=="head"&&c!=="body"&&!Vp(i.type,i.memoizedProps)),c&&(c=Na)){if(Xp(i))throw Wj(),Error(n(418));for(;c;)Uj(i,c),c=Tl(c.nextSibling)}if(Hj(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,c=0;i;){if(i.nodeType===8){var b=i.data;if(b==="/$"){if(c===0){Na=Tl(i.nextSibling);break e}c--}else b!=="$"&&b!=="$!"&&b!=="$?"||c++}i=i.nextSibling}Na=null}}else Na=ja?Tl(i.stateNode.nextSibling):null;return!0}function Wj(){for(var i=Na;i;)i=Tl(i.nextSibling)}function Rc(){Na=ja=null,Bn=!1}function ex(i){ti===null?ti=[i]:ti.push(i)}var OT=S.ReactCurrentBatchConfig;function Bd(i,c,b){if(i=b.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(b._owner){if(b=b._owner,b){if(b.tag!==1)throw Error(n(309));var k=b.stateNode}if(!k)throw Error(n(147,i));var M=k,U=""+i;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===U?c.ref:(c=function(le){var be=M.refs;le===null?delete be[U]:be[U]=le},c._stringRef=U,c)}if(typeof i!="string")throw Error(n(284));if(!b._owner)throw Error(n(290,i))}return i}function Ah(i,c){throw i=Object.prototype.toString.call(c),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":i))}function Gj(i){var c=i._init;return c(i._payload)}function Kj(i){function c(He,Ie){if(i){var Ke=He.deletions;Ke===null?(He.deletions=[Ie],He.flags|=16):Ke.push(Ie)}}function b(He,Ie){if(!i)return null;for(;Ie!==null;)c(He,Ie),Ie=Ie.sibling;return null}function k(He,Ie){for(He=new Map;Ie!==null;)Ie.key!==null?He.set(Ie.key,Ie):He.set(Ie.index,Ie),Ie=Ie.sibling;return He}function M(He,Ie){return He=Ul(He,Ie),He.index=0,He.sibling=null,He}function U(He,Ie,Ke){return He.index=Ke,i?(Ke=He.alternate,Ke!==null?(Ke=Ke.index,Ke<Ie?(He.flags|=2,Ie):Ke):(He.flags|=2,Ie)):(He.flags|=1048576,Ie)}function le(He){return i&&He.alternate===null&&(He.flags|=2),He}function be(He,Ie,Ke,$t){return Ie===null||Ie.tag!==6?(Ie=Hx(Ke,He.mode,$t),Ie.return=He,Ie):(Ie=M(Ie,Ke),Ie.return=He,Ie)}function Re(He,Ie,Ke,$t){var js=Ke.type;return js===A?Ct(He,Ie,Ke.props.children,$t,Ke.key):Ie!==null&&(Ie.elementType===js||typeof js=="object"&&js!==null&&js.$$typeof===Y&&Gj(js)===Ie.type)?($t=M(Ie,Ke.props),$t.ref=Bd(He,Ie,Ke),$t.return=He,$t):($t=Zh(Ke.type,Ke.key,Ke.props,null,He.mode,$t),$t.ref=Bd(He,Ie,Ke),$t.return=He,$t)}function Ze(He,Ie,Ke,$t){return Ie===null||Ie.tag!==4||Ie.stateNode.containerInfo!==Ke.containerInfo||Ie.stateNode.implementation!==Ke.implementation?(Ie=Wx(Ke,He.mode,$t),Ie.return=He,Ie):(Ie=M(Ie,Ke.children||[]),Ie.return=He,Ie)}function Ct(He,Ie,Ke,$t,js){return Ie===null||Ie.tag!==7?(Ie=$o(Ke,He.mode,$t,js),Ie.return=He,Ie):(Ie=M(Ie,Ke),Ie.return=He,Ie)}function _t(He,Ie,Ke){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return Ie=Hx(""+Ie,He.mode,Ke),Ie.return=He,Ie;if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case D:return Ke=Zh(Ie.type,Ie.key,Ie.props,null,He.mode,Ke),Ke.ref=Bd(He,null,Ie),Ke.return=He,Ke;case R:return Ie=Wx(Ie,He.mode,Ke),Ie.return=He,Ie;case Y:var $t=Ie._init;return _t(He,$t(Ie._payload),Ke)}if(qe(Ie)||_(Ie))return Ie=$o(Ie,He.mode,Ke,null),Ie.return=He,Ie;Ah(He,Ie)}return null}function St(He,Ie,Ke,$t){var js=Ie!==null?Ie.key:null;if(typeof Ke=="string"&&Ke!==""||typeof Ke=="number")return js!==null?null:be(He,Ie,""+Ke,$t);if(typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case D:return Ke.key===js?Re(He,Ie,Ke,$t):null;case R:return Ke.key===js?Ze(He,Ie,Ke,$t):null;case Y:return js=Ke._init,St(He,Ie,js(Ke._payload),$t)}if(qe(Ke)||_(Ke))return js!==null?null:Ct(He,Ie,Ke,$t,null);Ah(He,Ke)}return null}function rs(He,Ie,Ke,$t,js){if(typeof $t=="string"&&$t!==""||typeof $t=="number")return He=He.get(Ke)||null,be(Ie,He,""+$t,js);if(typeof $t=="object"&&$t!==null){switch($t.$$typeof){case D:return He=He.get($t.key===null?Ke:$t.key)||null,Re(Ie,He,$t,js);case R:return He=He.get($t.key===null?Ke:$t.key)||null,Ze(Ie,He,$t,js);case Y:var _s=$t._init;return rs(He,Ie,Ke,_s($t._payload),js)}if(qe($t)||_($t))return He=He.get(Ke)||null,Ct(Ie,He,$t,js,null);Ah(Ie,$t)}return null}function ms(He,Ie,Ke,$t){for(var js=null,_s=null,Ts=Ie,Vs=Ie=0,Nr=null;Ts!==null&&Vs<Ke.length;Vs++){Ts.index>Vs?(Nr=Ts,Ts=null):Nr=Ts.sibling;var wn=St(He,Ts,Ke[Vs],$t);if(wn===null){Ts===null&&(Ts=Nr);break}i&&Ts&&wn.alternate===null&&c(He,Ts),Ie=U(wn,Ie,Vs),_s===null?js=wn:_s.sibling=wn,_s=wn,Ts=Nr}if(Vs===Ke.length)return b(He,Ts),Bn&&To(He,Vs),js;if(Ts===null){for(;Vs<Ke.length;Vs++)Ts=_t(He,Ke[Vs],$t),Ts!==null&&(Ie=U(Ts,Ie,Vs),_s===null?js=Ts:_s.sibling=Ts,_s=Ts);return Bn&&To(He,Vs),js}for(Ts=k(He,Ts);Vs<Ke.length;Vs++)Nr=rs(Ts,He,Vs,Ke[Vs],$t),Nr!==null&&(i&&Nr.alternate!==null&&Ts.delete(Nr.key===null?Vs:Nr.key),Ie=U(Nr,Ie,Vs),_s===null?js=Nr:_s.sibling=Nr,_s=Nr);return i&&Ts.forEach(function(Vl){return c(He,Vl)}),Bn&&To(He,Vs),js}function gs(He,Ie,Ke,$t){var js=_(Ke);if(typeof js!="function")throw Error(n(150));if(Ke=js.call(Ke),Ke==null)throw Error(n(151));for(var _s=js=null,Ts=Ie,Vs=Ie=0,Nr=null,wn=Ke.next();Ts!==null&&!wn.done;Vs++,wn=Ke.next()){Ts.index>Vs?(Nr=Ts,Ts=null):Nr=Ts.sibling;var Vl=St(He,Ts,wn.value,$t);if(Vl===null){Ts===null&&(Ts=Nr);break}i&&Ts&&Vl.alternate===null&&c(He,Ts),Ie=U(Vl,Ie,Vs),_s===null?js=Vl:_s.sibling=Vl,_s=Vl,Ts=Nr}if(wn.done)return b(He,Ts),Bn&&To(He,Vs),js;if(Ts===null){for(;!wn.done;Vs++,wn=Ke.next())wn=_t(He,wn.value,$t),wn!==null&&(Ie=U(wn,Ie,Vs),_s===null?js=wn:_s.sibling=wn,_s=wn);return Bn&&To(He,Vs),js}for(Ts=k(He,Ts);!wn.done;Vs++,wn=Ke.next())wn=rs(Ts,He,Vs,wn.value,$t),wn!==null&&(i&&wn.alternate!==null&&Ts.delete(wn.key===null?Vs:wn.key),Ie=U(wn,Ie,Vs),_s===null?js=wn:_s.sibling=wn,_s=wn);return i&&Ts.forEach(function(m4){return c(He,m4)}),Bn&&To(He,Vs),js}function er(He,Ie,Ke,$t){if(typeof Ke=="object"&&Ke!==null&&Ke.type===A&&Ke.key===null&&(Ke=Ke.props.children),typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case D:e:{for(var js=Ke.key,_s=Ie;_s!==null;){if(_s.key===js){if(js=Ke.type,js===A){if(_s.tag===7){b(He,_s.sibling),Ie=M(_s,Ke.props.children),Ie.return=He,He=Ie;break e}}else if(_s.elementType===js||typeof js=="object"&&js!==null&&js.$$typeof===Y&&Gj(js)===_s.type){b(He,_s.sibling),Ie=M(_s,Ke.props),Ie.ref=Bd(He,_s,Ke),Ie.return=He,He=Ie;break e}b(He,_s);break}else c(He,_s);_s=_s.sibling}Ke.type===A?(Ie=$o(Ke.props.children,He.mode,$t,Ke.key),Ie.return=He,He=Ie):($t=Zh(Ke.type,Ke.key,Ke.props,null,He.mode,$t),$t.ref=Bd(He,Ie,Ke),$t.return=He,He=$t)}return le(He);case R:e:{for(_s=Ke.key;Ie!==null;){if(Ie.key===_s)if(Ie.tag===4&&Ie.stateNode.containerInfo===Ke.containerInfo&&Ie.stateNode.implementation===Ke.implementation){b(He,Ie.sibling),Ie=M(Ie,Ke.children||[]),Ie.return=He,He=Ie;break e}else{b(He,Ie);break}else c(He,Ie);Ie=Ie.sibling}Ie=Wx(Ke,He.mode,$t),Ie.return=He,He=Ie}return le(He);case Y:return _s=Ke._init,er(He,Ie,_s(Ke._payload),$t)}if(qe(Ke))return ms(He,Ie,Ke,$t);if(_(Ke))return gs(He,Ie,Ke,$t);Ah(He,Ke)}return typeof Ke=="string"&&Ke!==""||typeof Ke=="number"?(Ke=""+Ke,Ie!==null&&Ie.tag===6?(b(He,Ie.sibling),Ie=M(Ie,Ke),Ie.return=He,He=Ie):(b(He,Ie),Ie=Hx(Ke,He.mode,$t),Ie.return=He,He=Ie),le(He)):b(He,Ie)}return er}var Ec=Kj(!0),Yj=Kj(!1),kh=Pl(null),Dh=null,_c=null,tx=null;function sx(){tx=_c=Dh=null}function nx(i){var c=kh.current;In(kh),i._currentValue=c}function rx(i,c,b){for(;i!==null;){var k=i.alternate;if((i.childLanes&c)!==c?(i.childLanes|=c,k!==null&&(k.childLanes|=c)):k!==null&&(k.childLanes&c)!==c&&(k.childLanes|=c),i===b)break;i=i.return}}function Tc(i,c){Dh=i,tx=_c=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&c)!==0&&(ia=!0),i.firstContext=null)}function Ba(i){var c=i._currentValue;if(tx!==i)if(i={context:i,memoizedValue:c,next:null},_c===null){if(Dh===null)throw Error(n(308));_c=i,Dh.dependencies={lanes:0,firstContext:i}}else _c=_c.next=i;return c}var Po=null;function ax(i){Po===null?Po=[i]:Po.push(i)}function Zj(i,c,b,k){var M=c.interleaved;return M===null?(b.next=b,ax(c)):(b.next=M.next,M.next=b),c.interleaved=b,nl(i,k)}function nl(i,c){i.lanes|=c;var b=i.alternate;for(b!==null&&(b.lanes|=c),b=i,i=i.return;i!==null;)i.childLanes|=c,b=i.alternate,b!==null&&(b.childLanes|=c),b=i,i=i.return;return b.tag===3?b.stateNode:null}var Il=!1;function ix(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qj(i,c){i=i.updateQueue,c.updateQueue===i&&(c.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function rl(i,c){return{eventTime:i,lane:c,tag:0,payload:null,callback:null,next:null}}function Ml(i,c,b){var k=i.updateQueue;if(k===null)return null;if(k=k.shared,(jn&2)!==0){var M=k.pending;return M===null?c.next=c:(c.next=M.next,M.next=c),k.pending=c,nl(i,b)}return M=k.interleaved,M===null?(c.next=c,ax(k)):(c.next=M.next,M.next=c),k.interleaved=c,nl(i,b)}function Rh(i,c,b){if(c=c.updateQueue,c!==null&&(c=c.shared,(b&4194240)!==0)){var k=c.lanes;k&=i.pendingLanes,b|=k,c.lanes=b,Cn(i,b)}}function Xj(i,c){var b=i.updateQueue,k=i.alternate;if(k!==null&&(k=k.updateQueue,b===k)){var M=null,U=null;if(b=b.firstBaseUpdate,b!==null){do{var le={eventTime:b.eventTime,lane:b.lane,tag:b.tag,payload:b.payload,callback:b.callback,next:null};U===null?M=U=le:U=U.next=le,b=b.next}while(b!==null);U===null?M=U=c:U=U.next=c}else M=U=c;b={baseState:k.baseState,firstBaseUpdate:M,lastBaseUpdate:U,shared:k.shared,effects:k.effects},i.updateQueue=b;return}i=b.lastBaseUpdate,i===null?b.firstBaseUpdate=c:i.next=c,b.lastBaseUpdate=c}function Eh(i,c,b,k){var M=i.updateQueue;Il=!1;var U=M.firstBaseUpdate,le=M.lastBaseUpdate,be=M.shared.pending;if(be!==null){M.shared.pending=null;var Re=be,Ze=Re.next;Re.next=null,le===null?U=Ze:le.next=Ze,le=Re;var Ct=i.alternate;Ct!==null&&(Ct=Ct.updateQueue,be=Ct.lastBaseUpdate,be!==le&&(be===null?Ct.firstBaseUpdate=Ze:be.next=Ze,Ct.lastBaseUpdate=Re))}if(U!==null){var _t=M.baseState;le=0,Ct=Ze=Re=null,be=U;do{var St=be.lane,rs=be.eventTime;if((k&St)===St){Ct!==null&&(Ct=Ct.next={eventTime:rs,lane:0,tag:be.tag,payload:be.payload,callback:be.callback,next:null});e:{var ms=i,gs=be;switch(St=c,rs=b,gs.tag){case 1:if(ms=gs.payload,typeof ms=="function"){_t=ms.call(rs,_t,St);break e}_t=ms;break e;case 3:ms.flags=ms.flags&-65537|128;case 0:if(ms=gs.payload,St=typeof ms=="function"?ms.call(rs,_t,St):ms,St==null)break e;_t=z({},_t,St);break e;case 2:Il=!0}}be.callback!==null&&be.lane!==0&&(i.flags|=64,St=M.effects,St===null?M.effects=[be]:St.push(be))}else rs={eventTime:rs,lane:St,tag:be.tag,payload:be.payload,callback:be.callback,next:null},Ct===null?(Ze=Ct=rs,Re=_t):Ct=Ct.next=rs,le|=St;if(be=be.next,be===null){if(be=M.shared.pending,be===null)break;St=be,be=St.next,St.next=null,M.lastBaseUpdate=St,M.shared.pending=null}}while(!0);if(Ct===null&&(Re=_t),M.baseState=Re,M.firstBaseUpdate=Ze,M.lastBaseUpdate=Ct,c=M.shared.interleaved,c!==null){M=c;do le|=M.lane,M=M.next;while(M!==c)}else U===null&&(M.shared.lanes=0);Io|=le,i.lanes=le,i.memoizedState=_t}}function Jj(i,c,b){if(i=c.effects,c.effects=null,i!==null)for(c=0;c<i.length;c++){var k=i[c],M=k.callback;if(M!==null){if(k.callback=null,k=b,typeof M!="function")throw Error(n(191,M));M.call(k)}}}var $d={},Di=Pl($d),qd=Pl($d),zd=Pl($d);function Oo(i){if(i===$d)throw Error(n(174));return i}function lx(i,c){switch(_n(zd,c),_n(qd,i),_n(Di,$d),i=c.nodeType,i){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:It(null,"");break;default:i=i===8?c.parentNode:c,c=i.namespaceURI||null,i=i.tagName,c=It(c,i)}In(Di),_n(Di,c)}function Pc(){In(Di),In(qd),In(zd)}function eN(i){Oo(zd.current);var c=Oo(Di.current),b=It(c,i.type);c!==b&&(_n(qd,i),_n(Di,b))}function ox(i){qd.current===i&&(In(Di),In(qd))}var Un=Pl(0);function _h(i){for(var c=i;c!==null;){if(c.tag===13){var b=c.memoizedState;if(b!==null&&(b=b.dehydrated,b===null||b.data==="$?"||b.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===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var cx=[];function dx(){for(var i=0;i<cx.length;i++)cx[i]._workInProgressVersionPrimary=null;cx.length=0}var Th=S.ReactCurrentDispatcher,ux=S.ReactCurrentBatchConfig,Lo=0,Vn=null,hr=null,br=null,Ph=!1,Ud=!1,Vd=0,LT=0;function $r(){throw Error(n(321))}function hx(i,c){if(c===null)return!1;for(var b=0;b<c.length&&b<i.length;b++)if(!ei(i[b],c[b]))return!1;return!0}function mx(i,c,b,k,M,U){if(Lo=U,Vn=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Th.current=i===null||i.memoizedState===null?BT:$T,i=b(k,M),Ud){U=0;do{if(Ud=!1,Vd=0,25<=U)throw Error(n(301));U+=1,br=hr=null,c.updateQueue=null,Th.current=qT,i=b(k,M)}while(Ud)}if(Th.current=Ih,c=hr!==null&&hr.next!==null,Lo=0,br=hr=Vn=null,Ph=!1,c)throw Error(n(300));return i}function fx(){var i=Vd!==0;return Vd=0,i}function Ri(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return br===null?Vn.memoizedState=br=i:br=br.next=i,br}function $a(){if(hr===null){var i=Vn.alternate;i=i!==null?i.memoizedState:null}else i=hr.next;var c=br===null?Vn.memoizedState:br.next;if(c!==null)br=c,hr=i;else{if(i===null)throw Error(n(310));hr=i,i={memoizedState:hr.memoizedState,baseState:hr.baseState,baseQueue:hr.baseQueue,queue:hr.queue,next:null},br===null?Vn.memoizedState=br=i:br=br.next=i}return br}function Hd(i,c){return typeof c=="function"?c(i):c}function px(i){var c=$a(),b=c.queue;if(b===null)throw Error(n(311));b.lastRenderedReducer=i;var k=hr,M=k.baseQueue,U=b.pending;if(U!==null){if(M!==null){var le=M.next;M.next=U.next,U.next=le}k.baseQueue=M=U,b.pending=null}if(M!==null){U=M.next,k=k.baseState;var be=le=null,Re=null,Ze=U;do{var Ct=Ze.lane;if((Lo&Ct)===Ct)Re!==null&&(Re=Re.next={lane:0,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null}),k=Ze.hasEagerState?Ze.eagerState:i(k,Ze.action);else{var _t={lane:Ct,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null};Re===null?(be=Re=_t,le=k):Re=Re.next=_t,Vn.lanes|=Ct,Io|=Ct}Ze=Ze.next}while(Ze!==null&&Ze!==U);Re===null?le=k:Re.next=be,ei(k,c.memoizedState)||(ia=!0),c.memoizedState=k,c.baseState=le,c.baseQueue=Re,b.lastRenderedState=k}if(i=b.interleaved,i!==null){M=i;do U=M.lane,Vn.lanes|=U,Io|=U,M=M.next;while(M!==i)}else M===null&&(b.lanes=0);return[c.memoizedState,b.dispatch]}function xx(i){var c=$a(),b=c.queue;if(b===null)throw Error(n(311));b.lastRenderedReducer=i;var k=b.dispatch,M=b.pending,U=c.memoizedState;if(M!==null){b.pending=null;var le=M=M.next;do U=i(U,le.action),le=le.next;while(le!==M);ei(U,c.memoizedState)||(ia=!0),c.memoizedState=U,c.baseQueue===null&&(c.baseState=U),b.lastRenderedState=U}return[U,k]}function tN(){}function sN(i,c){var b=Vn,k=$a(),M=c(),U=!ei(k.memoizedState,M);if(U&&(k.memoizedState=M,ia=!0),k=k.queue,gx(aN.bind(null,b,k,i),[i]),k.getSnapshot!==c||U||br!==null&&br.memoizedState.tag&1){if(b.flags|=2048,Wd(9,rN.bind(null,b,k,M,c),void 0,null),jr===null)throw Error(n(349));(Lo&30)!==0||nN(b,c,M)}return M}function nN(i,c,b){i.flags|=16384,i={getSnapshot:c,value:b},c=Vn.updateQueue,c===null?(c={lastEffect:null,stores:null},Vn.updateQueue=c,c.stores=[i]):(b=c.stores,b===null?c.stores=[i]:b.push(i))}function rN(i,c,b,k){c.value=b,c.getSnapshot=k,iN(c)&&lN(i)}function aN(i,c,b){return b(function(){iN(c)&&lN(i)})}function iN(i){var c=i.getSnapshot;i=i.value;try{var b=c();return!ei(i,b)}catch{return!0}}function lN(i){var c=nl(i,1);c!==null&&ai(c,i,1,-1)}function oN(i){var c=Ri();return typeof i=="function"&&(i=i()),c.memoizedState=c.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Hd,lastRenderedState:i},c.queue=i,i=i.dispatch=FT.bind(null,Vn,i),[c.memoizedState,i]}function Wd(i,c,b,k){return i={tag:i,create:c,destroy:b,deps:k,next:null},c=Vn.updateQueue,c===null?(c={lastEffect:null,stores:null},Vn.updateQueue=c,c.lastEffect=i.next=i):(b=c.lastEffect,b===null?c.lastEffect=i.next=i:(k=b.next,b.next=i,i.next=k,c.lastEffect=i)),i}function cN(){return $a().memoizedState}function Oh(i,c,b,k){var M=Ri();Vn.flags|=i,M.memoizedState=Wd(1|c,b,void 0,k===void 0?null:k)}function Lh(i,c,b,k){var M=$a();k=k===void 0?null:k;var U=void 0;if(hr!==null){var le=hr.memoizedState;if(U=le.destroy,k!==null&&hx(k,le.deps)){M.memoizedState=Wd(c,b,U,k);return}}Vn.flags|=i,M.memoizedState=Wd(1|c,b,U,k)}function dN(i,c){return Oh(8390656,8,i,c)}function gx(i,c){return Lh(2048,8,i,c)}function uN(i,c){return Lh(4,2,i,c)}function hN(i,c){return Lh(4,4,i,c)}function mN(i,c){if(typeof c=="function")return i=i(),c(i),function(){c(null)};if(c!=null)return i=i(),c.current=i,function(){c.current=null}}function fN(i,c,b){return b=b!=null?b.concat([i]):null,Lh(4,4,mN.bind(null,c,i),b)}function vx(){}function pN(i,c){var b=$a();c=c===void 0?null:c;var k=b.memoizedState;return k!==null&&c!==null&&hx(c,k[1])?k[0]:(b.memoizedState=[i,c],i)}function xN(i,c){var b=$a();c=c===void 0?null:c;var k=b.memoizedState;return k!==null&&c!==null&&hx(c,k[1])?k[0]:(i=i(),b.memoizedState=[i,c],i)}function gN(i,c,b){return(Lo&21)===0?(i.baseState&&(i.baseState=!1,ia=!0),i.memoizedState=b):(ei(b,c)||(b=Is(),Vn.lanes|=b,Io|=b,i.baseState=!0),c)}function IT(i,c){var b=Us;Us=b!==0&&4>b?b:4,i(!0);var k=ux.transition;ux.transition={};try{i(!1),c()}finally{Us=b,ux.transition=k}}function vN(){return $a().memoizedState}function MT(i,c,b){var k=ql(i);if(b={lane:k,action:b,hasEagerState:!1,eagerState:null,next:null},yN(i))bN(c,b);else if(b=Zj(i,c,b,k),b!==null){var M=Yr();ai(b,i,k,M),jN(b,c,k)}}function FT(i,c,b){var k=ql(i),M={lane:k,action:b,hasEagerState:!1,eagerState:null,next:null};if(yN(i))bN(c,M);else{var U=i.alternate;if(i.lanes===0&&(U===null||U.lanes===0)&&(U=c.lastRenderedReducer,U!==null))try{var le=c.lastRenderedState,be=U(le,b);if(M.hasEagerState=!0,M.eagerState=be,ei(be,le)){var Re=c.interleaved;Re===null?(M.next=M,ax(c)):(M.next=Re.next,Re.next=M),c.interleaved=M;return}}catch{}finally{}b=Zj(i,c,M,k),b!==null&&(M=Yr(),ai(b,i,k,M),jN(b,c,k))}}function yN(i){var c=i.alternate;return i===Vn||c!==null&&c===Vn}function bN(i,c){Ud=Ph=!0;var b=i.pending;b===null?c.next=c:(c.next=b.next,b.next=c),i.pending=c}function jN(i,c,b){if((b&4194240)!==0){var k=c.lanes;k&=i.pendingLanes,b|=k,c.lanes=b,Cn(i,b)}}var Ih={readContext:Ba,useCallback:$r,useContext:$r,useEffect:$r,useImperativeHandle:$r,useInsertionEffect:$r,useLayoutEffect:$r,useMemo:$r,useReducer:$r,useRef:$r,useState:$r,useDebugValue:$r,useDeferredValue:$r,useTransition:$r,useMutableSource:$r,useSyncExternalStore:$r,useId:$r,unstable_isNewReconciler:!1},BT={readContext:Ba,useCallback:function(i,c){return Ri().memoizedState=[i,c===void 0?null:c],i},useContext:Ba,useEffect:dN,useImperativeHandle:function(i,c,b){return b=b!=null?b.concat([i]):null,Oh(4194308,4,mN.bind(null,c,i),b)},useLayoutEffect:function(i,c){return Oh(4194308,4,i,c)},useInsertionEffect:function(i,c){return Oh(4,2,i,c)},useMemo:function(i,c){var b=Ri();return c=c===void 0?null:c,i=i(),b.memoizedState=[i,c],i},useReducer:function(i,c,b){var k=Ri();return c=b!==void 0?b(c):c,k.memoizedState=k.baseState=c,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:c},k.queue=i,i=i.dispatch=MT.bind(null,Vn,i),[k.memoizedState,i]},useRef:function(i){var c=Ri();return i={current:i},c.memoizedState=i},useState:oN,useDebugValue:vx,useDeferredValue:function(i){return Ri().memoizedState=i},useTransition:function(){var i=oN(!1),c=i[0];return i=IT.bind(null,i[1]),Ri().memoizedState=i,[c,i]},useMutableSource:function(){},useSyncExternalStore:function(i,c,b){var k=Vn,M=Ri();if(Bn){if(b===void 0)throw Error(n(407));b=b()}else{if(b=c(),jr===null)throw Error(n(349));(Lo&30)!==0||nN(k,c,b)}M.memoizedState=b;var U={value:b,getSnapshot:c};return M.queue=U,dN(aN.bind(null,k,U,i),[i]),k.flags|=2048,Wd(9,rN.bind(null,k,U,b,c),void 0,null),b},useId:function(){var i=Ri(),c=jr.identifierPrefix;if(Bn){var b=sl,k=tl;b=(k&~(1<<32-ps(k)-1)).toString(32)+b,c=":"+c+"R"+b,b=Vd++,0<b&&(c+="H"+b.toString(32)),c+=":"}else b=LT++,c=":"+c+"r"+b.toString(32)+":";return i.memoizedState=c},unstable_isNewReconciler:!1},$T={readContext:Ba,useCallback:pN,useContext:Ba,useEffect:gx,useImperativeHandle:fN,useInsertionEffect:uN,useLayoutEffect:hN,useMemo:xN,useReducer:px,useRef:cN,useState:function(){return px(Hd)},useDebugValue:vx,useDeferredValue:function(i){var c=$a();return gN(c,hr.memoizedState,i)},useTransition:function(){var i=px(Hd)[0],c=$a().memoizedState;return[i,c]},useMutableSource:tN,useSyncExternalStore:sN,useId:vN,unstable_isNewReconciler:!1},qT={readContext:Ba,useCallback:pN,useContext:Ba,useEffect:gx,useImperativeHandle:fN,useInsertionEffect:uN,useLayoutEffect:hN,useMemo:xN,useReducer:xx,useRef:cN,useState:function(){return xx(Hd)},useDebugValue:vx,useDeferredValue:function(i){var c=$a();return hr===null?c.memoizedState=i:gN(c,hr.memoizedState,i)},useTransition:function(){var i=xx(Hd)[0],c=$a().memoizedState;return[i,c]},useMutableSource:tN,useSyncExternalStore:sN,useId:vN,unstable_isNewReconciler:!1};function si(i,c){if(i&&i.defaultProps){c=z({},c),i=i.defaultProps;for(var b in i)c[b]===void 0&&(c[b]=i[b]);return c}return c}function yx(i,c,b,k){c=i.memoizedState,b=b(k,c),b=b==null?c:z({},c,b),i.memoizedState=b,i.lanes===0&&(i.updateQueue.baseState=b)}var Mh={isMounted:function(i){return(i=i._reactInternals)?pt(i)===i:!1},enqueueSetState:function(i,c,b){i=i._reactInternals;var k=Yr(),M=ql(i),U=rl(k,M);U.payload=c,b!=null&&(U.callback=b),c=Ml(i,U,M),c!==null&&(ai(c,i,M,k),Rh(c,i,M))},enqueueReplaceState:function(i,c,b){i=i._reactInternals;var k=Yr(),M=ql(i),U=rl(k,M);U.tag=1,U.payload=c,b!=null&&(U.callback=b),c=Ml(i,U,M),c!==null&&(ai(c,i,M,k),Rh(c,i,M))},enqueueForceUpdate:function(i,c){i=i._reactInternals;var b=Yr(),k=ql(i),M=rl(b,k);M.tag=2,c!=null&&(M.callback=c),c=Ml(i,M,k),c!==null&&(ai(c,i,k,b),Rh(c,i,k))}};function NN(i,c,b,k,M,U,le){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(k,U,le):c.prototype&&c.prototype.isPureReactComponent?!Td(b,k)||!Td(M,U):!0}function wN(i,c,b){var k=!1,M=Ol,U=c.contextType;return typeof U=="object"&&U!==null?U=Ba(U):(M=aa(c)?Eo:Br.current,k=c.contextTypes,U=(k=k!=null)?Ac(i,M):Ol),c=new c(b,U),i.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Mh,i.stateNode=c,c._reactInternals=i,k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=M,i.__reactInternalMemoizedMaskedChildContext=U),c}function SN(i,c,b,k){i=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(b,k),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(b,k),c.state!==i&&Mh.enqueueReplaceState(c,c.state,null)}function bx(i,c,b,k){var M=i.stateNode;M.props=b,M.state=i.memoizedState,M.refs={},ix(i);var U=c.contextType;typeof U=="object"&&U!==null?M.context=Ba(U):(U=aa(c)?Eo:Br.current,M.context=Ac(i,U)),M.state=i.memoizedState,U=c.getDerivedStateFromProps,typeof U=="function"&&(yx(i,c,U,b),M.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof M.getSnapshotBeforeUpdate=="function"||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(c=M.state,typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount(),c!==M.state&&Mh.enqueueReplaceState(M,M.state,null),Eh(i,b,M,k),M.state=i.memoizedState),typeof M.componentDidMount=="function"&&(i.flags|=4194308)}function Oc(i,c){try{var b="",k=c;do b+=W(k),k=k.return;while(k);var M=b}catch(U){M=`
|
||
Error generating stack: `+U.message+`
|
||
`+U.stack}return{value:i,source:c,stack:M,digest:null}}function jx(i,c,b){return{value:i,source:null,stack:b??null,digest:c??null}}function Nx(i,c){try{console.error(c.value)}catch(b){setTimeout(function(){throw b})}}var zT=typeof WeakMap=="function"?WeakMap:Map;function CN(i,c,b){b=rl(-1,b),b.tag=3,b.payload={element:null};var k=c.value;return b.callback=function(){Vh||(Vh=!0,Mx=k),Nx(i,c)},b}function AN(i,c,b){b=rl(-1,b),b.tag=3;var k=i.type.getDerivedStateFromError;if(typeof k=="function"){var M=c.value;b.payload=function(){return k(M)},b.callback=function(){Nx(i,c)}}var U=i.stateNode;return U!==null&&typeof U.componentDidCatch=="function"&&(b.callback=function(){Nx(i,c),typeof k!="function"&&(Bl===null?Bl=new Set([this]):Bl.add(this));var le=c.stack;this.componentDidCatch(c.value,{componentStack:le!==null?le:""})}),b}function kN(i,c,b){var k=i.pingCache;if(k===null){k=i.pingCache=new zT;var M=new Set;k.set(c,M)}else M=k.get(c),M===void 0&&(M=new Set,k.set(c,M));M.has(b)||(M.add(b),i=s4.bind(null,i,c,b),c.then(i,i))}function DN(i){do{var c;if((c=i.tag===13)&&(c=i.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return i;i=i.return}while(i!==null);return null}function RN(i,c,b,k,M){return(i.mode&1)===0?(i===c?i.flags|=65536:(i.flags|=128,b.flags|=131072,b.flags&=-52805,b.tag===1&&(b.alternate===null?b.tag=17:(c=rl(-1,1),c.tag=2,Ml(b,c,1))),b.lanes|=1),i):(i.flags|=65536,i.lanes=M,i)}var UT=S.ReactCurrentOwner,ia=!1;function Kr(i,c,b,k){c.child=i===null?Yj(c,null,b,k):Ec(c,i.child,b,k)}function EN(i,c,b,k,M){b=b.render;var U=c.ref;return Tc(c,M),k=mx(i,c,b,k,U,M),b=fx(),i!==null&&!ia?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~M,al(i,c,M)):(Bn&&b&&Zp(c),c.flags|=1,Kr(i,c,k,M),c.child)}function _N(i,c,b,k,M){if(i===null){var U=b.type;return typeof U=="function"&&!Vx(U)&&U.defaultProps===void 0&&b.compare===null&&b.defaultProps===void 0?(c.tag=15,c.type=U,TN(i,c,U,k,M)):(i=Zh(b.type,null,k,c,c.mode,M),i.ref=c.ref,i.return=c,c.child=i)}if(U=i.child,(i.lanes&M)===0){var le=U.memoizedProps;if(b=b.compare,b=b!==null?b:Td,b(le,k)&&i.ref===c.ref)return al(i,c,M)}return c.flags|=1,i=Ul(U,k),i.ref=c.ref,i.return=c,c.child=i}function TN(i,c,b,k,M){if(i!==null){var U=i.memoizedProps;if(Td(U,k)&&i.ref===c.ref)if(ia=!1,c.pendingProps=k=U,(i.lanes&M)!==0)(i.flags&131072)!==0&&(ia=!0);else return c.lanes=i.lanes,al(i,c,M)}return wx(i,c,b,k,M)}function PN(i,c,b){var k=c.pendingProps,M=k.children,U=i!==null?i.memoizedState:null;if(k.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},_n(Ic,wa),wa|=b;else{if((b&1073741824)===0)return i=U!==null?U.baseLanes|b:b,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:i,cachePool:null,transitions:null},c.updateQueue=null,_n(Ic,wa),wa|=i,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=U!==null?U.baseLanes:b,_n(Ic,wa),wa|=k}else U!==null?(k=U.baseLanes|b,c.memoizedState=null):k=b,_n(Ic,wa),wa|=k;return Kr(i,c,M,b),c.child}function ON(i,c){var b=c.ref;(i===null&&b!==null||i!==null&&i.ref!==b)&&(c.flags|=512,c.flags|=2097152)}function wx(i,c,b,k,M){var U=aa(b)?Eo:Br.current;return U=Ac(c,U),Tc(c,M),b=mx(i,c,b,k,U,M),k=fx(),i!==null&&!ia?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~M,al(i,c,M)):(Bn&&k&&Zp(c),c.flags|=1,Kr(i,c,b,M),c.child)}function LN(i,c,b,k,M){if(aa(b)){var U=!0;jh(c)}else U=!1;if(Tc(c,M),c.stateNode===null)Bh(i,c),wN(c,b,k),bx(c,b,k,M),k=!0;else if(i===null){var le=c.stateNode,be=c.memoizedProps;le.props=be;var Re=le.context,Ze=b.contextType;typeof Ze=="object"&&Ze!==null?Ze=Ba(Ze):(Ze=aa(b)?Eo:Br.current,Ze=Ac(c,Ze));var Ct=b.getDerivedStateFromProps,_t=typeof Ct=="function"||typeof le.getSnapshotBeforeUpdate=="function";_t||typeof le.UNSAFE_componentWillReceiveProps!="function"&&typeof le.componentWillReceiveProps!="function"||(be!==k||Re!==Ze)&&SN(c,le,k,Ze),Il=!1;var St=c.memoizedState;le.state=St,Eh(c,k,le,M),Re=c.memoizedState,be!==k||St!==Re||ra.current||Il?(typeof Ct=="function"&&(yx(c,b,Ct,k),Re=c.memoizedState),(be=Il||NN(c,b,be,k,St,Re,Ze))?(_t||typeof le.UNSAFE_componentWillMount!="function"&&typeof le.componentWillMount!="function"||(typeof le.componentWillMount=="function"&&le.componentWillMount(),typeof le.UNSAFE_componentWillMount=="function"&&le.UNSAFE_componentWillMount()),typeof le.componentDidMount=="function"&&(c.flags|=4194308)):(typeof le.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=k,c.memoizedState=Re),le.props=k,le.state=Re,le.context=Ze,k=be):(typeof le.componentDidMount=="function"&&(c.flags|=4194308),k=!1)}else{le=c.stateNode,Qj(i,c),be=c.memoizedProps,Ze=c.type===c.elementType?be:si(c.type,be),le.props=Ze,_t=c.pendingProps,St=le.context,Re=b.contextType,typeof Re=="object"&&Re!==null?Re=Ba(Re):(Re=aa(b)?Eo:Br.current,Re=Ac(c,Re));var rs=b.getDerivedStateFromProps;(Ct=typeof rs=="function"||typeof le.getSnapshotBeforeUpdate=="function")||typeof le.UNSAFE_componentWillReceiveProps!="function"&&typeof le.componentWillReceiveProps!="function"||(be!==_t||St!==Re)&&SN(c,le,k,Re),Il=!1,St=c.memoizedState,le.state=St,Eh(c,k,le,M);var ms=c.memoizedState;be!==_t||St!==ms||ra.current||Il?(typeof rs=="function"&&(yx(c,b,rs,k),ms=c.memoizedState),(Ze=Il||NN(c,b,Ze,k,St,ms,Re)||!1)?(Ct||typeof le.UNSAFE_componentWillUpdate!="function"&&typeof le.componentWillUpdate!="function"||(typeof le.componentWillUpdate=="function"&&le.componentWillUpdate(k,ms,Re),typeof le.UNSAFE_componentWillUpdate=="function"&&le.UNSAFE_componentWillUpdate(k,ms,Re)),typeof le.componentDidUpdate=="function"&&(c.flags|=4),typeof le.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof le.componentDidUpdate!="function"||be===i.memoizedProps&&St===i.memoizedState||(c.flags|=4),typeof le.getSnapshotBeforeUpdate!="function"||be===i.memoizedProps&&St===i.memoizedState||(c.flags|=1024),c.memoizedProps=k,c.memoizedState=ms),le.props=k,le.state=ms,le.context=Re,k=Ze):(typeof le.componentDidUpdate!="function"||be===i.memoizedProps&&St===i.memoizedState||(c.flags|=4),typeof le.getSnapshotBeforeUpdate!="function"||be===i.memoizedProps&&St===i.memoizedState||(c.flags|=1024),k=!1)}return Sx(i,c,b,k,U,M)}function Sx(i,c,b,k,M,U){ON(i,c);var le=(c.flags&128)!==0;if(!k&&!le)return M&&$j(c,b,!1),al(i,c,U);k=c.stateNode,UT.current=c;var be=le&&typeof b.getDerivedStateFromError!="function"?null:k.render();return c.flags|=1,i!==null&&le?(c.child=Ec(c,i.child,null,U),c.child=Ec(c,null,be,U)):Kr(i,c,be,U),c.memoizedState=k.state,M&&$j(c,b,!0),c.child}function IN(i){var c=i.stateNode;c.pendingContext?Fj(i,c.pendingContext,c.pendingContext!==c.context):c.context&&Fj(i,c.context,!1),lx(i,c.containerInfo)}function MN(i,c,b,k,M){return Rc(),ex(M),c.flags|=256,Kr(i,c,b,k),c.child}var Cx={dehydrated:null,treeContext:null,retryLane:0};function Ax(i){return{baseLanes:i,cachePool:null,transitions:null}}function FN(i,c,b){var k=c.pendingProps,M=Un.current,U=!1,le=(c.flags&128)!==0,be;if((be=le)||(be=i!==null&&i.memoizedState===null?!1:(M&2)!==0),be?(U=!0,c.flags&=-129):(i===null||i.memoizedState!==null)&&(M|=1),_n(Un,M&1),i===null)return Jp(c),i=c.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((c.mode&1)===0?c.lanes=1:i.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(le=k.children,i=k.fallback,U?(k=c.mode,U=c.child,le={mode:"hidden",children:le},(k&1)===0&&U!==null?(U.childLanes=0,U.pendingProps=le):U=Qh(le,k,0,null),i=$o(i,k,b,null),U.return=c,i.return=c,U.sibling=i,c.child=U,c.child.memoizedState=Ax(b),c.memoizedState=Cx,i):kx(c,le));if(M=i.memoizedState,M!==null&&(be=M.dehydrated,be!==null))return VT(i,c,le,k,be,M,b);if(U){U=k.fallback,le=c.mode,M=i.child,be=M.sibling;var Re={mode:"hidden",children:k.children};return(le&1)===0&&c.child!==M?(k=c.child,k.childLanes=0,k.pendingProps=Re,c.deletions=null):(k=Ul(M,Re),k.subtreeFlags=M.subtreeFlags&14680064),be!==null?U=Ul(be,U):(U=$o(U,le,b,null),U.flags|=2),U.return=c,k.return=c,k.sibling=U,c.child=k,k=U,U=c.child,le=i.child.memoizedState,le=le===null?Ax(b):{baseLanes:le.baseLanes|b,cachePool:null,transitions:le.transitions},U.memoizedState=le,U.childLanes=i.childLanes&~b,c.memoizedState=Cx,k}return U=i.child,i=U.sibling,k=Ul(U,{mode:"visible",children:k.children}),(c.mode&1)===0&&(k.lanes=b),k.return=c,k.sibling=null,i!==null&&(b=c.deletions,b===null?(c.deletions=[i],c.flags|=16):b.push(i)),c.child=k,c.memoizedState=null,k}function kx(i,c){return c=Qh({mode:"visible",children:c},i.mode,0,null),c.return=i,i.child=c}function Fh(i,c,b,k){return k!==null&&ex(k),Ec(c,i.child,null,b),i=kx(c,c.pendingProps.children),i.flags|=2,c.memoizedState=null,i}function VT(i,c,b,k,M,U,le){if(b)return c.flags&256?(c.flags&=-257,k=jx(Error(n(422))),Fh(i,c,le,k)):c.memoizedState!==null?(c.child=i.child,c.flags|=128,null):(U=k.fallback,M=c.mode,k=Qh({mode:"visible",children:k.children},M,0,null),U=$o(U,M,le,null),U.flags|=2,k.return=c,U.return=c,k.sibling=U,c.child=k,(c.mode&1)!==0&&Ec(c,i.child,null,le),c.child.memoizedState=Ax(le),c.memoizedState=Cx,U);if((c.mode&1)===0)return Fh(i,c,le,null);if(M.data==="$!"){if(k=M.nextSibling&&M.nextSibling.dataset,k)var be=k.dgst;return k=be,U=Error(n(419)),k=jx(U,k,void 0),Fh(i,c,le,k)}if(be=(le&i.childLanes)!==0,ia||be){if(k=jr,k!==null){switch(le&-le){case 4:M=2;break;case 16:M=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:M=32;break;case 536870912:M=268435456;break;default:M=0}M=(M&(k.suspendedLanes|le))!==0?0:M,M!==0&&M!==U.retryLane&&(U.retryLane=M,nl(i,M),ai(k,i,M,-1))}return Ux(),k=jx(Error(n(421))),Fh(i,c,le,k)}return M.data==="$?"?(c.flags|=128,c.child=i.child,c=n4.bind(null,i),M._reactRetry=c,null):(i=U.treeContext,Na=Tl(M.nextSibling),ja=c,Bn=!0,ti=null,i!==null&&(Ma[Fa++]=tl,Ma[Fa++]=sl,Ma[Fa++]=_o,tl=i.id,sl=i.overflow,_o=c),c=kx(c,k.children),c.flags|=4096,c)}function BN(i,c,b){i.lanes|=c;var k=i.alternate;k!==null&&(k.lanes|=c),rx(i.return,c,b)}function Dx(i,c,b,k,M){var U=i.memoizedState;U===null?i.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:k,tail:b,tailMode:M}:(U.isBackwards=c,U.rendering=null,U.renderingStartTime=0,U.last=k,U.tail=b,U.tailMode=M)}function $N(i,c,b){var k=c.pendingProps,M=k.revealOrder,U=k.tail;if(Kr(i,c,k.children,b),k=Un.current,(k&2)!==0)k=k&1|2,c.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=c.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&BN(i,b,c);else if(i.tag===19)BN(i,b,c);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===c)break e;for(;i.sibling===null;){if(i.return===null||i.return===c)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}k&=1}if(_n(Un,k),(c.mode&1)===0)c.memoizedState=null;else switch(M){case"forwards":for(b=c.child,M=null;b!==null;)i=b.alternate,i!==null&&_h(i)===null&&(M=b),b=b.sibling;b=M,b===null?(M=c.child,c.child=null):(M=b.sibling,b.sibling=null),Dx(c,!1,M,b,U);break;case"backwards":for(b=null,M=c.child,c.child=null;M!==null;){if(i=M.alternate,i!==null&&_h(i)===null){c.child=M;break}i=M.sibling,M.sibling=b,b=M,M=i}Dx(c,!0,b,null,U);break;case"together":Dx(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Bh(i,c){(c.mode&1)===0&&i!==null&&(i.alternate=null,c.alternate=null,c.flags|=2)}function al(i,c,b){if(i!==null&&(c.dependencies=i.dependencies),Io|=c.lanes,(b&c.childLanes)===0)return null;if(i!==null&&c.child!==i.child)throw Error(n(153));if(c.child!==null){for(i=c.child,b=Ul(i,i.pendingProps),c.child=b,b.return=c;i.sibling!==null;)i=i.sibling,b=b.sibling=Ul(i,i.pendingProps),b.return=c;b.sibling=null}return c.child}function HT(i,c,b){switch(c.tag){case 3:IN(c),Rc();break;case 5:eN(c);break;case 1:aa(c.type)&&jh(c);break;case 4:lx(c,c.stateNode.containerInfo);break;case 10:var k=c.type._context,M=c.memoizedProps.value;_n(kh,k._currentValue),k._currentValue=M;break;case 13:if(k=c.memoizedState,k!==null)return k.dehydrated!==null?(_n(Un,Un.current&1),c.flags|=128,null):(b&c.child.childLanes)!==0?FN(i,c,b):(_n(Un,Un.current&1),i=al(i,c,b),i!==null?i.sibling:null);_n(Un,Un.current&1);break;case 19:if(k=(b&c.childLanes)!==0,(i.flags&128)!==0){if(k)return $N(i,c,b);c.flags|=128}if(M=c.memoizedState,M!==null&&(M.rendering=null,M.tail=null,M.lastEffect=null),_n(Un,Un.current),k)break;return null;case 22:case 23:return c.lanes=0,PN(i,c,b)}return al(i,c,b)}var qN,Rx,zN,UN;qN=function(i,c){for(var b=c.child;b!==null;){if(b.tag===5||b.tag===6)i.appendChild(b.stateNode);else if(b.tag!==4&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===c)break;for(;b.sibling===null;){if(b.return===null||b.return===c)return;b=b.return}b.sibling.return=b.return,b=b.sibling}},Rx=function(){},zN=function(i,c,b,k){var M=i.memoizedProps;if(M!==k){i=c.stateNode,Oo(Di.current);var U=null;switch(b){case"input":M=ke(i,M),k=ke(i,k),U=[];break;case"select":M=z({},M,{value:void 0}),k=z({},k,{value:void 0}),U=[];break;case"textarea":M=Be(i,M),k=Be(i,k),U=[];break;default:typeof M.onClick!="function"&&typeof k.onClick=="function"&&(i.onclick=vh)}Bs(b,k);var le;b=null;for(Ze in M)if(!k.hasOwnProperty(Ze)&&M.hasOwnProperty(Ze)&&M[Ze]!=null)if(Ze==="style"){var be=M[Ze];for(le in be)be.hasOwnProperty(le)&&(b||(b={}),b[le]="")}else Ze!=="dangerouslySetInnerHTML"&&Ze!=="children"&&Ze!=="suppressContentEditableWarning"&&Ze!=="suppressHydrationWarning"&&Ze!=="autoFocus"&&(a.hasOwnProperty(Ze)?U||(U=[]):(U=U||[]).push(Ze,null));for(Ze in k){var Re=k[Ze];if(be=M!=null?M[Ze]:void 0,k.hasOwnProperty(Ze)&&Re!==be&&(Re!=null||be!=null))if(Ze==="style")if(be){for(le in be)!be.hasOwnProperty(le)||Re&&Re.hasOwnProperty(le)||(b||(b={}),b[le]="");for(le in Re)Re.hasOwnProperty(le)&&be[le]!==Re[le]&&(b||(b={}),b[le]=Re[le])}else b||(U||(U=[]),U.push(Ze,b)),b=Re;else Ze==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,be=be?be.__html:void 0,Re!=null&&be!==Re&&(U=U||[]).push(Ze,Re)):Ze==="children"?typeof Re!="string"&&typeof Re!="number"||(U=U||[]).push(Ze,""+Re):Ze!=="suppressContentEditableWarning"&&Ze!=="suppressHydrationWarning"&&(a.hasOwnProperty(Ze)?(Re!=null&&Ze==="onScroll"&&Ln("scroll",i),U||be===Re||(U=[])):(U=U||[]).push(Ze,Re))}b&&(U=U||[]).push("style",b);var Ze=U;(c.updateQueue=Ze)&&(c.flags|=4)}},UN=function(i,c,b,k){b!==k&&(c.flags|=4)};function Gd(i,c){if(!Bn)switch(i.tailMode){case"hidden":c=i.tail;for(var b=null;c!==null;)c.alternate!==null&&(b=c),c=c.sibling;b===null?i.tail=null:b.sibling=null;break;case"collapsed":b=i.tail;for(var k=null;b!==null;)b.alternate!==null&&(k=b),b=b.sibling;k===null?c||i.tail===null?i.tail=null:i.tail.sibling=null:k.sibling=null}}function qr(i){var c=i.alternate!==null&&i.alternate.child===i.child,b=0,k=0;if(c)for(var M=i.child;M!==null;)b|=M.lanes|M.childLanes,k|=M.subtreeFlags&14680064,k|=M.flags&14680064,M.return=i,M=M.sibling;else for(M=i.child;M!==null;)b|=M.lanes|M.childLanes,k|=M.subtreeFlags,k|=M.flags,M.return=i,M=M.sibling;return i.subtreeFlags|=k,i.childLanes=b,c}function WT(i,c,b){var k=c.pendingProps;switch(Qp(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qr(c),null;case 1:return aa(c.type)&&bh(),qr(c),null;case 3:return k=c.stateNode,Pc(),In(ra),In(Br),dx(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(i===null||i.child===null)&&(Ch(c)?c.flags|=4:i===null||i.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,ti!==null&&($x(ti),ti=null))),Rx(i,c),qr(c),null;case 5:ox(c);var M=Oo(zd.current);if(b=c.type,i!==null&&c.stateNode!=null)zN(i,c,b,k,M),i.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!k){if(c.stateNode===null)throw Error(n(166));return qr(c),null}if(i=Oo(Di.current),Ch(c)){k=c.stateNode,b=c.type;var U=c.memoizedProps;switch(k[ki]=c,k[Md]=U,i=(c.mode&1)!==0,b){case"dialog":Ln("cancel",k),Ln("close",k);break;case"iframe":case"object":case"embed":Ln("load",k);break;case"video":case"audio":for(M=0;M<Od.length;M++)Ln(Od[M],k);break;case"source":Ln("error",k);break;case"img":case"image":case"link":Ln("error",k),Ln("load",k);break;case"details":Ln("toggle",k);break;case"input":Xe(k,U),Ln("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!U.multiple},Ln("invalid",k);break;case"textarea":ut(k,U),Ln("invalid",k)}Bs(b,U),M=null;for(var le in U)if(U.hasOwnProperty(le)){var be=U[le];le==="children"?typeof be=="string"?k.textContent!==be&&(U.suppressHydrationWarning!==!0&&gh(k.textContent,be,i),M=["children",be]):typeof be=="number"&&k.textContent!==""+be&&(U.suppressHydrationWarning!==!0&&gh(k.textContent,be,i),M=["children",""+be]):a.hasOwnProperty(le)&&be!=null&&le==="onScroll"&&Ln("scroll",k)}switch(b){case"input":xe(k),te(k,U,!0);break;case"textarea":xe(k),it(k);break;case"select":case"option":break;default:typeof U.onClick=="function"&&(k.onclick=vh)}k=M,c.updateQueue=k,k!==null&&(c.flags|=4)}else{le=M.nodeType===9?M:M.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Tt(b)),i==="http://www.w3.org/1999/xhtml"?b==="script"?(i=le.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof k.is=="string"?i=le.createElement(b,{is:k.is}):(i=le.createElement(b),b==="select"&&(le=i,k.multiple?le.multiple=!0:k.size&&(le.size=k.size))):i=le.createElementNS(i,b),i[ki]=c,i[Md]=k,qN(i,c,!1,!1),c.stateNode=i;e:{switch(le=Ys(b,k),b){case"dialog":Ln("cancel",i),Ln("close",i),M=k;break;case"iframe":case"object":case"embed":Ln("load",i),M=k;break;case"video":case"audio":for(M=0;M<Od.length;M++)Ln(Od[M],i);M=k;break;case"source":Ln("error",i),M=k;break;case"img":case"image":case"link":Ln("error",i),Ln("load",i),M=k;break;case"details":Ln("toggle",i),M=k;break;case"input":Xe(i,k),M=ke(i,k),Ln("invalid",i);break;case"option":M=k;break;case"select":i._wrapperState={wasMultiple:!!k.multiple},M=z({},k,{value:void 0}),Ln("invalid",i);break;case"textarea":ut(i,k),M=Be(i,k),Ln("invalid",i);break;default:M=k}Bs(b,M),be=M;for(U in be)if(be.hasOwnProperty(U)){var Re=be[U];U==="style"?Ds(i,Re):U==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Re!=null&&vt(i,Re)):U==="children"?typeof Re=="string"?(b!=="textarea"||Re!=="")&&mt(i,Re):typeof Re=="number"&&mt(i,""+Re):U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&U!=="autoFocus"&&(a.hasOwnProperty(U)?Re!=null&&U==="onScroll"&&Ln("scroll",i):Re!=null&&C(i,U,Re,le))}switch(b){case"input":xe(i),te(i,k,!1);break;case"textarea":xe(i),it(i);break;case"option":k.value!=null&&i.setAttribute("value",""+J(k.value));break;case"select":i.multiple=!!k.multiple,U=k.value,U!=null?ge(i,!!k.multiple,U,!1):k.defaultValue!=null&&ge(i,!!k.multiple,k.defaultValue,!0);break;default:typeof M.onClick=="function"&&(i.onclick=vh)}switch(b){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 qr(c),null;case 6:if(i&&c.stateNode!=null)UN(i,c,i.memoizedProps,k);else{if(typeof k!="string"&&c.stateNode===null)throw Error(n(166));if(b=Oo(zd.current),Oo(Di.current),Ch(c)){if(k=c.stateNode,b=c.memoizedProps,k[ki]=c,(U=k.nodeValue!==b)&&(i=ja,i!==null))switch(i.tag){case 3:gh(k.nodeValue,b,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&gh(k.nodeValue,b,(i.mode&1)!==0)}U&&(c.flags|=4)}else k=(b.nodeType===9?b:b.ownerDocument).createTextNode(k),k[ki]=c,c.stateNode=k}return qr(c),null;case 13:if(In(Un),k=c.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Bn&&Na!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Wj(),Rc(),c.flags|=98560,U=!1;else if(U=Ch(c),k!==null&&k.dehydrated!==null){if(i===null){if(!U)throw Error(n(318));if(U=c.memoizedState,U=U!==null?U.dehydrated:null,!U)throw Error(n(317));U[ki]=c}else Rc(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;qr(c),U=!1}else ti!==null&&($x(ti),ti=null),U=!0;if(!U)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=b,c):(k=k!==null,k!==(i!==null&&i.memoizedState!==null)&&k&&(c.child.flags|=8192,(c.mode&1)!==0&&(i===null||(Un.current&1)!==0?mr===0&&(mr=3):Ux())),c.updateQueue!==null&&(c.flags|=4),qr(c),null);case 4:return Pc(),Rx(i,c),i===null&&Ld(c.stateNode.containerInfo),qr(c),null;case 10:return nx(c.type._context),qr(c),null;case 17:return aa(c.type)&&bh(),qr(c),null;case 19:if(In(Un),U=c.memoizedState,U===null)return qr(c),null;if(k=(c.flags&128)!==0,le=U.rendering,le===null)if(k)Gd(U,!1);else{if(mr!==0||i!==null&&(i.flags&128)!==0)for(i=c.child;i!==null;){if(le=_h(i),le!==null){for(c.flags|=128,Gd(U,!1),k=le.updateQueue,k!==null&&(c.updateQueue=k,c.flags|=4),c.subtreeFlags=0,k=b,b=c.child;b!==null;)U=b,i=k,U.flags&=14680066,le=U.alternate,le===null?(U.childLanes=0,U.lanes=i,U.child=null,U.subtreeFlags=0,U.memoizedProps=null,U.memoizedState=null,U.updateQueue=null,U.dependencies=null,U.stateNode=null):(U.childLanes=le.childLanes,U.lanes=le.lanes,U.child=le.child,U.subtreeFlags=0,U.deletions=null,U.memoizedProps=le.memoizedProps,U.memoizedState=le.memoizedState,U.updateQueue=le.updateQueue,U.type=le.type,i=le.dependencies,U.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),b=b.sibling;return _n(Un,Un.current&1|2),c.child}i=i.sibling}U.tail!==null&&Ae()>Mc&&(c.flags|=128,k=!0,Gd(U,!1),c.lanes=4194304)}else{if(!k)if(i=_h(le),i!==null){if(c.flags|=128,k=!0,b=i.updateQueue,b!==null&&(c.updateQueue=b,c.flags|=4),Gd(U,!0),U.tail===null&&U.tailMode==="hidden"&&!le.alternate&&!Bn)return qr(c),null}else 2*Ae()-U.renderingStartTime>Mc&&b!==1073741824&&(c.flags|=128,k=!0,Gd(U,!1),c.lanes=4194304);U.isBackwards?(le.sibling=c.child,c.child=le):(b=U.last,b!==null?b.sibling=le:c.child=le,U.last=le)}return U.tail!==null?(c=U.tail,U.rendering=c,U.tail=c.sibling,U.renderingStartTime=Ae(),c.sibling=null,b=Un.current,_n(Un,k?b&1|2:b&1),c):(qr(c),null);case 22:case 23:return zx(),k=c.memoizedState!==null,i!==null&&i.memoizedState!==null!==k&&(c.flags|=8192),k&&(c.mode&1)!==0?(wa&1073741824)!==0&&(qr(c),c.subtreeFlags&6&&(c.flags|=8192)):qr(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function GT(i,c){switch(Qp(c),c.tag){case 1:return aa(c.type)&&bh(),i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 3:return Pc(),In(ra),In(Br),dx(),i=c.flags,(i&65536)!==0&&(i&128)===0?(c.flags=i&-65537|128,c):null;case 5:return ox(c),null;case 13:if(In(Un),i=c.memoizedState,i!==null&&i.dehydrated!==null){if(c.alternate===null)throw Error(n(340));Rc()}return i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 19:return In(Un),null;case 4:return Pc(),null;case 10:return nx(c.type._context),null;case 22:case 23:return zx(),null;case 24:return null;default:return null}}var $h=!1,zr=!1,KT=typeof WeakSet=="function"?WeakSet:Set,cs=null;function Lc(i,c){var b=i.ref;if(b!==null)if(typeof b=="function")try{b(null)}catch(k){Yn(i,c,k)}else b.current=null}function Ex(i,c,b){try{b()}catch(k){Yn(i,c,k)}}var VN=!1;function YT(i,c){if(zp=ya,i=Nj(),Op(i)){if("selectionStart"in i)var b={start:i.selectionStart,end:i.selectionEnd};else e:{b=(b=i.ownerDocument)&&b.defaultView||window;var k=b.getSelection&&b.getSelection();if(k&&k.rangeCount!==0){b=k.anchorNode;var M=k.anchorOffset,U=k.focusNode;k=k.focusOffset;try{b.nodeType,U.nodeType}catch{b=null;break e}var le=0,be=-1,Re=-1,Ze=0,Ct=0,_t=i,St=null;t:for(;;){for(var rs;_t!==b||M!==0&&_t.nodeType!==3||(be=le+M),_t!==U||k!==0&&_t.nodeType!==3||(Re=le+k),_t.nodeType===3&&(le+=_t.nodeValue.length),(rs=_t.firstChild)!==null;)St=_t,_t=rs;for(;;){if(_t===i)break t;if(St===b&&++Ze===M&&(be=le),St===U&&++Ct===k&&(Re=le),(rs=_t.nextSibling)!==null)break;_t=St,St=_t.parentNode}_t=rs}b=be===-1||Re===-1?null:{start:be,end:Re}}else b=null}b=b||{start:0,end:0}}else b=null;for(Up={focusedElem:i,selectionRange:b},ya=!1,cs=c;cs!==null;)if(c=cs,i=c.child,(c.subtreeFlags&1028)!==0&&i!==null)i.return=c,cs=i;else for(;cs!==null;){c=cs;try{var ms=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(ms!==null){var gs=ms.memoizedProps,er=ms.memoizedState,He=c.stateNode,Ie=He.getSnapshotBeforeUpdate(c.elementType===c.type?gs:si(c.type,gs),er);He.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Ke=c.stateNode.containerInfo;Ke.nodeType===1?Ke.textContent="":Ke.nodeType===9&&Ke.documentElement&&Ke.removeChild(Ke.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch($t){Yn(c,c.return,$t)}if(i=c.sibling,i!==null){i.return=c.return,cs=i;break}cs=c.return}return ms=VN,VN=!1,ms}function Kd(i,c,b){var k=c.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var M=k=k.next;do{if((M.tag&i)===i){var U=M.destroy;M.destroy=void 0,U!==void 0&&Ex(c,b,U)}M=M.next}while(M!==k)}}function qh(i,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var b=c=c.next;do{if((b.tag&i)===i){var k=b.create;b.destroy=k()}b=b.next}while(b!==c)}}function _x(i){var c=i.ref;if(c!==null){var b=i.stateNode;switch(i.tag){case 5:i=b;break;default:i=b}typeof c=="function"?c(i):c.current=i}}function HN(i){var c=i.alternate;c!==null&&(i.alternate=null,HN(c)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(c=i.stateNode,c!==null&&(delete c[ki],delete c[Md],delete c[Gp],delete c[_T],delete c[TT])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function WN(i){return i.tag===5||i.tag===3||i.tag===4}function GN(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||WN(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Tx(i,c,b){var k=i.tag;if(k===5||k===6)i=i.stateNode,c?b.nodeType===8?b.parentNode.insertBefore(i,c):b.insertBefore(i,c):(b.nodeType===8?(c=b.parentNode,c.insertBefore(i,b)):(c=b,c.appendChild(i)),b=b._reactRootContainer,b!=null||c.onclick!==null||(c.onclick=vh));else if(k!==4&&(i=i.child,i!==null))for(Tx(i,c,b),i=i.sibling;i!==null;)Tx(i,c,b),i=i.sibling}function Px(i,c,b){var k=i.tag;if(k===5||k===6)i=i.stateNode,c?b.insertBefore(i,c):b.appendChild(i);else if(k!==4&&(i=i.child,i!==null))for(Px(i,c,b),i=i.sibling;i!==null;)Px(i,c,b),i=i.sibling}var Pr=null,ni=!1;function Fl(i,c,b){for(b=b.child;b!==null;)KN(i,c,b),b=b.sibling}function KN(i,c,b){if(ys&&typeof ys.onCommitFiberUnmount=="function")try{ys.onCommitFiberUnmount(Pt,b)}catch{}switch(b.tag){case 5:zr||Lc(b,c);case 6:var k=Pr,M=ni;Pr=null,Fl(i,c,b),Pr=k,ni=M,Pr!==null&&(ni?(i=Pr,b=b.stateNode,i.nodeType===8?i.parentNode.removeChild(b):i.removeChild(b)):Pr.removeChild(b.stateNode));break;case 18:Pr!==null&&(ni?(i=Pr,b=b.stateNode,i.nodeType===8?Wp(i.parentNode,b):i.nodeType===1&&Wp(i,b),Hr(i)):Wp(Pr,b.stateNode));break;case 4:k=Pr,M=ni,Pr=b.stateNode.containerInfo,ni=!0,Fl(i,c,b),Pr=k,ni=M;break;case 0:case 11:case 14:case 15:if(!zr&&(k=b.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){M=k=k.next;do{var U=M,le=U.destroy;U=U.tag,le!==void 0&&((U&2)!==0||(U&4)!==0)&&Ex(b,c,le),M=M.next}while(M!==k)}Fl(i,c,b);break;case 1:if(!zr&&(Lc(b,c),k=b.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=b.memoizedProps,k.state=b.memoizedState,k.componentWillUnmount()}catch(be){Yn(b,c,be)}Fl(i,c,b);break;case 21:Fl(i,c,b);break;case 22:b.mode&1?(zr=(k=zr)||b.memoizedState!==null,Fl(i,c,b),zr=k):Fl(i,c,b);break;default:Fl(i,c,b)}}function YN(i){var c=i.updateQueue;if(c!==null){i.updateQueue=null;var b=i.stateNode;b===null&&(b=i.stateNode=new KT),c.forEach(function(k){var M=r4.bind(null,i,k);b.has(k)||(b.add(k),k.then(M,M))})}}function ri(i,c){var b=c.deletions;if(b!==null)for(var k=0;k<b.length;k++){var M=b[k];try{var U=i,le=c,be=le;e:for(;be!==null;){switch(be.tag){case 5:Pr=be.stateNode,ni=!1;break e;case 3:Pr=be.stateNode.containerInfo,ni=!0;break e;case 4:Pr=be.stateNode.containerInfo,ni=!0;break e}be=be.return}if(Pr===null)throw Error(n(160));KN(U,le,M),Pr=null,ni=!1;var Re=M.alternate;Re!==null&&(Re.return=null),M.return=null}catch(Ze){Yn(M,c,Ze)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)ZN(c,i),c=c.sibling}function ZN(i,c){var b=i.alternate,k=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(ri(c,i),Ei(i),k&4){try{Kd(3,i,i.return),qh(3,i)}catch(gs){Yn(i,i.return,gs)}try{Kd(5,i,i.return)}catch(gs){Yn(i,i.return,gs)}}break;case 1:ri(c,i),Ei(i),k&512&&b!==null&&Lc(b,b.return);break;case 5:if(ri(c,i),Ei(i),k&512&&b!==null&&Lc(b,b.return),i.flags&32){var M=i.stateNode;try{mt(M,"")}catch(gs){Yn(i,i.return,gs)}}if(k&4&&(M=i.stateNode,M!=null)){var U=i.memoizedProps,le=b!==null?b.memoizedProps:U,be=i.type,Re=i.updateQueue;if(i.updateQueue=null,Re!==null)try{be==="input"&&U.type==="radio"&&U.name!=null&&Ot(M,U),Ys(be,le);var Ze=Ys(be,U);for(le=0;le<Re.length;le+=2){var Ct=Re[le],_t=Re[le+1];Ct==="style"?Ds(M,_t):Ct==="dangerouslySetInnerHTML"?vt(M,_t):Ct==="children"?mt(M,_t):C(M,Ct,_t,Ze)}switch(be){case"input":bt(M,U);break;case"textarea":ht(M,U);break;case"select":var St=M._wrapperState.wasMultiple;M._wrapperState.wasMultiple=!!U.multiple;var rs=U.value;rs!=null?ge(M,!!U.multiple,rs,!1):St!==!!U.multiple&&(U.defaultValue!=null?ge(M,!!U.multiple,U.defaultValue,!0):ge(M,!!U.multiple,U.multiple?[]:"",!1))}M[Md]=U}catch(gs){Yn(i,i.return,gs)}}break;case 6:if(ri(c,i),Ei(i),k&4){if(i.stateNode===null)throw Error(n(162));M=i.stateNode,U=i.memoizedProps;try{M.nodeValue=U}catch(gs){Yn(i,i.return,gs)}}break;case 3:if(ri(c,i),Ei(i),k&4&&b!==null&&b.memoizedState.isDehydrated)try{Hr(c.containerInfo)}catch(gs){Yn(i,i.return,gs)}break;case 4:ri(c,i),Ei(i);break;case 13:ri(c,i),Ei(i),M=i.child,M.flags&8192&&(U=M.memoizedState!==null,M.stateNode.isHidden=U,!U||M.alternate!==null&&M.alternate.memoizedState!==null||(Ix=Ae())),k&4&&YN(i);break;case 22:if(Ct=b!==null&&b.memoizedState!==null,i.mode&1?(zr=(Ze=zr)||Ct,ri(c,i),zr=Ze):ri(c,i),Ei(i),k&8192){if(Ze=i.memoizedState!==null,(i.stateNode.isHidden=Ze)&&!Ct&&(i.mode&1)!==0)for(cs=i,Ct=i.child;Ct!==null;){for(_t=cs=Ct;cs!==null;){switch(St=cs,rs=St.child,St.tag){case 0:case 11:case 14:case 15:Kd(4,St,St.return);break;case 1:Lc(St,St.return);var ms=St.stateNode;if(typeof ms.componentWillUnmount=="function"){k=St,b=St.return;try{c=k,ms.props=c.memoizedProps,ms.state=c.memoizedState,ms.componentWillUnmount()}catch(gs){Yn(k,b,gs)}}break;case 5:Lc(St,St.return);break;case 22:if(St.memoizedState!==null){JN(_t);continue}}rs!==null?(rs.return=St,cs=rs):JN(_t)}Ct=Ct.sibling}e:for(Ct=null,_t=i;;){if(_t.tag===5){if(Ct===null){Ct=_t;try{M=_t.stateNode,Ze?(U=M.style,typeof U.setProperty=="function"?U.setProperty("display","none","important"):U.display="none"):(be=_t.stateNode,Re=_t.memoizedProps.style,le=Re!=null&&Re.hasOwnProperty("display")?Re.display:null,be.style.display=Et("display",le))}catch(gs){Yn(i,i.return,gs)}}}else if(_t.tag===6){if(Ct===null)try{_t.stateNode.nodeValue=Ze?"":_t.memoizedProps}catch(gs){Yn(i,i.return,gs)}}else if((_t.tag!==22&&_t.tag!==23||_t.memoizedState===null||_t===i)&&_t.child!==null){_t.child.return=_t,_t=_t.child;continue}if(_t===i)break e;for(;_t.sibling===null;){if(_t.return===null||_t.return===i)break e;Ct===_t&&(Ct=null),_t=_t.return}Ct===_t&&(Ct=null),_t.sibling.return=_t.return,_t=_t.sibling}}break;case 19:ri(c,i),Ei(i),k&4&&YN(i);break;case 21:break;default:ri(c,i),Ei(i)}}function Ei(i){var c=i.flags;if(c&2){try{e:{for(var b=i.return;b!==null;){if(WN(b)){var k=b;break e}b=b.return}throw Error(n(160))}switch(k.tag){case 5:var M=k.stateNode;k.flags&32&&(mt(M,""),k.flags&=-33);var U=GN(i);Px(i,U,M);break;case 3:case 4:var le=k.stateNode.containerInfo,be=GN(i);Tx(i,be,le);break;default:throw Error(n(161))}}catch(Re){Yn(i,i.return,Re)}i.flags&=-3}c&4096&&(i.flags&=-4097)}function ZT(i,c,b){cs=i,QN(i)}function QN(i,c,b){for(var k=(i.mode&1)!==0;cs!==null;){var M=cs,U=M.child;if(M.tag===22&&k){var le=M.memoizedState!==null||$h;if(!le){var be=M.alternate,Re=be!==null&&be.memoizedState!==null||zr;be=$h;var Ze=zr;if($h=le,(zr=Re)&&!Ze)for(cs=M;cs!==null;)le=cs,Re=le.child,le.tag===22&&le.memoizedState!==null?ew(M):Re!==null?(Re.return=le,cs=Re):ew(M);for(;U!==null;)cs=U,QN(U),U=U.sibling;cs=M,$h=be,zr=Ze}XN(i)}else(M.subtreeFlags&8772)!==0&&U!==null?(U.return=M,cs=U):XN(i)}}function XN(i){for(;cs!==null;){var c=cs;if((c.flags&8772)!==0){var b=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:zr||qh(5,c);break;case 1:var k=c.stateNode;if(c.flags&4&&!zr)if(b===null)k.componentDidMount();else{var M=c.elementType===c.type?b.memoizedProps:si(c.type,b.memoizedProps);k.componentDidUpdate(M,b.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var U=c.updateQueue;U!==null&&Jj(c,U,k);break;case 3:var le=c.updateQueue;if(le!==null){if(b=null,c.child!==null)switch(c.child.tag){case 5:b=c.child.stateNode;break;case 1:b=c.child.stateNode}Jj(c,le,b)}break;case 5:var be=c.stateNode;if(b===null&&c.flags&4){b=be;var Re=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":Re.autoFocus&&b.focus();break;case"img":Re.src&&(b.src=Re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var Ze=c.alternate;if(Ze!==null){var Ct=Ze.memoizedState;if(Ct!==null){var _t=Ct.dehydrated;_t!==null&&Hr(_t)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}zr||c.flags&512&&_x(c)}catch(St){Yn(c,c.return,St)}}if(c===i){cs=null;break}if(b=c.sibling,b!==null){b.return=c.return,cs=b;break}cs=c.return}}function JN(i){for(;cs!==null;){var c=cs;if(c===i){cs=null;break}var b=c.sibling;if(b!==null){b.return=c.return,cs=b;break}cs=c.return}}function ew(i){for(;cs!==null;){var c=cs;try{switch(c.tag){case 0:case 11:case 15:var b=c.return;try{qh(4,c)}catch(Re){Yn(c,b,Re)}break;case 1:var k=c.stateNode;if(typeof k.componentDidMount=="function"){var M=c.return;try{k.componentDidMount()}catch(Re){Yn(c,M,Re)}}var U=c.return;try{_x(c)}catch(Re){Yn(c,U,Re)}break;case 5:var le=c.return;try{_x(c)}catch(Re){Yn(c,le,Re)}}}catch(Re){Yn(c,c.return,Re)}if(c===i){cs=null;break}var be=c.sibling;if(be!==null){be.return=c.return,cs=be;break}cs=c.return}}var QT=Math.ceil,zh=S.ReactCurrentDispatcher,Ox=S.ReactCurrentOwner,qa=S.ReactCurrentBatchConfig,jn=0,jr=null,rr=null,Or=0,wa=0,Ic=Pl(0),mr=0,Yd=null,Io=0,Uh=0,Lx=0,Zd=null,la=null,Ix=0,Mc=1/0,il=null,Vh=!1,Mx=null,Bl=null,Hh=!1,$l=null,Wh=0,Qd=0,Fx=null,Gh=-1,Kh=0;function Yr(){return(jn&6)!==0?Ae():Gh!==-1?Gh:Gh=Ae()}function ql(i){return(i.mode&1)===0?1:(jn&2)!==0&&Or!==0?Or&-Or:OT.transition!==null?(Kh===0&&(Kh=Is()),Kh):(i=Us,i!==0||(i=window.event,i=i===void 0?16:Ki(i.type)),i)}function ai(i,c,b,k){if(50<Qd)throw Qd=0,Fx=null,Error(n(185));Nn(i,b,k),((jn&2)===0||i!==jr)&&(i===jr&&((jn&2)===0&&(Uh|=b),mr===4&&zl(i,Or)),oa(i,k),b===1&&jn===0&&(c.mode&1)===0&&(Mc=Ae()+500,Nh&&Ll()))}function oa(i,c){var b=i.callbackNode;gt(i,c);var k=We(i,i===jr?Or:0);if(k===0)b!==null&&en(b),i.callbackNode=null,i.callbackPriority=0;else if(c=k&-k,i.callbackPriority!==c){if(b!=null&&en(b),c===1)i.tag===0?PT(sw.bind(null,i)):qj(sw.bind(null,i)),RT(function(){(jn&6)===0&&Ll()}),b=null;else{switch(Za(k)){case 1:b=Pe;break;case 4:b=ct;break;case 16:b=tt;break;case 536870912:b=Mt;break;default:b=tt}b=dw(b,tw.bind(null,i))}i.callbackPriority=c,i.callbackNode=b}}function tw(i,c){if(Gh=-1,Kh=0,(jn&6)!==0)throw Error(n(327));var b=i.callbackNode;if(Fc()&&i.callbackNode!==b)return null;var k=We(i,i===jr?Or:0);if(k===0)return null;if((k&30)!==0||(k&i.expiredLanes)!==0||c)c=Yh(i,k);else{c=k;var M=jn;jn|=2;var U=rw();(jr!==i||Or!==c)&&(il=null,Mc=Ae()+500,Fo(i,c));do try{e4();break}catch(be){nw(i,be)}while(!0);sx(),zh.current=U,jn=M,rr!==null?c=0:(jr=null,Or=0,c=mr)}if(c!==0){if(c===2&&(M=rt(i),M!==0&&(k=M,c=Bx(i,M))),c===1)throw b=Yd,Fo(i,0),zl(i,k),oa(i,Ae()),b;if(c===6)zl(i,k);else{if(M=i.current.alternate,(k&30)===0&&!XT(M)&&(c=Yh(i,k),c===2&&(U=rt(i),U!==0&&(k=U,c=Bx(i,U))),c===1))throw b=Yd,Fo(i,0),zl(i,k),oa(i,Ae()),b;switch(i.finishedWork=M,i.finishedLanes=k,c){case 0:case 1:throw Error(n(345));case 2:Bo(i,la,il);break;case 3:if(zl(i,k),(k&130023424)===k&&(c=Ix+500-Ae(),10<c)){if(We(i,0)!==0)break;if(M=i.suspendedLanes,(M&k)!==k){Yr(),i.pingedLanes|=i.suspendedLanes&M;break}i.timeoutHandle=Hp(Bo.bind(null,i,la,il),c);break}Bo(i,la,il);break;case 4:if(zl(i,k),(k&4194240)===k)break;for(c=i.eventTimes,M=-1;0<k;){var le=31-ps(k);U=1<<le,le=c[le],le>M&&(M=le),k&=~U}if(k=M,k=Ae()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*QT(k/1960))-k,10<k){i.timeoutHandle=Hp(Bo.bind(null,i,la,il),k);break}Bo(i,la,il);break;case 5:Bo(i,la,il);break;default:throw Error(n(329))}}}return oa(i,Ae()),i.callbackNode===b?tw.bind(null,i):null}function Bx(i,c){var b=Zd;return i.current.memoizedState.isDehydrated&&(Fo(i,c).flags|=256),i=Yh(i,c),i!==2&&(c=la,la=b,c!==null&&$x(c)),i}function $x(i){la===null?la=i:la.push.apply(la,i)}function XT(i){for(var c=i;;){if(c.flags&16384){var b=c.updateQueue;if(b!==null&&(b=b.stores,b!==null))for(var k=0;k<b.length;k++){var M=b[k],U=M.getSnapshot;M=M.value;try{if(!ei(U(),M))return!1}catch{return!1}}}if(b=c.child,c.subtreeFlags&16384&&b!==null)b.return=c,c=b;else{if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function zl(i,c){for(c&=~Lx,c&=~Uh,i.suspendedLanes|=c,i.pingedLanes&=~c,i=i.expirationTimes;0<c;){var b=31-ps(c),k=1<<b;i[b]=-1,c&=~k}}function sw(i){if((jn&6)!==0)throw Error(n(327));Fc();var c=We(i,0);if((c&1)===0)return oa(i,Ae()),null;var b=Yh(i,c);if(i.tag!==0&&b===2){var k=rt(i);k!==0&&(c=k,b=Bx(i,k))}if(b===1)throw b=Yd,Fo(i,0),zl(i,c),oa(i,Ae()),b;if(b===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=c,Bo(i,la,il),oa(i,Ae()),null}function qx(i,c){var b=jn;jn|=1;try{return i(c)}finally{jn=b,jn===0&&(Mc=Ae()+500,Nh&&Ll())}}function Mo(i){$l!==null&&$l.tag===0&&(jn&6)===0&&Fc();var c=jn;jn|=1;var b=qa.transition,k=Us;try{if(qa.transition=null,Us=1,i)return i()}finally{Us=k,qa.transition=b,jn=c,(jn&6)===0&&Ll()}}function zx(){wa=Ic.current,In(Ic)}function Fo(i,c){i.finishedWork=null,i.finishedLanes=0;var b=i.timeoutHandle;if(b!==-1&&(i.timeoutHandle=-1,DT(b)),rr!==null)for(b=rr.return;b!==null;){var k=b;switch(Qp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&bh();break;case 3:Pc(),In(ra),In(Br),dx();break;case 5:ox(k);break;case 4:Pc();break;case 13:In(Un);break;case 19:In(Un);break;case 10:nx(k.type._context);break;case 22:case 23:zx()}b=b.return}if(jr=i,rr=i=Ul(i.current,null),Or=wa=c,mr=0,Yd=null,Lx=Uh=Io=0,la=Zd=null,Po!==null){for(c=0;c<Po.length;c++)if(b=Po[c],k=b.interleaved,k!==null){b.interleaved=null;var M=k.next,U=b.pending;if(U!==null){var le=U.next;U.next=M,k.next=le}b.pending=k}Po=null}return i}function nw(i,c){do{var b=rr;try{if(sx(),Th.current=Ih,Ph){for(var k=Vn.memoizedState;k!==null;){var M=k.queue;M!==null&&(M.pending=null),k=k.next}Ph=!1}if(Lo=0,br=hr=Vn=null,Ud=!1,Vd=0,Ox.current=null,b===null||b.return===null){mr=1,Yd=c,rr=null;break}e:{var U=i,le=b.return,be=b,Re=c;if(c=Or,be.flags|=32768,Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var Ze=Re,Ct=be,_t=Ct.tag;if((Ct.mode&1)===0&&(_t===0||_t===11||_t===15)){var St=Ct.alternate;St?(Ct.updateQueue=St.updateQueue,Ct.memoizedState=St.memoizedState,Ct.lanes=St.lanes):(Ct.updateQueue=null,Ct.memoizedState=null)}var rs=DN(le);if(rs!==null){rs.flags&=-257,RN(rs,le,be,U,c),rs.mode&1&&kN(U,Ze,c),c=rs,Re=Ze;var ms=c.updateQueue;if(ms===null){var gs=new Set;gs.add(Re),c.updateQueue=gs}else ms.add(Re);break e}else{if((c&1)===0){kN(U,Ze,c),Ux();break e}Re=Error(n(426))}}else if(Bn&&be.mode&1){var er=DN(le);if(er!==null){(er.flags&65536)===0&&(er.flags|=256),RN(er,le,be,U,c),ex(Oc(Re,be));break e}}U=Re=Oc(Re,be),mr!==4&&(mr=2),Zd===null?Zd=[U]:Zd.push(U),U=le;do{switch(U.tag){case 3:U.flags|=65536,c&=-c,U.lanes|=c;var He=CN(U,Re,c);Xj(U,He);break e;case 1:be=Re;var Ie=U.type,Ke=U.stateNode;if((U.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Ke!==null&&typeof Ke.componentDidCatch=="function"&&(Bl===null||!Bl.has(Ke)))){U.flags|=65536,c&=-c,U.lanes|=c;var $t=AN(U,be,c);Xj(U,$t);break e}}U=U.return}while(U!==null)}iw(b)}catch(js){c=js,rr===b&&b!==null&&(rr=b=b.return);continue}break}while(!0)}function rw(){var i=zh.current;return zh.current=Ih,i===null?Ih:i}function Ux(){(mr===0||mr===3||mr===2)&&(mr=4),jr===null||(Io&268435455)===0&&(Uh&268435455)===0||zl(jr,Or)}function Yh(i,c){var b=jn;jn|=2;var k=rw();(jr!==i||Or!==c)&&(il=null,Fo(i,c));do try{JT();break}catch(M){nw(i,M)}while(!0);if(sx(),jn=b,zh.current=k,rr!==null)throw Error(n(261));return jr=null,Or=0,mr}function JT(){for(;rr!==null;)aw(rr)}function e4(){for(;rr!==null&&!tn();)aw(rr)}function aw(i){var c=cw(i.alternate,i,wa);i.memoizedProps=i.pendingProps,c===null?iw(i):rr=c,Ox.current=null}function iw(i){var c=i;do{var b=c.alternate;if(i=c.return,(c.flags&32768)===0){if(b=WT(b,c,wa),b!==null){rr=b;return}}else{if(b=GT(b,c),b!==null){b.flags&=32767,rr=b;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{mr=6,rr=null;return}}if(c=c.sibling,c!==null){rr=c;return}rr=c=i}while(c!==null);mr===0&&(mr=5)}function Bo(i,c,b){var k=Us,M=qa.transition;try{qa.transition=null,Us=1,t4(i,c,b,k)}finally{qa.transition=M,Us=k}return null}function t4(i,c,b,k){do Fc();while($l!==null);if((jn&6)!==0)throw Error(n(327));b=i.finishedWork;var M=i.finishedLanes;if(b===null)return null;if(i.finishedWork=null,i.finishedLanes=0,b===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var U=b.lanes|b.childLanes;if(kn(i,U),i===jr&&(rr=jr=null,Or=0),(b.subtreeFlags&2064)===0&&(b.flags&2064)===0||Hh||(Hh=!0,dw(tt,function(){return Fc(),null})),U=(b.flags&15990)!==0,(b.subtreeFlags&15990)!==0||U){U=qa.transition,qa.transition=null;var le=Us;Us=1;var be=jn;jn|=4,Ox.current=null,YT(i,b),ZN(b,i),jT(Up),ya=!!zp,Up=zp=null,i.current=b,ZT(b),cn(),jn=be,Us=le,qa.transition=U}else i.current=b;if(Hh&&(Hh=!1,$l=i,Wh=M),U=i.pendingLanes,U===0&&(Bl=null),Yt(b.stateNode),oa(i,Ae()),c!==null)for(k=i.onRecoverableError,b=0;b<c.length;b++)M=c[b],k(M.value,{componentStack:M.stack,digest:M.digest});if(Vh)throw Vh=!1,i=Mx,Mx=null,i;return(Wh&1)!==0&&i.tag!==0&&Fc(),U=i.pendingLanes,(U&1)!==0?i===Fx?Qd++:(Qd=0,Fx=i):Qd=0,Ll(),null}function Fc(){if($l!==null){var i=Za(Wh),c=qa.transition,b=Us;try{if(qa.transition=null,Us=16>i?16:i,$l===null)var k=!1;else{if(i=$l,$l=null,Wh=0,(jn&6)!==0)throw Error(n(331));var M=jn;for(jn|=4,cs=i.current;cs!==null;){var U=cs,le=U.child;if((cs.flags&16)!==0){var be=U.deletions;if(be!==null){for(var Re=0;Re<be.length;Re++){var Ze=be[Re];for(cs=Ze;cs!==null;){var Ct=cs;switch(Ct.tag){case 0:case 11:case 15:Kd(8,Ct,U)}var _t=Ct.child;if(_t!==null)_t.return=Ct,cs=_t;else for(;cs!==null;){Ct=cs;var St=Ct.sibling,rs=Ct.return;if(HN(Ct),Ct===Ze){cs=null;break}if(St!==null){St.return=rs,cs=St;break}cs=rs}}}var ms=U.alternate;if(ms!==null){var gs=ms.child;if(gs!==null){ms.child=null;do{var er=gs.sibling;gs.sibling=null,gs=er}while(gs!==null)}}cs=U}}if((U.subtreeFlags&2064)!==0&&le!==null)le.return=U,cs=le;else e:for(;cs!==null;){if(U=cs,(U.flags&2048)!==0)switch(U.tag){case 0:case 11:case 15:Kd(9,U,U.return)}var He=U.sibling;if(He!==null){He.return=U.return,cs=He;break e}cs=U.return}}var Ie=i.current;for(cs=Ie;cs!==null;){le=cs;var Ke=le.child;if((le.subtreeFlags&2064)!==0&&Ke!==null)Ke.return=le,cs=Ke;else e:for(le=Ie;cs!==null;){if(be=cs,(be.flags&2048)!==0)try{switch(be.tag){case 0:case 11:case 15:qh(9,be)}}catch(js){Yn(be,be.return,js)}if(be===le){cs=null;break e}var $t=be.sibling;if($t!==null){$t.return=be.return,cs=$t;break e}cs=be.return}}if(jn=M,Ll(),ys&&typeof ys.onPostCommitFiberRoot=="function")try{ys.onPostCommitFiberRoot(Pt,i)}catch{}k=!0}return k}finally{Us=b,qa.transition=c}}return!1}function lw(i,c,b){c=Oc(b,c),c=CN(i,c,1),i=Ml(i,c,1),c=Yr(),i!==null&&(Nn(i,1,c),oa(i,c))}function Yn(i,c,b){if(i.tag===3)lw(i,i,b);else for(;c!==null;){if(c.tag===3){lw(c,i,b);break}else if(c.tag===1){var k=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Bl===null||!Bl.has(k))){i=Oc(b,i),i=AN(c,i,1),c=Ml(c,i,1),i=Yr(),c!==null&&(Nn(c,1,i),oa(c,i));break}}c=c.return}}function s4(i,c,b){var k=i.pingCache;k!==null&&k.delete(c),c=Yr(),i.pingedLanes|=i.suspendedLanes&b,jr===i&&(Or&b)===b&&(mr===4||mr===3&&(Or&130023424)===Or&&500>Ae()-Ix?Fo(i,0):Lx|=b),oa(i,c)}function ow(i,c){c===0&&((i.mode&1)===0?c=1:(c=dn,dn<<=1,(dn&130023424)===0&&(dn=4194304)));var b=Yr();i=nl(i,c),i!==null&&(Nn(i,c,b),oa(i,b))}function n4(i){var c=i.memoizedState,b=0;c!==null&&(b=c.retryLane),ow(i,b)}function r4(i,c){var b=0;switch(i.tag){case 13:var k=i.stateNode,M=i.memoizedState;M!==null&&(b=M.retryLane);break;case 19:k=i.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(c),ow(i,b)}var cw;cw=function(i,c,b){if(i!==null)if(i.memoizedProps!==c.pendingProps||ra.current)ia=!0;else{if((i.lanes&b)===0&&(c.flags&128)===0)return ia=!1,HT(i,c,b);ia=(i.flags&131072)!==0}else ia=!1,Bn&&(c.flags&1048576)!==0&&zj(c,Sh,c.index);switch(c.lanes=0,c.tag){case 2:var k=c.type;Bh(i,c),i=c.pendingProps;var M=Ac(c,Br.current);Tc(c,b),M=mx(null,c,k,i,M,b);var U=fx();return c.flags|=1,typeof M=="object"&&M!==null&&typeof M.render=="function"&&M.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,aa(k)?(U=!0,jh(c)):U=!1,c.memoizedState=M.state!==null&&M.state!==void 0?M.state:null,ix(c),M.updater=Mh,c.stateNode=M,M._reactInternals=c,bx(c,k,i,b),c=Sx(null,c,k,!0,U,b)):(c.tag=0,Bn&&U&&Zp(c),Kr(null,c,M,b),c=c.child),c;case 16:k=c.elementType;e:{switch(Bh(i,c),i=c.pendingProps,M=k._init,k=M(k._payload),c.type=k,M=c.tag=i4(k),i=si(k,i),M){case 0:c=wx(null,c,k,i,b);break e;case 1:c=LN(null,c,k,i,b);break e;case 11:c=EN(null,c,k,i,b);break e;case 14:c=_N(null,c,k,si(k.type,i),b);break e}throw Error(n(306,k,""))}return c;case 0:return k=c.type,M=c.pendingProps,M=c.elementType===k?M:si(k,M),wx(i,c,k,M,b);case 1:return k=c.type,M=c.pendingProps,M=c.elementType===k?M:si(k,M),LN(i,c,k,M,b);case 3:e:{if(IN(c),i===null)throw Error(n(387));k=c.pendingProps,U=c.memoizedState,M=U.element,Qj(i,c),Eh(c,k,null,b);var le=c.memoizedState;if(k=le.element,U.isDehydrated)if(U={element:k,isDehydrated:!1,cache:le.cache,pendingSuspenseBoundaries:le.pendingSuspenseBoundaries,transitions:le.transitions},c.updateQueue.baseState=U,c.memoizedState=U,c.flags&256){M=Oc(Error(n(423)),c),c=MN(i,c,k,b,M);break e}else if(k!==M){M=Oc(Error(n(424)),c),c=MN(i,c,k,b,M);break e}else for(Na=Tl(c.stateNode.containerInfo.firstChild),ja=c,Bn=!0,ti=null,b=Yj(c,null,k,b),c.child=b;b;)b.flags=b.flags&-3|4096,b=b.sibling;else{if(Rc(),k===M){c=al(i,c,b);break e}Kr(i,c,k,b)}c=c.child}return c;case 5:return eN(c),i===null&&Jp(c),k=c.type,M=c.pendingProps,U=i!==null?i.memoizedProps:null,le=M.children,Vp(k,M)?le=null:U!==null&&Vp(k,U)&&(c.flags|=32),ON(i,c),Kr(i,c,le,b),c.child;case 6:return i===null&&Jp(c),null;case 13:return FN(i,c,b);case 4:return lx(c,c.stateNode.containerInfo),k=c.pendingProps,i===null?c.child=Ec(c,null,k,b):Kr(i,c,k,b),c.child;case 11:return k=c.type,M=c.pendingProps,M=c.elementType===k?M:si(k,M),EN(i,c,k,M,b);case 7:return Kr(i,c,c.pendingProps,b),c.child;case 8:return Kr(i,c,c.pendingProps.children,b),c.child;case 12:return Kr(i,c,c.pendingProps.children,b),c.child;case 10:e:{if(k=c.type._context,M=c.pendingProps,U=c.memoizedProps,le=M.value,_n(kh,k._currentValue),k._currentValue=le,U!==null)if(ei(U.value,le)){if(U.children===M.children&&!ra.current){c=al(i,c,b);break e}}else for(U=c.child,U!==null&&(U.return=c);U!==null;){var be=U.dependencies;if(be!==null){le=U.child;for(var Re=be.firstContext;Re!==null;){if(Re.context===k){if(U.tag===1){Re=rl(-1,b&-b),Re.tag=2;var Ze=U.updateQueue;if(Ze!==null){Ze=Ze.shared;var Ct=Ze.pending;Ct===null?Re.next=Re:(Re.next=Ct.next,Ct.next=Re),Ze.pending=Re}}U.lanes|=b,Re=U.alternate,Re!==null&&(Re.lanes|=b),rx(U.return,b,c),be.lanes|=b;break}Re=Re.next}}else if(U.tag===10)le=U.type===c.type?null:U.child;else if(U.tag===18){if(le=U.return,le===null)throw Error(n(341));le.lanes|=b,be=le.alternate,be!==null&&(be.lanes|=b),rx(le,b,c),le=U.sibling}else le=U.child;if(le!==null)le.return=U;else for(le=U;le!==null;){if(le===c){le=null;break}if(U=le.sibling,U!==null){U.return=le.return,le=U;break}le=le.return}U=le}Kr(i,c,M.children,b),c=c.child}return c;case 9:return M=c.type,k=c.pendingProps.children,Tc(c,b),M=Ba(M),k=k(M),c.flags|=1,Kr(i,c,k,b),c.child;case 14:return k=c.type,M=si(k,c.pendingProps),M=si(k.type,M),_N(i,c,k,M,b);case 15:return TN(i,c,c.type,c.pendingProps,b);case 17:return k=c.type,M=c.pendingProps,M=c.elementType===k?M:si(k,M),Bh(i,c),c.tag=1,aa(k)?(i=!0,jh(c)):i=!1,Tc(c,b),wN(c,k,M),bx(c,k,M,b),Sx(null,c,k,!0,i,b);case 19:return $N(i,c,b);case 22:return PN(i,c,b)}throw Error(n(156,c.tag))};function dw(i,c){return on(i,c)}function a4(i,c,b,k){this.tag=i,this.key=b,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 za(i,c,b,k){return new a4(i,c,b,k)}function Vx(i){return i=i.prototype,!(!i||!i.isReactComponent)}function i4(i){if(typeof i=="function")return Vx(i)?1:0;if(i!=null){if(i=i.$$typeof,i===O)return 11;if(i===G)return 14}return 2}function Ul(i,c){var b=i.alternate;return b===null?(b=za(i.tag,c,i.key,i.mode),b.elementType=i.elementType,b.type=i.type,b.stateNode=i.stateNode,b.alternate=i,i.alternate=b):(b.pendingProps=c,b.type=i.type,b.flags=0,b.subtreeFlags=0,b.deletions=null),b.flags=i.flags&14680064,b.childLanes=i.childLanes,b.lanes=i.lanes,b.child=i.child,b.memoizedProps=i.memoizedProps,b.memoizedState=i.memoizedState,b.updateQueue=i.updateQueue,c=i.dependencies,b.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},b.sibling=i.sibling,b.index=i.index,b.ref=i.ref,b}function Zh(i,c,b,k,M,U){var le=2;if(k=i,typeof i=="function")Vx(i)&&(le=1);else if(typeof i=="string")le=5;else e:switch(i){case A:return $o(b.children,M,U,c);case L:le=8,M|=8;break;case $:return i=za(12,b,c,M|2),i.elementType=$,i.lanes=U,i;case I:return i=za(13,b,c,M),i.elementType=I,i.lanes=U,i;case q:return i=za(19,b,c,M),i.elementType=q,i.lanes=U,i;case V:return Qh(b,M,U,c);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case P:le=10;break e;case E:le=9;break e;case O:le=11;break e;case G:le=14;break e;case Y:le=16,k=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return c=za(le,b,c,M),c.elementType=i,c.type=k,c.lanes=U,c}function $o(i,c,b,k){return i=za(7,i,k,c),i.lanes=b,i}function Qh(i,c,b,k){return i=za(22,i,k,c),i.elementType=V,i.lanes=b,i.stateNode={isHidden:!1},i}function Hx(i,c,b){return i=za(6,i,null,c),i.lanes=b,i}function Wx(i,c,b){return c=za(4,i.children!==null?i.children:[],i.key,c),c.lanes=b,c.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},c}function l4(i,c,b,k,M){this.tag=c,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=xs(0),this.expirationTimes=xs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xs(0),this.identifierPrefix=k,this.onRecoverableError=M,this.mutableSourceEagerHydrationData=null}function Gx(i,c,b,k,M,U,le,be,Re){return i=new l4(i,c,b,be,Re),c===1?(c=1,U===!0&&(c|=8)):c=0,U=za(3,null,null,c),i.current=U,U.stateNode=i,U.memoizedState={element:k,isDehydrated:b,cache:null,transitions:null,pendingSuspenseBoundaries:null},ix(U),i}function o4(i,c,b){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:k==null?null:""+k,children:i,containerInfo:c,implementation:b}}function uw(i){if(!i)return Ol;i=i._reactInternals;e:{if(pt(i)!==i||i.tag!==1)throw Error(n(170));var c=i;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(aa(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(i.tag===1){var b=i.type;if(aa(b))return Bj(i,b,c)}return c}function hw(i,c,b,k,M,U,le,be,Re){return i=Gx(b,k,!0,i,M,U,le,be,Re),i.context=uw(null),b=i.current,k=Yr(),M=ql(b),U=rl(k,M),U.callback=c??null,Ml(b,U,M),i.current.lanes=M,Nn(i,M,k),oa(i,k),i}function Xh(i,c,b,k){var M=c.current,U=Yr(),le=ql(M);return b=uw(b),c.context===null?c.context=b:c.pendingContext=b,c=rl(U,le),c.payload={element:i},k=k===void 0?null:k,k!==null&&(c.callback=k),i=Ml(M,c,le),i!==null&&(ai(i,M,le,U),Rh(i,M,le)),le}function Jh(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function mw(i,c){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var b=i.retryLane;i.retryLane=b!==0&&b<c?b:c}}function Kx(i,c){mw(i,c),(i=i.alternate)&&mw(i,c)}function c4(){return null}var fw=typeof reportError=="function"?reportError:function(i){console.error(i)};function Yx(i){this._internalRoot=i}em.prototype.render=Yx.prototype.render=function(i){var c=this._internalRoot;if(c===null)throw Error(n(409));Xh(i,c,null,null)},em.prototype.unmount=Yx.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var c=i.containerInfo;Mo(function(){Xh(null,i,null,null)}),c[Ji]=null}};function em(i){this._internalRoot=i}em.prototype.unstable_scheduleHydration=function(i){if(i){var c=ta();i={blockedOn:null,target:i,priority:c};for(var b=0;b<Gn.length&&c!==0&&c<Gn[b].priority;b++);Gn.splice(b,0,i),b===0&&nn(i)}};function Zx(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function tm(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function pw(){}function d4(i,c,b,k,M){if(M){if(typeof k=="function"){var U=k;k=function(){var Ze=Jh(le);U.call(Ze)}}var le=hw(c,k,i,0,null,!1,!1,"",pw);return i._reactRootContainer=le,i[Ji]=le.current,Ld(i.nodeType===8?i.parentNode:i),Mo(),le}for(;M=i.lastChild;)i.removeChild(M);if(typeof k=="function"){var be=k;k=function(){var Ze=Jh(Re);be.call(Ze)}}var Re=Gx(i,0,!1,null,null,!1,!1,"",pw);return i._reactRootContainer=Re,i[Ji]=Re.current,Ld(i.nodeType===8?i.parentNode:i),Mo(function(){Xh(c,Re,b,k)}),Re}function sm(i,c,b,k,M){var U=b._reactRootContainer;if(U){var le=U;if(typeof M=="function"){var be=M;M=function(){var Re=Jh(le);be.call(Re)}}Xh(c,le,i,M)}else le=d4(b,c,i,M,k);return Jh(le)}Pa=function(i){switch(i.tag){case 3:var c=i.stateNode;if(c.current.memoizedState.isDehydrated){var b=sn(c.pendingLanes);b!==0&&(Cn(c,b|1),oa(c,Ae()),(jn&6)===0&&(Mc=Ae()+500,Ll()))}break;case 13:Mo(function(){var k=nl(i,1);if(k!==null){var M=Yr();ai(k,i,1,M)}}),Kx(i,1)}},Ms=function(i){if(i.tag===13){var c=nl(i,134217728);if(c!==null){var b=Yr();ai(c,i,134217728,b)}Kx(i,134217728)}},un=function(i){if(i.tag===13){var c=ql(i),b=nl(i,c);if(b!==null){var k=Yr();ai(b,i,c,k)}Kx(i,c)}},ta=function(){return Us},sa=function(i,c){var b=Us;try{return Us=i,c()}finally{Us=b}},Ws=function(i,c,b){switch(c){case"input":if(bt(i,b),c=b.name,b.type==="radio"&&c!=null){for(b=i;b.parentNode;)b=b.parentNode;for(b=b.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<b.length;c++){var k=b[c];if(k!==i&&k.form===i.form){var M=yh(k);if(!M)throw Error(n(90));ce(k),bt(k,M)}}}break;case"textarea":ht(i,b);break;case"select":c=b.value,c!=null&&ge(i,!!b.multiple,c,!1)}},ye=qx,Ve=Mo;var u4={usingClientEntryPoint:!1,Events:[Fd,Sc,yh,Oe,De,qx]},Xd={findFiberByHostInstance:Ro,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},h4={bundleType:Xd.bundleType,version:Xd.version,rendererPackageName:Xd.rendererPackageName,rendererConfig:Xd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Ss(i),i===null?null:i.stateNode},findFiberByHostInstance:Xd.findFiberByHostInstance||c4,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{Pt=nm.inject(h4),ys=nm}catch{}}return ca.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=u4,ca.createPortal=function(i,c){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Zx(c))throw Error(n(200));return o4(i,c,null,b)},ca.createRoot=function(i,c){if(!Zx(i))throw Error(n(299));var b=!1,k="",M=fw;return c!=null&&(c.unstable_strictMode===!0&&(b=!0),c.identifierPrefix!==void 0&&(k=c.identifierPrefix),c.onRecoverableError!==void 0&&(M=c.onRecoverableError)),c=Gx(i,1,!1,null,null,b,!1,k,M),i[Ji]=c.current,Ld(i.nodeType===8?i.parentNode:i),new Yx(c)},ca.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var c=i._reactInternals;if(c===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Ss(c),i=i===null?null:i.stateNode,i},ca.flushSync=function(i){return Mo(i)},ca.hydrate=function(i,c,b){if(!tm(c))throw Error(n(200));return sm(null,i,c,!0,b)},ca.hydrateRoot=function(i,c,b){if(!Zx(i))throw Error(n(405));var k=b!=null&&b.hydratedSources||null,M=!1,U="",le=fw;if(b!=null&&(b.unstable_strictMode===!0&&(M=!0),b.identifierPrefix!==void 0&&(U=b.identifierPrefix),b.onRecoverableError!==void 0&&(le=b.onRecoverableError)),c=hw(c,null,i,1,b??null,M,!1,U,le),i[Ji]=c.current,Ld(i),k)for(i=0;i<k.length;i++)b=k[i],M=b._getVersion,M=M(b._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[b,M]:c.mutableSourceEagerHydrationData.push(b,M);return new em(c)},ca.render=function(i,c,b){if(!tm(c))throw Error(n(200));return sm(null,i,c,!1,b)},ca.unmountComponentAtNode=function(i){if(!tm(i))throw Error(n(40));return i._reactRootContainer?(Mo(function(){sm(null,null,i,!1,function(){i._reactRootContainer=null,i[Ji]=null})}),!0):!1},ca.unstable_batchedUpdates=qx,ca.unstable_renderSubtreeIntoContainer=function(i,c,b,k){if(!tm(b))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return sm(i,c,b,!1,k)},ca.version="18.3.1-next-f1338f8080-20240426",ca}var ww;function Iy(){if(ww)return eg.exports;ww=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(),eg.exports=N4(),eg.exports}var Sw;function w4(){if(Sw)return rm;Sw=1;var t=Iy();return rm.createRoot=t.createRoot,rm.hydrateRoot=t.hydrateRoot,rm}var S4=w4();const C4=wf(S4);var ng={exports:{}},rg={};/**
|
||
* @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 Cw;function A4(){if(Cw)return rg;Cw=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,l=t.useEffect,o=t.useMemo,d=t.useDebugValue;return rg.useSyncExternalStoreWithSelector=function(m,f,x,h,p){var u=a(null);if(u.current===null){var w={hasValue:!1,value:null};u.current=w}else w=u.current;u=o(function(){function N(D){if(!j){if(j=!0,y=D,D=h(D),p!==void 0&&w.hasValue){var R=w.value;if(p(R,D))return C=R}return C=D}if(R=C,n(y,D))return R;var A=h(D);return p!==void 0&&p(R,A)?(y=D,R):(y=D,C=A)}var j=!1,y,C,S=x===void 0?null:x;return[function(){return N(f())},S===null?void 0:function(){return N(S())}]},[f,x,h,p]);var v=r(m,u[0],u[1]);return l(function(){w.hasValue=!0,w.value=v},[v]),d(v),v},rg}var Aw;function k4(){return Aw||(Aw=1,ng.exports=A4()),ng.exports}var D4=k4();function R4(t){t()}function E4(){let t=null,s=null;return{clear(){t=null,s=null},notify(){R4(()=>{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 kw={notify(){},get:()=>[]};function _4(t,s){let n,r=kw,a=0,l=!1;function o(v){x();const N=r.subscribe(v);let j=!1;return()=>{j||(j=!0,N(),h())}}function d(){r.notify()}function m(){w.onStateChange&&w.onStateChange()}function f(){return l}function x(){a++,n||(n=t.subscribe(m),r=E4())}function h(){a--,n&&a===0&&(n(),n=void 0,r.clear(),r=kw)}function p(){l||(l=!0,x())}function u(){l&&(l=!1,h())}const w={addNestedSub:o,notifyNestedSubs:d,handleChangeWrapper:m,isSubscribed:f,trySubscribe:p,tryUnsubscribe:u,getListeners:()=>r};return w}var T4=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",P4=T4(),O4=()=>typeof navigator<"u"&&navigator.product==="ReactNative",L4=O4(),I4=()=>P4||L4?g.useLayoutEffect:g.useEffect,M4=I4(),ag=Symbol.for("react-redux-context"),ig=typeof globalThis<"u"?globalThis:{};function F4(){if(!g.createContext)return{};const t=ig[ag]??(ig[ag]=new Map);let s=t.get(g.createContext);return s||(s=g.createContext(null),t.set(g.createContext,s)),s}var to=F4();function B4(t){const{children:s,context:n,serverState:r,store:a}=t,l=g.useMemo(()=>{const m=_4(a);return{store:a,subscription:m,getServerState:r?()=>r:void 0}},[a,r]),o=g.useMemo(()=>a.getState(),[a]);M4(()=>{const{subscription:m}=l;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),o!==a.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[l,o]);const d=n||to;return g.createElement(d.Provider,{value:l},s)}var $4=B4;function My(t=to){return function(){return g.useContext(t)}}var $C=My();function qC(t=to){const s=t===to?$C:My(t),n=()=>{const{store:r}=s();return r};return Object.assign(n,{withTypes:()=>n}),n}var q4=qC();function z4(t=to){const s=t===to?q4:qC(t),n=()=>s().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var Iu=z4(),U4=(t,s)=>t===s;function V4(t=to){const s=t===to?$C:My(t),n=(r,a={})=>{const{equalityFn:l=U4}=typeof a=="function"?{equalityFn:a}:a,o=s(),{store:d,subscription:m,getServerState:f}=o;g.useRef(!0);const x=g.useCallback({[r.name](p){return r(p)}}[r.name],[r]),h=D4.useSyncExternalStoreWithSelector(m.addNestedSub,d.getState,f||d.getState,x,l);return g.useDebugValue(h),h};return Object.assign(n,{withTypes:()=>n}),n}var Fn=V4();function Lr(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 H4=typeof Symbol=="function"&&Symbol.observable||"@@observable",Dw=H4,lg=()=>Math.random().toString(36).substring(7).split("").join("."),W4={INIT:`@@redux/INIT${lg()}`,REPLACE:`@@redux/REPLACE${lg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${lg()}`},Ym=W4;function Fy(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 zC(t,s,n){if(typeof t!="function")throw new Error(Lr(2));if(typeof s=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Lr(0));if(typeof s=="function"&&typeof n>"u"&&(n=s,s=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Lr(1));return n(zC)(t,s)}let r=t,a=s,l=new Map,o=l,d=0,m=!1;function f(){o===l&&(o=new Map,l.forEach((N,j)=>{o.set(j,N)}))}function x(){if(m)throw new Error(Lr(3));return a}function h(N){if(typeof N!="function")throw new Error(Lr(4));if(m)throw new Error(Lr(5));let j=!0;f();const y=d++;return o.set(y,N),function(){if(j){if(m)throw new Error(Lr(6));j=!1,f(),o.delete(y),l=null}}}function p(N){if(!Fy(N))throw new Error(Lr(7));if(typeof N.type>"u")throw new Error(Lr(8));if(typeof N.type!="string")throw new Error(Lr(17));if(m)throw new Error(Lr(9));try{m=!0,a=r(a,N)}finally{m=!1}return(l=o).forEach(y=>{y()}),N}function u(N){if(typeof N!="function")throw new Error(Lr(10));r=N,p({type:Ym.REPLACE})}function w(){const N=h;return{subscribe(j){if(typeof j!="object"||j===null)throw new Error(Lr(11));function y(){const S=j;S.next&&S.next(x())}return y(),{unsubscribe:N(y)}},[Dw](){return this}}}return p({type:Ym.INIT}),{dispatch:p,subscribe:h,getState:x,replaceReducer:u,[Dw]:w}}function G4(t){Object.keys(t).forEach(s=>{const n=t[s];if(typeof n(void 0,{type:Ym.INIT})>"u")throw new Error(Lr(12));if(typeof n(void 0,{type:Ym.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Lr(13))})}function K4(t){const s=Object.keys(t),n={};for(let l=0;l<s.length;l++){const o=s[l];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let a;try{G4(n)}catch(l){a=l}return function(o={},d){if(a)throw a;let m=!1;const f={};for(let x=0;x<r.length;x++){const h=r[x],p=n[h],u=o[h],w=p(u,d);if(typeof w>"u")throw d&&d.type,new Error(Lr(14));f[h]=w,m=m||w!==u}return m=m||r.length!==Object.keys(o).length,m?f:o}}function Zm(...t){return t.length===0?s=>s:t.length===1?t[0]:t.reduce((s,n)=>(...r)=>s(n(...r)))}function Y4(...t){return s=>(n,r)=>{const a=s(n,r);let l=()=>{throw new Error(Lr(15))};const o={getState:a.getState,dispatch:(m,...f)=>l(m,...f)},d=t.map(m=>m(o));return l=Zm(...d)(a.dispatch),{...a,dispatch:l}}}function Z4(t){return Fy(t)&&"type"in t&&typeof t.type=="string"}var UC=Symbol.for("immer-nothing"),Rw=Symbol.for("immer-draftable"),Qr=Symbol.for("immer-state");function hi(t,...s){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Da=Object,td=Da.getPrototypeOf,Qm="constructor",Cf="prototype",qv="configurable",Xm="enumerable",Tm="writable",Nu="value",xl=t=>!!t&&!!t[Qr];function fi(t){var s;return t?VC(t)||kf(t)||!!t[Rw]||!!((s=t[Qm])!=null&&s[Rw])||Df(t)||Rf(t):!1}var Q4=Da[Cf][Qm].toString(),Ew=new WeakMap;function VC(t){if(!t||!By(t))return!1;const s=td(t);if(s===null||s===Da[Cf])return!0;const n=Da.hasOwnProperty.call(s,Qm)&&s[Qm];if(n===Object)return!0;if(!Gc(n))return!1;let r=Ew.get(n);return r===void 0&&(r=Function.toString.call(n),Ew.set(n,r)),r===Q4}function Af(t,s,n=!0){Mu(t)===0?(n?Reflect.ownKeys(t):Da.keys(t)).forEach(a=>{s(a,t[a],t)}):t.forEach((r,a)=>s(a,r,t))}function Mu(t){const s=t[Qr];return s?s.type_:kf(t)?1:Df(t)?2:Rf(t)?3:0}var _w=(t,s,n=Mu(t))=>n===2?t.has(s):Da[Cf].hasOwnProperty.call(t,s),zv=(t,s,n=Mu(t))=>n===2?t.get(s):t[s],Jm=(t,s,n,r=Mu(t))=>{r===2?t.set(s,n):r===3?t.add(n):t[s]=n};function X4(t,s){return t===s?t!==0||1/t===1/s:t!==t&&s!==s}var kf=Array.isArray,Df=t=>t instanceof Map,Rf=t=>t instanceof Set,By=t=>typeof t=="object",Gc=t=>typeof t=="function",og=t=>typeof t=="boolean";function J4(t){const s=+t;return Number.isInteger(s)&&String(s)===t}var ul=t=>t.copy_||t.base_,$y=t=>t.modified_?t.copy_:t.base_;function Uv(t,s){if(Df(t))return new Map(t);if(Rf(t))return new Set(t);if(kf(t))return Array[Cf].slice.call(t);const n=VC(t);if(s===!0||s==="class_only"&&!n){const r=Da.getOwnPropertyDescriptors(t);delete r[Qr];let a=Reflect.ownKeys(r);for(let l=0;l<a.length;l++){const o=a[l],d=r[o];d[Tm]===!1&&(d[Tm]=!0,d[qv]=!0),(d.get||d.set)&&(r[o]={[qv]:!0,[Tm]:!0,[Xm]:d[Xm],[Nu]:t[o]})}return Da.create(td(t),r)}else{const r=td(t);if(r!==null&&n)return{...t};const a=Da.create(r);return Da.assign(a,t)}}function qy(t,s=!1){return Ef(t)||xl(t)||!fi(t)||(Mu(t)>1&&Da.defineProperties(t,{set:am,add:am,clear:am,delete:am}),Da.freeze(t),s&&Af(t,(n,r)=>{qy(r,!0)},!1)),t}function eP(){hi(2)}var am={[Nu]:eP};function Ef(t){return t===null||!By(t)?!0:Da.isFrozen(t)}var ef="MapSet",Vv="Patches",Tw="ArrayMethods",HC={};function nc(t){const s=HC[t];return s||hi(0,t),s}var Pw=t=>!!HC[t],wu,WC=()=>wu,tP=(t,s)=>({drafts_:[],parent_:t,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Pw(ef)?nc(ef):void 0,arrayMethodsPlugin_:Pw(Tw)?nc(Tw):void 0});function Ow(t,s){s&&(t.patchPlugin_=nc(Vv),t.patches_=[],t.inversePatches_=[],t.patchListener_=s)}function Hv(t){Wv(t),t.drafts_.forEach(sP),t.drafts_=null}function Wv(t){t===wu&&(wu=t.parent_)}var Lw=t=>wu=tP(wu,t);function sP(t){const s=t[Qr];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function Iw(t,s){s.unfinalizedDrafts_=s.drafts_.length;const n=s.drafts_[0];if(t!==void 0&&t!==n){n[Qr].modified_&&(Hv(s),hi(4)),fi(t)&&(t=Mw(s,t));const{patchPlugin_:a}=s;a&&a.generateReplacementPatches_(n[Qr].base_,t,s)}else t=Mw(s,n);return nP(s,t,!0),Hv(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),t!==UC?t:void 0}function Mw(t,s){if(Ef(s))return s;const n=s[Qr];if(!n)return tf(s,t.handledSet_,t);if(!_f(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);YC(n,t)}return n.copy_}function nP(t,s,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&qy(s,n)}function GC(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var _f=(t,s)=>t.scope_===s,rP=[];function KC(t,s,n,r){const a=ul(t),l=t.type_;if(r!==void 0&&zv(a,r,l)===s){Jm(a,r,n,l);return}if(!t.draftLocations_){const d=t.draftLocations_=new Map;Af(a,(m,f)=>{if(xl(f)){const x=d.get(f)||[];x.push(m),d.set(f,x)}})}const o=t.draftLocations_.get(s)??rP;for(const d of o)Jm(a,d,n,l)}function aP(t,s,n){t.callbacks_.push(function(a){var d;const l=s;if(!l||!_f(l,a))return;(d=a.mapSetPlugin_)==null||d.fixSetContents(l);const o=$y(l);KC(t,l.draft_??l,o,n),YC(l,a)})}function YC(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 l=a.getPath(t);l&&a.generatePatches_(t,l,s)}GC(t)}}function iP(t,s,n){const{scope_:r}=t;if(xl(n)){const a=n[Qr];_f(a,r)&&a.callbacks_.push(function(){Pm(t);const o=$y(a);KC(t,n,o,s)})}else fi(n)&&t.callbacks_.push(function(){const l=ul(t);t.type_===3?l.has(n)&&tf(n,r.handledSet_,r):zv(l,s,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(s)??!1)===!0&&t.copy_&&tf(zv(t.copy_,s,t.type_),r.handledSet_,r)})}function tf(t,s,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||xl(t)||s.has(t)||!fi(t)||Ef(t)||(s.add(t),Af(t,(r,a)=>{if(xl(a)){const l=a[Qr];if(_f(l,n)){const o=$y(l);Jm(t,r,o,t.type_),GC(l)}}else fi(a)&&tf(a,s,n)})),t}function lP(t,s){const n=kf(t),r={type_:n?1:0,scope_:s?s.scope_:WC(),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,l=sf;n&&(a=[r],l=Su);const{revoke:o,proxy:d}=Proxy.revocable(a,l);return r.draft_=d,r.revoke_=o,[d,r]}var sf={get(t,s){if(s===Qr)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=ul(t);if(!_w(a,s,t.type_))return oP(t,a,s);const l=a[s];if(t.finalized_||!fi(l)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&J4(s))return l;if(l===cg(t.base_,s)){Pm(t);const o=t.type_===1?+s:s,d=Kv(t.scope_,l,t,o);return t.copy_[o]=d}return l},has(t,s){return s in ul(t)},ownKeys(t){return Reflect.ownKeys(ul(t))},set(t,s,n){const r=ZC(ul(t),s);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const a=cg(ul(t),s),l=a==null?void 0:a[Qr];if(l&&l.base_===n)return t.copy_[s]=n,t.assigned_.set(s,!1),!0;if(X4(n,a)&&(n!==void 0||_w(t.base_,s,t.type_)))return!0;Pm(t),Gv(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),iP(t,s,n)),!0},deleteProperty(t,s){return Pm(t),cg(t.base_,s)!==void 0||s in t.base_?(t.assigned_.set(s,!1),Gv(t)):t.assigned_.delete(s),t.copy_&&delete t.copy_[s],!0},getOwnPropertyDescriptor(t,s){const n=ul(t),r=Reflect.getOwnPropertyDescriptor(n,s);return r&&{[Tm]:!0,[qv]:t.type_!==1||s!=="length",[Xm]:r[Xm],[Nu]:n[s]}},defineProperty(){hi(11)},getPrototypeOf(t){return td(t.base_)},setPrototypeOf(){hi(12)}},Su={};for(let t in sf){let s=sf[t];Su[t]=function(){const n=arguments;return n[0]=n[0][0],s.apply(this,n)}}Su.deleteProperty=function(t,s){return Su.set.call(this,t,s,void 0)};Su.set=function(t,s,n){return sf.set.call(this,t[0],s,n,t[0])};function cg(t,s){const n=t[Qr];return(n?ul(n):t)[s]}function oP(t,s,n){var a;const r=ZC(s,n);return r?Nu in r?r[Nu]:(a=r.get)==null?void 0:a.call(t.draft_):void 0}function ZC(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 Gv(t){t.modified_||(t.modified_=!0,t.parent_&&Gv(t.parent_))}function Pm(t){t.copy_||(t.assigned_=new Map,t.copy_=Uv(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var cP=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,n,r)=>{if(Gc(s)&&!Gc(n)){const l=n;n=s;const o=this;return function(m=l,...f){return o.produce(m,x=>n.call(this,x,...f))}}Gc(n)||hi(6),r!==void 0&&!Gc(r)&&hi(7);let a;if(fi(s)){const l=Lw(this),o=Kv(l,s,void 0);let d=!0;try{a=n(o),d=!1}finally{d?Hv(l):Wv(l)}return Ow(l,r),Iw(a,l)}else if(!s||!By(s)){if(a=n(s),a===void 0&&(a=s),a===UC&&(a=void 0),this.autoFreeze_&&qy(a,!0),r){const l=[],o=[];nc(Vv).generateReplacementPatches_(s,a,{patches_:l,inversePatches_:o}),r(l,o)}return a}else hi(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]},og(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),og(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),og(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){fi(t)||hi(8),xl(t)&&(t=dP(t));const s=Lw(this),n=Kv(s,t,void 0);return n[Qr].isManual_=!0,Wv(s),n}finishDraft(t,s){const n=t&&t[Qr];(!n||!n.isManual_)&&hi(9);const{scope_:r}=n;return Ow(r,s),Iw(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=nc(Vv).applyPatches_;return xl(t)?r(t,s):this.produce(t,a=>r(a,s))}};function Kv(t,s,n,r){const[a,l]=Df(s)?nc(ef).proxyMap_(s,n):Rf(s)?nc(ef).proxySet_(s,n):lP(s,n);return((n==null?void 0:n.scope_)??WC()).drafts_.push(a),l.callbacks_=(n==null?void 0:n.callbacks_)??[],l.key_=r,n&&r!==void 0?aP(n,l,r):l.callbacks_.push(function(m){var x;(x=m.mapSetPlugin_)==null||x.fixSetContents(l);const{patchPlugin_:f}=m;l.modified_&&f&&f.generatePatches_(l,[],m)}),a}function dP(t){return xl(t)||hi(10,t),QC(t)}function QC(t){if(!fi(t)||Ef(t))return t;const s=t[Qr];let n,r=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,n=Uv(t,s.scope_.immer_.useStrictShallowCopy_),r=s.scope_.immer_.shouldUseStrictIteration()}else n=Uv(t,!0);return Af(n,(a,l)=>{Jm(n,a,QC(l))},r),s&&(s.finalized_=!1),n}var uP=new cP,XC=uP.produce;function JC(t){return({dispatch:n,getState:r})=>a=>l=>typeof l=="function"?l(n,r,t):a(l)}var hP=JC(),mP=JC,fP=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Zm:Zm.apply(null,arguments)},pP=t=>t&&typeof t.match=="function";function yu(t,s){function n(...r){if(s){let a=s(...r);if(!a)throw new Error(ml(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=>Z4(r)&&r.type===t,n}var eA=class hu extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,hu.prototype)}static get[Symbol.species](){return hu}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new hu(...s[0].concat(this)):new hu(...s.concat(this))}};function Fw(t){return fi(t)?XC(t,()=>{}):t}function im(t,s,n){return t.has(s)?t.get(s):t.set(s,n(s)).get(s)}function xP(t){return typeof t=="boolean"}var gP=()=>function(s){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:a=!0,actionCreatorCheck:l=!0}=s??{};let o=new eA;return n&&(xP(n)?o.push(hP):o.push(mP(n.extraArgument))),o},vP="RTK_autoBatch",Bw=t=>s=>{setTimeout(s,t)},yP=(t={type:"raf"})=>s=>(...n)=>{const r=s(...n);let a=!0,l=!1,o=!1;const d=new Set,m=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Bw(10):t.type==="callback"?t.queueNotification:Bw(t.timeout),f=()=>{o=!1,l&&(l=!1,d.forEach(x=>x()))};return Object.assign({},r,{subscribe(x){const h=()=>a&&x(),p=r.subscribe(h);return d.add(x),()=>{p(),d.delete(x)}},dispatch(x){var h;try{return a=!((h=x==null?void 0:x.meta)!=null&&h[vP]),l=!a,l&&(o||(o=!0,m(f))),r.dispatch(x)}finally{a=!0}}})},bP=t=>function(n){const{autoBatch:r=!0}=n??{};let a=new eA(t);return r&&a.push(yP(typeof r=="object"?r:void 0)),a};function jP(t){const s=gP(),{reducer:n=void 0,middleware:r,devTools:a=!0,preloadedState:l=void 0,enhancers:o=void 0}=t||{};let d;if(typeof n=="function")d=n;else if(Fy(n))d=K4(n);else throw new Error(ml(1));let m;typeof r=="function"?m=r(s):m=s();let f=Zm;a&&(f=fP({trace:!1,...typeof a=="object"&&a}));const x=Y4(...m),h=bP(x);let p=typeof o=="function"?o(h):h();const u=f(...p);return zC(d,l,u)}function tA(t){const s={},n=[];let r;const a={addCase(l,o){const d=typeof l=="string"?l:l.type;if(!d)throw new Error(ml(28));if(d in s)throw new Error(ml(29));return s[d]=o,a},addAsyncThunk(l,o){return o.pending&&(s[l.pending.type]=o.pending),o.rejected&&(s[l.rejected.type]=o.rejected),o.fulfilled&&(s[l.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:l.settled,reducer:o.settled}),a},addMatcher(l,o){return n.push({matcher:l,reducer:o}),a},addDefaultCase(l){return r=l,a}};return t(a),[s,n,r]}function NP(t){return typeof t=="function"}function wP(t,s){let[n,r,a]=tA(s),l;if(NP(t))l=()=>Fw(t());else{const d=Fw(t);l=()=>d}function o(d=l(),m){let f=[n[m.type],...r.filter(({matcher:x})=>x(m)).map(({reducer:x})=>x)];return f.filter(x=>!!x).length===0&&(f=[a]),f.reduce((x,h)=>{if(h)if(xl(x)){const u=h(x,m);return u===void 0?x:u}else{if(fi(x))return XC(x,p=>h(p,m));{const p=h(x,m);if(p===void 0){if(x===null)return x;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return x},d)}return o.getInitialState=l,o}var SP=(t,s)=>pP(t)?t.match(s):t(s);function CP(...t){return s=>t.some(n=>SP(n,s))}var AP="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",kP=(t=21)=>{let s="",n=t;for(;n--;)s+=AP[Math.random()*64|0];return s},DP=["name","message","stack","code"],dg=class{constructor(t,s){Qx(this,"_type");this.payload=t,this.meta=s}},$w=class{constructor(t,s){Qx(this,"_type");this.payload=t,this.meta=s}},RP=t=>{if(typeof t=="object"&&t!==null){const s={};for(const n of DP)typeof t[n]=="string"&&(s[n]=t[n]);return s}return{message:String(t)}},qw="External signal was aborted",EP=(()=>{function t(s,n,r){const a=yu(s+"/fulfilled",(m,f,x,h)=>({payload:m,meta:{...h||{},arg:x,requestId:f,requestStatus:"fulfilled"}})),l=yu(s+"/pending",(m,f,x)=>({payload:void 0,meta:{...x||{},arg:f,requestId:m,requestStatus:"pending"}})),o=yu(s+"/rejected",(m,f,x,h,p)=>({payload:h,error:(r&&r.serializeError||RP)(m||"Rejected"),meta:{...p||{},arg:x,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(x,h,p)=>{const u=r!=null&&r.idGenerator?r.idGenerator(m):kP(),w=new AbortController;let v,N;function j(C){N=C,w.abort()}f&&(f.aborted?j(qw):f.addEventListener("abort",()=>j(qw),{once:!0}));const y=(async function(){var D,R;let C;try{let A=(D=r==null?void 0:r.condition)==null?void 0:D.call(r,m,{getState:h,extra:p});if(TP(A)&&(A=await A),A===!1||w.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const L=new Promise(($,P)=>{v=()=>{P({name:"AbortError",message:N||"Aborted"})},w.signal.addEventListener("abort",v,{once:!0})});x(l(u,m,(R=r==null?void 0:r.getPendingMeta)==null?void 0:R.call(r,{requestId:u,arg:m},{getState:h,extra:p}))),C=await Promise.race([L,Promise.resolve(n(m,{dispatch:x,getState:h,extra:p,requestId:u,signal:w.signal,abort:j,rejectWithValue:($,P)=>new dg($,P),fulfillWithValue:($,P)=>new $w($,P)})).then($=>{if($ instanceof dg)throw $;return $ instanceof $w?a($.payload,u,m,$.meta):a($,u,m)})])}catch(A){C=A instanceof dg?o(null,u,m,A.payload,A.meta):o(A,u,m)}finally{v&&w.signal.removeEventListener("abort",v)}return r&&!r.dispatchConditionRejection&&o.match(C)&&C.meta.condition||x(C),C})();return Object.assign(y,{abort:j,requestId:u,arg:m,unwrap(){return y.then(_P)}})}}return Object.assign(d,{pending:l,rejected:o,fulfilled:a,settled:CP(o,a),typePrefix:s})}return t.withTypes=()=>t,t})();function _P(t){if(t.meta&&t.meta.rejectedWithValue)throw t.payload;if(t.error)throw t.error;return t.payload}function TP(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}var PP=Symbol.for("rtk-slice-createasyncthunk");function OP(t,s){return`${t}/${s}`}function LP({creators:t}={}){var n;const s=(n=t==null?void 0:t.asyncThunk)==null?void 0:n[PP];return function(a){const{name:l,reducerPath:o=l}=a;if(!l)throw new Error(ml(11));const d=(typeof a.reducers=="function"?a.reducers(MP()):a.reducers)||{},m=Object.keys(d),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},x={addCase(S,D){const R=typeof S=="string"?S:S.type;if(!R)throw new Error(ml(12));if(R in f.sliceCaseReducersByType)throw new Error(ml(13));return f.sliceCaseReducersByType[R]=D,x},addMatcher(S,D){return f.sliceMatchers.push({matcher:S,reducer:D}),x},exposeAction(S,D){return f.actionCreators[S]=D,x},exposeCaseReducer(S,D){return f.sliceCaseReducersByName[S]=D,x}};m.forEach(S=>{const D=d[S],R={reducerName:S,type:OP(l,S),createNotation:typeof a.reducers=="function"};BP(D)?qP(R,D,x,s):FP(R,D,x)});function h(){const[S={},D=[],R=void 0]=typeof a.extraReducers=="function"?tA(a.extraReducers):[a.extraReducers],A={...S,...f.sliceCaseReducersByType};return wP(a.initialState,L=>{for(let $ in A)L.addCase($,A[$]);for(let $ of f.sliceMatchers)L.addMatcher($.matcher,$.reducer);for(let $ of D)L.addMatcher($.matcher,$.reducer);R&&L.addDefaultCase(R)})}const p=S=>S,u=new Map,w=new WeakMap;let v;function N(S,D){return v||(v=h()),v(S,D)}function j(){return v||(v=h()),v.getInitialState()}function y(S,D=!1){function R(L){let $=L[S];return typeof $>"u"&&D&&($=im(w,R,j)),$}function A(L=p){const $=im(u,D,()=>new WeakMap);return im($,L,()=>{const P={};for(const[E,O]of Object.entries(a.selectors??{}))P[E]=IP(O,L,()=>im(w,L,j),D);return P})}return{reducerPath:S,getSelectors:A,get selectors(){return A(R)},selectSlice:R}}const C={name:l,reducer:N,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:j,...y(o),injectInto(S,{reducerPath:D,...R}={}){const A=D??o;return S.inject({reducerPath:A,reducer:N},R),{...C,...y(A,!0)}}};return C}}function IP(t,s,n,r){function a(l,...o){let d=s(l);return typeof d>"u"&&r&&(d=n()),t(d,...o)}return a.unwrapped=t,a}var sA=LP();function MP(){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 FP({type:t,reducerName:s,createNotation:n},r,a){let l,o;if("reducer"in r){if(n&&!$P(r))throw new Error(ml(17));l=r.reducer,o=r.prepare}else l=r;a.addCase(t,l).exposeCaseReducer(s,l).exposeAction(s,o?yu(t,o):yu(t))}function BP(t){return t._reducerDefinitionType==="asyncThunk"}function $P(t){return t._reducerDefinitionType==="reducerWithPrepare"}function qP({type:t,reducerName:s},n,r,a){if(!a)throw new Error(ml(18));const{payloadCreator:l,fulfilled:o,pending:d,rejected:m,settled:f,options:x}=n,h=a(t,l,x);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 ml(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 wr={};/*! Axios v1.13.6 Copyright (c) 2026 Matt Zabriskie and contributors */var ug,zw;function zP(){if(zw)return ug;zw=1;function t(ne,re){return function(){return ne.apply(re,arguments)}}const{toString:s}=Object.prototype,{getPrototypeOf:n}=Object,{iterator:r,toStringTag:a}=Symbol,l=(ne=>re=>{const me=s.call(re);return ne[me]||(ne[me]=me.slice(8,-1).toLowerCase())})(Object.create(null)),o=ne=>(ne=ne.toLowerCase(),re=>l(re)===ne),d=ne=>re=>typeof re===ne,{isArray:m}=Array,f=d("undefined");function x(ne){return ne!==null&&!f(ne)&&ne.constructor!==null&&!f(ne.constructor)&&w(ne.constructor.isBuffer)&&ne.constructor.isBuffer(ne)}const h=o("ArrayBuffer");function p(ne){let re;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?re=ArrayBuffer.isView(ne):re=ne&&ne.buffer&&h(ne.buffer),re}const u=d("string"),w=d("function"),v=d("number"),N=ne=>ne!==null&&typeof ne=="object",j=ne=>ne===!0||ne===!1,y=ne=>{if(l(ne)!=="object")return!1;const re=n(ne);return(re===null||re===Object.prototype||Object.getPrototypeOf(re)===null)&&!(a in ne)&&!(r in ne)},C=ne=>{if(!N(ne)||x(ne))return!1;try{return Object.keys(ne).length===0&&Object.getPrototypeOf(ne)===Object.prototype}catch{return!1}},S=o("Date"),D=o("File"),R=ne=>!!(ne&&typeof ne.uri<"u"),A=ne=>ne&&typeof ne.getParts<"u",L=o("Blob"),$=o("FileList"),P=ne=>N(ne)&&w(ne.pipe);function E(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof Go<"u"?Go:{}}const O=E(),I=typeof O.FormData<"u"?O.FormData:void 0,q=ne=>{let re;return ne&&(I&&ne instanceof I||w(ne.append)&&((re=l(ne))==="formdata"||re==="object"&&w(ne.toString)&&ne.toString()==="[object FormData]"))},G=o("URLSearchParams"),[Y,V,Q,_]=["ReadableStream","Request","Response","Headers"].map(o),z=ne=>ne.trim?ne.trim():ne.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function T(ne,re,{allOwnKeys:me=!1}={}){if(ne===null||typeof ne>"u")return;let pe,Se;if(typeof ne!="object"&&(ne=[ne]),m(ne))for(pe=0,Se=ne.length;pe<Se;pe++)re.call(null,ne[pe],pe,ne);else{if(x(ne))return;const ze=me?Object.getOwnPropertyNames(ne):Object.keys(ne),Ue=ze.length;let dt;for(pe=0;pe<Ue;pe++)dt=ze[pe],re.call(null,ne[dt],dt,ne)}}function F(ne,re){if(x(ne))return null;re=re.toLowerCase();const me=Object.keys(ne);let pe=me.length,Se;for(;pe-- >0;)if(Se=me[pe],re===Se.toLowerCase())return Se;return null}const B=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Go,K=ne=>!f(ne)&&ne!==B;function W(){const{caseless:ne,skipUndefined:re}=K(this)&&this||{},me={},pe=(Se,ze)=>{if(ze==="__proto__"||ze==="constructor"||ze==="prototype")return;const Ue=ne&&F(me,ze)||ze;y(me[Ue])&&y(Se)?me[Ue]=W(me[Ue],Se):y(Se)?me[Ue]=W({},Se):m(Se)?me[Ue]=Se.slice():(!re||!f(Se))&&(me[Ue]=Se)};for(let Se=0,ze=arguments.length;Se<ze;Se++)arguments[Se]&&T(arguments[Se],pe);return me}const H=(ne,re,me,{allOwnKeys:pe}={})=>(T(re,(Se,ze)=>{me&&w(Se)?Object.defineProperty(ne,ze,{value:t(Se,me),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(ne,ze,{value:Se,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:pe}),ne),X=ne=>(ne.charCodeAt(0)===65279&&(ne=ne.slice(1)),ne),J=(ne,re,me,pe)=>{ne.prototype=Object.create(re.prototype,pe),Object.defineProperty(ne.prototype,"constructor",{value:ne,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(ne,"super",{value:re.prototype}),me&&Object.assign(ne.prototype,me)},ie=(ne,re,me,pe)=>{let Se,ze,Ue;const dt={};if(re=re||{},ne==null)return re;do{for(Se=Object.getOwnPropertyNames(ne),ze=Se.length;ze-- >0;)Ue=Se[ze],(!pe||pe(Ue,ne,re))&&!dt[Ue]&&(re[Ue]=ne[Ue],dt[Ue]=!0);ne=me!==!1&&n(ne)}while(ne&&(!me||me(ne,re))&&ne!==Object.prototype);return re},ae=(ne,re,me)=>{ne=String(ne),(me===void 0||me>ne.length)&&(me=ne.length),me-=re.length;const pe=ne.indexOf(re,me);return pe!==-1&&pe===me},xe=ne=>{if(!ne)return null;if(m(ne))return ne;let re=ne.length;if(!v(re))return null;const me=new Array(re);for(;re-- >0;)me[re]=ne[re];return me},ce=(ne=>re=>ne&&re instanceof ne)(typeof Uint8Array<"u"&&n(Uint8Array)),we=(ne,re)=>{const pe=(ne&&ne[r]).call(ne);let Se;for(;(Se=pe.next())&&!Se.done;){const ze=Se.value;re.call(ne,ze[0],ze[1])}},ke=(ne,re)=>{let me;const pe=[];for(;(me=ne.exec(re))!==null;)pe.push(me);return pe},Xe=o("HTMLFormElement"),Ot=ne=>ne.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(me,pe,Se){return pe.toUpperCase()+Se}),bt=(({hasOwnProperty:ne})=>(re,me)=>ne.call(re,me))(Object.prototype),te=o("RegExp"),ve=(ne,re)=>{const me=Object.getOwnPropertyDescriptors(ne),pe={};T(me,(Se,ze)=>{let Ue;(Ue=re(Se,ze,ne))!==!1&&(pe[ze]=Ue||Se)}),Object.defineProperties(ne,pe)},qe=ne=>{ve(ne,(re,me)=>{if(w(ne)&&["arguments","caller","callee"].indexOf(me)!==-1)return!1;const pe=ne[me];if(w(pe)){if(re.enumerable=!1,"writable"in re){re.writable=!1;return}re.set||(re.set=()=>{throw Error("Can not rewrite read-only method '"+me+"'")})}})},ge=(ne,re)=>{const me={},pe=Se=>{Se.forEach(ze=>{me[ze]=!0})};return m(ne)?pe(ne):pe(String(ne).split(re)),me},Be=()=>{},ut=(ne,re)=>ne!=null&&Number.isFinite(ne=+ne)?ne:re;function ht(ne){return!!(ne&&w(ne.append)&&ne[a]==="FormData"&&ne[r])}const it=ne=>{const re=new Array(10),me=(pe,Se)=>{if(N(pe)){if(re.indexOf(pe)>=0)return;if(x(pe))return pe;if(!("toJSON"in pe)){re[Se]=pe;const ze=m(pe)?[]:{};return T(pe,(Ue,dt)=>{const is=me(Ue,Se+1);!f(is)&&(ze[dt]=is)}),re[Se]=void 0,ze}}return pe};return me(ne,0)},Tt=o("AsyncFunction"),It=ne=>ne&&(N(ne)||w(ne))&&w(ne.then)&&w(ne.catch),he=((ne,re)=>ne?setImmediate:re?((me,pe)=>(B.addEventListener("message",({source:Se,data:ze})=>{Se===B&&ze===me&&pe.length&&pe.shift()()},!1),Se=>{pe.push(Se),B.postMessage(me,"*")}))(`axios@${Math.random()}`,[]):me=>setTimeout(me))(typeof setImmediate=="function",w(B.postMessage)),vt=typeof queueMicrotask<"u"?queueMicrotask.bind(B):typeof process<"u"&&process.nextTick||he;var _e={isArray:m,isArrayBuffer:h,isBuffer:x,isFormData:q,isArrayBufferView:p,isString:u,isNumber:v,isBoolean:j,isObject:N,isPlainObject:y,isEmptyObject:C,isReadableStream:Y,isRequest:V,isResponse:Q,isHeaders:_,isUndefined:f,isDate:S,isFile:D,isReactNativeBlob:R,isReactNative:A,isBlob:L,isRegExp:te,isFunction:w,isStream:P,isURLSearchParams:G,isTypedArray:ce,isFileList:$,forEach:T,merge:W,extend:H,trim:z,stripBOM:X,inherits:J,toFlatObject:ie,kindOf:l,kindOfTest:o,endsWith:ae,toArray:xe,forEachEntry:we,matchAll:ke,isHTMLForm:Xe,hasOwnProperty:bt,hasOwnProp:bt,reduceDescriptors:ve,freezeMethods:qe,toObjectSet:ge,toCamelCase:Ot,noop:Be,toFiniteNumber:ut,findKey:F,global:B,isContextDefined:K,isSpecCompliantForm:ht,toJSONObject:it,isAsyncFn:Tt,isThenable:It,setImmediate:he,asap:vt,isIterable:ne=>ne!=null&&w(ne[r])};class Vt extends Error{static from(re,me,pe,Se,ze,Ue){const dt=new Vt(re.message,me||re.code,pe,Se,ze);return dt.cause=re,dt.name=re.name,re.status!=null&&dt.status==null&&(dt.status=re.status),Ue&&Object.assign(dt,Ue),dt}constructor(re,me,pe,Se,ze){super(re),Object.defineProperty(this,"message",{value:re,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,me&&(this.code=me),pe&&(this.config=pe),Se&&(this.request=Se),ze&&(this.response=ze,this.status=ze.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:_e.toJSONObject(this.config),code:this.code,status:this.status}}}Vt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Vt.ERR_BAD_OPTION="ERR_BAD_OPTION",Vt.ECONNABORTED="ECONNABORTED",Vt.ETIMEDOUT="ETIMEDOUT",Vt.ERR_NETWORK="ERR_NETWORK",Vt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Vt.ERR_DEPRECATED="ERR_DEPRECATED",Vt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Vt.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Vt.ERR_CANCELED="ERR_CANCELED",Vt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Vt.ERR_INVALID_URL="ERR_INVALID_URL";var Et=Vt,Ds=null;function ln(ne){return _e.isPlainObject(ne)||_e.isArray(ne)}function Bs(ne){return _e.endsWith(ne,"[]")?ne.slice(0,-2):ne}function Ys(ne,re,me){return ne?ne.concat(re).map(function(Se,ze){return Se=Bs(Se),!me&&ze?"["+Se+"]":Se}).join(me?".":""):re}function Xs(ne){return _e.isArray(ne)&&!ne.some(ln)}const Js=_e.toFlatObject(_e,{},null,function(re){return/^is[A-Z]/.test(re)});function Ws(ne,re,me){if(!_e.isObject(ne))throw new TypeError("target must be an object");re=re||new FormData,me=_e.toFlatObject(me,{metaTokens:!0,dots:!1,indexes:!1},!1,function(As,os){return!_e.isUndefined(os[As])});const pe=me.metaTokens,Se=me.visitor||Lt,ze=me.dots,Ue=me.indexes,is=(me.Blob||typeof Blob<"u"&&Blob)&&_e.isSpecCompliantForm(re);if(!_e.isFunction(Se))throw new TypeError("visitor must be a function");function Ut(Bt){if(Bt===null)return"";if(_e.isDate(Bt))return Bt.toISOString();if(_e.isBoolean(Bt))return Bt.toString();if(!is&&_e.isBlob(Bt))throw new Et("Blob is not supported. Use a Buffer instead.");return _e.isArrayBuffer(Bt)||_e.isTypedArray(Bt)?is&&typeof Blob=="function"?new Blob([Bt]):Buffer.from(Bt):Bt}function Lt(Bt,As,os){let En=Bt;if(_e.isReactNative(re)&&_e.isReactNativeBlob(Bt))return re.append(Ys(os,As,ze),Ut(Bt)),!1;if(Bt&&!os&&typeof Bt=="object"){if(_e.endsWith(As,"{}"))As=pe?As:As.slice(0,-2),Bt=JSON.stringify(Bt);else if(_e.isArray(Bt)&&Xs(Bt)||(_e.isFileList(Bt)||_e.endsWith(As,"[]"))&&(En=_e.toArray(Bt)))return As=Bs(As),En.forEach(function(Kn,xr){!(_e.isUndefined(Kn)||Kn===null)&&re.append(Ue===!0?Ys([As],xr,ze):Ue===null?As:As+"[]",Ut(Kn))}),!1}return ln(Bt)?!0:(re.append(Ys(os,As,ze),Ut(Bt)),!1)}const Cs=[],vn=Object.assign(Js,{defaultVisitor:Lt,convertValue:Ut,isVisitable:ln});function nr(Bt,As){if(!_e.isUndefined(Bt)){if(Cs.indexOf(Bt)!==-1)throw Error("Circular reference detected in "+As.join("."));Cs.push(Bt),_e.forEach(Bt,function(En,Tr){(!(_e.isUndefined(En)||En===null)&&Se.call(re,En,_e.isString(Tr)?Tr.trim():Tr,As,vn))===!0&&nr(En,As?As.concat(Tr):[Tr])}),Cs.pop()}}if(!_e.isObject(ne))throw new TypeError("data must be an object");return nr(ne),re}function Z(ne){const re={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(ne).replace(/[!'()~]|%20|%00/g,function(pe){return re[pe]})}function oe(ne,re){this._pairs=[],ne&&Ws(ne,this,re)}const Ne=oe.prototype;Ne.append=function(re,me){this._pairs.push([re,me])},Ne.toString=function(re){const me=re?function(pe){return re.call(this,pe,Z)}:Z;return this._pairs.map(function(Se){return me(Se[0])+"="+me(Se[1])},"").join("&")};function Oe(ne){return encodeURIComponent(ne).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function De(ne,re,me){if(!re)return ne;const pe=me&&me.encode||Oe,Se=_e.isFunction(me)?{serialize:me}:me,ze=Se&&Se.serialize;let Ue;if(ze?Ue=ze(re,Se):Ue=_e.isURLSearchParams(re)?re.toString():new oe(re,Se).toString(pe),Ue){const dt=ne.indexOf("#");dt!==-1&&(ne=ne.slice(0,dt)),ne+=(ne.indexOf("?")===-1?"?":"&")+Ue}return ne}class ye{constructor(){this.handlers=[]}use(re,me,pe){return this.handlers.push({fulfilled:re,rejected:me,synchronous:pe?pe.synchronous:!1,runWhen:pe?pe.runWhen:null}),this.handlers.length-1}eject(re){this.handlers[re]&&(this.handlers[re]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(re){_e.forEach(this.handlers,function(pe){pe!==null&&re(pe)})}}var Ve=ye,Ge={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},st=typeof URLSearchParams<"u"?URLSearchParams:oe,Kt=typeof FormData<"u"?FormData:null,Xt=typeof Blob<"u"?Blob:null,ot={isBrowser:!0,classes:{URLSearchParams:st,FormData:Kt,Blob:Xt},protocols:["http","https","file","blob","url","data"]};const ft=typeof window<"u"&&typeof document<"u",Es=typeof navigator=="object"&&navigator||void 0,ts=ft&&(!Es||["ReactNative","NativeScript","NS"].indexOf(Es.product)<0),vs=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Te=ft&&window.location.href||"http://localhost";var je=Object.freeze({__proto__:null,hasBrowserEnv:ft,hasStandardBrowserWebWorkerEnv:vs,hasStandardBrowserEnv:ts,navigator:Es,origin:Te}),nt={...je,...ot};function Ye(ne,re){return Ws(ne,new nt.classes.URLSearchParams,{visitor:function(me,pe,Se,ze){return nt.isNode&&_e.isBuffer(me)?(this.append(pe,me.toString("base64")),!1):ze.defaultVisitor.apply(this,arguments)},...re})}function pt(ne){return _e.matchAll(/\w+|\[(\w*)]/g,ne).map(re=>re[0]==="[]"?"":re[1]||re[0])}function yt(ne){const re={},me=Object.keys(ne);let pe;const Se=me.length;let ze;for(pe=0;pe<Se;pe++)ze=me[pe],re[ze]=ne[ze];return re}function Jt(ne){function re(me,pe,Se,ze){let Ue=me[ze++];if(Ue==="__proto__")return!0;const dt=Number.isFinite(+Ue),is=ze>=me.length;return Ue=!Ue&&_e.isArray(Se)?Se.length:Ue,is?(_e.hasOwnProp(Se,Ue)?Se[Ue]=[Se[Ue],pe]:Se[Ue]=pe,!dt):((!Se[Ue]||!_e.isObject(Se[Ue]))&&(Se[Ue]=[]),re(me,pe,Se[Ue],ze)&&_e.isArray(Se[Ue])&&(Se[Ue]=yt(Se[Ue])),!dt)}if(_e.isFormData(ne)&&_e.isFunction(ne.entries)){const me={};return _e.forEachEntry(ne,(pe,Se)=>{re(pt(pe),Se,me,0)}),me}return null}function ss(ne,re,me){if(_e.isString(ne))try{return(re||JSON.parse)(ne),_e.trim(ne)}catch(pe){if(pe.name!=="SyntaxError")throw pe}return(me||JSON.stringify)(ne)}const Ss={transitional:Ge,adapter:["xhr","http","fetch"],transformRequest:[function(re,me){const pe=me.getContentType()||"",Se=pe.indexOf("application/json")>-1,ze=_e.isObject(re);if(ze&&_e.isHTMLForm(re)&&(re=new FormData(re)),_e.isFormData(re))return Se?JSON.stringify(Jt(re)):re;if(_e.isArrayBuffer(re)||_e.isBuffer(re)||_e.isStream(re)||_e.isFile(re)||_e.isBlob(re)||_e.isReadableStream(re))return re;if(_e.isArrayBufferView(re))return re.buffer;if(_e.isURLSearchParams(re))return me.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),re.toString();let dt;if(ze){if(pe.indexOf("application/x-www-form-urlencoded")>-1)return Ye(re,this.formSerializer).toString();if((dt=_e.isFileList(re))||pe.indexOf("multipart/form-data")>-1){const is=this.env&&this.env.FormData;return Ws(dt?{"files[]":re}:re,is&&new is,this.formSerializer)}}return ze||Se?(me.setContentType("application/json",!1),ss(re)):re}],transformResponse:[function(re){const me=this.transitional||Ss.transitional,pe=me&&me.forcedJSONParsing,Se=this.responseType==="json";if(_e.isResponse(re)||_e.isReadableStream(re))return re;if(re&&_e.isString(re)&&(pe&&!this.responseType||Se)){const Ue=!(me&&me.silentJSONParsing)&&Se;try{return JSON.parse(re,this.parseReviver)}catch(dt){if(Ue)throw dt.name==="SyntaxError"?Et.from(dt,Et.ERR_BAD_RESPONSE,this,null,this.response):dt}}return re}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:nt.classes.FormData,Blob:nt.classes.Blob},validateStatus:function(re){return re>=200&&re<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_e.forEach(["delete","get","head","post","put","patch"],ne=>{Ss.headers[ne]={}});var Zs=Ss;const on=_e.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 en=ne=>{const re={};let me,pe,Se;return ne&&ne.split(`
|
||
`).forEach(function(Ue){Se=Ue.indexOf(":"),me=Ue.substring(0,Se).trim().toLowerCase(),pe=Ue.substring(Se+1).trim(),!(!me||re[me]&&on[me])&&(me==="set-cookie"?re[me]?re[me].push(pe):re[me]=[pe]:re[me]=re[me]?re[me]+", "+pe:pe)}),re};const tn=Symbol("internals");function cn(ne){return ne&&String(ne).trim().toLowerCase()}function Ae(ne){return ne===!1||ne==null?ne:_e.isArray(ne)?ne.map(Ae):String(ne)}function Ht(ne){const re=Object.create(null),me=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let pe;for(;pe=me.exec(ne);)re[pe[1]]=pe[2];return re}const Pe=ne=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(ne.trim());function ct(ne,re,me,pe,Se){if(_e.isFunction(pe))return pe.call(this,re,me);if(Se&&(re=me),!!_e.isString(re)){if(_e.isString(pe))return re.indexOf(pe)!==-1;if(_e.isRegExp(pe))return pe.test(re)}}function tt(ne){return ne.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(re,me,pe)=>me.toUpperCase()+pe)}function Nt(ne,re){const me=_e.toCamelCase(" "+re);["get","set","has"].forEach(pe=>{Object.defineProperty(ne,pe+me,{value:function(Se,ze,Ue){return this[pe].call(this,re,Se,ze,Ue)},configurable:!0})})}class Mt{constructor(re){re&&this.set(re)}set(re,me,pe){const Se=this;function ze(dt,is,Ut){const Lt=cn(is);if(!Lt)throw new Error("header name must be a non-empty string");const Cs=_e.findKey(Se,Lt);(!Cs||Se[Cs]===void 0||Ut===!0||Ut===void 0&&Se[Cs]!==!1)&&(Se[Cs||is]=Ae(dt))}const Ue=(dt,is)=>_e.forEach(dt,(Ut,Lt)=>ze(Ut,Lt,is));if(_e.isPlainObject(re)||re instanceof this.constructor)Ue(re,me);else if(_e.isString(re)&&(re=re.trim())&&!Pe(re))Ue(en(re),me);else if(_e.isObject(re)&&_e.isIterable(re)){let dt={},is,Ut;for(const Lt of re){if(!_e.isArray(Lt))throw TypeError("Object iterator must return a key-value pair");dt[Ut=Lt[0]]=(is=dt[Ut])?_e.isArray(is)?[...is,Lt[1]]:[is,Lt[1]]:Lt[1]}Ue(dt,me)}else re!=null&&ze(me,re,pe);return this}get(re,me){if(re=cn(re),re){const pe=_e.findKey(this,re);if(pe){const Se=this[pe];if(!me)return Se;if(me===!0)return Ht(Se);if(_e.isFunction(me))return me.call(this,Se,pe);if(_e.isRegExp(me))return me.exec(Se);throw new TypeError("parser must be boolean|regexp|function")}}}has(re,me){if(re=cn(re),re){const pe=_e.findKey(this,re);return!!(pe&&this[pe]!==void 0&&(!me||ct(this,this[pe],pe,me)))}return!1}delete(re,me){const pe=this;let Se=!1;function ze(Ue){if(Ue=cn(Ue),Ue){const dt=_e.findKey(pe,Ue);dt&&(!me||ct(pe,pe[dt],dt,me))&&(delete pe[dt],Se=!0)}}return _e.isArray(re)?re.forEach(ze):ze(re),Se}clear(re){const me=Object.keys(this);let pe=me.length,Se=!1;for(;pe--;){const ze=me[pe];(!re||ct(this,this[ze],ze,re,!0))&&(delete this[ze],Se=!0)}return Se}normalize(re){const me=this,pe={};return _e.forEach(this,(Se,ze)=>{const Ue=_e.findKey(pe,ze);if(Ue){me[Ue]=Ae(Se),delete me[ze];return}const dt=re?tt(ze):String(ze).trim();dt!==ze&&delete me[ze],me[dt]=Ae(Se),pe[dt]=!0}),this}concat(...re){return this.constructor.concat(this,...re)}toJSON(re){const me=Object.create(null);return _e.forEach(this,(pe,Se)=>{pe!=null&&pe!==!1&&(me[Se]=re&&_e.isArray(pe)?pe.join(", "):pe)}),me}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([re,me])=>re+": "+me).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(re){return re instanceof this?re:new this(re)}static concat(re,...me){const pe=new this(re);return me.forEach(Se=>pe.set(Se)),pe}static accessor(re){const pe=(this[tn]=this[tn]={accessors:{}}).accessors,Se=this.prototype;function ze(Ue){const dt=cn(Ue);pe[dt]||(Nt(Se,Ue),pe[dt]=!0)}return _e.isArray(re)?re.forEach(ze):ze(re),this}}Mt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_e.reduceDescriptors(Mt.prototype,({value:ne},re)=>{let me=re[0].toUpperCase()+re.slice(1);return{get:()=>ne,set(pe){this[me]=pe}}}),_e.freezeMethods(Mt);var Pt=Mt;function ys(ne,re){const me=this||Zs,pe=re||me,Se=Pt.from(pe.headers);let ze=pe.data;return _e.forEach(ne,function(dt){ze=dt.call(me,ze,Se.normalize(),re?re.status:void 0)}),Se.normalize(),ze}function Yt(ne){return!!(ne&&ne.__CANCEL__)}class ps extends Et{constructor(re,me,pe){super(re??"canceled",Et.ERR_CANCELED,me,pe),this.name="CanceledError",this.__CANCEL__=!0}}var ks=ps;function hs(ne,re,me){const pe=me.config.validateStatus;!me.status||!pe||pe(me.status)?ne(me):re(new Et("Request failed with status code "+me.status,[Et.ERR_BAD_REQUEST,Et.ERR_BAD_RESPONSE][Math.floor(me.status/100)-4],me.config,me.request,me))}function gn(ne){const re=/^([-+\w]{1,25})(:?\/\/|:)/.exec(ne);return re&&re[1]||""}function $s(ne,re){ne=ne||10;const me=new Array(ne),pe=new Array(ne);let Se=0,ze=0,Ue;return re=re!==void 0?re:1e3,function(is){const Ut=Date.now(),Lt=pe[ze];Ue||(Ue=Ut),me[Se]=is,pe[Se]=Ut;let Cs=ze,vn=0;for(;Cs!==Se;)vn+=me[Cs++],Cs=Cs%ne;if(Se=(Se+1)%ne,Se===ze&&(ze=(ze+1)%ne),Ut-Ue<re)return;const nr=Lt&&Ut-Lt;return nr?Math.round(vn*1e3/nr):void 0}}function dn(ne,re){let me=0,pe=1e3/re,Se,ze;const Ue=(Ut,Lt=Date.now())=>{me=Lt,Se=null,ze&&(clearTimeout(ze),ze=null),ne(...Ut)};return[(...Ut)=>{const Lt=Date.now(),Cs=Lt-me;Cs>=pe?Ue(Ut,Lt):(Se=Ut,ze||(ze=setTimeout(()=>{ze=null,Ue(Se)},pe-Cs)))},()=>Se&&Ue(Se)]}const sn=(ne,re,me=3)=>{let pe=0;const Se=$s(50,250);return dn(ze=>{const Ue=ze.loaded,dt=ze.lengthComputable?ze.total:void 0,is=Ue-pe,Ut=Se(is),Lt=Ue<=dt;pe=Ue;const Cs={loaded:Ue,total:dt,progress:dt?Ue/dt:void 0,bytes:is,rate:Ut||void 0,estimated:Ut&&dt&&Lt?(dt-Ue)/Ut:void 0,event:ze,lengthComputable:dt!=null,[re?"download":"upload"]:!0};ne(Cs)},me)},We=(ne,re)=>{const me=ne!=null;return[pe=>re[0]({lengthComputable:me,total:ne,loaded:pe}),re[1]]},Ft=ne=>(...re)=>_e.asap(()=>ne(...re));var gt=nt.hasStandardBrowserEnv?((ne,re)=>me=>(me=new URL(me,nt.origin),ne.protocol===me.protocol&&ne.host===me.host&&(re||ne.port===me.port)))(new URL(nt.origin),nt.navigator&&/(msie|trident)/i.test(nt.navigator.userAgent)):()=>!0,rt=nt.hasStandardBrowserEnv?{write(ne,re,me,pe,Se,ze,Ue){if(typeof document>"u")return;const dt=[`${ne}=${encodeURIComponent(re)}`];_e.isNumber(me)&&dt.push(`expires=${new Date(me).toUTCString()}`),_e.isString(pe)&&dt.push(`path=${pe}`),_e.isString(Se)&&dt.push(`domain=${Se}`),ze===!0&&dt.push("secure"),_e.isString(Ue)&&dt.push(`SameSite=${Ue}`),document.cookie=dt.join("; ")},read(ne){if(typeof document>"u")return null;const re=document.cookie.match(new RegExp("(?:^|; )"+ne+"=([^;]*)"));return re?decodeURIComponent(re[1]):null},remove(ne){this.write(ne,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Is(ne){return typeof ne!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(ne)}function xs(ne,re){return re?ne.replace(/\/?\/$/,"")+"/"+re.replace(/^\/+/,""):ne}function Nn(ne,re,me){let pe=!Is(re);return ne&&(pe||me==!1)?xs(ne,re):re}const kn=ne=>ne instanceof Pt?{...ne}:ne;function Cn(ne,re){re=re||{};const me={};function pe(Ut,Lt,Cs,vn){return _e.isPlainObject(Ut)&&_e.isPlainObject(Lt)?_e.merge.call({caseless:vn},Ut,Lt):_e.isPlainObject(Lt)?_e.merge({},Lt):_e.isArray(Lt)?Lt.slice():Lt}function Se(Ut,Lt,Cs,vn){if(_e.isUndefined(Lt)){if(!_e.isUndefined(Ut))return pe(void 0,Ut,Cs,vn)}else return pe(Ut,Lt,Cs,vn)}function ze(Ut,Lt){if(!_e.isUndefined(Lt))return pe(void 0,Lt)}function Ue(Ut,Lt){if(_e.isUndefined(Lt)){if(!_e.isUndefined(Ut))return pe(void 0,Ut)}else return pe(void 0,Lt)}function dt(Ut,Lt,Cs){if(Cs in re)return pe(Ut,Lt);if(Cs in ne)return pe(void 0,Ut)}const is={url:ze,method:ze,data:ze,baseURL:Ue,transformRequest:Ue,transformResponse:Ue,paramsSerializer:Ue,timeout:Ue,timeoutMessage:Ue,withCredentials:Ue,withXSRFToken:Ue,adapter:Ue,responseType:Ue,xsrfCookieName:Ue,xsrfHeaderName:Ue,onUploadProgress:Ue,onDownloadProgress:Ue,decompress:Ue,maxContentLength:Ue,maxBodyLength:Ue,beforeRedirect:Ue,transport:Ue,httpAgent:Ue,httpsAgent:Ue,cancelToken:Ue,socketPath:Ue,responseEncoding:Ue,validateStatus:dt,headers:(Ut,Lt,Cs)=>Se(kn(Ut),kn(Lt),Cs,!0)};return _e.forEach(Object.keys({...ne,...re}),function(Lt){if(Lt==="__proto__"||Lt==="constructor"||Lt==="prototype")return;const Cs=_e.hasOwnProp(is,Lt)?is[Lt]:Se,vn=Cs(ne[Lt],re[Lt],Lt);_e.isUndefined(vn)&&Cs!==dt||(me[Lt]=vn)}),me}var Us=ne=>{const re=Cn({},ne);let{data:me,withXSRFToken:pe,xsrfHeaderName:Se,xsrfCookieName:ze,headers:Ue,auth:dt}=re;if(re.headers=Ue=Pt.from(Ue),re.url=De(Nn(re.baseURL,re.url,re.allowAbsoluteUrls),ne.params,ne.paramsSerializer),dt&&Ue.set("Authorization","Basic "+btoa((dt.username||"")+":"+(dt.password?unescape(encodeURIComponent(dt.password)):""))),_e.isFormData(me)){if(nt.hasStandardBrowserEnv||nt.hasStandardBrowserWebWorkerEnv)Ue.setContentType(void 0);else if(_e.isFunction(me.getHeaders)){const is=me.getHeaders(),Ut=["content-type","content-length"];Object.entries(is).forEach(([Lt,Cs])=>{Ut.includes(Lt.toLowerCase())&&Ue.set(Lt,Cs)})}}if(nt.hasStandardBrowserEnv&&(pe&&_e.isFunction(pe)&&(pe=pe(re)),pe||pe!==!1&>(re.url))){const is=Se&&ze&&rt.read(ze);is&&Ue.set(Se,is)}return re},Pa=typeof XMLHttpRequest<"u"&&function(ne){return new Promise(function(me,pe){const Se=Us(ne);let ze=Se.data;const Ue=Pt.from(Se.headers).normalize();let{responseType:dt,onUploadProgress:is,onDownloadProgress:Ut}=Se,Lt,Cs,vn,nr,Bt;function As(){nr&&nr(),Bt&&Bt(),Se.cancelToken&&Se.cancelToken.unsubscribe(Lt),Se.signal&&Se.signal.removeEventListener("abort",Lt)}let os=new XMLHttpRequest;os.open(Se.method.toUpperCase(),Se.url,!0),os.timeout=Se.timeout;function En(){if(!os)return;const Kn=Pt.from("getAllResponseHeaders"in os&&os.getAllResponseHeaders()),Gr={data:!dt||dt==="text"||dt==="json"?os.responseText:os.response,status:os.status,statusText:os.statusText,headers:Kn,config:ne,request:os};hs(function(gr){me(gr),As()},function(gr){pe(gr),As()},Gr),os=null}"onloadend"in os?os.onloadend=En:os.onreadystatechange=function(){!os||os.readyState!==4||os.status===0&&!(os.responseURL&&os.responseURL.indexOf("file:")===0)||setTimeout(En)},os.onabort=function(){os&&(pe(new Et("Request aborted",Et.ECONNABORTED,ne,os)),os=null)},os.onerror=function(xr){const Gr=xr&&xr.message?xr.message:"Network Error",Qa=new Et(Gr,Et.ERR_NETWORK,ne,os);Qa.event=xr||null,pe(Qa),os=null},os.ontimeout=function(){let xr=Se.timeout?"timeout of "+Se.timeout+"ms exceeded":"timeout exceeded";const Gr=Se.transitional||Ge;Se.timeoutErrorMessage&&(xr=Se.timeoutErrorMessage),pe(new Et(xr,Gr.clarifyTimeoutError?Et.ETIMEDOUT:Et.ECONNABORTED,ne,os)),os=null},ze===void 0&&Ue.setContentType(null),"setRequestHeader"in os&&_e.forEach(Ue.toJSON(),function(xr,Gr){os.setRequestHeader(Gr,xr)}),_e.isUndefined(Se.withCredentials)||(os.withCredentials=!!Se.withCredentials),dt&&dt!=="json"&&(os.responseType=Se.responseType),Ut&&([vn,Bt]=sn(Ut,!0),os.addEventListener("progress",vn)),is&&os.upload&&([Cs,nr]=sn(is),os.upload.addEventListener("progress",Cs),os.upload.addEventListener("loadend",nr)),(Se.cancelToken||Se.signal)&&(Lt=Kn=>{os&&(pe(!Kn||Kn.type?new ks(null,ne,os):Kn),os.abort(),os=null)},Se.cancelToken&&Se.cancelToken.subscribe(Lt),Se.signal&&(Se.signal.aborted?Lt():Se.signal.addEventListener("abort",Lt)));const Tr=gn(Se.url);if(Tr&&nt.protocols.indexOf(Tr)===-1){pe(new Et("Unsupported protocol "+Tr+":",Et.ERR_BAD_REQUEST,ne));return}os.send(ze||null)})},un=(ne,re)=>{const{length:me}=ne=ne?ne.filter(Boolean):[];if(re||me){let pe=new AbortController,Se;const ze=function(Ut){if(!Se){Se=!0,dt();const Lt=Ut instanceof Error?Ut:this.reason;pe.abort(Lt instanceof Et?Lt:new ks(Lt instanceof Error?Lt.message:Lt))}};let Ue=re&&setTimeout(()=>{Ue=null,ze(new Et(`timeout of ${re}ms exceeded`,Et.ETIMEDOUT))},re);const dt=()=>{ne&&(Ue&&clearTimeout(Ue),Ue=null,ne.forEach(Ut=>{Ut.unsubscribe?Ut.unsubscribe(ze):Ut.removeEventListener("abort",ze)}),ne=null)};ne.forEach(Ut=>Ut.addEventListener("abort",ze));const{signal:is}=pe;return is.unsubscribe=()=>_e.asap(dt),is}};const ta=function*(ne,re){let me=ne.byteLength;if(me<re){yield ne;return}let pe=0,Se;for(;pe<me;)Se=pe+re,yield ne.slice(pe,Se),pe=Se},sa=async function*(ne,re){for await(const me of na(ne))yield*ta(me,re)},na=async function*(ne){if(ne[Symbol.asyncIterator]){yield*ne;return}const re=ne.getReader();try{for(;;){const{done:me,value:pe}=await re.read();if(me)break;yield pe}}finally{await re.cancel()}},Mr=(ne,re,me,pe)=>{const Se=sa(ne,re);let ze=0,Ue,dt=is=>{Ue||(Ue=!0,pe&&pe(is))};return new ReadableStream({async pull(is){try{const{done:Ut,value:Lt}=await Se.next();if(Ut){dt(),is.close();return}let Cs=Lt.byteLength;if(me){let vn=ze+=Cs;me(vn)}is.enqueue(new Uint8Array(Lt))}catch(Ut){throw dt(Ut),Ut}},cancel(is){return dt(is),Se.return()}},{highWaterMark:2})},Xn=64*1024,{isFunction:zn}=_e,Zt=(({Request:ne,Response:re})=>({Request:ne,Response:re}))(_e.global),{ReadableStream:Jn,TextEncoder:Er}=_e.global,Gn=(ne,...re)=>{try{return!!ne(...re)}catch{return!1}},_r=ne=>{ne=_e.merge.call({skipUndefined:!0},Zt,ne);const{fetch:re,Request:me,Response:pe}=ne,Se=re?zn(re):typeof fetch=="function",ze=zn(me),Ue=zn(pe);if(!Se)return!1;const dt=Se&&zn(Jn),is=Se&&(typeof Er=="function"?(Bt=>As=>Bt.encode(As))(new Er):async Bt=>new Uint8Array(await new me(Bt).arrayBuffer())),Ut=ze&&dt&&Gn(()=>{let Bt=!1;const As=new me(nt.origin,{body:new Jn,method:"POST",get duplex(){return Bt=!0,"half"}}).headers.has("Content-Type");return Bt&&!As}),Lt=Ue&&dt&&Gn(()=>_e.isReadableStream(new pe("").body)),Cs={stream:Lt&&(Bt=>Bt.body)};Se&&["text","arrayBuffer","blob","formData","stream"].forEach(Bt=>{!Cs[Bt]&&(Cs[Bt]=(As,os)=>{let En=As&&As[Bt];if(En)return En.call(As);throw new Et(`Response type '${Bt}' is not supported`,Et.ERR_NOT_SUPPORT,os)})});const vn=async Bt=>{if(Bt==null)return 0;if(_e.isBlob(Bt))return Bt.size;if(_e.isSpecCompliantForm(Bt))return(await new me(nt.origin,{method:"POST",body:Bt}).arrayBuffer()).byteLength;if(_e.isArrayBufferView(Bt)||_e.isArrayBuffer(Bt))return Bt.byteLength;if(_e.isURLSearchParams(Bt)&&(Bt=Bt+""),_e.isString(Bt))return(await is(Bt)).byteLength},nr=async(Bt,As)=>{const os=_e.toFiniteNumber(Bt.getContentLength());return os??vn(As)};return async Bt=>{let{url:As,method:os,data:En,signal:Tr,cancelToken:Kn,timeout:xr,onDownloadProgress:Gr,onUploadProgress:Qa,responseType:gr,headers:wo,withCredentials:Cl="same-origin",fetchOptions:gc}=Us(Bt),So=re||fetch;gr=gr?(gr+"").toLowerCase():"text";let Al=un([Tr,Kn&&Kn.toAbortSignal()],xr),Zi=null;const Xa=Al&&Al.unsubscribe&&(()=>{Al.unsubscribe()});let vc;try{if(Qa&&Ut&&os!=="get"&&os!=="head"&&(vc=await nr(wo,En))!==0){let Ia=new me(As,{method:"POST",body:En,duplex:"half"}),Ja;if(_e.isFormData(En)&&(Ja=Ia.headers.get("content-type"))&&wo.setContentType(Ja),Ia.body){const[Dl,Xi]=We(vc,sn(Ft(Qa)));En=Mr(Ia.body,Xn,Dl,Xi)}}_e.isString(Cl)||(Cl=Cl?"include":"omit");const vr=ze&&"credentials"in me.prototype,Co={...gc,signal:Al,method:os.toUpperCase(),headers:wo.normalize().toJSON(),body:En,duplex:"half",credentials:vr?Cl:void 0};Zi=ze&&new me(As,Co);let La=await(ze?So(Zi,gc):So(As,Co));const kl=Lt&&(gr==="stream"||gr==="response");if(Lt&&(Gr||kl&&Xa)){const Ia={};["status","statusText","headers"].forEach(Ao=>{Ia[Ao]=La[Ao]});const Ja=_e.toFiniteNumber(La.headers.get("content-length")),[Dl,Xi]=Gr&&We(Ja,sn(Ft(Gr),!0))||[];La=new pe(Mr(La.body,Xn,Dl,()=>{Xi&&Xi(),Xa&&Xa()}),Ia)}gr=gr||"text";let Qi=await Cs[_e.findKey(Cs,gr)||"text"](La,Bt);return!kl&&Xa&&Xa(),await new Promise((Ia,Ja)=>{hs(Ia,Ja,{data:Qi,headers:Pt.from(La.headers),status:La.status,statusText:La.statusText,config:Bt,request:Zi})})}catch(vr){throw Xa&&Xa(),vr&&vr.name==="TypeError"&&/Load failed|fetch/i.test(vr.message)?Object.assign(new Et("Network Error",Et.ERR_NETWORK,Bt,Zi,vr&&vr.response),{cause:vr.cause||vr}):Et.from(vr,vr&&vr.code,Bt,Zi,vr&&vr.response)}}},On=new Map,ur=ne=>{let re=ne&&ne.env||{};const{fetch:me,Request:pe,Response:Se}=re,ze=[pe,Se,me];let Ue=ze.length,dt=Ue,is,Ut,Lt=On;for(;dt--;)is=ze[dt],Ut=Lt.get(is),Ut===void 0&&Lt.set(is,Ut=dt?new Map:_r(re)),Lt=Ut;return Ut};ur();const ns={http:Ds,xhr:Pa,fetch:{get:ur}};_e.forEach(ns,(ne,re)=>{if(ne){try{Object.defineProperty(ne,"name",{value:re})}catch{}Object.defineProperty(ne,"adapterName",{value:re})}});const nn=ne=>`- ${ne}`,va=ne=>_e.isFunction(ne)||ne===null||ne===!1;function Si(ne,re){ne=_e.isArray(ne)?ne:[ne];const{length:me}=ne;let pe,Se;const ze={};for(let Ue=0;Ue<me;Ue++){pe=ne[Ue];let dt;if(Se=pe,!va(pe)&&(Se=ns[(dt=String(pe)).toLowerCase()],Se===void 0))throw new Et(`Unknown adapter '${dt}'`);if(Se&&(_e.isFunction(Se)||(Se=Se.get(re))))break;ze[dt||"#"+Ue]=Se}if(!Se){const Ue=Object.entries(ze).map(([is,Ut])=>`adapter ${is} `+(Ut===!1?"is not supported by the environment":"is not available in the build"));let dt=me?Ue.length>1?`since :
|
||
`+Ue.map(nn).join(`
|
||
`):" "+nn(Ue[0]):"as no adapter specified";throw new Et("There is no suitable adapter to dispatch the request "+dt,"ERR_NOT_SUPPORT")}return Se}var Ci={getAdapter:Si,adapters:ns};function Fr(ne){if(ne.cancelToken&&ne.cancelToken.throwIfRequested(),ne.signal&&ne.signal.aborted)throw new ks(null,ne)}function Hr(ne){return Fr(ne),ne.headers=Pt.from(ne.headers),ne.data=ys.call(ne,ne.transformRequest),["post","put","patch"].indexOf(ne.method)!==-1&&ne.headers.setContentType("application/x-www-form-urlencoded",!1),Ci.getAdapter(ne.adapter||Zs.adapter,ne)(ne).then(function(pe){return Fr(ne),pe.data=ys.call(ne,ne.transformResponse,pe),pe.headers=Pt.from(pe.headers),pe},function(pe){return Yt(pe)||(Fr(ne),pe&&pe.response&&(pe.response.data=ys.call(ne,ne.transformResponse,pe.response),pe.response.headers=Pt.from(pe.response.headers))),Promise.reject(pe)})}const sr="1.13.6",ya={};["object","boolean","number","function","string","symbol"].forEach((ne,re)=>{ya[ne]=function(pe){return typeof pe===ne||"a"+(re<1?"n ":" ")+ne}});const Gi={};ya.transitional=function(re,me,pe){function Se(ze,Ue){return"[Axios v"+sr+"] Transitional option '"+ze+"'"+Ue+(pe?". "+pe:"")}return(ze,Ue,dt)=>{if(re===!1)throw new Et(Se(Ue," has been removed"+(me?" in "+me:"")),Et.ERR_DEPRECATED);return me&&!Gi[Ue]&&(Gi[Ue]=!0,console.warn(Se(Ue," has been deprecated since v"+me+" and will be removed in the near future"))),re?re(ze,Ue,dt):!0}},ya.spelling=function(re){return(me,pe)=>(console.warn(`${pe} is likely a misspelling of ${re}`),!0)};function bo(ne,re,me){if(typeof ne!="object")throw new Et("options must be an object",Et.ERR_BAD_OPTION_VALUE);const pe=Object.keys(ne);let Se=pe.length;for(;Se-- >0;){const ze=pe[Se],Ue=re[ze];if(Ue){const dt=ne[ze],is=dt===void 0||Ue(dt,ze,ne);if(is!==!0)throw new Et("option "+ze+" must be "+is,Et.ERR_BAD_OPTION_VALUE);continue}if(me!==!0)throw new Et("Unknown option "+ze,Et.ERR_BAD_OPTION)}}var Oa={assertOptions:bo,validators:ya};const An=Oa.validators;class ba{constructor(re){this.defaults=re||{},this.interceptors={request:new Ve,response:new Ve}}async request(re,me){try{return await this._request(re,me)}catch(pe){if(pe instanceof Error){let Se={};Error.captureStackTrace?Error.captureStackTrace(Se):Se=new Error;const ze=Se.stack?Se.stack.replace(/^.+\n/,""):"";try{pe.stack?ze&&!String(pe.stack).endsWith(ze.replace(/^.+\n.+\n/,""))&&(pe.stack+=`
|
||
`+ze):pe.stack=ze}catch{}}throw pe}}_request(re,me){typeof re=="string"?(me=me||{},me.url=re):me=re||{},me=Cn(this.defaults,me);const{transitional:pe,paramsSerializer:Se,headers:ze}=me;pe!==void 0&&Oa.assertOptions(pe,{silentJSONParsing:An.transitional(An.boolean),forcedJSONParsing:An.transitional(An.boolean),clarifyTimeoutError:An.transitional(An.boolean),legacyInterceptorReqResOrdering:An.transitional(An.boolean)},!1),Se!=null&&(_e.isFunction(Se)?me.paramsSerializer={serialize:Se}:Oa.assertOptions(Se,{encode:An.function,serialize:An.function},!0)),me.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?me.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:me.allowAbsoluteUrls=!0),Oa.assertOptions(me,{baseUrl:An.spelling("baseURL"),withXsrfToken:An.spelling("withXSRFToken")},!0),me.method=(me.method||this.defaults.method||"get").toLowerCase();let Ue=ze&&_e.merge(ze.common,ze[me.method]);ze&&_e.forEach(["delete","get","head","post","put","patch","common"],Bt=>{delete ze[Bt]}),me.headers=Pt.concat(Ue,ze);const dt=[];let is=!0;this.interceptors.request.forEach(function(As){if(typeof As.runWhen=="function"&&As.runWhen(me)===!1)return;is=is&&As.synchronous;const os=me.transitional||Ge;os&&os.legacyInterceptorReqResOrdering?dt.unshift(As.fulfilled,As.rejected):dt.push(As.fulfilled,As.rejected)});const Ut=[];this.interceptors.response.forEach(function(As){Ut.push(As.fulfilled,As.rejected)});let Lt,Cs=0,vn;if(!is){const Bt=[Hr.bind(this),void 0];for(Bt.unshift(...dt),Bt.push(...Ut),vn=Bt.length,Lt=Promise.resolve(me);Cs<vn;)Lt=Lt.then(Bt[Cs++],Bt[Cs++]);return Lt}vn=dt.length;let nr=me;for(;Cs<vn;){const Bt=dt[Cs++],As=dt[Cs++];try{nr=Bt(nr)}catch(os){As.call(this,os);break}}try{Lt=Hr.call(this,nr)}catch(Bt){return Promise.reject(Bt)}for(Cs=0,vn=Ut.length;Cs<vn;)Lt=Lt.then(Ut[Cs++],Ut[Cs++]);return Lt}getUri(re){re=Cn(this.defaults,re);const me=Nn(re.baseURL,re.url,re.allowAbsoluteUrls);return De(me,re.params,re.paramsSerializer)}}_e.forEach(["delete","get","head","options"],function(re){ba.prototype[re]=function(me,pe){return this.request(Cn(pe||{},{method:re,url:me,data:(pe||{}).data}))}}),_e.forEach(["post","put","patch"],function(re){function me(pe){return function(ze,Ue,dt){return this.request(Cn(dt||{},{method:re,headers:pe?{"Content-Type":"multipart/form-data"}:{},url:ze,data:Ue}))}}ba.prototype[re]=me(),ba.prototype[re+"Form"]=me(!0)});var Ki=ba;class Wr{constructor(re){if(typeof re!="function")throw new TypeError("executor must be a function.");let me;this.promise=new Promise(function(ze){me=ze});const pe=this;this.promise.then(Se=>{if(!pe._listeners)return;let ze=pe._listeners.length;for(;ze-- >0;)pe._listeners[ze](Se);pe._listeners=null}),this.promise.then=Se=>{let ze;const Ue=new Promise(dt=>{pe.subscribe(dt),ze=dt}).then(Se);return Ue.cancel=function(){pe.unsubscribe(ze)},Ue},re(function(ze,Ue,dt){pe.reason||(pe.reason=new ks(ze,Ue,dt),me(pe.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(re){if(this.reason){re(this.reason);return}this._listeners?this._listeners.push(re):this._listeners=[re]}unsubscribe(re){if(!this._listeners)return;const me=this._listeners.indexOf(re);me!==-1&&this._listeners.splice(me,1)}toAbortSignal(){const re=new AbortController,me=pe=>{re.abort(pe)};return this.subscribe(me),re.signal.unsubscribe=()=>this.unsubscribe(me),re.signal}static source(){let re;return{token:new Wr(function(Se){re=Se}),cancel:re}}}var jo=Wr;function Yi(ne){return function(me){return ne.apply(null,me)}}function No(ne){return _e.isObject(ne)&&ne.isAxiosError===!0}const Ai={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(Ai).forEach(([ne,re])=>{Ai[re]=ne});var wl=Ai;function Sl(ne){const re=new Ki(ne),me=t(Ki.prototype.request,re);return _e.extend(me,Ki.prototype,re,{allOwnKeys:!0}),_e.extend(me,re,null,{allOwnKeys:!0}),me.create=function(Se){return Sl(Cn(ne,Se))},me}const hn=Sl(Zs);return hn.Axios=Ki,hn.CanceledError=ks,hn.CancelToken=jo,hn.isCancel=Yt,hn.VERSION=sr,hn.toFormData=Ws,hn.AxiosError=Et,hn.Cancel=hn.CanceledError,hn.all=function(re){return Promise.all(re)},hn.spread=Yi,hn.isAxiosError=No,hn.mergeConfig=Cn,hn.AxiosHeaders=Pt,hn.formToJSON=ne=>Jt(_e.isHTMLForm(ne)?new FormData(ne):ne),hn.getAdapter=Ci.getAdapter,hn.HttpStatusCode=wl,hn.default=hn,ug=hn,ug}var Uw;function UP(){if(Uw)return wr;Uw=1;function t(q){return q&&typeof q=="object"&&"default"in q?q.default:q}Object.defineProperty(wr,"__esModule",{value:!0});var s=t(zP()),n=function(){return(n=Object.assign||function(q){for(var G,Y=1,V=arguments.length;Y<V;Y++)for(var Q in G=arguments[Y])Object.prototype.hasOwnProperty.call(G,Q)&&(q[Q]=G[Q]);return q}).apply(this,arguments)},r=function(q,G,Y,V){return new(Y||(Y=Promise))(function(Q,_){function z(B){try{F(V.next(B))}catch(K){_(K)}}function T(B){try{F(V.throw(B))}catch(K){_(K)}}function F(B){var K;B.done?Q(B.value):(K=B.value,K instanceof Y?K:new Y(function(W){W(K)})).then(z,T)}F((V=V.apply(q,[])).next())})},a=function(q,G){var Y,V,Q,_,z={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return _={next:T(0),throw:T(1),return:T(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function T(F){return function(B){return(function(K){if(Y)throw new TypeError("Generator is already executing.");for(;_&&(_=0,K[0]&&(z=0)),z;)try{if(Y=1,V&&(Q=2&K[0]?V.return:K[0]?V.throw||((Q=V.return)&&Q.call(V),0):V.next)&&!(Q=Q.call(V,K[1])).done)return Q;switch(V=0,Q&&(K=[2&K[0],Q.value]),K[0]){case 0:case 1:Q=K;break;case 4:return z.label++,{value:K[1],done:!1};case 5:z.label++,V=K[1],K=[0];continue;case 7:K=z.ops.pop(),z.trys.pop();continue;default:if(!(Q=(Q=z.trys).length>0&&Q[Q.length-1])&&(K[0]===6||K[0]===2)){z=0;continue}if(K[0]===3&&(!Q||K[1]>Q[0]&&K[1]<Q[3])){z.label=K[1];break}if(K[0]===6&&z.label<Q[1]){z.label=Q[1],Q=K;break}if(Q&&z.label<Q[2]){z.label=Q[2],z.ops.push(K);break}Q[2]&&z.ops.pop(),z.trys.pop();continue}K=G.call(q,z)}catch(W){K=[6,W],V=0}finally{Y=Q=0}if(5&K[0])throw K[1];return{value:K[0]?K[1]:void 0,done:!0}})([F,B])}}},l=function(q){return q instanceof Date?q.getTime():typeof q=="number"||q===null||q===void 0?q:Number(q)},o=function(q,G,Y){return Y>=q&&Y<=G},d=function(q){return!!q&&(typeof q=="object"||typeof q=="function")&&typeof q.then=="function"},m={Accept:"application/json","Content-Type":"application/json"},f={timeout:0},x=null,h="CLIENT_ERROR",p="SERVER_ERROR",u="TIMEOUT_ERROR",w="CONNECTION_ERROR",v="NETWORK_ERROR",N="UNKNOWN_ERROR",j="CANCEL_ERROR",y=["ECONNABORTED"],C=["ENOTFOUND","ECONNREFUSED","ECONNRESET"],S=["ERR_BAD_REQUEST","ERR_BAD_RESPONSE"],D=function(q){return o(200,299,q)},R=function(q){return o(400,499,q)},A=function(q){return o(500,599,q)},L=function(q){return q.message==="Network Error"?v:s.isCancel(q)?j:q.code?S.includes(q.code)?$(q.response.status):y.includes(q.code)?u:C.includes(q.code)?w:N:$(q.response?q.response.status:null)},$=function(q){return q?D(q)?x:R(q)?h:A(q)?p:N:N},P=function(q){var G,Y=n(n({},m),q.headers||{});if(q.axiosInstance)G=q.axiosInstance;else{var V=n(n({},q),{headers:void 0}),Q=n(n({},f),V);G=s.create(Q)}var _=[],z=[],T=[],F=[],B=[],K=function(ae,xe){return Y[ae]=xe,G},W=function(ae){return function(xe,ce,we){return ce===void 0&&(ce={}),we===void 0&&(we={}),X(n(n({},we),{url:xe,params:ce,method:ae}))}},H=function(ae){return function(xe,ce,we){return we===void 0&&(we={}),X(n(n({},we),{url:xe,method:ae,data:ce}))}},X=function(ae){return r(void 0,void 0,void 0,function(){var xe,ce,we,ke;return a(this,function(Xe){switch(Xe.label){case 0:if(ae.headers=n(n({},Y),ae.headers),z.length>0&&z.forEach(function(Ot){return Ot(ae)}),!(T.length>0))return[3,6];xe=0,Xe.label=1;case 1:return xe<T.length?(ce=T[xe](ae),d(ce)?[4,ce]:[3,3]):[3,6];case 2:return Xe.sent(),[3,5];case 3:return[4,ce(ae)];case 4:Xe.sent(),Xe.label=5;case 5:return xe++,[3,1];case 6:return we=l(new Date),ke=function(Ot){return r(void 0,void 0,void 0,function(){var bt;return a(this,function(te){switch(te.label){case 0:return[4,ie(we,Ot)];case 1:return bt=te.sent(),[2,J(bt)]}})})},[2,G.request(ae).then(ke).catch(ke)]}})})},J=function(ae){return _.forEach(function(xe){try{xe(ae)}catch{}}),ae},ie=function(ae,xe){return r(void 0,void 0,void 0,function(){var ce,we,ke,Xe,Ot,bt,te,ve,qe,ge,Be,ut,ht,it,Tt,It,he;return a(this,function(vt){switch(vt.label){case 0:if(ce=l(new Date),we=ce-ae,ke=xe instanceof Error||s.isCancel(xe),Xe=xe,Ot=xe,bt=ke?Ot.response:Xe,te=bt&&bt.status||null,ve=ke?L(xe):$(te),qe=ke?Ot:null,ge=D(te),Be=xe.config||null,ut=bt&&bt.headers||null,ht=(he=bt&&bt.data)!==null&&he!==void 0?he:null,it={duration:we,problem:ve,originalError:qe,ok:ge,status:te,headers:ut,config:Be,data:ht},F.length>0&&F.forEach(function(mt){return mt(it)}),!(B.length>0))return[3,6];Tt=0,vt.label=1;case 1:return Tt<B.length?(It=B[Tt](it),d(It)?[4,It]:[3,3]):[3,6];case 2:return vt.sent(),[3,5];case 3:return[4,It(it)];case 4:vt.sent(),vt.label=5;case 5:return Tt++,[3,1];case 6:return[2,it]}})})};return{axiosInstance:G,monitors:_,addMonitor:function(ae){_.push(ae)},requestTransforms:z,asyncRequestTransforms:T,responseTransforms:F,asyncResponseTransforms:B,addRequestTransform:function(ae){return z.push(ae)},addAsyncRequestTransform:function(ae){return T.push(ae)},addResponseTransform:function(ae){return F.push(ae)},addAsyncResponseTransform:function(ae){return B.push(ae)},setHeader:K,setHeaders:function(ae){return Object.keys(ae).forEach(function(xe){return K(xe,ae[xe])}),G},deleteHeader:function(ae){return delete Y[ae],G},headers:Y,setBaseURL:function(ae){return G.defaults.baseURL=ae,G},getBaseURL:function(){return G.defaults.baseURL},any:X,get:W("get"),delete:W("delete"),head:W("head"),post:H("post"),put:H("put"),patch:H("patch"),link:W("link"),unlink:W("unlink")}},E=s.isCancel,O=s.CancelToken,I={DEFAULT_HEADERS:m,NONE:x,CLIENT_ERROR:h,SERVER_ERROR:p,TIMEOUT_ERROR:u,CONNECTION_ERROR:w,NETWORK_ERROR:v,UNKNOWN_ERROR:N,create:P,isCancel:E,CancelToken:O};return wr.DEFAULT_HEADERS=m,wr.NONE=x,wr.CLIENT_ERROR=h,wr.SERVER_ERROR=p,wr.TIMEOUT_ERROR=u,wr.CONNECTION_ERROR=w,wr.NETWORK_ERROR=v,wr.UNKNOWN_ERROR=N,wr.CANCEL_ERROR=j,wr.getProblemFromError=L,wr.getProblemFromStatus=$,wr.create=P,wr.isCancel=E,wr.CancelToken=O,wr.default=I,wr}var VP=UP();const HP="https://dealeronboarding-uat.royalenfield.com/api",$e=VP.create({baseURL:HP,headers:{"Content-Type":"application/json",Accept:"application/json"},timeout:3e4});$e.addRequestTransform(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`)});$e.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 nA(t,s){return function(){return t.apply(s,arguments)}}const{toString:WP}=Object.prototype,{getPrototypeOf:zy}=Object,{iterator:Tf,toStringTag:rA}=Symbol,Pf=(t=>s=>{const n=WP.call(s);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),bi=t=>(t=t.toLowerCase(),s=>Pf(s)===t),Of=t=>s=>typeof s===t,{isArray:pd}=Array,sd=Of("undefined");function Fu(t){return t!==null&&!sd(t)&&t.constructor!==null&&!sd(t.constructor)&&ma(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const aA=bi("ArrayBuffer");function GP(t){let s;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?s=ArrayBuffer.isView(t):s=t&&t.buffer&&aA(t.buffer),s}const KP=Of("string"),ma=Of("function"),iA=Of("number"),Bu=t=>t!==null&&typeof t=="object",YP=t=>t===!0||t===!1,Om=t=>{if(Pf(t)!=="object")return!1;const s=zy(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(rA in t)&&!(Tf in t)},ZP=t=>{if(!Bu(t)||Fu(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},QP=bi("Date"),XP=bi("File"),JP=t=>!!(t&&typeof t.uri<"u"),eO=t=>t&&typeof t.getParts<"u",tO=bi("Blob"),sO=bi("FileList"),nO=t=>Bu(t)&&ma(t.pipe);function rO(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Vw=rO(),Hw=typeof Vw.FormData<"u"?Vw.FormData:void 0,aO=t=>{let s;return t&&(Hw&&t instanceof Hw||ma(t.append)&&((s=Pf(t))==="formdata"||s==="object"&&ma(t.toString)&&t.toString()==="[object FormData]"))},iO=bi("URLSearchParams"),[lO,oO,cO,dO]=["ReadableStream","Request","Response","Headers"].map(bi),uO=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $u(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(Fu(t))return;const l=n?Object.getOwnPropertyNames(t):Object.keys(t),o=l.length;let d;for(r=0;r<o;r++)d=l[r],s.call(null,t[d],d,t)}}function lA(t,s){if(Fu(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 Ko=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,oA=t=>!sd(t)&&t!==Ko;function Yv(){const{caseless:t,skipUndefined:s}=oA(this)&&this||{},n={},r=(a,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const o=t&&lA(n,l)||l;Om(n[o])&&Om(a)?n[o]=Yv(n[o],a):Om(a)?n[o]=Yv({},a):pd(a)?n[o]=a.slice():(!s||!sd(a))&&(n[o]=a)};for(let a=0,l=arguments.length;a<l;a++)arguments[a]&&$u(arguments[a],r);return n}const hO=(t,s,n,{allOwnKeys:r}={})=>($u(s,(a,l)=>{n&&ma(a)?Object.defineProperty(t,l,{value:nA(a,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:a,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),mO=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),fO=(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)},pO=(t,s,n,r)=>{let a,l,o;const d={};if(s=s||{},t==null)return s;do{for(a=Object.getOwnPropertyNames(t),l=a.length;l-- >0;)o=a[l],(!r||r(o,t,s))&&!d[o]&&(s[o]=t[o],d[o]=!0);t=n!==!1&&zy(t)}while(t&&(!n||n(t,s))&&t!==Object.prototype);return s},xO=(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},gO=t=>{if(!t)return null;if(pd(t))return t;let s=t.length;if(!iA(s))return null;const n=new Array(s);for(;s-- >0;)n[s]=t[s];return n},vO=(t=>s=>t&&s instanceof t)(typeof Uint8Array<"u"&&zy(Uint8Array)),yO=(t,s)=>{const r=(t&&t[Tf]).call(t);let a;for(;(a=r.next())&&!a.done;){const l=a.value;s.call(t,l[0],l[1])}},bO=(t,s)=>{let n;const r=[];for(;(n=t.exec(s))!==null;)r.push(n);return r},jO=bi("HTMLFormElement"),NO=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),Ww=(({hasOwnProperty:t})=>(s,n)=>t.call(s,n))(Object.prototype),wO=bi("RegExp"),cA=(t,s)=>{const n=Object.getOwnPropertyDescriptors(t),r={};$u(n,(a,l)=>{let o;(o=s(a,l,t))!==!1&&(r[l]=o||a)}),Object.defineProperties(t,r)},SO=t=>{cA(t,(s,n)=>{if(ma(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(ma(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+"'")})}})},CO=(t,s)=>{const n={},r=a=>{a.forEach(l=>{n[l]=!0})};return pd(t)?r(t):r(String(t).split(s)),n},AO=()=>{},kO=(t,s)=>t!=null&&Number.isFinite(t=+t)?t:s;function DO(t){return!!(t&&ma(t.append)&&t[rA]==="FormData"&&t[Tf])}const RO=t=>{const s=new Array(10),n=(r,a)=>{if(Bu(r)){if(s.indexOf(r)>=0)return;if(Fu(r))return r;if(!("toJSON"in r)){s[a]=r;const l=pd(r)?[]:{};return $u(r,(o,d)=>{const m=n(o,a+1);!sd(m)&&(l[d]=m)}),s[a]=void 0,l}}return r};return n(t,0)},EO=bi("AsyncFunction"),_O=t=>t&&(Bu(t)||ma(t))&&ma(t.then)&&ma(t.catch),dA=((t,s)=>t?setImmediate:s?((n,r)=>(Ko.addEventListener("message",({source:a,data:l})=>{a===Ko&&l===n&&r.length&&r.shift()()},!1),a=>{r.push(a),Ko.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ma(Ko.postMessage)),TO=typeof queueMicrotask<"u"?queueMicrotask.bind(Ko):typeof process<"u"&&process.nextTick||dA,PO=t=>t!=null&&ma(t[Tf]),Je={isArray:pd,isArrayBuffer:aA,isBuffer:Fu,isFormData:aO,isArrayBufferView:GP,isString:KP,isNumber:iA,isBoolean:YP,isObject:Bu,isPlainObject:Om,isEmptyObject:ZP,isReadableStream:lO,isRequest:oO,isResponse:cO,isHeaders:dO,isUndefined:sd,isDate:QP,isFile:XP,isReactNativeBlob:JP,isReactNative:eO,isBlob:tO,isRegExp:wO,isFunction:ma,isStream:nO,isURLSearchParams:iO,isTypedArray:vO,isFileList:sO,forEach:$u,merge:Yv,extend:hO,trim:uO,stripBOM:mO,inherits:fO,toFlatObject:pO,kindOf:Pf,kindOfTest:bi,endsWith:xO,toArray:gO,forEachEntry:yO,matchAll:bO,isHTMLForm:jO,hasOwnProperty:Ww,hasOwnProp:Ww,reduceDescriptors:cA,freezeMethods:SO,toObjectSet:CO,toCamelCase:NO,noop:AO,toFiniteNumber:kO,findKey:lA,global:Ko,isContextDefined:oA,isSpecCompliantForm:DO,toJSONObject:RO,isAsyncFn:EO,isThenable:_O,setImmediate:dA,asap:TO,isIterable:PO};let zs=class uA extends Error{static from(s,n,r,a,l,o){const d=new uA(s.message,n||s.code,r,a,l);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,l){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),l&&(this.response=l,this.status=l.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:Je.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 OO=null;function Zv(t){return Je.isPlainObject(t)||Je.isArray(t)}function hA(t){return Je.endsWith(t,"[]")?t.slice(0,-2):t}function hg(t,s,n){return t?t.concat(s).map(function(a,l){return a=hA(a),!n&&l?"["+a+"]":a}).join(n?".":""):s}function LO(t){return Je.isArray(t)&&!t.some(Zv)}const IO=Je.toFlatObject(Je,{},null,function(s){return/^is[A-Z]/.test(s)});function Lf(t,s,n){if(!Je.isObject(t))throw new TypeError("target must be an object");s=s||new FormData,n=Je.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,N){return!Je.isUndefined(N[v])});const r=n.metaTokens,a=n.visitor||x,l=n.dots,o=n.indexes,m=(n.Blob||typeof Blob<"u"&&Blob)&&Je.isSpecCompliantForm(s);if(!Je.isFunction(a))throw new TypeError("visitor must be a function");function f(w){if(w===null)return"";if(Je.isDate(w))return w.toISOString();if(Je.isBoolean(w))return w.toString();if(!m&&Je.isBlob(w))throw new zs("Blob is not supported. Use a Buffer instead.");return Je.isArrayBuffer(w)||Je.isTypedArray(w)?m&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function x(w,v,N){let j=w;if(Je.isReactNative(s)&&Je.isReactNativeBlob(w))return s.append(hg(N,v,l),f(w)),!1;if(w&&!N&&typeof w=="object"){if(Je.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(Je.isArray(w)&&LO(w)||(Je.isFileList(w)||Je.endsWith(v,"[]"))&&(j=Je.toArray(w)))return v=hA(v),j.forEach(function(C,S){!(Je.isUndefined(C)||C===null)&&s.append(o===!0?hg([v],S,l):o===null?v:v+"[]",f(C))}),!1}return Zv(w)?!0:(s.append(hg(N,v,l),f(w)),!1)}const h=[],p=Object.assign(IO,{defaultVisitor:x,convertValue:f,isVisitable:Zv});function u(w,v){if(!Je.isUndefined(w)){if(h.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));h.push(w),Je.forEach(w,function(j,y){(!(Je.isUndefined(j)||j===null)&&a.call(s,j,Je.isString(y)?y.trim():y,v,p))===!0&&u(j,v?v.concat(y):[y])}),h.pop()}}if(!Je.isObject(t))throw new TypeError("data must be an object");return u(t),s}function Gw(t){const s={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return s[r]})}function Uy(t,s){this._pairs=[],t&&Lf(t,this,s)}const mA=Uy.prototype;mA.append=function(s,n){this._pairs.push([s,n])};mA.toString=function(s){const n=s?function(r){return s.call(this,r,Gw)}:Gw;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function MO(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function fA(t,s,n){if(!s)return t;const r=n&&n.encode||MO,a=Je.isFunction(n)?{serialize:n}:n,l=a&&a.serialize;let o;if(l?o=l(s,a):o=Je.isURLSearchParams(s)?s.toString():new Uy(s,a).toString(r),o){const d=t.indexOf("#");d!==-1&&(t=t.slice(0,d)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Kw{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){Je.forEach(this.handlers,function(r){r!==null&&s(r)})}}const Vy={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},FO=typeof URLSearchParams<"u"?URLSearchParams:Uy,BO=typeof FormData<"u"?FormData:null,$O=typeof Blob<"u"?Blob:null,qO={isBrowser:!0,classes:{URLSearchParams:FO,FormData:BO,Blob:$O},protocols:["http","https","file","blob","url","data"]},Hy=typeof window<"u"&&typeof document<"u",Qv=typeof navigator=="object"&&navigator||void 0,zO=Hy&&(!Qv||["ReactNative","NativeScript","NS"].indexOf(Qv.product)<0),UO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VO=Hy&&window.location.href||"http://localhost",HO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Hy,hasStandardBrowserEnv:zO,hasStandardBrowserWebWorkerEnv:UO,navigator:Qv,origin:VO},Symbol.toStringTag,{value:"Module"})),Ur={...HO,...qO};function WO(t,s){return Lf(t,new Ur.classes.URLSearchParams,{visitor:function(n,r,a,l){return Ur.isNode&&Je.isBuffer(n)?(this.append(r,n.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...s})}function GO(t){return Je.matchAll(/\w+|\[(\w*)]/g,t).map(s=>s[0]==="[]"?"":s[1]||s[0])}function KO(t){const s={},n=Object.keys(t);let r;const a=n.length;let l;for(r=0;r<a;r++)l=n[r],s[l]=t[l];return s}function pA(t){function s(n,r,a,l){let o=n[l++];if(o==="__proto__")return!0;const d=Number.isFinite(+o),m=l>=n.length;return o=!o&&Je.isArray(a)?a.length:o,m?(Je.hasOwnProp(a,o)?a[o]=[a[o],r]:a[o]=r,!d):((!a[o]||!Je.isObject(a[o]))&&(a[o]=[]),s(n,r,a[o],l)&&Je.isArray(a[o])&&(a[o]=KO(a[o])),!d)}if(Je.isFormData(t)&&Je.isFunction(t.entries)){const n={};return Je.forEachEntry(t,(r,a)=>{s(GO(r),a,n,0)}),n}return null}function YO(t,s,n){if(Je.isString(t))try{return(s||JSON.parse)(t),Je.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const qu={transitional:Vy,adapter:["xhr","http","fetch"],transformRequest:[function(s,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,l=Je.isObject(s);if(l&&Je.isHTMLForm(s)&&(s=new FormData(s)),Je.isFormData(s))return a?JSON.stringify(pA(s)):s;if(Je.isArrayBuffer(s)||Je.isBuffer(s)||Je.isStream(s)||Je.isFile(s)||Je.isBlob(s)||Je.isReadableStream(s))return s;if(Je.isArrayBufferView(s))return s.buffer;if(Je.isURLSearchParams(s))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),s.toString();let d;if(l){if(r.indexOf("application/x-www-form-urlencoded")>-1)return WO(s,this.formSerializer).toString();if((d=Je.isFileList(s))||r.indexOf("multipart/form-data")>-1){const m=this.env&&this.env.FormData;return Lf(d?{"files[]":s}:s,m&&new m,this.formSerializer)}}return l||a?(n.setContentType("application/json",!1),YO(s)):s}],transformResponse:[function(s){const n=this.transitional||qu.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(Je.isResponse(s)||Je.isReadableStream(s))return s;if(s&&Je.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:Ur.classes.FormData,Blob:Ur.classes.Blob},validateStatus:function(s){return s>=200&&s<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Je.forEach(["delete","get","head","post","put","patch"],t=>{qu.headers[t]={}});const ZO=Je.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"]),QO=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]&&ZO[n])&&(n==="set-cookie"?s[n]?s[n].push(r):s[n]=[r]:s[n]=s[n]?s[n]+", "+r:r)}),s},Yw=Symbol("internals");function eu(t){return t&&String(t).trim().toLowerCase()}function Lm(t){return t===!1||t==null?t:Je.isArray(t)?t.map(Lm):String(t)}function XO(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 JO=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function mg(t,s,n,r,a){if(Je.isFunction(r))return r.call(this,s,n);if(a&&(s=n),!!Je.isString(s)){if(Je.isString(r))return s.indexOf(r)!==-1;if(Je.isRegExp(r))return r.test(s)}}function e5(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(s,n,r)=>n.toUpperCase()+r)}function t5(t,s){const n=Je.toCamelCase(" "+s);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(a,l,o){return this[r].call(this,s,a,l,o)},configurable:!0})})}let fa=class{constructor(s){s&&this.set(s)}set(s,n,r){const a=this;function l(d,m,f){const x=eu(m);if(!x)throw new Error("header name must be a non-empty string");const h=Je.findKey(a,x);(!h||a[h]===void 0||f===!0||f===void 0&&a[h]!==!1)&&(a[h||m]=Lm(d))}const o=(d,m)=>Je.forEach(d,(f,x)=>l(f,x,m));if(Je.isPlainObject(s)||s instanceof this.constructor)o(s,n);else if(Je.isString(s)&&(s=s.trim())&&!JO(s))o(QO(s),n);else if(Je.isObject(s)&&Je.isIterable(s)){let d={},m,f;for(const x of s){if(!Je.isArray(x))throw TypeError("Object iterator must return a key-value pair");d[f=x[0]]=(m=d[f])?Je.isArray(m)?[...m,x[1]]:[m,x[1]]:x[1]}o(d,n)}else s!=null&&l(n,s,r);return this}get(s,n){if(s=eu(s),s){const r=Je.findKey(this,s);if(r){const a=this[r];if(!n)return a;if(n===!0)return XO(a);if(Je.isFunction(n))return n.call(this,a,r);if(Je.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(s,n){if(s=eu(s),s){const r=Je.findKey(this,s);return!!(r&&this[r]!==void 0&&(!n||mg(this,this[r],r,n)))}return!1}delete(s,n){const r=this;let a=!1;function l(o){if(o=eu(o),o){const d=Je.findKey(r,o);d&&(!n||mg(r,r[d],d,n))&&(delete r[d],a=!0)}}return Je.isArray(s)?s.forEach(l):l(s),a}clear(s){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const l=n[r];(!s||mg(this,this[l],l,s,!0))&&(delete this[l],a=!0)}return a}normalize(s){const n=this,r={};return Je.forEach(this,(a,l)=>{const o=Je.findKey(r,l);if(o){n[o]=Lm(a),delete n[l];return}const d=s?e5(l):String(l).trim();d!==l&&delete n[l],n[d]=Lm(a),r[d]=!0}),this}concat(...s){return this.constructor.concat(this,...s)}toJSON(s){const n=Object.create(null);return Je.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=s&&Je.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[Yw]=this[Yw]={accessors:{}}).accessors,a=this.prototype;function l(o){const d=eu(o);r[d]||(t5(a,o),r[d]=!0)}return Je.isArray(s)?s.forEach(l):l(s),this}};fa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Je.reduceDescriptors(fa.prototype,({value:t},s)=>{let n=s[0].toUpperCase()+s.slice(1);return{get:()=>t,set(r){this[n]=r}}});Je.freezeMethods(fa);function fg(t,s){const n=this||qu,r=s||n,a=fa.from(r.headers);let l=r.data;return Je.forEach(t,function(d){l=d.call(n,l,a.normalize(),s?s.status:void 0)}),a.normalize(),l}function xA(t){return!!(t&&t.__CANCEL__)}let zu=class extends zs{constructor(s,n,r){super(s??"canceled",zs.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function gA(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 s5(t){const s=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return s&&s[1]||""}function n5(t,s){t=t||10;const n=new Array(t),r=new Array(t);let a=0,l=0,o;return s=s!==void 0?s:1e3,function(m){const f=Date.now(),x=r[l];o||(o=f),n[a]=m,r[a]=f;let h=l,p=0;for(;h!==a;)p+=n[h++],h=h%t;if(a=(a+1)%t,a===l&&(l=(l+1)%t),f-o<s)return;const u=x&&f-x;return u?Math.round(p*1e3/u):void 0}}function r5(t,s){let n=0,r=1e3/s,a,l;const o=(f,x=Date.now())=>{n=x,a=null,l&&(clearTimeout(l),l=null),t(...f)};return[(...f)=>{const x=Date.now(),h=x-n;h>=r?o(f,x):(a=f,l||(l=setTimeout(()=>{l=null,o(a)},r-h)))},()=>a&&o(a)]}const nf=(t,s,n=3)=>{let r=0;const a=n5(50,250);return r5(l=>{const o=l.loaded,d=l.lengthComputable?l.total:void 0,m=o-r,f=a(m),x=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&&x?(d-o)/f:void 0,event:l,lengthComputable:d!=null,[s?"download":"upload"]:!0};t(h)},n)},Zw=(t,s)=>{const n=t!=null;return[r=>s[0]({lengthComputable:n,total:t,loaded:r}),s[1]]},Qw=t=>(...s)=>Je.asap(()=>t(...s)),a5=Ur.hasStandardBrowserEnv?((t,s)=>n=>(n=new URL(n,Ur.origin),t.protocol===n.protocol&&t.host===n.host&&(s||t.port===n.port)))(new URL(Ur.origin),Ur.navigator&&/(msie|trident)/i.test(Ur.navigator.userAgent)):()=>!0,i5=Ur.hasStandardBrowserEnv?{write(t,s,n,r,a,l,o){if(typeof document>"u")return;const d=[`${t}=${encodeURIComponent(s)}`];Je.isNumber(n)&&d.push(`expires=${new Date(n).toUTCString()}`),Je.isString(r)&&d.push(`path=${r}`),Je.isString(a)&&d.push(`domain=${a}`),l===!0&&d.push("secure"),Je.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 l5(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function o5(t,s){return s?t.replace(/\/?\/$/,"")+"/"+s.replace(/^\/+/,""):t}function vA(t,s,n){let r=!l5(s);return t&&(r||n==!1)?o5(t,s):s}const Xw=t=>t instanceof fa?{...t}:t;function rc(t,s){s=s||{};const n={};function r(f,x,h,p){return Je.isPlainObject(f)&&Je.isPlainObject(x)?Je.merge.call({caseless:p},f,x):Je.isPlainObject(x)?Je.merge({},x):Je.isArray(x)?x.slice():x}function a(f,x,h,p){if(Je.isUndefined(x)){if(!Je.isUndefined(f))return r(void 0,f,h,p)}else return r(f,x,h,p)}function l(f,x){if(!Je.isUndefined(x))return r(void 0,x)}function o(f,x){if(Je.isUndefined(x)){if(!Je.isUndefined(f))return r(void 0,f)}else return r(void 0,x)}function d(f,x,h){if(h in s)return r(f,x);if(h in t)return r(void 0,f)}const m={url:l,method:l,data:l,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,x,h)=>a(Xw(f),Xw(x),h,!0)};return Je.forEach(Object.keys({...t,...s}),function(x){if(x==="__proto__"||x==="constructor"||x==="prototype")return;const h=Je.hasOwnProp(m,x)?m[x]:a,p=h(t[x],s[x],x);Je.isUndefined(p)&&h!==d||(n[x]=p)}),n}const yA=t=>{const s=rc({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:l,headers:o,auth:d}=s;if(s.headers=o=fa.from(o),s.url=fA(vA(s.baseURL,s.url,s.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&o.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),Je.isFormData(n)){if(Ur.hasStandardBrowserEnv||Ur.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Je.isFunction(n.getHeaders)){const m=n.getHeaders(),f=["content-type","content-length"];Object.entries(m).forEach(([x,h])=>{f.includes(x.toLowerCase())&&o.set(x,h)})}}if(Ur.hasStandardBrowserEnv&&(r&&Je.isFunction(r)&&(r=r(s)),r||r!==!1&&a5(s.url))){const m=a&&l&&i5.read(l);m&&o.set(a,m)}return s},c5=typeof XMLHttpRequest<"u",d5=c5&&function(t){return new Promise(function(n,r){const a=yA(t);let l=a.data;const o=fa.from(a.headers).normalize();let{responseType:d,onUploadProgress:m,onDownloadProgress:f}=a,x,h,p,u,w;function v(){u&&u(),w&&w(),a.cancelToken&&a.cancelToken.unsubscribe(x),a.signal&&a.signal.removeEventListener("abort",x)}let N=new XMLHttpRequest;N.open(a.method.toUpperCase(),a.url,!0),N.timeout=a.timeout;function j(){if(!N)return;const C=fa.from("getAllResponseHeaders"in N&&N.getAllResponseHeaders()),D={data:!d||d==="text"||d==="json"?N.responseText:N.response,status:N.status,statusText:N.statusText,headers:C,config:t,request:N};gA(function(A){n(A),v()},function(A){r(A),v()},D),N=null}"onloadend"in N?N.onloadend=j:N.onreadystatechange=function(){!N||N.readyState!==4||N.status===0&&!(N.responseURL&&N.responseURL.indexOf("file:")===0)||setTimeout(j)},N.onabort=function(){N&&(r(new zs("Request aborted",zs.ECONNABORTED,t,N)),N=null)},N.onerror=function(S){const D=S&&S.message?S.message:"Network Error",R=new zs(D,zs.ERR_NETWORK,t,N);R.event=S||null,r(R),N=null},N.ontimeout=function(){let S=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const D=a.transitional||Vy;a.timeoutErrorMessage&&(S=a.timeoutErrorMessage),r(new zs(S,D.clarifyTimeoutError?zs.ETIMEDOUT:zs.ECONNABORTED,t,N)),N=null},l===void 0&&o.setContentType(null),"setRequestHeader"in N&&Je.forEach(o.toJSON(),function(S,D){N.setRequestHeader(D,S)}),Je.isUndefined(a.withCredentials)||(N.withCredentials=!!a.withCredentials),d&&d!=="json"&&(N.responseType=a.responseType),f&&([p,w]=nf(f,!0),N.addEventListener("progress",p)),m&&N.upload&&([h,u]=nf(m),N.upload.addEventListener("progress",h),N.upload.addEventListener("loadend",u)),(a.cancelToken||a.signal)&&(x=C=>{N&&(r(!C||C.type?new zu(null,t,N):C),N.abort(),N=null)},a.cancelToken&&a.cancelToken.subscribe(x),a.signal&&(a.signal.aborted?x():a.signal.addEventListener("abort",x)));const y=s5(a.url);if(y&&Ur.protocols.indexOf(y)===-1){r(new zs("Unsupported protocol "+y+":",zs.ERR_BAD_REQUEST,t));return}N.send(l||null)})},u5=(t,s)=>{const{length:n}=t=t?t.filter(Boolean):[];if(s||n){let r=new AbortController,a;const l=function(f){if(!a){a=!0,d();const x=f instanceof Error?f:this.reason;r.abort(x instanceof zs?x:new zu(x instanceof Error?x.message:x))}};let o=s&&setTimeout(()=>{o=null,l(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(l):f.removeEventListener("abort",l)}),t=null)};t.forEach(f=>f.addEventListener("abort",l));const{signal:m}=r;return m.unsubscribe=()=>Je.asap(d),m}},h5=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},m5=async function*(t,s){for await(const n of f5(t))yield*h5(n,s)},f5=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()}},Jw=(t,s,n,r)=>{const a=m5(t,s);let l=0,o,d=m=>{o||(o=!0,r&&r(m))};return new ReadableStream({async pull(m){try{const{done:f,value:x}=await a.next();if(f){d(),m.close();return}let h=x.byteLength;if(n){let p=l+=h;n(p)}m.enqueue(new Uint8Array(x))}catch(f){throw d(f),f}},cancel(m){return d(m),a.return()}},{highWaterMark:2})},e1=64*1024,{isFunction:om}=Je,p5=(({Request:t,Response:s})=>({Request:t,Response:s}))(Je.global),{ReadableStream:t1,TextEncoder:s1}=Je.global,n1=(t,...s)=>{try{return!!t(...s)}catch{return!1}},x5=t=>{t=Je.merge.call({skipUndefined:!0},p5,t);const{fetch:s,Request:n,Response:r}=t,a=s?om(s):typeof fetch=="function",l=om(n),o=om(r);if(!a)return!1;const d=a&&om(t1),m=a&&(typeof s1=="function"?(w=>v=>w.encode(v))(new s1):async w=>new Uint8Array(await new n(w).arrayBuffer())),f=l&&d&&n1(()=>{let w=!1;const v=new n(Ur.origin,{body:new t1,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),x=o&&d&&n1(()=>Je.isReadableStream(new r("").body)),h={stream:x&&(w=>w.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!h[w]&&(h[w]=(v,N)=>{let j=v&&v[w];if(j)return j.call(v);throw new zs(`Response type '${w}' is not supported`,zs.ERR_NOT_SUPPORT,N)})});const p=async w=>{if(w==null)return 0;if(Je.isBlob(w))return w.size;if(Je.isSpecCompliantForm(w))return(await new n(Ur.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(Je.isArrayBufferView(w)||Je.isArrayBuffer(w))return w.byteLength;if(Je.isURLSearchParams(w)&&(w=w+""),Je.isString(w))return(await m(w)).byteLength},u=async(w,v)=>{const N=Je.toFiniteNumber(w.getContentLength());return N??p(v)};return async w=>{let{url:v,method:N,data:j,signal:y,cancelToken:C,timeout:S,onDownloadProgress:D,onUploadProgress:R,responseType:A,headers:L,withCredentials:$="same-origin",fetchOptions:P}=yA(w),E=s||fetch;A=A?(A+"").toLowerCase():"text";let O=u5([y,C&&C.toAbortSignal()],S),I=null;const q=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let G;try{if(R&&f&&N!=="get"&&N!=="head"&&(G=await u(L,j))!==0){let T=new n(v,{method:"POST",body:j,duplex:"half"}),F;if(Je.isFormData(j)&&(F=T.headers.get("content-type"))&&L.setContentType(F),T.body){const[B,K]=Zw(G,nf(Qw(R)));j=Jw(T.body,e1,B,K)}}Je.isString($)||($=$?"include":"omit");const Y=l&&"credentials"in n.prototype,V={...P,signal:O,method:N.toUpperCase(),headers:L.normalize().toJSON(),body:j,duplex:"half",credentials:Y?$:void 0};I=l&&new n(v,V);let Q=await(l?E(I,P):E(v,V));const _=x&&(A==="stream"||A==="response");if(x&&(D||_&&q)){const T={};["status","statusText","headers"].forEach(W=>{T[W]=Q[W]});const F=Je.toFiniteNumber(Q.headers.get("content-length")),[B,K]=D&&Zw(F,nf(Qw(D),!0))||[];Q=new r(Jw(Q.body,e1,B,()=>{K&&K(),q&&q()}),T)}A=A||"text";let z=await h[Je.findKey(h,A)||"text"](Q,w);return!_&&q&&q(),await new Promise((T,F)=>{gA(T,F,{data:z,headers:fa.from(Q.headers),status:Q.status,statusText:Q.statusText,config:w,request:I})})}catch(Y){throw q&&q(),Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new zs("Network Error",zs.ERR_NETWORK,w,I,Y&&Y.response),{cause:Y.cause||Y}):zs.from(Y,Y&&Y.code,w,I,Y&&Y.response)}}},g5=new Map,bA=t=>{let s=t&&t.env||{};const{fetch:n,Request:r,Response:a}=s,l=[r,a,n];let o=l.length,d=o,m,f,x=g5;for(;d--;)m=l[d],f=x.get(m),f===void 0&&x.set(m,f=d?new Map:x5(s)),x=f;return f};bA();const Wy={http:OO,xhr:d5,fetch:{get:bA}};Je.forEach(Wy,(t,s)=>{if(t){try{Object.defineProperty(t,"name",{value:s})}catch{}Object.defineProperty(t,"adapterName",{value:s})}});const r1=t=>`- ${t}`,v5=t=>Je.isFunction(t)||t===null||t===!1;function y5(t,s){t=Je.isArray(t)?t:[t];const{length:n}=t;let r,a;const l={};for(let o=0;o<n;o++){r=t[o];let d;if(a=r,!v5(r)&&(a=Wy[(d=String(r)).toLowerCase()],a===void 0))throw new zs(`Unknown adapter '${d}'`);if(a&&(Je.isFunction(a)||(a=a.get(s))))break;l[d||"#"+o]=a}if(!a){const o=Object.entries(l).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(r1).join(`
|
||
`):" "+r1(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 jA={getAdapter:y5,adapters:Wy};function pg(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new zu(null,t)}function a1(t){return pg(t),t.headers=fa.from(t.headers),t.data=fg.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),jA.getAdapter(t.adapter||qu.adapter,t)(t).then(function(r){return pg(t),r.data=fg.call(t,t.transformResponse,r),r.headers=fa.from(r.headers),r},function(r){return xA(r)||(pg(t),r&&r.response&&(r.response.data=fg.call(t,t.transformResponse,r.response),r.response.headers=fa.from(r.response.headers))),Promise.reject(r)})}const NA="1.13.6",If={};["object","boolean","number","function","string","symbol"].forEach((t,s)=>{If[t]=function(r){return typeof r===t||"a"+(s<1?"n ":" ")+t}});const i1={};If.transitional=function(s,n,r){function a(l,o){return"[Axios v"+NA+"] Transitional option '"+l+"'"+o+(r?". "+r:"")}return(l,o,d)=>{if(s===!1)throw new zs(a(o," has been removed"+(n?" in "+n:"")),zs.ERR_DEPRECATED);return n&&!i1[o]&&(i1[o]=!0,console.warn(a(o," has been deprecated since v"+n+" and will be removed in the near future"))),s?s(l,o,d):!0}};If.spelling=function(s){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${s}`),!0)};function b5(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 l=r[a],o=s[l];if(o){const d=t[l],m=d===void 0||o(d,l,t);if(m!==!0)throw new zs("option "+l+" must be "+m,zs.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new zs("Unknown option "+l,zs.ERR_BAD_OPTION)}}const Im={assertOptions:b5,validators:If},Ua=Im.validators;let Jo=class{constructor(s){this.defaults=s||{},this.interceptors={request:new Kw,response:new Kw}}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 l=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?l&&!String(r.stack).endsWith(l.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
||
`+l):r.stack=l}catch{}}throw r}}_request(s,n){typeof s=="string"?(n=n||{},n.url=s):n=s||{},n=rc(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:l}=n;r!==void 0&&Im.assertOptions(r,{silentJSONParsing:Ua.transitional(Ua.boolean),forcedJSONParsing:Ua.transitional(Ua.boolean),clarifyTimeoutError:Ua.transitional(Ua.boolean),legacyInterceptorReqResOrdering:Ua.transitional(Ua.boolean)},!1),a!=null&&(Je.isFunction(a)?n.paramsSerializer={serialize:a}:Im.assertOptions(a,{encode:Ua.function,serialize:Ua.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Im.assertOptions(n,{baseUrl:Ua.spelling("baseURL"),withXsrfToken:Ua.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=l&&Je.merge(l.common,l[n.method]);l&&Je.forEach(["delete","get","head","post","put","patch","common"],w=>{delete l[w]}),n.headers=fa.concat(o,l);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 N=n.transitional||Vy;N&&N.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 x,h=0,p;if(!m){const w=[a1.bind(this),void 0];for(w.unshift(...d),w.push(...f),p=w.length,x=Promise.resolve(n);h<p;)x=x.then(w[h++],w[h++]);return x}p=d.length;let u=n;for(;h<p;){const w=d[h++],v=d[h++];try{u=w(u)}catch(N){v.call(this,N);break}}try{x=a1.call(this,u)}catch(w){return Promise.reject(w)}for(h=0,p=f.length;h<p;)x=x.then(f[h++],f[h++]);return x}getUri(s){s=rc(this.defaults,s);const n=vA(s.baseURL,s.url,s.allowAbsoluteUrls);return fA(n,s.params,s.paramsSerializer)}};Je.forEach(["delete","get","head","options"],function(s){Jo.prototype[s]=function(n,r){return this.request(rc(r||{},{method:s,url:n,data:(r||{}).data}))}});Je.forEach(["post","put","patch"],function(s){function n(r){return function(l,o,d){return this.request(rc(d||{},{method:s,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:o}))}}Jo.prototype[s]=n(),Jo.prototype[s+"Form"]=n(!0)});let j5=class wA{constructor(s){if(typeof s!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(l){n=l});const r=this;this.promise.then(a=>{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](a);r._listeners=null}),this.promise.then=a=>{let l;const o=new Promise(d=>{r.subscribe(d),l=d}).then(a);return o.cancel=function(){r.unsubscribe(l)},o},s(function(l,o,d){r.reason||(r.reason=new zu(l,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 wA(function(a){s=a}),cancel:s}}};function N5(t){return function(n){return t.apply(null,n)}}function w5(t){return Je.isObject(t)&&t.isAxiosError===!0}const Xv={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(Xv).forEach(([t,s])=>{Xv[s]=t});function SA(t){const s=new Jo(t),n=nA(Jo.prototype.request,s);return Je.extend(n,Jo.prototype,s,{allOwnKeys:!0}),Je.extend(n,s,null,{allOwnKeys:!0}),n.create=function(a){return SA(rc(t,a))},n}const Qn=SA(qu);Qn.Axios=Jo;Qn.CanceledError=zu;Qn.CancelToken=j5;Qn.isCancel=xA;Qn.VERSION=NA;Qn.toFormData=Lf;Qn.AxiosError=zs;Qn.Cancel=Qn.CanceledError;Qn.all=function(s){return Promise.all(s)};Qn.spread=N5;Qn.isAxiosError=w5;Qn.mergeConfig=rc;Qn.AxiosHeaders=fa;Qn.formToJSON=t=>pA(Je.isHTMLForm(t)?new FormData(t):t);Qn.getAdapter=jA.getAdapter;Qn.HttpStatusCode=Xv;Qn.default=Qn;const{Axios:oY,AxiosError:cY,CanceledError:dY,isCancel:uY,CancelToken:hY,VERSION:mY,all:fY,Cancel:pY,isAxiosError:xY,spread:gY,toFormData:vY,AxiosHeaders:yY,HttpStatusCode:bY,formToJSON:jY,getAdapter:NY,mergeConfig:wY}=Qn,l1="https://dealeronboarding-uat.royalenfield.com/api",Ee={login:t=>$e.post("/auth/login",t),logout:()=>$e.post("/auth/logout"),getCurrentUser:()=>$e.get("/auth/me"),getRoles:()=>$e.get("/admin/roles"),createRole:t=>$e.post("/admin/roles",t),getPermissions:()=>$e.get("/admin/permissions"),updateRole:(t,s)=>$e.put(`/admin/roles/${t}`,s),getZones:()=>$e.get("/master/zones"),createZone:t=>$e.post("/master/zones",t),updateZone:(t,s)=>$e.put(`/master/zones/${t}`,s),createRegion:t=>$e.post("/master/regions",t),updateRegion:(t,s)=>$e.put(`/master/regions/${t}`,s),getRegions:()=>$e.get("/master/regions"),getOutlets:()=>$e.get("/outlets"),getOutletByCode:t=>$e.get(`/master/outlets/code/${t}`),getStates:t=>$e.get("/master/states",typeof t=="string"?{zoneId:t}:t),getDistricts:t=>$e.get("/master/districts",typeof t=="string"?{stateId:t}:t),getAreas:t=>$e.get("/master/areas",t),updateArea:(t,s)=>$e.put(`/master/areas/${t}`,s),createArea:t=>$e.post("/master/areas",t),getAreaManagers:()=>$e.get("/master/area-managers"),getASMs:()=>$e.get("/master/asms"),getZonalManagers:()=>$e.get("/master/zonal-managers"),saveZonalManager:t=>$e.post("/master/zonal-managers",t),getDDLeads:()=>$e.get("/master/dd-leads"),saveDDLead:t=>$e.post("/master/dd-leads",t),getManagersByRole:t=>$e.get("/master/managers",t),submitApplication:t=>$e.post("/onboarding/apply",t),exportApplicationResponses:t=>$e.get("/onboarding/applications/export-responses",t),getApplications:t=>$e.get("/onboarding/applications",t),shortlistApplications:t=>$e.post("/onboarding/applications/shortlist",t),sendBulkReminders:t=>$e.post("/onboarding/applications/reminders",t),getApplicationById:t=>$e.get(`/onboarding/applications/${t}`),updateApplication:(t,s)=>$e.put(`/onboarding/applications/${t}`,s),getLatestQuestionnaire:()=>$e.get("/questionnaire/latest"),createQuestionnaireVersion:t=>$e.post("/questionnaire/version",t),submitQuestionnaireResponse:t=>$e.post("/questionnaire/response",t),getAllQuestionnaires:()=>$e.get("/onboarding/questionnaires"),getQuestionnaireById:t=>$e.get(`/onboarding/questionnaires/${t}`),assignArchitectureTeam:(t,s)=>$e.post(`/onboarding/applications/${t}/assign-architecture`,{assignedTo:s}),updateArchitectureStatus:(t,s,n)=>$e.post(`/onboarding/applications/${t}/architecture-status`,{status:s,remarks:n}),generateDealerCodes:t=>$e.post(`/onboarding/applications/${t}/generate-codes`),requestProspectDocuments:(t,s)=>$e.post(`/onboarding/applications/${t}/request-documents`,s),updateApplicationStatus:(t,s)=>$e.put(`/onboarding/applications/${t}/status`,s),convertToOpportunity:(t,s)=>$e.post(`/onboarding/applications/${t}/convert-to-opportunity`,s),bulkConvertToOpportunity:t=>$e.post("/onboarding/applications/bulk-convert-to-opportunity",t),retriggerEvaluators:t=>$e.post(`/onboarding/applications/${t}/retrigger-evaluators`),getSecurityDeposit:t=>$e.get(`/loa/security-deposit/${t}`),updateSecurityDeposit:t=>$e.post("/loa/security-deposit",t),uploadDocument:(t,s)=>$e.post(`/onboarding/applications/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getDocuments:t=>$e.get(`/onboarding/applications/${t}/documents`),getDocumentConfigMetadata:()=>$e.get("/onboarding/document-configs/metadata"),getDocumentConfigs:t=>$e.get("/onboarding/document-configs",t),createDocumentConfig:t=>$e.post("/onboarding/document-configs",t),updateDocumentConfig:(t,s)=>$e.put(`/onboarding/document-configs/${t}`,s),deleteDocumentConfig:t=>$e.delete(`/onboarding/document-configs/${t}`),getPublicQuestionnaire:t=>Qn.get(`${l1}/questionnaire/public/${t}`),submitPublicResponse:t=>Qn.post(`${l1}/questionnaire/public/submit`,t),getAiSummary:t=>$e.get(`/assessment/ai-summary/${t}`),scheduleInterview:t=>$e.post("/assessment/interviews",t),updateInterview:(t,s)=>$e.put(`/assessment/interviews/${t}`,s),submitEvaluation:(t,s)=>$e.post(`/assessment/interviews/${t}/evaluation`,s),submitKTMatrix:t=>$e.post("/assessment/kt-matrix",t),submitLevel2Feedback:t=>$e.post("/assessment/level2-feedback",t),getInterviews:t=>$e.get(`/assessment/interviews/${t}`),updateRecommendation:t=>$e.post("/assessment/recommendation",t),updateInterviewDecision:t=>$e.post("/assessment/decision",t),submitStageDecision:t=>$e.post("/assessment/stage-decision",t),getInterviewApprovalStatus:t=>$e.get(`/assessment/interviews/${t}/approval-status`),getApprovalPolicies:()=>$e.get("/assessment/approval-policies"),upsertApprovalPolicy:(t,s)=>$e.put(`/assessment/approval-policies/${t}`,s),getWorknotes:(t,s)=>$e.get("/collaboration/worknotes",{requestId:t,requestType:s}),addWorknote:t=>$e.post("/collaboration/worknotes",t),addParticipant:t=>$e.post("/collaboration/participants",t),removeParticipant:t=>$e.delete(`/collaboration/participants/${t}`),getUsers:t=>$e.get("/admin/users",t),createUser:t=>$e.post("/admin/users",t),updateUser:(t,s)=>$e.put(`/admin/users/${t}`,s),updateUserStatus:(t,s)=>$e.patch(`/admin/users/${t}/status`,s),deleteUser:t=>$e.delete(`/admin/users/${t}`),getDealers:t=>$e.get("/dealer",t),createDealer:t=>$e.post("/dealer",t),getDealerById:t=>$e.get(`/dealer/${t}`),updateDealer:(t,s)=>$e.put(`/dealer/${t}`,s),getDealerDashboard:()=>$e.get("/dealer/dashboard"),getDealerBankDetails:t=>$e.get(`/dealer/${t}/bank-details`),saveBankDetail:(t,s)=>$e.post(`/dealer/${t}/bank-details`,s),deleteBankDetail:t=>$e.delete(`/dealer/bank-details/${t}`),getEmailTemplates:()=>$e.get("/admin/email-templates"),getEmailTemplate:t=>$e.get(`/admin/email-templates/${t}`),createEmailTemplate:t=>$e.post("/admin/email-templates",t),updateEmailTemplate:(t,s)=>$e.put(`/admin/email-templates/${t}`,s),deleteEmailTemplate:t=>$e.delete(`/admin/email-templates/${t}`),previewEmailTemplate:t=>$e.post("/admin/email-templates/preview",t),getAuditLogs:(t,s,n=1,r=50)=>$e.get("/audit/logs",{entityType:t,entityId:s,page:n,limit:r}),getAuditSummary:(t,s)=>$e.get("/audit/summary",{entityType:t,entityId:s}),sendOtp:t=>$e.post("/prospective-login/send-otp",{phone:t}),verifyOtp:(t,s)=>$e.post("/prospective-login/verify-otp",{phone:t,otp:s}),getResignationById:t=>$e.get(`/resignation/${t}`),uploadResignationDocument:(t,s)=>$e.post(`/resignation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateClearance:(t,s)=>$e.put(`/resignation/${t}/clearance`,s,{headers:s instanceof FormData?{"Content-Type":"multipart/form-data"}:{}}),updateResignationStatus:(t,s)=>$e.post(`/resignation/${t}/status`,s),getTerminationById:t=>$e.get(`/termination/${t}`),uploadTerminationDocument:(t,s)=>$e.post(`/termination/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),updateTerminationStatus:(t,s)=>$e.post(`/termination/${t}/status`,s),issueSCN:(t,s)=>$e.post(`/termination/${t}/scn`,s),uploadSCNResponse:(t,s)=>$e.post(`/termination/${t}/scn-response`,s,{headers:{"Content-Type":"multipart/form-data"}}),finalizeTermination:(t,s)=>$e.post(`/termination/${t}/finalize`,s),getResignations:t=>$e.get("/resignation",t),createResignation:t=>$e.post("/resignation",t),approveResignation:(t,s)=>$e.post(`/resignation/${t}/approve`,s),dispatchResignation:(t,s)=>$e.post(`/resignation/${t}/dispatch`,s),rejectResignation:(t,s)=>$e.post(`/resignation/${t}/reject`,s),withdrawResignation:(t,s)=>$e.post(`/resignation/${t}/withdraw`,{reason:s}),getTerminations:t=>$e.get("/termination",t),createTermination:t=>{const s=typeof FormData<"u"&&t instanceof FormData;return $e.post("/termination",t,s?{headers:{"Content-Type":"multipart/form-data"}}:void 0)},updateTermination:(t,s)=>$e.post(`/termination/${t}/status`,s),getOnboardingPayments:()=>$e.get("/settlement/onboarding"),updatePayment:(t,s)=>$e.put(`/settlement/payments/${t}`,s),getFnFSettlements:()=>$e.get("/settlement/fnf"),getFnFSettlementById:t=>$e.get(`/settlement/fnf/${t}`),calculateFnF:t=>$e.post(`/settlement/fnf/${t}/calculate`),updateFnF:(t,s)=>$e.put(`/settlement/fnf/${t}`,s),uploadFnFDocument:(t,s)=>$e.post(`/settlement/fnf/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),getSettlementDepartments:()=>$e.get("/settlement/departments"),addLineItem:(t,s)=>$e.post(`/settlement/fnf/${t}/line-items`,s),updateFnFClearance:(t,s,n)=>$e.put(`/settlement/fnf/${t}/clearances/${s}`,n,{headers:{"Content-Type":"multipart/form-data"}}),updateLineItem:(t,s)=>$e.put(`/settlement/fnf/line-items/${t}`,s),deleteLineItem:t=>$e.delete(`/settlement/fnf/line-items/${t}`),getRelocationRequests:t=>$e.get("/relocation",t),getRelocationRequestById:t=>$e.get(`/relocation/${t}`),createRelocationRequest:t=>$e.post("/relocation",t),updateRelocationRequest:(t,s,n)=>$e.post(`/relocation/${t}/action`,{action:s,...n}),uploadRelocationDocument:(t,s)=>$e.post(`/relocation/${t}/documents`,s,{headers:{"Content-Type":"multipart/form-data"}}),verifyRelocationDocument:(t,s)=>$e.post(`/relocation/${t}/documents/${s}/verify`),rejectRelocationDocument:(t,s,n)=>$e.post(`/relocation/${t}/documents/${s}/reject`,n||{}),getConstitutionalChanges:t=>$e.get("/constitutional-change",t),getConstitutionalChangeMeta:()=>$e.get("/constitutional-change/meta"),getConstitutionalChangeById:t=>$e.get(`/constitutional-change/${t}`),createConstitutionalChange:t=>$e.post("/constitutional-change",t),updateConstitutionalChange:(t,s,n)=>$e.post(`/constitutional-change/${t}/action`,{action:s,...n}),uploadConstitutionalDocuments:(t,s)=>$e.post(`/constitutional-change/${t}/documents`,{documents:s}),verifyConstitutionalDocument:(t,s)=>$e.post(`/constitutional-change/${t}/documents/${s}/verify`),rejectConstitutionalDocument:(t,s,n)=>$e.post(`/constitutional-change/${t}/documents/${s}/reject`,n||{}),getSlaConfigs:()=>$e.get("/master/sla-configs"),saveSlaConfig:t=>$e.post("/master/sla-configs",t),initializeDefaultSlas:()=>$e.post("/master/sla-configs/initialize"),getSlaOperationsDashboard:t=>$e.get("/sla/operations/dashboard",t),postSlaBatchStatus:t=>$e.post("/sla/status/batch",t),getQuestionnaireReminderSettings:()=>$e.get("/sla/settings/questionnaire-reminder"),updateQuestionnaireReminderSettings:t=>$e.put("/sla/settings/questionnaire-reminder",t),getInterviewConfigs:t=>$e.get("/master/interview-configs",t),getInterviewConfigById:t=>$e.get(`/master/interview-configs/${t}`),getInterviewConfigByType:t=>$e.get(`/master/interview-configs/active/${t}`),createInterviewConfig:t=>$e.post("/master/interview-configs",t),updateInterviewConfig:(t,s)=>$e.put(`/master/interview-configs/${t}`,s),deleteInterviewConfig:t=>$e.delete(`/master/interview-configs/${t}`),initializeDefaultInterviewConfigs:()=>$e.post("/master/interview-configs/initialize"),getSystemConfigs:t=>$e.get("/master/system-configs",t),saveSystemConfig:t=>$e.post("/master/system-configs",t),getDealerAsmMappings:()=>$e.get("/master/dealer-asm-mappings"),saveDealerAsmMapping:t=>$e.post("/master/dealer-asm-mappings",t),getEorChecklistForApplication:t=>$e.get(`/eor/application/${t}`),getEorChecklistForRelocation:t=>$e.get(`/eor/relocation/${t}`),updateEorChecklistItem:(t,s)=>$e.post(`/eor/item/${t}`,s),submitEorAudit:(t,s)=>$e.post(`/eor/audit/${t}`,s),submitFddReport:t=>$e.post("/fdd/report",t),getFddAssignment:t=>$e.get(`/fdd/${t}`),assignFddAgency:t=>$e.post("/fdd/assign",t),flagNonResponsive:t=>$e.post("/flag",t),getSystemAuditLogs:t=>$e.get("/audit/system-logs",t),getSystemAuditSummary:()=>$e.get("/audit/system-summary")},cm=Object.freeze(Object.defineProperty({__proto__:null,API:Ee,default:Ee},Symbol.toStringTag,{value:"Module"})),S5={user:null,token:localStorage.getItem("token"),isAuthenticated:!1,loading:!0,error:null},Mm=EP("auth/initializeAuth",async(t,{rejectWithValue:s})=>{const n=localStorage.getItem("token");if(!n)return s("No token found");try{const r=await Ee.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")}}),CA=sA({name:"auth",initialState:S5,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(Mm.pending,s=>{s.loading=!0}).addCase(Mm.fulfilled,(s,n)=>{s.user=n.payload.user,s.token=n.payload.token,s.isAuthenticated=!0,s.loading=!1}).addCase(Mm.rejected,s=>{s.user=null,s.token=null,s.isAuthenticated=!1,s.loading=!1,localStorage.removeItem("token")})}}),{setCredentials:AA,logout:kA,setLoading:SY}=CA.actions,C5=CA.reducer,A5={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},DA=sA({name:"master",initialState:A5,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:RA,setZones:CY,setRegionalOffices:AY,setAsms:kY,setZonalManagerMappings:DY,setUsers:RY,setLoading:o1,setError:k5,setAreasData:D5,setAreasLoading:c1,setDdLeads:EY}=DA.actions,R5=DA.reducer,E5=jP({reducer:{auth:C5,master:R5}});var Uu=Iy();const Gy=wf(Uu);/**
|
||
* @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 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)}var Yl;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Yl||(Yl={}));const d1="popstate";function _5(t){t===void 0&&(t={});function s(r,a){let{pathname:l,search:o,hash:d}=r.location;return Jv("",{pathname:l,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:EA(a)}return P5(s,n,null,t)}function lr(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Ky(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function T5(){return Math.random().toString(36).substr(2,8)}function u1(t,s){return{usr:t.state,key:t.key,idx:s}}function Jv(t,s,n,r){return n===void 0&&(n=null),Cu({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?xd(s):s,{state:n,key:s&&s.key||r||T5()})}function EA(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 P5(t,s,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:l=!1}=r,o=a.history,d=Yl.Pop,m=null,f=x();f==null&&(f=0,o.replaceState(Cu({},o.state,{idx:f}),""));function x(){return(o.state||{idx:null}).idx}function h(){d=Yl.Pop;let N=x(),j=N==null?null:N-f;f=N,m&&m({action:d,location:v.location,delta:j})}function p(N,j){d=Yl.Push;let y=Jv(v.location,N,j);f=x()+1;let C=u1(y,f),S=v.createHref(y);try{o.pushState(C,"",S)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;a.location.assign(S)}l&&m&&m({action:d,location:v.location,delta:1})}function u(N,j){d=Yl.Replace;let y=Jv(v.location,N,j);f=x();let C=u1(y,f),S=v.createHref(y);o.replaceState(C,"",S),l&&m&&m({action:d,location:v.location,delta:0})}function w(N){let j=a.location.origin!=="null"?a.location.origin:a.location.href,y=typeof N=="string"?N:EA(N);return y=y.replace(/ $/,"%20"),lr(j,"No window.location.(origin|href) available to create URL for href: "+y),new URL(y,j)}let v={get action(){return d},get location(){return t(a,o)},listen(N){if(m)throw new Error("A history only accepts one active listener");return a.addEventListener(d1,h),m=N,()=>{a.removeEventListener(d1,h),m=null}},createHref(N){return s(a,N)},createURL:w,encodeLocation(N){let j=w(N);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:p,replace:u,go(N){return o.go(N)}};return v}var h1;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(h1||(h1={}));function O5(t,s,n){return n===void 0&&(n="/"),L5(t,s,n)}function L5(t,s,n,r){let a=typeof s=="string"?xd(s):s,l=PA(a.pathname||"/",n);if(l==null)return null;let o=_A(t);I5(o);let d=null;for(let m=0;d==null&&m<o.length;++m){let f=K5(l);d=H5(o[m],f)}return d}function _A(t,s,n,r){s===void 0&&(s=[]),n===void 0&&(n=[]),r===void 0&&(r="");let a=(l,o,d)=>{let m={relativePath:d===void 0?l.path||"":d,caseSensitive:l.caseSensitive===!0,childrenIndex:o,route:l};m.relativePath.startsWith("/")&&(lr(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=ec([r,m.relativePath]),x=n.concat(m);l.children&&l.children.length>0&&(lr(l.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+f+'".')),_A(l.children,s,x,f)),!(l.path==null&&!l.index)&&s.push({path:f,score:U5(f,l.index),routesMeta:x})};return t.forEach((l,o)=>{var d;if(l.path===""||!((d=l.path)!=null&&d.includes("?")))a(l,o);else for(let m of TA(l.path))a(l,o,m)}),s}function TA(t){let s=t.split("/");if(s.length===0)return[];let[n,...r]=s,a=n.endsWith("?"),l=n.replace(/\?$/,"");if(r.length===0)return a?[l,""]:[l];let o=TA(r.join("/")),d=[];return d.push(...o.map(m=>m===""?l:[l,m].join("/"))),a&&d.push(...o),d.map(m=>t.startsWith("/")&&m===""?"/":m)}function I5(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:V5(s.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const M5=/^:[\w-]+$/,F5=3,B5=2,$5=1,q5=10,z5=-2,m1=t=>t==="*";function U5(t,s){let n=t.split("/"),r=n.length;return n.some(m1)&&(r+=z5),s&&(r+=B5),n.filter(a=>!m1(a)).reduce((a,l)=>a+(M5.test(l)?F5:l===""?$5:q5),r)}function V5(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 H5(t,s,n){let{routesMeta:r}=t,a={},l="/",o=[];for(let d=0;d<r.length;++d){let m=r[d],f=d===r.length-1,x=l==="/"?s:s.slice(l.length)||"/",h=W5({path:m.relativePath,caseSensitive:m.caseSensitive,end:f},x),p=m.route;if(!h)return null;Object.assign(a,h.params),o.push({params:a,pathname:ec([l,h.pathname]),pathnameBase:J5(ec([l,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(l=ec([l,h.pathnameBase]))}return o}function W5(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=G5(t.path,t.caseSensitive,t.end),a=s.match(n);if(!a)return null;let l=a[0],o=l.replace(/(.)\/+$/,"$1"),d=a.slice(1);return{params:r.reduce((f,x,h)=>{let{paramName:p,isOptional:u}=x;if(p==="*"){let v=d[h]||"";o=l.slice(0,l.length-v.length).replace(/(.)\/+$/,"$1")}const w=d[h];return u&&!w?f[p]=void 0:f[p]=(w||"").replace(/%2F/g,"/"),f},{}),pathname:l,pathnameBase:o,pattern:t}}function G5(t,s,n){s===void 0&&(s=!1),n===void 0&&(n=!0),Ky(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 K5(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Ky(!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 PA(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 Y5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Z5=t=>Y5.test(t);function Q5(t,s){s===void 0&&(s="/");let{pathname:n,search:r="",hash:a=""}=typeof t=="string"?xd(t):t,l;if(n)if(Z5(n))l=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Ky(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?l=f1(n.substring(1),"/"):l=f1(n,s)}else l=s;return{pathname:l,search:eL(r),hash:tL(a)}}function f1(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 xg(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 X5(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function OA(t,s){let n=X5(t);return s?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function LA(t,s,n,r){r===void 0&&(r=!1);let a;typeof t=="string"?a=xd(t):(a=Cu({},t),lr(!a.pathname||!a.pathname.includes("?"),xg("?","pathname","search",a)),lr(!a.pathname||!a.pathname.includes("#"),xg("#","pathname","hash",a)),lr(!a.search||!a.search.includes("#"),xg("#","search","hash",a)));let l=t===""||a.pathname==="",o=l?"/":a.pathname,d;if(o==null)d=n;else{let h=s.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}d=h>=0?s[h]:"/"}let m=Q5(a,d),f=o&&o!=="/"&&o.endsWith("/"),x=(l||o===".")&&n.endsWith("/");return!m.pathname.endsWith("/")&&(f||x)&&(m.pathname+="/"),m}const ec=t=>t.join("/").replace(/\/\/+/g,"/"),J5=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),eL=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,tL=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function sL(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const IA=["post","put","patch","delete"];new Set(IA);const nL=["get",...IA];new Set(nL);/**
|
||
* 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 Au(){return Au=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},Au.apply(this,arguments)}const Yy=g.createContext(null),rL=g.createContext(null),Vu=g.createContext(null),Mf=g.createContext(null),yl=g.createContext({outlet:null,matches:[],isDataRoute:!1}),MA=g.createContext(null);function Hu(){return g.useContext(Mf)!=null}function Ui(){return Hu()||lr(!1),g.useContext(Mf).location}function FA(t){g.useContext(Vu).static||g.useLayoutEffect(t)}function tr(){let{isDataRoute:t}=g.useContext(yl);return t?yL():aL()}function aL(){Hu()||lr(!1);let t=g.useContext(Yy),{basename:s,future:n,navigator:r}=g.useContext(Vu),{matches:a}=g.useContext(yl),{pathname:l}=Ui(),o=JSON.stringify(OA(a,n.v7_relativeSplatPath)),d=g.useRef(!1);return FA(()=>{d.current=!0}),g.useCallback(function(f,x){if(x===void 0&&(x={}),!d.current)return;if(typeof f=="number"){r.go(f);return}let h=LA(f,JSON.parse(o),l,x.relative==="path");t==null&&s!=="/"&&(h.pathname=h.pathname==="/"?s:ec([s,h.pathname])),(x.replace?r.replace:r.push)(h,x.state,x)},[s,r,o,l,t])}const iL=g.createContext(null);function lL(t){let s=g.useContext(yl).outlet;return s&&g.createElement(iL.Provider,{value:t},s)}function gd(){let{matches:t}=g.useContext(yl),s=t[t.length-1];return s?s.params:{}}function oL(t,s){return cL(t,s)}function cL(t,s,n,r){Hu()||lr(!1);let{navigator:a}=g.useContext(Vu),{matches:l}=g.useContext(yl),o=l[l.length-1],d=o?o.params:{};o&&o.pathname;let m=o?o.pathnameBase:"/";o&&o.route;let f=Ui(),x;if(s){var h;let N=typeof s=="string"?xd(s):s;m==="/"||(h=N.pathname)!=null&&h.startsWith(m)||lr(!1),x=N}else x=f;let p=x.pathname||"/",u=p;if(m!=="/"){let N=m.replace(/^\//,"").split("/");u="/"+p.replace(/^\//,"").split("/").slice(N.length).join("/")}let w=O5(t,{pathname:u}),v=fL(w&&w.map(N=>Object.assign({},N,{params:Object.assign({},d,N.params),pathname:ec([m,a.encodeLocation?a.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?m:ec([m,a.encodeLocation?a.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),l,n,r);return s&&v?g.createElement(Mf.Provider,{value:{location:Au({pathname:"/",search:"",hash:"",state:null,key:"default"},x),navigationType:Yl.Pop}},v):v}function dL(){let t=vL(),s=sL(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 uL=g.createElement(dL,null);class hL 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(yl.Provider,{value:this.props.routeContext},g.createElement(MA.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function mL(t){let{routeContext:s,match:n,children:r}=t,a=g.useContext(Yy);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(yl.Provider,{value:s},r)}function fL(t,s,n,r){var a;if(s===void 0&&(s=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var l;if(!n)return null;if(n.errors)t=n.matches;else if((l=r)!=null&&l.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 x=o.findIndex(h=>h.route.id&&(d==null?void 0:d[h.route.id])!==void 0);x>=0||lr(!1),o=o.slice(0,Math.min(o.length,x+1))}let m=!1,f=-1;if(n&&r&&r.v7_partialHydration)for(let x=0;x<o.length;x++){let h=o[x];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(f=x),h.route.id){let{loaderData:p,errors:u}=n,w=h.route.loader&&p[h.route.id]===void 0&&(!u||u[h.route.id]===void 0);if(h.route.lazy||w){m=!0,f>=0?o=o.slice(0,f+1):o=[o[0]];break}}}return o.reduceRight((x,h,p)=>{let u,w=!1,v=null,N=null;n&&(u=d&&h.route.id?d[h.route.id]:void 0,v=h.route.errorElement||uL,m&&(f<0&&p===0?(bL("route-fallback"),w=!0,N=null):f===p&&(w=!0,N=h.route.hydrateFallbackElement||null)));let j=s.concat(o.slice(0,p+1)),y=()=>{let C;return u?C=v:w?C=N:h.route.Component?C=g.createElement(h.route.Component,null):h.route.element?C=h.route.element:C=x,g.createElement(mL,{match:h,routeContext:{outlet:x,matches:j,isDataRoute:n!=null},children:C})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?g.createElement(hL,{location:n.location,revalidation:n.revalidation,component:v,error:u,children:y(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):y()},null)}var BA=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(BA||{}),$A=(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})($A||{});function pL(t){let s=g.useContext(Yy);return s||lr(!1),s}function xL(t){let s=g.useContext(rL);return s||lr(!1),s}function gL(t){let s=g.useContext(yl);return s||lr(!1),s}function qA(t){let s=gL(),n=s.matches[s.matches.length-1];return n.route.id||lr(!1),n.route.id}function vL(){var t;let s=g.useContext(MA),n=xL(),r=qA();return s!==void 0?s:(t=n.errors)==null?void 0:t[r]}function yL(){let{router:t}=pL(BA.UseNavigateStable),s=qA($A.UseNavigateStable),n=g.useRef(!1);return FA(()=>{n.current=!0}),g.useCallback(function(a,l){l===void 0&&(l={}),n.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Au({fromRouteId:s},l)))},[t,s])}const p1={};function bL(t,s,n){p1[t]||(p1[t]=!0)}function jL(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Zn(t){let{to:s,replace:n,state:r,relative:a}=t;Hu()||lr(!1);let{future:l,static:o}=g.useContext(Vu),{matches:d}=g.useContext(yl),{pathname:m}=Ui(),f=tr(),x=LA(s,OA(d,l.v7_relativeSplatPath),m,a==="path"),h=JSON.stringify(x);return g.useEffect(()=>f(JSON.parse(h),{replace:n,state:r,relative:a}),[f,h,a,n,r]),null}function NL(t){return lL(t.context)}function Rs(t){lr(!1)}function wL(t){let{basename:s="/",children:n=null,location:r,navigationType:a=Yl.Pop,navigator:l,static:o=!1,future:d}=t;Hu()&&lr(!1);let m=s.replace(/^\/*/,"/"),f=g.useMemo(()=>({basename:m,navigator:l,static:o,future:Au({v7_relativeSplatPath:!1},d)}),[m,d,l,o]);typeof r=="string"&&(r=xd(r));let{pathname:x="/",search:h="",hash:p="",state:u=null,key:w="default"}=r,v=g.useMemo(()=>{let N=PA(x,m);return N==null?null:{location:{pathname:N,search:h,hash:p,state:u,key:w},navigationType:a}},[m,x,h,p,u,w,a]);return v==null?null:g.createElement(Vu.Provider,{value:f},g.createElement(Mf.Provider,{children:n,value:v}))}function ey(t){let{children:s,location:n}=t;return oL(ty(s),n)}new Promise(()=>{});function ty(t,s){s===void 0&&(s=[]);let n=[];return g.Children.forEach(t,(r,a)=>{if(!g.isValidElement(r))return;let l=[...s,a];if(r.type===g.Fragment){n.push.apply(n,ty(r.props.children,l));return}r.type!==Rs&&lr(!1),!r.props.index||!r.props.children||lr(!1);let o={id:r.props.id||l.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=ty(r.props.children,l)),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 SL="6";try{window.__reactRouterVersion=SL}catch{}const CL="startTransition",x1=Sf[CL];function AL(t){let{basename:s,children:n,future:r,window:a}=t,l=g.useRef();l.current==null&&(l.current=_5({window:a,v5Compat:!0}));let o=l.current,[d,m]=g.useState({action:o.action,location:o.location}),{v7_startTransition:f}=r||{},x=g.useCallback(h=>{f&&x1?x1(()=>m(h)):m(h)},[m,f]);return g.useLayoutEffect(()=>o.listen(x),[o,x]),g.useEffect(()=>jL(r),[r]),g.createElement(wL,{basename:s,children:n,location:d.location,navigationType:d.action,navigator:o,future:r})}var g1;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(g1||(g1={}));var v1;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(v1||(v1={}));const y1=({children:t,allowedRoles:s,excludeRoles:n,redirectTo:r})=>{const{user:a,isAuthenticated:l,loading:o}=Fn(h=>h.auth),d=Ui(),m=String((a==null?void 0:a.role)||(a==null?void 0:a.roleCode)||"").trim().toLowerCase(),f=(s||[]).map(h=>String(h).trim().toLowerCase()),x=(n||[]).map(h=>String(h).trim().toLowerCase());return o?e.jsx("div",{className:"flex h-screen items-center justify-center",children:"Loading..."}):l?n&&a&&x.includes(m)?m==="prospective dealer"?e.jsx(Zn,{to:"/prospective-dashboard",replace:!0}):e.jsx(Zn,{to:r||"/dashboard",replace:!0}):s&&a&&!f.includes(m)?e.jsx(Zn,{to:r||"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Zn,{to:"/admin-login",state:{from:d},replace:!0})};function b1(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function Xr(...t){return s=>{let n=!1;const r=t.map(a=>{const l=b1(a,s);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let a=0;a<r.length;a++){const l=r[a];typeof l=="function"?l():b1(t[a],null)}}}}function Ks(...t){return g.useCallback(Xr(...t),t)}var kL=Symbol.for("react.lazy"),rf=Sf[" use ".trim().toString()];function DL(t){return typeof t=="object"&&t!==null&&"then"in t}function zA(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===kL&&"_payload"in t&&DL(t._payload)}function Wu(t){const s=RL(t),n=g.forwardRef((r,a)=>{let{children:l,...o}=r;zA(l)&&typeof rf=="function"&&(l=rf(l._payload));const d=g.Children.toArray(l),m=d.find(_L);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}var UA=Wu("Slot");function RL(t){const s=g.forwardRef((n,r)=>{let{children:a,...l}=n;if(zA(a)&&typeof rf=="function"&&(a=rf(a._payload)),g.isValidElement(a)){const o=PL(a),d=TL(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 EL=Symbol("radix.slottable");function _L(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===EL}function TL(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function PL(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 VA(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=VA(t[s]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function HA(){for(var t,s,n=0,r="",a=arguments.length;n<a;n++)(t=arguments[n])&&(s=VA(t))&&(r&&(r+=" "),r+=s);return r}const j1=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,N1=HA,Zy=(t,s)=>n=>{var r;if((s==null?void 0:s.variants)==null)return N1(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:l}=s,o=Object.keys(a).map(f=>{const x=n==null?void 0:n[f],h=l==null?void 0:l[f];if(x===null)return null;const p=j1(x)||j1(h);return a[f][p]}),d=n&&Object.entries(n).reduce((f,x)=>{let[h,p]=x;return p===void 0||(f[h]=p),f},{}),m=s==null||(r=s.compoundVariants)===null||r===void 0?void 0:r.reduce((f,x)=>{let{class:h,className:p,...u}=x;return Object.entries(u).every(w=>{let[v,N]=w;return Array.isArray(N)?N.includes({...l,...d}[v]):{...l,...d}[v]===N})?[...f,h,p]:f},[]);return N1(t,o,m,n==null?void 0:n.class,n==null?void 0:n.className)},Qy="-",OL=t=>{const s=IL(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const d=o.split(Qy);return d[0]===""&&d.length!==1&&d.shift(),WA(d,s)||LL(o)},getConflictingClassGroupIds:(o,d)=>{const m=n[o]||[];return d&&r[o]?[...m,...r[o]]:m}}},WA=(t,s)=>{var o;if(t.length===0)return s.classGroupId;const n=t[0],r=s.nextPart.get(n),a=r?WA(t.slice(1),r):void 0;if(a)return a;if(s.validators.length===0)return;const l=t.join(Qy);return(o=s.validators.find(({validator:d})=>d(l)))==null?void 0:o.classGroupId},w1=/^\[(.+)\]$/,LL=t=>{if(w1.test(t)){const s=w1.exec(t)[1],n=s==null?void 0:s.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},IL=t=>{const{theme:s,prefix:n}=t,r={nextPart:new Map,validators:[]};return FL(Object.entries(t.classGroups),n).forEach(([l,o])=>{sy(o,r,l,s)}),r},sy=(t,s,n,r)=>{t.forEach(a=>{if(typeof a=="string"){const l=a===""?s:S1(s,a);l.classGroupId=n;return}if(typeof a=="function"){if(ML(a)){sy(a(r),s,n,r);return}s.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([l,o])=>{sy(o,S1(s,l),n,r)})})},S1=(t,s)=>{let n=t;return s.split(Qy).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},ML=t=>t.isThemeGetter,FL=(t,s)=>s?t.map(([n,r])=>{const a=r.map(l=>typeof l=="string"?s+l:typeof l=="object"?Object.fromEntries(Object.entries(l).map(([o,d])=>[s+o,d])):l);return[n,a]}):t,BL=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,r=new Map;const a=(l,o)=>{n.set(l,o),s++,s>t&&(s=0,r=n,n=new Map)};return{get(l){let o=n.get(l);if(o!==void 0)return o;if((o=r.get(l))!==void 0)return a(l,o),o},set(l,o){n.has(l)?n.set(l,o):a(l,o)}}},GA="!",$L=t=>{const{separator:s,experimentalParseClassName:n}=t,r=s.length===1,a=s[0],l=s.length,o=d=>{const m=[];let f=0,x=0,h;for(let N=0;N<d.length;N++){let j=d[N];if(f===0){if(j===a&&(r||d.slice(N,N+l)===s)){m.push(d.slice(x,N)),x=N+l;continue}if(j==="/"){h=N;continue}}j==="["?f++:j==="]"&&f--}const p=m.length===0?d:d.substring(x),u=p.startsWith(GA),w=u?p.substring(1):p,v=h&&h>x?h-x:void 0;return{modifiers:m,hasImportantModifier:u,baseClassName:w,maybePostfixModifierPosition:v}};return n?d=>n({className:d,parseClassName:o}):o},qL=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},zL=t=>({cache:BL(t.cacheSize),parseClassName:$L(t),...OL(t)}),UL=/\s+/,VL=(t,s)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a}=s,l=[],o=t.trim().split(UL);let d="";for(let m=o.length-1;m>=0;m-=1){const f=o[m],{modifiers:x,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:u}=n(f);let w=!!u,v=r(w?p.substring(0,u):p);if(!v){if(!w){d=f+(d.length>0?" "+d:d);continue}if(v=r(p),!v){d=f+(d.length>0?" "+d:d);continue}w=!1}const N=qL(x).join(":"),j=h?N+GA:N,y=j+v;if(l.includes(y))continue;l.push(y);const C=a(v,w);for(let S=0;S<C.length;++S){const D=C[S];l.push(j+D)}d=f+(d.length>0?" "+d:d)}return d};function HL(){let t=0,s,n,r="";for(;t<arguments.length;)(s=arguments[t++])&&(n=KA(s))&&(r&&(r+=" "),r+=n);return r}const KA=t=>{if(typeof t=="string")return t;let s,n="";for(let r=0;r<t.length;r++)t[r]&&(s=KA(t[r]))&&(n&&(n+=" "),n+=s);return n};function WL(t,...s){let n,r,a,l=o;function o(m){const f=s.reduce((x,h)=>h(x),t());return n=zL(f),r=n.cache.get,a=n.cache.set,l=d,d(m)}function d(m){const f=r(m);if(f)return f;const x=VL(m,n);return a(m,x),x}return function(){return l(HL.apply(null,arguments))}}const Mn=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},YA=/^\[(?:([a-z-]+):)?(.+)\]$/i,GL=/^\d+\/\d+$/,KL=new Set(["px","full","screen"]),YL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ZL=/\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$/,QL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,XL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,JL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ll=t=>Zc(t)||KL.has(t)||GL.test(t),Hl=t=>vd(t,"length",lI),Zc=t=>!!t&&!Number.isNaN(Number(t)),gg=t=>vd(t,"number",Zc),tu=t=>!!t&&Number.isInteger(Number(t)),eI=t=>t.endsWith("%")&&Zc(t.slice(0,-1)),Qs=t=>YA.test(t),Wl=t=>YL.test(t),tI=new Set(["length","size","percentage"]),sI=t=>vd(t,tI,ZA),nI=t=>vd(t,"position",ZA),rI=new Set(["image","url"]),aI=t=>vd(t,rI,cI),iI=t=>vd(t,"",oI),su=()=>!0,vd=(t,s,n)=>{const r=YA.exec(t);return r?r[1]?typeof s=="string"?r[1]===s:s.has(r[1]):n(r[2]):!1},lI=t=>ZL.test(t)&&!QL.test(t),ZA=()=>!1,oI=t=>XL.test(t),cI=t=>JL.test(t),dI=()=>{const t=Mn("colors"),s=Mn("spacing"),n=Mn("blur"),r=Mn("brightness"),a=Mn("borderColor"),l=Mn("borderRadius"),o=Mn("borderSpacing"),d=Mn("borderWidth"),m=Mn("contrast"),f=Mn("grayscale"),x=Mn("hueRotate"),h=Mn("invert"),p=Mn("gap"),u=Mn("gradientColorStops"),w=Mn("gradientColorStopPositions"),v=Mn("inset"),N=Mn("margin"),j=Mn("opacity"),y=Mn("padding"),C=Mn("saturate"),S=Mn("scale"),D=Mn("sepia"),R=Mn("skew"),A=Mn("space"),L=Mn("translate"),$=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto",Qs,s],O=()=>[Qs,s],I=()=>["",ll,Hl],q=()=>["auto",Zc,Qs],G=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Y=()=>["solid","dashed","dotted","double","none"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>["start","end","center","between","around","evenly","stretch"],_=()=>["","0",Qs],z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>[Zc,Qs];return{cacheSize:500,separator:":",theme:{colors:[su],spacing:[ll,Hl],blur:["none","",Wl,Qs],brightness:T(),borderColor:[t],borderRadius:["none","","full",Wl,Qs],borderSpacing:O(),borderWidth:I(),contrast:T(),grayscale:_(),hueRotate:T(),invert:_(),gap:O(),gradientColorStops:[t],gradientColorStopPositions:[eI,Hl],inset:E(),margin:E(),opacity:T(),padding:O(),saturate:T(),scale:T(),sepia:_(),skew:T(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",Qs]}],container:["container"],columns:[{columns:[Wl]}],"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:[...G(),Qs]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],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",tu,Qs]}],basis:[{basis:E()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Qs]}],grow:[{grow:_()}],shrink:[{shrink:_()}],order:[{order:["first","last","none",tu,Qs]}],"grid-cols":[{"grid-cols":[su]}],"col-start-end":[{col:["auto",{span:["full",tu,Qs]},Qs]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[su]}],"row-start-end":[{row:["auto",{span:[tu,Qs]},Qs]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Qs]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Qs]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...Q()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Q(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Q(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[N]}],mx:[{mx:[N]}],my:[{my:[N]}],ms:[{ms:[N]}],me:[{me:[N]}],mt:[{mt:[N]}],mr:[{mr:[N]}],mb:[{mb:[N]}],ml:[{ml:[N]}],"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",Qs,s]}],"min-w":[{"min-w":[Qs,s,"min","max","fit"]}],"max-w":[{"max-w":[Qs,s,"none","full","min","max","fit","prose",{screen:[Wl]},Wl]}],h:[{h:[Qs,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Qs,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Qs,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Qs,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Wl,Hl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",gg]}],"font-family":[{font:[su]}],"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",Qs]}],"line-clamp":[{"line-clamp":["none",Zc,gg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ll,Qs]}],"list-image":[{"list-image":["none",Qs]}],"list-style-type":[{list:["none","disc","decimal",Qs]}],"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:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ll,Hl]}],"underline-offset":[{"underline-offset":["auto",ll,Qs]}],"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:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Qs]}],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",Qs]}],"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:[...G(),nI]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",sI]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},aI]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[w]}],"gradient-via-pos":[{via:[w]}],"gradient-to-pos":[{to:[w]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[l]}],"rounded-s":[{"rounded-s":[l]}],"rounded-e":[{"rounded-e":[l]}],"rounded-t":[{"rounded-t":[l]}],"rounded-r":[{"rounded-r":[l]}],"rounded-b":[{"rounded-b":[l]}],"rounded-l":[{"rounded-l":[l]}],"rounded-ss":[{"rounded-ss":[l]}],"rounded-se":[{"rounded-se":[l]}],"rounded-ee":[{"rounded-ee":[l]}],"rounded-es":[{"rounded-es":[l]}],"rounded-tl":[{"rounded-tl":[l]}],"rounded-tr":[{"rounded-tr":[l]}],"rounded-br":[{"rounded-br":[l]}],"rounded-bl":[{"rounded-bl":[l]}],"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:[...Y(),"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:Y()}],"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:["",...Y()]}],"outline-offset":[{"outline-offset":[ll,Qs]}],"outline-w":[{outline:[ll,Hl]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[ll,Hl]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Wl,iI]}],"shadow-color":[{shadow:[su]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...V(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":V()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[m]}],"drop-shadow":[{"drop-shadow":["","none",Wl,Qs]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[x]}],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":[x]}],"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",Qs]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",Qs]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",Qs]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[tu,Qs]}],"translate-x":[{"translate-x":[L]}],"translate-y":[{"translate-y":[L]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Qs]}],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",Qs]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"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",Qs]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ll,Hl,gg]}],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"]}}},uI=WL(dI);function jt(...t){return uI(HA(t))}function Gt(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=Zy("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"}}),se=g.forwardRef(({className:t,variant:s,size:n,asChild:r=!1,...a},l)=>{const o=r?UA:"button";return e.jsx(o,{"data-slot":"button",className:jt(nd({variant:s,size:n,className:t})),ref:l,...a})});se.displayName="Button";const at=g.forwardRef(({className:t,type:s,...n},r)=>e.jsx("input",{type:s,ref:r,"data-slot":"input",className:jt("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}));at.displayName="Input";function Gs({className:t,...s}){return e.jsx("textarea",{"data-slot":"textarea",className:jt("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 hI(t,s){const n=g.createContext(s),r=l=>{const{children:o,...d}=l,m=g.useMemo(()=>d,Object.values(d));return e.jsx(n.Provider,{value:m,children:o})};r.displayName=t+"Provider";function a(l){const o=g.useContext(n);if(o)return o;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${t}\``)}return[r,a]}function ga(t,s=[]){let n=[];function r(l,o){const d=g.createContext(o),m=n.length;n=[...n,o];const f=h=>{var j;const{scope:p,children:u,...w}=h,v=((j=p==null?void 0:p[t])==null?void 0:j[m])||d,N=g.useMemo(()=>w,Object.values(w));return e.jsx(v.Provider,{value:N,children:u})};f.displayName=l+"Provider";function x(h,p){var v;const u=((v=p==null?void 0:p[t])==null?void 0:v[m])||d,w=g.useContext(u);if(w)return w;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${l}\``)}return[f,x]}const a=()=>{const l=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||l;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,mI(a,...s)]}function mI(...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(l){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(l)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}function Wt(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 cr=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},fI=Sf[" useInsertionEffect ".trim().toString()]||cr;function $i({prop:t,defaultProp:s,onChange:n=()=>{},caller:r}){const[a,l,o]=pI({defaultProp:s,onChange:n}),d=t!==void 0,m=d?t:a;{const x=g.useRef(t!==void 0);g.useEffect(()=>{const h=x.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.`),x.current=d},[d,r])}const f=g.useCallback(x=>{var h;if(d){const p=xI(x)?x(t):x;p!==t&&((h=o.current)==null||h.call(o,p))}else l(x)},[d,t,l,o]);return[m,f]}function pI({defaultProp:t,onChange:s}){const[n,r]=g.useState(t),a=g.useRef(n),l=g.useRef(s);return fI(()=>{l.current=s},[s]),g.useEffect(()=>{var o;a.current!==n&&((o=l.current)==null||o.call(l,n),a.current=n)},[n,a]),[n,r,l]}function xI(t){return typeof t=="function"}function Xy(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 Jy(t){const[s,n]=g.useState(void 0);return cr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const l=a[0];let o,d;if("borderBoxSize"in l){const m=l.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 gI(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var Rr=t=>{const{present:s,children:n}=t,r=vI(s),a=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),l=Ks(r.ref,yI(a));return typeof n=="function"||r.isPresent?g.cloneElement(a,{ref:l}):null};Rr.displayName="Presence";function vI(t){const[s,n]=g.useState(),r=g.useRef(null),a=g.useRef(t),l=g.useRef("none"),o=t?"mounted":"unmounted",[d,m]=gI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const f=dm(r.current);l.current=d==="mounted"?f:"none"},[d]),cr(()=>{const f=r.current,x=a.current;if(x!==t){const p=l.current,u=dm(f);t?m("MOUNT"):u==="none"||(f==null?void 0:f.display)==="none"?m("UNMOUNT"):m(x&&p!==u?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,m]),cr(()=>{if(s){let f;const x=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 N=s.style.animationFillMode;s.style.animationFillMode="forwards",f=x.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=N)})}},p=u=>{u.target===s&&(l.current=dm(r.current))};return s.addEventListener("animationstart",p),s.addEventListener("animationcancel",h),s.addEventListener("animationend",h),()=>{x.clearTimeout(f),s.removeEventListener("animationstart",p),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 yI(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 bI(t){const s=jI(t),n=g.forwardRef((r,a)=>{const{children:l,...o}=r,d=g.Children.toArray(l),m=d.find(wI);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function jI(t){const s=g.forwardRef((n,r)=>{const{children:a,...l}=n;if(g.isValidElement(a)){const o=CI(a),d=SI(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 NI=Symbol("radix.slottable");function wI(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===NI}function SI(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function CI(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 AI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ws=AI.reduce((t,s)=>{const n=bI(`Primitive.${s}`),r=g.forwardRef((a,l)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{});function QA(t,s){t&&Uu.flushSync(()=>t.dispatchEvent(s))}var Ff="Checkbox",[kI]=ga(Ff),[DI,eb]=kI(Ff);function RI(t){const{__scopeCheckbox:s,checked:n,children:r,defaultChecked:a,disabled:l,form:o,name:d,onCheckedChange:m,required:f,value:x="on",internal_do_not_use_render:h}=t,[p,u]=$i({prop:n,defaultProp:a??!1,onChange:m,caller:Ff}),[w,v]=g.useState(null),[N,j]=g.useState(null),y=g.useRef(!1),C=w?!!o||!!w.closest("form"):!0,S={checked:p,disabled:l,setChecked:u,control:w,setControl:v,name:d,form:o,value:x,hasConsumerStoppedPropagationRef:y,required:f,defaultChecked:Ql(a)?!1:a,isFormControl:C,bubbleInput:N,setBubbleInput:j};return e.jsx(DI,{scope:s,...S,children:EI(h)?h(S):r})}var XA="CheckboxTrigger",JA=g.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:n,...r},a)=>{const{control:l,value:o,disabled:d,checked:m,required:f,setControl:x,setChecked:h,hasConsumerStoppedPropagationRef:p,isFormControl:u,bubbleInput:w}=eb(XA,t),v=Ks(a,x),N=g.useRef(m);return g.useEffect(()=>{const j=l==null?void 0:l.form;if(j){const y=()=>h(N.current);return j.addEventListener("reset",y),()=>j.removeEventListener("reset",y)}},[l,h]),e.jsx(ws.button,{type:"button",role:"checkbox","aria-checked":Ql(m)?"mixed":m,"aria-required":f,"data-state":ak(m),"data-disabled":d?"":void 0,disabled:d,value:o,...r,ref:v,onKeyDown:Wt(s,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Wt(n,j=>{h(y=>Ql(y)?!0:!y),w&&u&&(p.current=j.isPropagationStopped(),p.current||j.stopPropagation())})})});JA.displayName=XA;var ek=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:l,required:o,disabled:d,value:m,onCheckedChange:f,form:x,...h}=t;return e.jsx(RI,{__scopeCheckbox:n,checked:a,defaultChecked:l,disabled:d,required:o,onCheckedChange:f,name:r,form:x,value:m,internal_do_not_use_render:({isFormControl:p})=>e.jsxs(e.Fragment,{children:[e.jsx(JA,{...h,ref:s,__scopeCheckbox:n}),p&&e.jsx(rk,{__scopeCheckbox:n})]})})});ek.displayName=Ff;var tk="CheckboxIndicator",sk=g.forwardRef((t,s)=>{const{__scopeCheckbox:n,forceMount:r,...a}=t,l=eb(tk,n);return e.jsx(Rr,{present:r||Ql(l.checked)||l.checked===!0,children:e.jsx(ws.span,{"data-state":ak(l.checked),"data-disabled":l.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});sk.displayName=tk;var nk="CheckboxBubbleInput",rk=g.forwardRef(({__scopeCheckbox:t,...s},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:l,defaultChecked:o,required:d,disabled:m,name:f,value:x,form:h,bubbleInput:p,setBubbleInput:u}=eb(nk,t),w=Ks(n,u),v=Xy(l),N=Jy(r);g.useEffect(()=>{const y=p;if(!y)return;const C=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(C,"checked").set,R=!a.current;if(v!==l&&D){const A=new Event("click",{bubbles:R});y.indeterminate=Ql(l),D.call(y,Ql(l)?!1:l),y.dispatchEvent(A)}},[p,v,l,a]);const j=g.useRef(Ql(l)?!1:l);return e.jsx(ws.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:d,disabled:m,name:f,value:x,form:h,...s,tabIndex:-1,ref:w,style:{...s.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});rk.displayName=nk;function EI(t){return typeof t=="function"}function Ql(t){return t==="indeterminate"}function ak(t){return Ql(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 _I={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 TI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),xt=(t,s)=>{const n=g.forwardRef(({color:r="currentColor",size:a=24,strokeWidth:l=2,absoluteStrokeWidth:o,className:d="",children:m,...f},x)=>g.createElement("svg",{ref:x,..._I,width:a,height:a,stroke:r,strokeWidth:o?Number(l)*24/Number(a):l,className:["lucide",`lucide-${TI(t)}`,d].join(" "),...f},[...s.map(([h,p])=>g.createElement(h,p)),...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=xt("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 an=xt("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 Ha=xt("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 Jr=xt("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 Yo=xt("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 PI=xt("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 ik=xt("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 tb=xt("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 OI=xt("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 LI=xt("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 ku=xt("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 C1=xt("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 so=xt("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=xt("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 lk=xt("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 dr=xt("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=xt("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 fn=xt("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 II=xt("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 Wn=xt("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 Aa=xt("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 lo=xt("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 ji=xt("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 bu=xt("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 MI=xt("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 ok=xt("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 ac=xt("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 yn=xt("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 A1=xt("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 Gu=xt("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 ny=xt("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 Ni=xt("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 ck=xt("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 FI=xt("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 bn=xt("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 k1=xt("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/**
|
||
* @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 mu=xt("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 BI=xt("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 $I=xt("FileQuestion",[["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:"M10 10.3c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"1umxtm"}],["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 Ns=xt("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 qI=xt("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 af=xt("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 sb=xt("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 zI=xt("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 UI=xt("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 ry=xt("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 Du=xt("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 VI=xt("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 dk=xt("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 uk=xt("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 D1=xt("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 HI=xt("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 ka=xt("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 _a=xt("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 hk=xt("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 WI=xt("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=xt("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 GI=xt("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 mk=xt("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 es=xt("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 ay=xt("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 KI=xt("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 fk=xt("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 Dr=xt("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 Vr=xt("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 Ga=xt("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 YI=xt("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 pk=xt("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 ju=xt("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 ZI=xt("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 R1=xt("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 Cr=xt("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 iy=xt("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 nb=xt("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 vg=xt("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 Dn=xt("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 ly=xt("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 fl=xt("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 pr=xt("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 QI=xt("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 rb=xt("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 pl=xt("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 Ta=xt("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 Ku=xt("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 XI=xt("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 Bf=xt("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=xt("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 xk=xt("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 no=xt("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 mc=xt("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 JI=xt("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 eM=xt("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 tM=xt("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 sM=xt("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 nM=xt("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 rM=xt("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 aM=xt("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 ar=xt("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 Zo=xt("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 hl=xt("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 iM=xt("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 lM=xt("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 or=xt("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 oM=xt("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 cM=xt("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 yg=xt("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 ab=xt("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 bg=xt("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 Ir=xt("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 Ra=xt("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 lf=xt("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 mi=xt("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=xt("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 E1=xt("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(ek,{"data-slot":"checkbox",className:jt("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(sk,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:e.jsx(Wn,{className:"size-3.5"})})})}var dM=t=>{switch(t){case"success":return mM;case"info":return pM;case"warning":return fM;case"error":return xM;default:return null}},uM=Array(12).fill(0),hM=({visible:t,className:s})=>wt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},wt.createElement("div",{className:"sonner-spinner"},uM.map((n,r)=>wt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),mM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},wt.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"})),fM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},wt.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"})),pM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},wt.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"})),xM=wt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},wt.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"})),gM=wt.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"},wt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),wt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),vM=()=>{let[t,s]=wt.useState(document.hidden);return wt.useEffect(()=>{let n=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},oy=1,yM=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:oy++,l=this.toasts.find(d=>d.id===a),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),l?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,l,o=r.then(async m=>{if(l=["resolve",m],wt.isValidElement(m))a=!1,this.create({id:n,type:"default",message:m});else if(jM(m)&&!m.ok){a=!1;let f=typeof s.error=="function"?await s.error(`HTTP error! status: ${m.status}`):s.error,x=typeof s.description=="function"?await s.description(`HTTP error! status: ${m.status}`):s.description;this.create({id:n,type:"error",message:f,description:x})}else if(s.success!==void 0){a=!1;let f=typeof s.success=="function"?await s.success(m):s.success,x=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"success",message:f,description:x})}}).catch(async m=>{if(l=["reject",m],s.error!==void 0){a=!1;let f=typeof s.error=="function"?await s.error(m):s.error,x=typeof s.description=="function"?await s.description(m):s.description;this.create({id:n,type:"error",message:f,description:x})}}).finally(()=>{var m;a&&(this.dismiss(n),n=void 0),(m=s.finally)==null||m.call(s)}),d=()=>new Promise((m,f)=>o.then(()=>l[0]==="reject"?f(l[1]):m(l[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)||oy++;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}},da=new yM,bM=(t,s)=>{let n=(s==null?void 0:s.id)||oy++;return da.addToast({title:t,...s,id:n}),n},jM=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",NM=bM,wM=()=>da.toasts,SM=()=>da.getActiveToasts(),ee=Object.assign(NM,{success:da.success,info:da.info,warning:da.warning,error:da.error,custom:da.custom,message:da.message,promise:da.promise,dismiss:da.dismiss,loading:da.loading},{getHistory:wM,getToasts:SM});function CM(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))}CM(`: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 AM=3,kM="32px",DM="16px",_1=4e3,RM=356,EM=14,_M=20,TM=200;function ii(...t){return t.filter(Boolean).join(" ")}function PM(t){let[s,n]=t.split("-"),r=[];return s&&r.push(s),n&&r.push(n),r}var OM=t=>{var s,n,r,a,l,o,d,m,f,x,h;let{invert:p,toast:u,unstyled:w,interacting:v,setHeights:N,visibleToasts:j,heights:y,index:C,toasts:S,expanded:D,removeToast:R,defaultRichColors:A,closeButton:L,style:$,cancelButtonStyle:P,actionButtonStyle:E,className:O="",descriptionClassName:I="",duration:q,position:G,gap:Y,loadingIcon:V,expandByDefault:Q,classNames:_,icons:z,closeButtonAriaLabel:T="Close toast",pauseWhenPageIsHidden:F}=t,[B,K]=wt.useState(null),[W,H]=wt.useState(null),[X,J]=wt.useState(!1),[ie,ae]=wt.useState(!1),[xe,ce]=wt.useState(!1),[we,ke]=wt.useState(!1),[Xe,Ot]=wt.useState(!1),[bt,te]=wt.useState(0),[ve,qe]=wt.useState(0),ge=wt.useRef(u.duration||q||_1),Be=wt.useRef(null),ut=wt.useRef(null),ht=C===0,it=C+1<=j,Tt=u.type,It=u.dismissible!==!1,he=u.className||"",vt=u.descriptionClassName||"",mt=wt.useMemo(()=>y.findIndex(De=>De.toastId===u.id)||0,[y,u.id]),_e=wt.useMemo(()=>{var De;return(De=u.closeButton)!=null?De:L},[u.closeButton,L]),Vt=wt.useMemo(()=>u.duration||q||_1,[u.duration,q]),Et=wt.useRef(0),Ds=wt.useRef(0),ln=wt.useRef(0),Bs=wt.useRef(null),[Ys,Xs]=G.split("-"),Js=wt.useMemo(()=>y.reduce((De,ye,Ve)=>Ve>=mt?De:De+ye.height,0),[y,mt]),Ws=vM(),Z=u.invert||p,oe=Tt==="loading";Ds.current=wt.useMemo(()=>mt*Y+Js,[mt,Js]),wt.useEffect(()=>{ge.current=Vt},[Vt]),wt.useEffect(()=>{J(!0)},[]),wt.useEffect(()=>{let De=ut.current;if(De){let ye=De.getBoundingClientRect().height;return qe(ye),N(Ve=>[{toastId:u.id,height:ye,position:u.position},...Ve]),()=>N(Ve=>Ve.filter(Ge=>Ge.toastId!==u.id))}},[N,u.id]),wt.useLayoutEffect(()=>{if(!X)return;let De=ut.current,ye=De.style.height;De.style.height="auto";let Ve=De.getBoundingClientRect().height;De.style.height=ye,qe(Ve),N(Ge=>Ge.find(st=>st.toastId===u.id)?Ge.map(st=>st.toastId===u.id?{...st,height:Ve}:st):[{toastId:u.id,height:Ve,position:u.position},...Ge])},[X,u.title,u.description,N,u.id]);let Ne=wt.useCallback(()=>{ae(!0),te(Ds.current),N(De=>De.filter(ye=>ye.toastId!==u.id)),setTimeout(()=>{R(u)},TM)},[u,R,N,Ds]);wt.useEffect(()=>{if(u.promise&&Tt==="loading"||u.duration===1/0||u.type==="loading")return;let De;return D||v||F&&Ws?(()=>{if(ln.current<Et.current){let ye=new Date().getTime()-Et.current;ge.current=ge.current-ye}ln.current=new Date().getTime()})():ge.current!==1/0&&(Et.current=new Date().getTime(),De=setTimeout(()=>{var ye;(ye=u.onAutoClose)==null||ye.call(u,u),Ne()},ge.current)),()=>clearTimeout(De)},[D,v,u,Tt,F,Ws,Ne]),wt.useEffect(()=>{u.delete&&Ne()},[Ne,u.delete]);function Oe(){var De,ye,Ve;return z!=null&&z.loading?wt.createElement("div",{className:ii(_==null?void 0:_.loader,(De=u==null?void 0:u.classNames)==null?void 0:De.loader,"sonner-loader"),"data-visible":Tt==="loading"},z.loading):V?wt.createElement("div",{className:ii(_==null?void 0:_.loader,(ye=u==null?void 0:u.classNames)==null?void 0:ye.loader,"sonner-loader"),"data-visible":Tt==="loading"},V):wt.createElement(hM,{className:ii(_==null?void 0:_.loader,(Ve=u==null?void 0:u.classNames)==null?void 0:Ve.loader),visible:Tt==="loading"})}return wt.createElement("li",{tabIndex:0,ref:ut,className:ii(O,he,_==null?void 0:_.toast,(s=u==null?void 0:u.classNames)==null?void 0:s.toast,_==null?void 0:_.default,_==null?void 0:_[Tt],(n=u==null?void 0:u.classNames)==null?void 0:n[Tt]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:A,"data-styled":!(u.jsx||u.unstyled||w),"data-mounted":X,"data-promise":!!u.promise,"data-swiped":Xe,"data-removed":ie,"data-visible":it,"data-y-position":Ys,"data-x-position":Xs,"data-index":C,"data-front":ht,"data-swiping":xe,"data-dismissible":It,"data-type":Tt,"data-invert":Z,"data-swipe-out":we,"data-swipe-direction":W,"data-expanded":!!(D||Q&&X),style:{"--index":C,"--toasts-before":C,"--z-index":S.length-C,"--offset":`${ie?bt:Ds.current}px`,"--initial-height":Q?"auto":`${ve}px`,...$,...u.style},onDragEnd:()=>{ce(!1),K(null),Bs.current=null},onPointerDown:De=>{oe||!It||(Be.current=new Date,te(Ds.current),De.target.setPointerCapture(De.pointerId),De.target.tagName!=="BUTTON"&&(ce(!0),Bs.current={x:De.clientX,y:De.clientY}))},onPointerUp:()=>{var De,ye,Ve,Ge;if(we||!It)return;Bs.current=null;let st=Number(((De=ut.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Kt=Number(((ye=ut.current)==null?void 0:ye.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Xt=new Date().getTime()-((Ve=Be.current)==null?void 0:Ve.getTime()),ot=B==="x"?st:Kt,ft=Math.abs(ot)/Xt;if(Math.abs(ot)>=_M||ft>.11){te(Ds.current),(Ge=u.onDismiss)==null||Ge.call(u,u),H(B==="x"?st>0?"right":"left":Kt>0?"down":"up"),Ne(),ke(!0),Ot(!1);return}ce(!1),K(null)},onPointerMove:De=>{var ye,Ve,Ge,st;if(!Bs.current||!It||((ye=window.getSelection())==null?void 0:ye.toString().length)>0)return;let Kt=De.clientY-Bs.current.y,Xt=De.clientX-Bs.current.x,ot=(Ve=t.swipeDirections)!=null?Ve:PM(G);!B&&(Math.abs(Xt)>1||Math.abs(Kt)>1)&&K(Math.abs(Xt)>Math.abs(Kt)?"x":"y");let ft={x:0,y:0};B==="y"?(ot.includes("top")||ot.includes("bottom"))&&(ot.includes("top")&&Kt<0||ot.includes("bottom")&&Kt>0)&&(ft.y=Kt):B==="x"&&(ot.includes("left")||ot.includes("right"))&&(ot.includes("left")&&Xt<0||ot.includes("right")&&Xt>0)&&(ft.x=Xt),(Math.abs(ft.x)>0||Math.abs(ft.y)>0)&&Ot(!0),(Ge=ut.current)==null||Ge.style.setProperty("--swipe-amount-x",`${ft.x}px`),(st=ut.current)==null||st.style.setProperty("--swipe-amount-y",`${ft.y}px`)}},_e&&!u.jsx?wt.createElement("button",{"aria-label":T,"data-disabled":oe,"data-close-button":!0,onClick:oe||!It?()=>{}:()=>{var De;Ne(),(De=u.onDismiss)==null||De.call(u,u)},className:ii(_==null?void 0:_.closeButton,(a=u==null?void 0:u.classNames)==null?void 0:a.closeButton)},(l=z==null?void 0:z.close)!=null?l:gM):null,u.jsx||g.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:wt.createElement(wt.Fragment,null,Tt||u.icon||u.promise?wt.createElement("div",{"data-icon":"",className:ii(_==null?void 0:_.icon,(o=u==null?void 0:u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Oe():null,u.type!=="loading"?u.icon||(z==null?void 0:z[Tt])||dM(Tt):null):null,wt.createElement("div",{"data-content":"",className:ii(_==null?void 0:_.content,(d=u==null?void 0:u.classNames)==null?void 0:d.content)},wt.createElement("div",{"data-title":"",className:ii(_==null?void 0:_.title,(m=u==null?void 0:u.classNames)==null?void 0:m.title)},typeof u.title=="function"?u.title():u.title),u.description?wt.createElement("div",{"data-description":"",className:ii(I,vt,_==null?void 0:_.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)?wt.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||P,onClick:De=>{var ye,Ve;hm(u.cancel)&&It&&((Ve=(ye=u.cancel).onClick)==null||Ve.call(ye,De),Ne())},className:ii(_==null?void 0:_.cancelButton,(x=u==null?void 0:u.classNames)==null?void 0:x.cancelButton)},u.cancel.label):null,g.isValidElement(u.action)?u.action:u.action&&hm(u.action)?wt.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||E,onClick:De=>{var ye,Ve;hm(u.action)&&((Ve=(ye=u.action).onClick)==null||Ve.call(ye,De),!De.defaultPrevented&&Ne())},className:ii(_==null?void 0:_.actionButton,(h=u==null?void 0:u.classNames)==null?void 0:h.actionButton)},u.action.label):null))};function T1(){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 LM(t,s){let n={};return[t,s].forEach((r,a)=>{let l=a===1,o=l?"--mobile-offset":"--offset",d=l?DM:kM;function m(f){["top","right","bottom","left"].forEach(x=>{n[`${o}-${x}`]=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 IM=g.forwardRef(function(t,s){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:o,className:d,offset:m,mobileOffset:f,theme:x="light",richColors:h,duration:p,style:u,visibleToasts:w=AM,toastOptions:v,dir:N=T1(),gap:j=EM,loadingIcon:y,icons:C,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:D}=t,[R,A]=wt.useState([]),L=wt.useMemo(()=>Array.from(new Set([r].concat(R.filter(F=>F.position).map(F=>F.position)))),[R,r]),[$,P]=wt.useState([]),[E,O]=wt.useState(!1),[I,q]=wt.useState(!1),[G,Y]=wt.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),V=wt.useRef(null),Q=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=wt.useRef(null),z=wt.useRef(!1),T=wt.useCallback(F=>{A(B=>{var K;return(K=B.find(W=>W.id===F.id))!=null&&K.delete||da.dismiss(F.id),B.filter(({id:W})=>W!==F.id)})},[]);return wt.useEffect(()=>da.subscribe(F=>{if(F.dismiss){A(B=>B.map(K=>K.id===F.id?{...K,delete:!0}:K));return}setTimeout(()=>{Gy.flushSync(()=>{A(B=>{let K=B.findIndex(W=>W.id===F.id);return K!==-1?[...B.slice(0,K),{...B[K],...F},...B.slice(K+1)]:[F,...B]})})})}),[]),wt.useEffect(()=>{if(x!=="system"){Y(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Y("dark"):Y("light")),typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:B})=>{Y(B?"dark":"light")})}catch{F.addListener(({matches:K})=>{try{Y(K?"dark":"light")}catch(W){console.error(W)}})}},[x]),wt.useEffect(()=>{R.length<=1&&O(!1)},[R]),wt.useEffect(()=>{let F=B=>{var K,W;a.every(H=>B[H]||B.code===H)&&(O(!0),(K=V.current)==null||K.focus()),B.code==="Escape"&&(document.activeElement===V.current||(W=V.current)!=null&&W.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[a]),wt.useEffect(()=>{if(V.current)return()=>{_.current&&(_.current.focus({preventScroll:!0}),_.current=null,z.current=!1)}},[V.current]),wt.createElement("section",{ref:s,"aria-label":`${S} ${Q}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},L.map((F,B)=>{var K;let[W,H]=F.split("-");return R.length?wt.createElement("ol",{key:F,dir:N==="auto"?T1():N,tabIndex:-1,ref:V,className:d,"data-sonner-toaster":!0,"data-theme":G,"data-y-position":W,"data-lifted":E&&R.length>1&&!l,"data-x-position":H,style:{"--front-toast-height":`${((K=$[0])==null?void 0:K.height)||0}px`,"--width":`${RM}px`,"--gap":`${j}px`,...u,...LM(m,f)},onBlur:X=>{z.current&&!X.currentTarget.contains(X.relatedTarget)&&(z.current=!1,_.current&&(_.current.focus({preventScroll:!0}),_.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||z.current||(z.current=!0,_.current=X.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{I||O(!1)},onDragEnd:()=>O(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||q(!0)},onPointerUp:()=>q(!1)},R.filter(X=>!X.position&&B===0||X.position===F).map((X,J)=>{var ie,ae;return wt.createElement(OM,{key:X.id,icons:C,index:J,toast:X,defaultRichColors:h,duration:(ie=v==null?void 0:v.duration)!=null?ie:p,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:n,visibleToasts:w,closeButton:(ae=v==null?void 0:v.closeButton)!=null?ae:o,interacting:I,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:R.filter(xe=>xe.position==X.position),heights:$.filter(xe=>xe.position==X.position),setHeights:P,expandByDefault:l,gap:j,loadingIcon:y,expanded:E,pauseWhenPageIsHidden:D,swipeDirections:t.swipeDirections})})):null}))});const ds={submitApplication:async t=>{var n;const s=await Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.generateDealerCodes(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to generate dealer codes");return s.data},requestProspectDocuments:async(t,s)=>{var r,a;const n=await Ee.requestProspectDocuments(t,s);if(!n.ok)throw new Error(((r=n.data)==null?void 0:r.message)||"Failed to send document request");return((a=n.data)==null?void 0:a.data)||n.data},updateApplicationStatus:async(t,s)=>{var r;const n=await Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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)||[]}},Fs={getRoles:async()=>(await Ee.getRoles()).data,getPermissions:async()=>(await Ee.getPermissions()).data,updateRole:async(t,s)=>(await Ee.updateRole(t,s)).data,createRole:async t=>(await Ee.createRole(t)).data,getZones:async()=>(await Ee.getZones()).data,updateZone:async(t,s)=>(await Ee.updateZone(t,s)).data,createZone:async t=>(await Ee.createZone(t)).data,createRegion:async t=>(await Ee.createRegion(t)).data,updateRegion:async(t,s)=>(await Ee.updateRegion(t,s)).data,getRegions:async()=>(await Ee.getRegions()).data,getStates:async t=>(await Ee.getStates(t)).data,getDistricts:async t=>{const s=typeof t=="string"?{stateId:t,limit:"all"}:{limit:"all",...t};return(await Ee.getDistricts(s)).data},getAreas:async t=>(await Ee.getAreas(t)).data,updateArea:async(t,s)=>(await Ee.updateArea(t,s)).data,createArea:async t=>(await Ee.createArea(t)).data,deleteArea:async t=>(await Ee.deleteArea(t)).data,getAreaManagers:async()=>(await Ee.getAreaManagers()).data,getASMs:async()=>(await Ee.getASMs()).data,getZonalManagers:async()=>(await Ee.getZonalManagers()).data,saveZonalManager:async t=>Ee.saveZonalManager(t).then(s=>s.data),getDDLeads:async()=>(await Ee.getDDLeads()).data,saveDDLead:async t=>Ee.saveDDLead(t).then(s=>s.data),getUsers:async()=>(await Ee.getUsers()).data,updateUser:async(t,s)=>(await Ee.updateUser(t,s)).data,getEmailTemplates:async()=>(await Ee.getEmailTemplates()).data,getEmailTemplate:async t=>(await Ee.getEmailTemplate(t)).data,createEmailTemplate:async t=>(await Ee.createEmailTemplate(t)).data,updateEmailTemplate:async(t,s)=>(await Ee.updateEmailTemplate(t,s)).data,deleteEmailTemplate:async t=>(await Ee.deleteEmailTemplate(t)).data,previewEmailTemplate:async t=>(await Ee.previewEmailTemplate(t)).data,getSlaConfigs:async()=>(await Ee.getSlaConfigs()).data,saveSlaConfig:async t=>(await Ee.saveSlaConfig(t)).data,initializeDefaultSlas:async()=>(await Ee.initializeDefaultSlas()).data,saveZone:async t=>t.id?Fs.updateZone(t.id,t):Fs.createZone(t),saveRegion:async t=>t.id?Fs.updateRegion(t.id,t):Fs.createRegion(t),saveASM:async t=>Ee.updateUser(t.userId,t).then(s=>s.data),getSystemConfigs:async t=>(await Ee.getSystemConfigs(t)).data,saveSystemConfig:async t=>(await Ee.saveSystemConfig(t)).data,getDealerAsmMappings:async()=>(await Ee.getDealerAsmMappings()).data,saveDealerAsmMapping:async t=>(await Ee.saveDealerAsmMapping(t)).data};function MM({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),[l,o]=g.useState([]),[d,m]=g.useState([]);g.useEffect(()=>{f()},[]);const f=async()=>{try{const C=await Fs.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)}},x=async C=>{if(C){n(S=>({...S,stateId:C,districtId:""})),m([]);try{const S=await Fs.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),p=C=>/^[0-9]{10}$/.test(C),u=C=>/^[0-9]{6}$/.test(C),w=!!(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)&&p(s.mobile)&&u(s.pincode)&&(s.ownRoyalEnfield==="no"||s.ownRoyalEnfield==="yes"&&s.royalEnfieldModel)),v=()=>{if(!s.mobile||s.mobile.length<10){ee.error("Please enter a valid mobile number");return}ee.success("OTP sent to "+s.mobile),setTimeout(()=>{a(!0),ee.success("Mobile number verified")},1500)},N=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){ee.error("Please fill in all required fields");return}if(!r){ee.error("Please verify your mobile number");return}if(s.ownRoyalEnfield==="yes"&&!s.royalEnfieldModel){ee.error("Please select your motorcycle model");return}if(!s.acceptTerms){ee.error("Please accept the terms and conditions");return}try{const R=l.find(E=>E.id===s.stateId),A=d.find(E=>E.id===s.districtId),L=(R==null?void 0:R.name)||(R==null?void 0:R.stateName)||"",$=(A==null?void 0:A.name)||(A==null?void 0:A.districtName)||"",P={applicantName:s.name,email:s.email,phone:s.mobile,state:L,city:s.interestedCity,district:$,preferredLocation:`${s.interestedCity}, ${L}`,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 ds.submitApplication(P),ee.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(R){ee.error(((D=(S=R.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"],y=["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(se,{variant:"ghost",onClick:t,className:"text-[10px] uppercase tracking-widest font-bold text-slate-400 hover:text-white transition-colors",children:[e.jsx(KI,{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:N,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(Aa,{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=>x(C.target.value),children:[e.jsx("option",{value:"",children:"Select State*"}),l.map(C=>e.jsx("option",{value:C.id,children:C.name||C.stateName},C.id))]}),e.jsx(Aa,{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(Aa,{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(at,{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(at,{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(at,{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(at,{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(at,{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(at,{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(Aa,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"})]}),e.jsx(at,{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(at,{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*"}),y.map(C=>e.jsx("option",{value:C,children:C},C))]}),e.jsx(Aa,{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(Gs,{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(Gs,{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:!w,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(ji,{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 FM=()=>{const{applicationId:t}=gd(),s=tr(),{user:n}=Fn(A=>A.auth),[r,a]=g.useState(!0),[l,o]=g.useState([]),[d,m]=g.useState([]),[f,x]=g.useState(""),[h,p]=g.useState({}),[u,w]=g.useState(!1),[v,N]=g.useState("none");g.useEffect(()=>{(async()=>{var L,$;if(t)try{const P=await Ee.getPublicQuestionnaire(t);if(P.data.success){const E=P.data.data.questions||[];o(E);const O=Array.from(new Set(E.map(I=>I.sectionName)));m(O),O.length>0&&x(O[0])}}catch(P){console.error("Error fetching questionnaire:",P),(($=(L=P.response)==null?void 0:L.data)==null?void 0:$.code)==="ALREADY_SUBMITTED"?N("already"):ee.error("Failed to load questionnaire")}finally{a(!1)}})()},[t]);const j=(A,L)=>{p($=>({...$,[A]:L}))},y=()=>{const A=d.indexOf(f);A<d.length-1&&(x(d[A+1]),window.scrollTo({top:0,behavior:"smooth"}))},C=()=>{const A=d.indexOf(f);A>0&&(x(d[A-1]),window.scrollTo({top:0,behavior:"smooth"}))},S=async()=>{const A=l.filter(L=>L.isMandatory&&!h[L.id]);if(A.length>0){ee.error(`Please answer all mandatory questions. Missing: ${A.length}`);return}try{w(!0);const L=Object.entries(h).map(([$,P])=>({questionId:$,value:P}));await Ee.submitPublicResponse({applicationId:t,responses:L}),ee.success("Responses submitted successfully"),N("success")}catch(L){console.error(L),ee.error("Failed to submit responses")}finally{w(!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(_a,{className:"w-8 h-8"}):e.jsx(fn,{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=l.filter(A=>A.sectionName===f),R=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(Ir,{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(pr,{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(uk,{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(Jr,{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:l.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:()=>x(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(Ns,{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:l.filter(L=>L.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(Ra,{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 ",R+1," of ",d.length," • ",D.length," questions"]})]})]}),e.jsxs("div",{className:"space-y-10",children:[D.map((A,L)=>e.jsx("div",{className:"group animate-in fade-in duration-500",style:{animationDelay:`${L*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:L+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:$=>j(A.id,$.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:$=>j(A.id,$.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(($,P)=>{const E=$.optionText||$.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]===E,onChange:()=>j(A.id,E)}),e.jsx("span",{className:"text-slate-700 group-hover/opt:text-slate-900 transition-colors",children:E})]},P)})})]})]})]})},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:R===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"}),R<d.length-1?e.jsxs("button",{onClick:y,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(ji,{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(fn,{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 BM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$M=BM.reduce((t,s)=>{const n=Wu(`Primitive.${s}`),r=g.forwardRef((a,l)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),qM="Label",gk=g.forwardRef((t,s)=>e.jsx($M.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())}}));gk.displayName=qM;var zM=gk;function de({className:t,...s}){return e.jsx(zM,{"data-slot":"label",className:jt("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 UM=[{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"}],_i={totalApplications:0,loaIssued:0,level1Pending:0,level2Pending:0,level3Pending:0,eorInProgress:0,disqualified:0,pendingReminders:0,shortlistedToday:0,pendingShortlisting:0},VM=[];function P1({onLogin:t}){const[s,n]=g.useState(""),[r,a]=g.useState(""),[l,o]=g.useState(!1),[d,m]=g.useState(""),[f,x]=g.useState(!1),[h,p]=g.useState(!1),[u,w]=g.useState(!1),[v,N]=g.useState(null),j=async(D,R)=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(D),N(R),setTimeout(()=>N(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 L=document.execCommand("copy");document.body.removeChild(A),L&&(N(R),setTimeout(()=>N(null),2e3))}catch{}},y=async(D,R)=>{var A,L;n(D),a(R),m(""),p(!0);try{await t(D,R)}catch($){const P=((L=(A=$.response)==null?void 0:A.data)==null?void 0:L.message)||$.message||"Auto-login failed";m(P),ee.error(P)}finally{p(!1)}},C=async D=>{var R,A;if(D.preventDefault(),!h){if(m(""),!s||!r){m("Please enter both email and password");return}p(!0);try{await t(s,r)}catch(L){const $=((A=(R=L.response)==null?void 0:R.data)==null?void 0:A.message)||L.message||"Login failed";m($),ee.error($)}finally{p(!1)}}},S=D=>{D.preventDefault(),alert("Password reset link sent to "+s),x(!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(de,{htmlFor:"reset-email",children:"Email Address"}),e.jsx(at,{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(se,{type:"button",variant:"outline",onClick:()=>x(!1),className:"flex-1",children:"Back to Login"}),e.jsx(se,{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(de,{htmlFor:"email",children:"Email Address"}),e.jsx(at,{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(de,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(at,{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:()=>w(!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(FI,{className:"w-5 h-5"}):e.jsx(bn,{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:l,onCheckedChange:D=>o(D),disabled:h}),e.jsx(de,{htmlFor:"remember",className:"cursor-pointer",children:"Remember Me"})]}),e.jsx("button",{type:"button",onClick:()=>x(!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(an,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:d})]}),e.jsx(se,{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(se,{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:UM.map((D,R)=>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:()=>y(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,R*2)},className:"p-2 hover:bg-slate-100 rounded",children:v===R*2?e.jsx(Wn,{className:"w-4 h-4 text-green-600"}):e.jsx(A1,{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,R*2+1)},className:"p-2 hover:bg-slate-100 rounded",children:v===R*2+1?e.jsx(Wn,{className:"w-4 h-4 text-green-600"}):e.jsx(A1,{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 HM(){const t=tr(),s=Ui(),n=Iu(),[r,a]=g.useState("PHONE"),[l,o]=g.useState(""),[d,m]=g.useState(""),[f,x]=g.useState(!1),[h,p]=g.useState(""),u=()=>{const N=new URLSearchParams(s.search).get("next");if(!N)return"/prospective-dashboard";try{const j=decodeURIComponent(N);if(j.startsWith("/prospective-dashboard"))return j}catch{}return"/prospective-dashboard"},w=async N=>{var j;if(N.preventDefault(),!l||l.length<10){p("Please enter a valid 10-digit phone number");return}x(!0),p("");try{const y=await Ee.sendOtp(l);if(y.ok)a("OTP"),ee.success("OTP sent successfully!");else{console.error("Send OTP error response:",y);const C=((j=y.data)==null?void 0:j.message)||"Failed to send OTP";p(C),ee.error(C)}}catch(y){console.error("Send OTP network error:",y),p("Network error. Please try again."),ee.error("Network error. Please try again.")}finally{x(!1)}},v=async N=>{var j;if(N.preventDefault(),!d||d.length<6){p("Please enter a valid 6-digit OTP");return}x(!0),p("");try{const y=await Ee.verifyOtp(l,d);if(y.ok&&y.data){const{token:C,user:S}=y.data.data||y.data;if(!C||!S)throw new Error("Invalid response format");n(AA({user:S,token:C})),localStorage.setItem("token",C),ee.success("Logged in successfully!"),t(u())}else{const C=((j=y.data)==null?void 0:j.message)||"Invalid OTP";p(C),ee.error(C)}}catch(y){console.error("Verify OTP error:",y),p("An unexpected error occurred"),ee.error("An unexpected error occurred")}finally{x(!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(se,{variant:"ghost",className:"px-0 flex items-center gap-2 text-slate-600 hover:text-slate-900 mb-4 hover:bg-transparent",onClick:()=>r==="OTP"?a("PHONE"):t("/admin-login"),children:[e.jsx(Jr,{className:"w-4 h-4"}),r==="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(tM,{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"})]})]})]}),r==="PHONE"?e.jsxs("form",{onSubmit:w,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"phone",children:"Registered Phone Number"}),e.jsx(at,{id:"phone",type:"tel",placeholder:"Enter 10-digit phone number",maxLength:10,value:l,onChange:N=>o(N.target.value.replace(/\D/g,"")),className:"w-full",disabled:f}),e.jsx("p",{className:"text-slate-500 text-xs",children:"Enter the phone number you used during application"})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(an,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:h})]}),e.jsx(se,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:f||l.length<10,children:f?"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:v,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 ",l]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"otp",children:"Enter OTP"}),e.jsx(at,{id:"otp",type:"text",placeholder:"Enter 6-digit OTP",maxLength:6,value:d,onChange:N=>m(N.target.value.replace(/\D/g,"")),className:"w-full text-center text-2xl tracking-widest",disabled:f}),e.jsx("p",{className:"text-slate-500 text-xs text-center",children:"Check your SMS for the OTP"})]}),h&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-md",children:[e.jsx(an,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-600 font-medium text-sm",children:h})]}),e.jsx(se,{type:"submit",className:"w-full bg-re-red hover:bg-re-red-hover h-9",disabled:f||d.length<6,children:f?"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:()=>a("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:w,disabled:f,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 WM({onLogout:t}){const s=tr(),r=Ui().pathname.substring(1)||"dashboard",{user:a}=Fn(I=>I.auth),[l,o]=g.useState(!1),[d,m]=g.useState(""),[f,x]=g.useState(!1),[h,p]=g.useState(!1),[u,w]=g.useState(null),v=g.useRef(null),N=I=>{const q=I.map(V=>V.toLowerCase()),G=String((a==null?void 0:a.role)||"").toLowerCase(),Y=String((a==null?void 0:a.roleCode)||"").toLowerCase();return q.includes(G)||q.includes(Y)},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"],y=["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=N(j),D=N(y),R=N(C),A=[S?{id:"resignation",label:"Resignation"}:null,D?{id:"termination",label:"Termination"}:null,R?{id:"fnf",label:"F&F"}:null].filter(Boolean),L=N(["Finance","Finance Admin"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"finance-onboarding",label:"Onboarding",icon:Ns},{id:"finance-fnf",label:"F&F",icon:yg}]:N(["Dealer"])?[{id:"dashboard",label:"Dashboard",icon:um},{id:"dealer-resignation",label:"My Resignations",icon:yg},{id:"dealer-constitutional",label:"Constitutional Change",icon:fl},{id:"dealer-relocation",label:"Relocation Requests",icon:Vr}]:N(["FDD"])?[{id:"fdd-dashboard",label:"FDD Dashboard",icon:um}]:[{id:"dashboard",label:"Dashboard",icon:um},{id:"applications",label:"Dealership Requests",icon:Ns},...A.length>0?[{id:"offboarding",label:"Offboarding",icon:yg,hasSubmenu:!0,submenuKey:"offboarding",submenu:A}]:[],{id:"constitutional-change",label:"Constitutional Change",icon:fl},{id:"relocation-requests",label:"Relocation Requests",icon:Vr}];N(["DD Lead","DD Admin","Super Admin"])&&L.splice(1,0,{id:"all-requests",label:"All Requests",icon:zI,hasSubmenu:!0,submenuKey:"allRequests",submenu:[{id:"opportunity-requests",label:"Opportunity Requests"},{id:"non-opportunities",label:"Non-opportunities"}]}),N(["Super Admin","DD Admin","DD Lead"])&&(L.push({id:"master",label:"Master",icon:Qc}),L.push({id:"sla-configurations",label:"SLA Matrix",icon:fl})),N(["Super Admin"])&&(L.push({id:"users",label:"User Management",icon:Ra}),L.push({id:"questionnaires",label:"Questionnaire Templates",icon:ac}),L.push({id:"interview-configs",label:"Interview Configs",icon:GI}),L.push({id:"system-logs",label:"System Logs",icon:rd}));const $=I=>{I.preventDefault(),d.trim()&&s("/applications")},P=g.useCallback((I,q)=>{v.current&&clearTimeout(v.current);const G=q.getBoundingClientRect();w({submenuKey:I,top:G.top,left:G.right+8})},[]),E=g.useCallback((I=!1)=>{I?(v.current&&clearTimeout(v.current),w(null)):v.current=setTimeout(()=>w(null),150)},[]),O=g.useCallback(()=>{v.current&&clearTimeout(v.current)},[]);return g.useEffect(()=>{l||w(null)},[l]),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 ${l?"w-20":"w-64"}`,children:[e.jsx("div",{className:"border-b border-white/10",children:l?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(ji,{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(lo,{className:"w-4 h-4"})})]})}),!l&&e.jsx("div",{className:"p-4 border-b border-white/10",children:e.jsxs("form",{onSubmit:$,className:"relative",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search applications...",value:d,onChange:I=>m(I.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:L.map(I=>{var z,T;const q=I.icon,G=r===I.id,Y=!!I.hasSubmenu,V=Y&&((z=I.submenu)==null?void 0:z.some(F=>r===F.id)),Q=I.submenuKey,_=Q==="offboarding"?f:Q==="allRequests"?h:!1;return e.jsxs("div",{children:[e.jsxs("button",{onMouseEnter:F=>{l&&Y&&Q&&P(Q,F.currentTarget)},onMouseLeave:()=>{l&&Y&&E()},onClick:()=>{Y?l?(o(!1),Q==="offboarding"?x(!0):Q==="allRequests"&&p(!0)):Q==="offboarding"?x(!f):Q==="allRequests"&&p(!h):s(`/${I.id}`)},className:`w-full flex items-center gap-3 px-3 py-3 rounded-lg transition-colors ${l?"justify-center":""} ${G||V?"bg-re-red text-white shadow-lg shadow-re-red/20":"text-slate-400 hover:bg-white/5 hover:text-white"}`,title:l?I.label:void 0,children:[e.jsx(q,{className:"w-5 h-5 flex-shrink-0"}),!l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left text-sm",children:I.label}),Y&&(_?e.jsx(bu,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(Aa,{className:"w-4 h-4 flex-shrink-0"}))]})]}),Y&&_&&!l&&e.jsx("div",{className:"ml-3 mt-1 space-y-1 border-l border-white/10 pl-3",children:(T=I.submenu)==null?void 0:T.map(F=>{const B=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 ${B?"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)})})]},I.id)})}),e.jsxs("div",{className:"p-4 border-t border-white/10 space-y-2",children:[!l&&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})]})]})}),l&&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(se,{onClick:t,variant:"ghost",className:`w-full ${l?"px-2 justify-center":"justify-start"} text-slate-400 hover:bg-white/5 hover:text-white`,title:l?"Logout":void 0,children:[e.jsx(fk,{className:"w-5 h-5 flex-shrink-0"}),!l&&e.jsx("span",{className:"ml-3",children:"Logout"})]})]})]}),u&&l&&(()=>{const I=L.find(q=>q.submenuKey===u.submenuKey);return!I||!I.submenu?null:Gy.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:O,onMouseLeave:()=>E(),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:I.label}),I.submenu.map(q=>{const G=r===q.id;return e.jsxs("button",{onClick:()=>{s(`/${q.id}`),E(!0)},className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-sm transition-colors ${G?"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:q.label})]},q.id)})]}),document.body)})()]})}function O1(t){const s=GM(t),n=g.forwardRef((r,a)=>{const{children:l,...o}=r,d=g.Children.toArray(l),m=d.find(YM);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function GM(t){const s=g.forwardRef((n,r)=>{const{children:a,...l}=n;if(g.isValidElement(a)){const o=QM(a),d=ZM(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 KM=Symbol("radix.slottable");function YM(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===KM}function ZM(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function QM(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 ib(t){const s=t+"CollectionProvider",[n,r]=ga(s),[a,l]=n(s,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:N,children:j}=v,y=wt.useRef(null),C=wt.useRef(new Map).current;return e.jsx(a,{scope:N,itemMap:C,collectionRef:y,children:j})};o.displayName=s;const d=t+"CollectionSlot",m=O1(d),f=wt.forwardRef((v,N)=>{const{scope:j,children:y}=v,C=l(d,j),S=Ks(N,C.collectionRef);return e.jsx(m,{ref:S,children:y})});f.displayName=d;const x=t+"CollectionItemSlot",h="data-radix-collection-item",p=O1(x),u=wt.forwardRef((v,N)=>{const{scope:j,children:y,...C}=v,S=wt.useRef(null),D=Ks(N,S),R=l(x,j);return wt.useEffect(()=>(R.itemMap.set(S,{ref:S,...C}),()=>void R.itemMap.delete(S))),e.jsx(p,{[h]:"",ref:D,children:y})});u.displayName=x;function w(v){const N=l(t+"CollectionConsumer",v);return wt.useCallback(()=>{const y=N.collectionRef.current;if(!y)return[];const C=Array.from(y.querySelectorAll(`[${h}]`));return Array.from(N.itemMap.values()).sort((R,A)=>C.indexOf(R.ref.current)-C.indexOf(A.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:o,Slot:f,ItemSlot:u},w,r]}var XM=g.createContext(void 0);function Yu(t){const s=g.useContext(XM);return t||s||"ltr"}function Sr(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 JM(t,s=globalThis==null?void 0:globalThis.document){const n=Sr(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 e3="DismissableLayer",cy="dismissableLayer.update",t3="dismissableLayer.pointerDownOutside",s3="dismissableLayer.focusOutside",L1,vk=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:l,onInteractOutside:o,onDismiss:d,...m}=t,f=g.useContext(vk),[x,h]=g.useState(null),p=(x==null?void 0:x.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=g.useState({}),w=Ks(s,A=>h(A)),v=Array.from(f.layers),[N]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(N),y=x?v.indexOf(x):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,S=y>=j,D=a3(A=>{const L=A.target,$=[...f.branches].some(P=>P.contains(L));!S||$||(a==null||a(A),o==null||o(A),A.defaultPrevented||d==null||d())},p),R=i3(A=>{const L=A.target;[...f.branches].some(P=>P.contains(L))||(l==null||l(A),o==null||o(A),A.defaultPrevented||d==null||d())},p);return JM(A=>{y===f.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&d&&(A.preventDefault(),d()))},p),g.useEffect(()=>{if(x)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(L1=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(x)),f.layers.add(x),I1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=L1)}},[x,p,n,f]),g.useEffect(()=>()=>{x&&(f.layers.delete(x),f.layersWithOutsidePointerEventsDisabled.delete(x),I1())},[x,f]),g.useEffect(()=>{const A=()=>u({});return document.addEventListener(cy,A),()=>document.removeEventListener(cy,A)},[]),e.jsx(ws.div,{...m,ref:w,style:{pointerEvents:C?S?"auto":"none":void 0,...t.style},onFocusCapture:Wt(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Wt(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Wt(t.onPointerDownCapture,D.onPointerDownCapture)})});yd.displayName=e3;var n3="DismissableLayerBranch",r3=g.forwardRef((t,s)=>{const n=g.useContext(vk),r=g.useRef(null),a=Ks(s,r);return g.useEffect(()=>{const l=r.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),e.jsx(ws.div,{...t,ref:a})});r3.displayName=n3;function a3(t,s=globalThis==null?void 0:globalThis.document){const n=Sr(t),r=g.useRef(!1),a=g.useRef(()=>{});return g.useEffect(()=>{const l=d=>{if(d.target&&!r.current){let m=function(){yk(t3,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",l)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",l),s.removeEventListener("click",a.current)}},[s,n]),{onPointerDownCapture:()=>r.current=!0}}function i3(t,s=globalThis==null?void 0:globalThis.document){const n=Sr(t),r=g.useRef(!1);return g.useEffect(()=>{const a=l=>{l.target&&!r.current&&yk(s3,n,{originalEvent:l},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function I1(){const t=new CustomEvent(cy);document.dispatchEvent(t)}function yk(t,s,n,{discrete:r}){const a=n.originalEvent.target,l=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&a.addEventListener(t,s,{once:!0}),r?QA(a,l):a.dispatchEvent(l)}var jg=0;function $f(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??M1()),document.body.insertAdjacentElement("beforeend",t[1]??M1()),jg++,()=>{jg===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),jg--}},[])}function M1(){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 Ng="focusScope.autoFocusOnMount",wg="focusScope.autoFocusOnUnmount",F1={bubbles:!1,cancelable:!0},l3="FocusScope",Zu=g.forwardRef((t,s)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...o}=t,[d,m]=g.useState(null),f=Sr(a),x=Sr(l),h=g.useRef(null),p=Ks(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:Kl(h.current,{select:!0})},N=function(C){if(u.paused||!d)return;const S=C.relatedTarget;S!==null&&(d.contains(S)||Kl(h.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&Kl(d)};document.addEventListener("focusin",v),document.addEventListener("focusout",N);const y=new MutationObserver(j);return d&&y.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",N),y.disconnect()}}},[r,d,u.paused]),g.useEffect(()=>{if(d){$1.add(u);const v=document.activeElement;if(!d.contains(v)){const j=new CustomEvent(Ng,F1);d.addEventListener(Ng,f),d.dispatchEvent(j),j.defaultPrevented||(o3(m3(bk(d)),{select:!0}),document.activeElement===v&&Kl(d))}return()=>{d.removeEventListener(Ng,f),setTimeout(()=>{const j=new CustomEvent(wg,F1);d.addEventListener(wg,x),d.dispatchEvent(j),j.defaultPrevented||Kl(v??document.body,{select:!0}),d.removeEventListener(wg,x),$1.remove(u)},0)}}},[d,f,x,u]);const w=g.useCallback(v=>{if(!n&&!r||u.paused)return;const N=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,j=document.activeElement;if(N&&j){const y=v.currentTarget,[C,S]=c3(y);C&&S?!v.shiftKey&&j===S?(v.preventDefault(),n&&Kl(C,{select:!0})):v.shiftKey&&j===C&&(v.preventDefault(),n&&Kl(S,{select:!0})):j===y&&v.preventDefault()}},[n,r,u.paused]);return e.jsx(ws.div,{tabIndex:-1,...o,ref:p,onKeyDown:w})});Zu.displayName=l3;function o3(t,{select:s=!1}={}){const n=document.activeElement;for(const r of t)if(Kl(r,{select:s}),document.activeElement!==n)return}function c3(t){const s=bk(t),n=B1(s,t),r=B1(s.reverse(),t);return[n,r]}function bk(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 B1(t,s){for(const n of t)if(!d3(n,{upTo:s}))return n}function d3(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 u3(t){return t instanceof HTMLInputElement&&"select"in t}function Kl(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&u3(t)&&s&&t.select()}}var $1=h3();function h3(){let t=[];return{add(s){const n=t[0];s!==n&&(n==null||n.pause()),t=q1(t,s),t.unshift(s)},remove(s){var n;t=q1(t,s),(n=t[0])==null||n.resume()}}}function q1(t,s){const n=[...t],r=n.indexOf(s);return r!==-1&&n.splice(r,1),n}function m3(t){return t.filter(s=>s.tagName!=="A")}var f3=Sf[" useId ".trim().toString()]||(()=>{}),p3=0;function Ar(t){const[s,n]=g.useState(f3());return cr(()=>{n(r=>r??String(p3++))},[t]),t||(s?`radix-${s}`:"")}const x3=["top","right","bottom","left"],ro=Math.min,Ca=Math.max,of=Math.round,mm=Math.floor,Fi=t=>({x:t,y:t}),g3={left:"right",right:"left",bottom:"top",top:"bottom"};function dy(t,s,n){return Ca(t,ro(s,n))}function gl(t,s){return typeof t=="function"?t(s):t}function vl(t){return t.split("-")[0]}function bd(t){return t.split("-")[1]}function lb(t){return t==="x"?"y":"x"}function ob(t){return t==="y"?"height":"width"}function Ii(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function cb(t){return lb(Ii(t))}function v3(t,s,n){n===void 0&&(n=!1);const r=bd(t),a=cb(t),l=ob(a);let o=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[l]>s.floating[l]&&(o=cf(o)),[o,cf(o)]}function y3(t){const s=cf(t);return[uy(t),s,uy(s)]}function uy(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const z1=["left","right"],U1=["right","left"],b3=["top","bottom"],j3=["bottom","top"];function N3(t,s,n){switch(t){case"top":case"bottom":return n?s?U1:z1:s?z1:U1;case"left":case"right":return s?b3:j3;default:return[]}}function w3(t,s,n,r){const a=bd(t);let l=N3(vl(t),n==="start",r);return a&&(l=l.map(o=>o+"-"+a),s&&(l=l.concat(l.map(uy)))),l}function cf(t){const s=vl(t);return g3[s]+t.slice(s.length)}function S3(t){return{top:0,right:0,bottom:0,left:0,...t}}function jk(t){return typeof t!="number"?S3(t):{top:t,right:t,bottom:t,left:t}}function df(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 V1(t,s,n){let{reference:r,floating:a}=t;const l=Ii(s),o=cb(s),d=ob(o),m=vl(s),f=l==="y",x=r.x+r.width/2-a.width/2,h=r.y+r.height/2-a.height/2,p=r[d]/2-a[d]/2;let u;switch(m){case"top":u={x,y:r.y-a.height};break;case"bottom":u={x,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]-=p*(n&&f?-1:1);break;case"end":u[o]+=p*(n&&f?-1:1);break}return u}async function C3(t,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:l,rects:o,elements:d,strategy:m}=t,{boundary:f="clippingAncestors",rootBoundary:x="viewport",elementContext:h="floating",altBoundary:p=!1,padding:u=0}=gl(s,t),w=jk(u),N=d[p?h==="floating"?"reference":"floating":h],j=df(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(N)))==null||n?N:N.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(d.floating)),boundary:f,rootBoundary:x,strategy:m})),y=h==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(l.getOffsetParent==null?void 0:l.getOffsetParent(d.floating)),S=await(l.isElement==null?void 0:l.isElement(C))?await(l.getScale==null?void 0:l.getScale(C))||{x:1,y:1}:{x:1,y:1},D=df(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:y,offsetParent:C,strategy:m}):y);return{top:(j.top-D.top+w.top)/S.y,bottom:(D.bottom-j.bottom+w.bottom)/S.y,left:(j.left-D.left+w.left)/S.x,right:(D.right-j.right+w.right)/S.x}}const A3=50,k3=async(t,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:l=[],platform:o}=n,d=o.detectOverflow?o:{...o,detectOverflow:C3},m=await(o.isRTL==null?void 0:o.isRTL(s));let f=await o.getElementRects({reference:t,floating:s,strategy:a}),{x,y:h}=V1(f,r,m),p=r,u=0;const w={};for(let v=0;v<l.length;v++){const N=l[v];if(!N)continue;const{name:j,fn:y}=N,{x:C,y:S,data:D,reset:R}=await y({x,y:h,initialPlacement:r,placement:p,strategy:a,middlewareData:w,rects:f,platform:d,elements:{reference:t,floating:s}});x=C??x,h=S??h,w[j]={...w[j],...D},R&&u<A3&&(u++,typeof R=="object"&&(R.placement&&(p=R.placement),R.rects&&(f=R.rects===!0?await o.getElementRects({reference:t,floating:s,strategy:a}):R.rects),{x,y:h}=V1(f,p,m)),v=-1)}return{x,y:h,placement:p,strategy:a,middlewareData:w}},D3=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:r,placement:a,rects:l,platform:o,elements:d,middlewareData:m}=s,{element:f,padding:x=0}=gl(t,s)||{};if(f==null)return{};const h=jk(x),p={x:n,y:r},u=cb(a),w=ob(u),v=await o.getDimensions(f),N=u==="y",j=N?"top":"left",y=N?"bottom":"right",C=N?"clientHeight":"clientWidth",S=l.reference[w]+l.reference[u]-p[u]-l.floating[w],D=p[u]-l.reference[u],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let A=R?R[C]:0;(!A||!await(o.isElement==null?void 0:o.isElement(R)))&&(A=d.floating[C]||l.floating[w]);const L=S/2-D/2,$=A/2-v[w]/2-1,P=ro(h[j],$),E=ro(h[y],$),O=P,I=A-v[w]-E,q=A/2-v[w]/2+L,G=dy(O,q,I),Y=!m.arrow&&bd(a)!=null&&q!==G&&l.reference[w]/2-(q<O?P:E)-v[w]/2<0,V=Y?q<O?q-O:q-I:0;return{[u]:p[u]+V,data:{[u]:G,centerOffset:q-G-V,...Y&&{alignmentOffset:V}},reset:Y}}}),R3=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,r;const{placement:a,middlewareData:l,rects:o,initialPlacement:d,platform:m,elements:f}=s,{mainAxis:x=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...N}=gl(t,s);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const j=vl(a),y=Ii(d),C=vl(d)===d,S=await(m.isRTL==null?void 0:m.isRTL(f.floating)),D=p||(C||!v?[cf(d)]:y3(d)),R=w!=="none";!p&&R&&D.push(...w3(d,v,w,S));const A=[d,...D],L=await m.detectOverflow(s,N),$=[];let P=((r=l.flip)==null?void 0:r.overflows)||[];if(x&&$.push(L[j]),h){const q=v3(a,o,S);$.push(L[q[0]],L[q[1]])}if(P=[...P,{placement:a,overflows:$}],!$.every(q=>q<=0)){var E,O;const q=(((E=l.flip)==null?void 0:E.index)||0)+1,G=A[q];if(G&&(!(h==="alignment"?y!==Ii(G):!1)||P.every(Q=>Ii(Q.placement)===y?Q.overflows[0]>0:!0)))return{data:{index:q,overflows:P},reset:{placement:G}};let Y=(O=P.filter(V=>V.overflows[0]<=0).sort((V,Q)=>V.overflows[1]-Q.overflows[1])[0])==null?void 0:O.placement;if(!Y)switch(u){case"bestFit":{var I;const V=(I=P.filter(Q=>{if(R){const _=Ii(Q.placement);return _===y||_==="y"}return!0}).map(Q=>[Q.placement,Q.overflows.filter(_=>_>0).reduce((_,z)=>_+z,0)]).sort((Q,_)=>Q[1]-_[1])[0])==null?void 0:I[0];V&&(Y=V);break}case"initialPlacement":Y=d;break}if(a!==Y)return{reset:{placement:Y}}}return{}}}};function H1(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function W1(t){return x3.some(s=>t[s]>=0)}const E3=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...l}=gl(t,s);switch(a){case"referenceHidden":{const o=await r.detectOverflow(s,{...l,elementContext:"reference"}),d=H1(o,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:W1(d)}}}case"escaped":{const o=await r.detectOverflow(s,{...l,altBoundary:!0}),d=H1(o,n.floating);return{data:{escapedOffsets:d,escaped:W1(d)}}}default:return{}}}}},Nk=new Set(["left","top"]);async function _3(t,s){const{placement:n,platform:r,elements:a}=t,l=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=vl(n),d=bd(n),m=Ii(n)==="y",f=Nk.has(o)?-1:1,x=l&&m?-1:1,h=gl(s,t);let{mainAxis:p,crossAxis:u,alignmentAxis:w}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return d&&typeof w=="number"&&(u=d==="end"?w*-1:w),m?{x:u*x,y:p*f}:{x:p*f,y:u*x}}const T3=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,r;const{x:a,y:l,placement:o,middlewareData:d}=s,m=await _3(s,t);return o===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+m.x,y:l+m.y,data:{...m,placement:o}}}}},P3=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:r,placement:a,platform:l}=s,{mainAxis:o=!0,crossAxis:d=!1,limiter:m={fn:j=>{let{x:y,y:C}=j;return{x:y,y:C}}},...f}=gl(t,s),x={x:n,y:r},h=await l.detectOverflow(s,f),p=Ii(vl(a)),u=lb(p);let w=x[u],v=x[p];if(o){const j=u==="y"?"top":"left",y=u==="y"?"bottom":"right",C=w+h[j],S=w-h[y];w=dy(C,w,S)}if(d){const j=p==="y"?"top":"left",y=p==="y"?"bottom":"right",C=v+h[j],S=v-h[y];v=dy(C,v,S)}const N=m.fn({...s,[u]:w,[p]:v});return{...N,data:{x:N.x-n,y:N.y-r,enabled:{[u]:o,[p]:d}}}}}},O3=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:r,placement:a,rects:l,middlewareData:o}=s,{offset:d=0,mainAxis:m=!0,crossAxis:f=!0}=gl(t,s),x={x:n,y:r},h=Ii(a),p=lb(h);let u=x[p],w=x[h];const v=gl(d,s),N=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(m){const C=p==="y"?"height":"width",S=l.reference[p]-l.floating[C]+N.mainAxis,D=l.reference[p]+l.reference[C]-N.mainAxis;u<S?u=S:u>D&&(u=D)}if(f){var j,y;const C=p==="y"?"width":"height",S=Nk.has(vl(a)),D=l.reference[h]-l.floating[C]+(S&&((j=o.offset)==null?void 0:j[h])||0)+(S?0:N.crossAxis),R=l.reference[h]+l.reference[C]+(S?0:((y=o.offset)==null?void 0:y[h])||0)-(S?N.crossAxis:0);w<D?w=D:w>R&&(w=R)}return{[p]:u,[h]:w}}}},L3=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,r;const{placement:a,rects:l,platform:o,elements:d}=s,{apply:m=()=>{},...f}=gl(t,s),x=await o.detectOverflow(s,f),h=vl(a),p=bd(a),u=Ii(a)==="y",{width:w,height:v}=l.floating;let N,j;h==="top"||h==="bottom"?(N=h,j=p===(await(o.isRTL==null?void 0:o.isRTL(d.floating))?"start":"end")?"left":"right"):(j=h,N=p==="end"?"top":"bottom");const y=v-x.top-x.bottom,C=w-x.left-x.right,S=ro(v-x[N],y),D=ro(w-x[j],C),R=!s.middlewareData.shift;let A=S,L=D;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(L=C),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(A=y),R&&!p){const P=Ca(x.left,0),E=Ca(x.right,0),O=Ca(x.top,0),I=Ca(x.bottom,0);u?L=w-2*(P!==0||E!==0?P+E:Ca(x.left,x.right)):A=v-2*(O!==0||I!==0?O+I:Ca(x.top,x.bottom))}await m({...s,availableWidth:L,availableHeight:A});const $=await o.getDimensions(d.floating);return w!==$.width||v!==$.height?{reset:{rects:!0}}:{}}}};function qf(){return typeof window<"u"}function jd(t){return wk(t)?(t.nodeName||"").toLowerCase():"#document"}function Ea(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Vi(t){var s;return(s=(wk(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function wk(t){return qf()?t instanceof Node||t instanceof Ea(t).Node:!1}function pi(t){return qf()?t instanceof Element||t instanceof Ea(t).Element:!1}function bl(t){return qf()?t instanceof HTMLElement||t instanceof Ea(t).HTMLElement:!1}function G1(t){return!qf()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ea(t).ShadowRoot}function Qu(t){const{overflow:s,overflowX:n,overflowY:r,display:a}=xi(t);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function I3(t){return/^(table|td|th)$/.test(jd(t))}function zf(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const M3=/transform|translate|scale|rotate|perspective|filter/,F3=/paint|layout|strict|content/,qo=t=>!!t&&t!=="none";let Sg;function db(t){const s=pi(t)?xi(t):t;return qo(s.transform)||qo(s.translate)||qo(s.scale)||qo(s.rotate)||qo(s.perspective)||!ub()&&(qo(s.backdropFilter)||qo(s.filter))||M3.test(s.willChange||"")||F3.test(s.contain||"")}function B3(t){let s=ao(t);for(;bl(s)&&!ld(s);){if(db(s))return s;if(zf(s))return null;s=ao(s)}return null}function ub(){return Sg==null&&(Sg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Sg}function ld(t){return/^(html|body|#document)$/.test(jd(t))}function xi(t){return Ea(t).getComputedStyle(t)}function Uf(t){return pi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ao(t){if(jd(t)==="html")return t;const s=t.assignedSlot||t.parentNode||G1(t)&&t.host||Vi(t);return G1(s)?s.host:s}function Sk(t){const s=ao(t);return ld(s)?t.ownerDocument?t.ownerDocument.body:t.body:bl(s)&&Qu(s)?s:Sk(s)}function Ru(t,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=Sk(t),l=a===((r=t.ownerDocument)==null?void 0:r.body),o=Ea(a);if(l){const d=hy(o);return s.concat(o,o.visualViewport||[],Qu(a)?a:[],d&&n?Ru(d):[])}else return s.concat(a,Ru(a,[],n))}function hy(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ck(t){const s=xi(t);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=bl(t),l=a?t.offsetWidth:n,o=a?t.offsetHeight:r,d=of(n)!==l||of(r)!==o;return d&&(n=l,r=o),{width:n,height:r,$:d}}function hb(t){return pi(t)?t:t.contextElement}function Xc(t){const s=hb(t);if(!bl(s))return Fi(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:l}=Ck(s);let o=(l?of(n.width):n.width)/r,d=(l?of(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!d||!Number.isFinite(d))&&(d=1),{x:o,y:d}}const $3=Fi(0);function Ak(t){const s=Ea(t);return!ub()||!s.visualViewport?$3:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function q3(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==Ea(t)?!1:s}function ic(t,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),l=hb(t);let o=Fi(1);s&&(r?pi(r)&&(o=Xc(r)):o=Xc(t));const d=q3(l,n,r)?Ak(l):Fi(0);let m=(a.left+d.x)/o.x,f=(a.top+d.y)/o.y,x=a.width/o.x,h=a.height/o.y;if(l){const p=Ea(l),u=r&&pi(r)?Ea(r):r;let w=p,v=hy(w);for(;v&&r&&u!==w;){const N=Xc(v),j=v.getBoundingClientRect(),y=xi(v),C=j.left+(v.clientLeft+parseFloat(y.paddingLeft))*N.x,S=j.top+(v.clientTop+parseFloat(y.paddingTop))*N.y;m*=N.x,f*=N.y,x*=N.x,h*=N.y,m+=C,f+=S,w=Ea(v),v=hy(w)}}return df({width:x,height:h,x:m,y:f})}function Vf(t,s){const n=Uf(t).scrollLeft;return s?s.left+n:ic(Vi(t)).left+n}function kk(t,s){const n=t.getBoundingClientRect(),r=n.left+s.scrollLeft-Vf(t,n),a=n.top+s.scrollTop;return{x:r,y:a}}function z3(t){let{elements:s,rect:n,offsetParent:r,strategy:a}=t;const l=a==="fixed",o=Vi(r),d=s?zf(s.floating):!1;if(r===o||d&&l)return n;let m={scrollLeft:0,scrollTop:0},f=Fi(1);const x=Fi(0),h=bl(r);if((h||!h&&!l)&&((jd(r)!=="body"||Qu(o))&&(m=Uf(r)),h)){const u=ic(r);f=Xc(r),x.x=u.x+r.clientLeft,x.y=u.y+r.clientTop}const p=o&&!h&&!l?kk(o,m):Fi(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-m.scrollLeft*f.x+x.x+p.x,y:n.y*f.y-m.scrollTop*f.y+x.y+p.y}}function U3(t){return Array.from(t.getClientRects())}function V3(t){const s=Vi(t),n=Uf(t),r=t.ownerDocument.body,a=Ca(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),l=Ca(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Vf(t);const d=-n.scrollTop;return xi(r).direction==="rtl"&&(o+=Ca(s.clientWidth,r.clientWidth)-a),{width:a,height:l,x:o,y:d}}const K1=25;function H3(t,s){const n=Ea(t),r=Vi(t),a=n.visualViewport;let l=r.clientWidth,o=r.clientHeight,d=0,m=0;if(a){l=a.width,o=a.height;const x=ub();(!x||x&&s==="fixed")&&(d=a.offsetLeft,m=a.offsetTop)}const f=Vf(r);if(f<=0){const x=r.ownerDocument,h=x.body,p=getComputedStyle(h),u=x.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,w=Math.abs(r.clientWidth-h.clientWidth-u);w<=K1&&(l-=w)}else f<=K1&&(l+=f);return{width:l,height:o,x:d,y:m}}function W3(t,s){const n=ic(t,!0,s==="fixed"),r=n.top+t.clientTop,a=n.left+t.clientLeft,l=bl(t)?Xc(t):Fi(1),o=t.clientWidth*l.x,d=t.clientHeight*l.y,m=a*l.x,f=r*l.y;return{width:o,height:d,x:m,y:f}}function Y1(t,s,n){let r;if(s==="viewport")r=H3(t,n);else if(s==="document")r=V3(Vi(t));else if(pi(s))r=W3(s,n);else{const a=Ak(t);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return df(r)}function Dk(t,s){const n=ao(t);return n===s||!pi(n)||ld(n)?!1:xi(n).position==="fixed"||Dk(n,s)}function G3(t,s){const n=s.get(t);if(n)return n;let r=Ru(t,[],!1).filter(d=>pi(d)&&jd(d)!=="body"),a=null;const l=xi(t).position==="fixed";let o=l?ao(t):t;for(;pi(o)&&!ld(o);){const d=xi(o),m=db(o);!m&&d.position==="fixed"&&(a=null),(l?!m&&!a:!m&&d.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Qu(o)&&!m&&Dk(t,o))?r=r.filter(x=>x!==o):a=d,o=ao(o)}return s.set(t,r),r}function K3(t){let{element:s,boundary:n,rootBoundary:r,strategy:a}=t;const o=[...n==="clippingAncestors"?zf(s)?[]:G3(s,this._c):[].concat(n),r],d=Y1(s,o[0],a);let m=d.top,f=d.right,x=d.bottom,h=d.left;for(let p=1;p<o.length;p++){const u=Y1(s,o[p],a);m=Ca(u.top,m),f=ro(u.right,f),x=ro(u.bottom,x),h=Ca(u.left,h)}return{width:f-h,height:x-m,x:h,y:m}}function Y3(t){const{width:s,height:n}=Ck(t);return{width:s,height:n}}function Z3(t,s,n){const r=bl(s),a=Vi(s),l=n==="fixed",o=ic(t,!0,l,s);let d={scrollLeft:0,scrollTop:0};const m=Fi(0);function f(){m.x=Vf(a)}if(r||!r&&!l)if((jd(s)!=="body"||Qu(a))&&(d=Uf(s)),r){const u=ic(s,!0,l,s);m.x=u.x+s.clientLeft,m.y=u.y+s.clientTop}else a&&f();l&&!r&&a&&f();const x=a&&!r&&!l?kk(a,d):Fi(0),h=o.left+d.scrollLeft-m.x-x.x,p=o.top+d.scrollTop-m.y-x.y;return{x:h,y:p,width:o.width,height:o.height}}function Cg(t){return xi(t).position==="static"}function Z1(t,s){if(!bl(t)||xi(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return Vi(t)===n&&(n=n.ownerDocument.body),n}function Rk(t,s){const n=Ea(t);if(zf(t))return n;if(!bl(t)){let a=ao(t);for(;a&&!ld(a);){if(pi(a)&&!Cg(a))return a;a=ao(a)}return n}let r=Z1(t,s);for(;r&&I3(r)&&Cg(r);)r=Z1(r,s);return r&&ld(r)&&Cg(r)&&!db(r)?n:r||B3(t)||n}const Q3=async function(t){const s=this.getOffsetParent||Rk,n=this.getDimensions,r=await n(t.floating);return{reference:Z3(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function X3(t){return xi(t).direction==="rtl"}const J3={convertOffsetParentRelativeRectToViewportRelativeRect:z3,getDocumentElement:Vi,getClippingRect:K3,getOffsetParent:Rk,getElementRects:Q3,getClientRects:U3,getDimensions:Y3,getScale:Xc,isElement:pi,isRTL:X3};function Ek(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function eF(t,s){let n=null,r;const a=Vi(t);function l(){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),l();const f=t.getBoundingClientRect(),{left:x,top:h,width:p,height:u}=f;if(d||s(),!p||!u)return;const w=mm(h),v=mm(a.clientWidth-(x+p)),N=mm(a.clientHeight-(h+u)),j=mm(x),C={rootMargin:-w+"px "+-v+"px "+-N+"px "+-j+"px",threshold:Ca(0,ro(1,m))||1};let S=!0;function D(R){const A=R[0].intersectionRatio;if(A!==m){if(!S)return o();A?o(!1,A):r=setTimeout(()=>{o(!1,1e-7)},1e3)}A===1&&!Ek(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),l}function tF(t,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:m=!1}=r,f=hb(t),x=a||l?[...f?Ru(f):[],...s?Ru(s):[]]:[];x.forEach(j=>{a&&j.addEventListener("scroll",n,{passive:!0}),l&&j.addEventListener("resize",n)});const h=f&&d?eF(f,n):null;let p=-1,u=null;o&&(u=new ResizeObserver(j=>{let[y]=j;y&&y.target===f&&u&&s&&(u.unobserve(s),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=u)==null||C.observe(s)})),n()}),f&&!m&&u.observe(f),s&&u.observe(s));let w,v=m?ic(t):null;m&&N();function N(){const j=ic(t);v&&!Ek(v,j)&&n(),v=j,w=requestAnimationFrame(N)}return n(),()=>{var j;x.forEach(y=>{a&&y.removeEventListener("scroll",n),l&&y.removeEventListener("resize",n)}),h==null||h(),(j=u)==null||j.disconnect(),u=null,m&&cancelAnimationFrame(w)}}const sF=T3,nF=P3,rF=R3,aF=L3,iF=E3,Q1=D3,lF=O3,oF=(t,s,n)=>{const r=new Map,a={platform:J3,...n},l={...a.platform,_c:r};return k3(t,s,{...a,platform:l})};var cF=typeof document<"u",dF=function(){},Fm=cF?g.useLayoutEffect:dF;function uf(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(!uf(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 l=a[r];if(!(l==="_owner"&&t.$$typeof)&&!uf(t[l],s[l]))return!1}return!0}return t!==t&&s!==s}function _k(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function X1(t,s){const n=_k(t);return Math.round(s*n)/n}function Ag(t){const s=g.useRef(t);return Fm(()=>{s.current=t}),s}function uF(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:l,floating:o}={},transform:d=!0,whileElementsMounted:m,open:f}=t,[x,h]=g.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[p,u]=g.useState(r);uf(p,r)||u(r);const[w,v]=g.useState(null),[N,j]=g.useState(null),y=g.useCallback(Q=>{Q!==R.current&&(R.current=Q,v(Q))},[]),C=g.useCallback(Q=>{Q!==A.current&&(A.current=Q,j(Q))},[]),S=l||w,D=o||N,R=g.useRef(null),A=g.useRef(null),L=g.useRef(x),$=m!=null,P=Ag(m),E=Ag(a),O=Ag(f),I=g.useCallback(()=>{if(!R.current||!A.current)return;const Q={placement:s,strategy:n,middleware:p};E.current&&(Q.platform=E.current),oF(R.current,A.current,Q).then(_=>{const z={..._,isPositioned:O.current!==!1};q.current&&!uf(L.current,z)&&(L.current=z,Uu.flushSync(()=>{h(z)}))})},[p,s,n,E,O]);Fm(()=>{f===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,h(Q=>({...Q,isPositioned:!1})))},[f]);const q=g.useRef(!1);Fm(()=>(q.current=!0,()=>{q.current=!1}),[]),Fm(()=>{if(S&&(R.current=S),D&&(A.current=D),S&&D){if(P.current)return P.current(S,D,I);I()}},[S,D,I,P,$]);const G=g.useMemo(()=>({reference:R,floating:A,setReference:y,setFloating:C}),[y,C]),Y=g.useMemo(()=>({reference:S,floating:D}),[S,D]),V=g.useMemo(()=>{const Q={position:n,left:0,top:0};if(!Y.floating)return Q;const _=X1(Y.floating,x.x),z=X1(Y.floating,x.y);return d?{...Q,transform:"translate("+_+"px, "+z+"px)",..._k(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:z}},[n,d,Y.floating,x.x,x.y]);return g.useMemo(()=>({...x,update:I,refs:G,elements:Y,floatingStyles:V}),[x,I,G,Y,V])}const hF=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?Q1({element:r.current,padding:a}).fn(n):{}:r?Q1({element:r,padding:a}).fn(n):{}}}},mF=(t,s)=>{const n=sF(t);return{name:n.name,fn:n.fn,options:[t,s]}},fF=(t,s)=>{const n=nF(t);return{name:n.name,fn:n.fn,options:[t,s]}},pF=(t,s)=>({fn:lF(t).fn,options:[t,s]}),xF=(t,s)=>{const n=rF(t);return{name:n.name,fn:n.fn,options:[t,s]}},gF=(t,s)=>{const n=aF(t);return{name:n.name,fn:n.fn,options:[t,s]}},vF=(t,s)=>{const n=iF(t);return{name:n.name,fn:n.fn,options:[t,s]}},yF=(t,s)=>{const n=hF(t);return{name:n.name,fn:n.fn,options:[t,s]}};var bF="Arrow",Tk=g.forwardRef((t,s)=>{const{children:n,width:r=10,height:a=5,...l}=t;return e.jsx(ws.svg,{...l,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"})})});Tk.displayName=bF;var jF=Tk,mb="Popper",[Pk,oo]=ga(mb),[NF,Ok]=Pk(mb),Lk=t=>{const{__scopePopper:s,children:n}=t,[r,a]=g.useState(null);return e.jsx(NF,{scope:s,anchor:r,onAnchorChange:a,children:n})};Lk.displayName=mb;var Ik="PopperAnchor",Mk=g.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:r,...a}=t,l=Ok(Ik,n),o=g.useRef(null),d=Ks(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&&l.onAnchorChange(m.current)}),r?null:e.jsx(ws.div,{...a,ref:d})});Mk.displayName=Ik;var fb="PopperContent",[wF,SF]=Pk(fb),Fk=g.forwardRef((t,s)=>{var X,J,ie,ae,xe,ce;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:l="center",alignOffset:o=0,arrowPadding:d=0,avoidCollisions:m=!0,collisionBoundary:f=[],collisionPadding:x=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:u="optimized",onPlaced:w,...v}=t,N=Ok(fb,n),[j,y]=g.useState(null),C=Ks(s,we=>y(we)),[S,D]=g.useState(null),R=Jy(S),A=(R==null?void 0:R.width)??0,L=(R==null?void 0:R.height)??0,$=r+(l!=="center"?"-"+l:""),P=typeof x=="number"?x:{top:0,right:0,bottom:0,left:0,...x},E=Array.isArray(f)?f:[f],O=E.length>0,I={padding:P,boundary:E.filter(AF),altBoundary:O},{refs:q,floatingStyles:G,placement:Y,isPositioned:V,middlewareData:Q}=uF({strategy:"fixed",placement:$,whileElementsMounted:(...we)=>tF(...we,{animationFrame:u==="always"}),elements:{reference:N.anchor},middleware:[mF({mainAxis:a+L,alignmentAxis:o}),m&&fF({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?pF():void 0,...I}),m&&xF({...I}),gF({...I,apply:({elements:we,rects:ke,availableWidth:Xe,availableHeight:Ot})=>{const{width:bt,height:te}=ke.reference,ve=we.floating.style;ve.setProperty("--radix-popper-available-width",`${Xe}px`),ve.setProperty("--radix-popper-available-height",`${Ot}px`),ve.setProperty("--radix-popper-anchor-width",`${bt}px`),ve.setProperty("--radix-popper-anchor-height",`${te}px`)}}),S&&yF({element:S,padding:d}),kF({arrowWidth:A,arrowHeight:L}),p&&vF({strategy:"referenceHidden",...I})]}),[_,z]=qk(Y),T=Sr(w);cr(()=>{V&&(T==null||T())},[V,T]);const F=(X=Q.arrow)==null?void 0:X.x,B=(J=Q.arrow)==null?void 0:J.y,K=((ie=Q.arrow)==null?void 0:ie.centerOffset)!==0,[W,H]=g.useState();return cr(()=>{j&&H(window.getComputedStyle(j).zIndex)},[j]),e.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:V?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(ae=Q.transformOrigin)==null?void 0:ae.x,(xe=Q.transformOrigin)==null?void 0:xe.y].join(" "),...((ce=Q.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(wF,{scope:n,placedSide:_,onArrowChange:D,arrowX:F,arrowY:B,shouldHideArrow:K,children:e.jsx(ws.div,{"data-side":_,"data-align":z,...v,ref:C,style:{...v.style,animation:V?void 0:"none"}})})})});Fk.displayName=fb;var Bk="PopperArrow",CF={top:"bottom",right:"left",bottom:"top",left:"right"},$k=g.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,l=SF(Bk,r),o=CF[l.placedSide];return e.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:e.jsx(jF,{...a,ref:n,style:{...a.style,display:"block"}})})});$k.displayName=Bk;function AF(t){return t!==null}var kF=t=>({name:"transformOrigin",options:t,fn(s){var N,j,y;const{placement:n,rects:r,middlewareData:a}=s,o=((N=a.arrow)==null?void 0:N.centerOffset)!==0,d=o?0:t.arrowWidth,m=o?0:t.arrowHeight,[f,x]=qk(n),h={start:"0%",center:"50%",end:"100%"}[x],p=(((j=a.arrow)==null?void 0:j.x)??0)+d/2,u=(((y=a.arrow)==null?void 0:y.y)??0)+m/2;let w="",v="";return f==="bottom"?(w=o?h:`${p}px`,v=`${-m}px`):f==="top"?(w=o?h:`${p}px`,v=`${r.floating.height+m}px`):f==="right"?(w=`${-m}px`,v=o?h:`${u}px`):f==="left"&&(w=`${r.floating.width+m}px`,v=o?h:`${u}px`),{data:{x:w,y:v}}}});function qk(t){const[s,n="center"]=t.split("-");return[s,n]}var Hf=Lk,Xu=Mk,Wf=Fk,Gf=$k,DF="Portal",Nd=g.forwardRef((t,s)=>{var d;const{container:n,...r}=t,[a,l]=g.useState(!1);cr(()=>l(!0),[]);const o=n||a&&((d=globalThis==null?void 0:globalThis.document)==null?void 0:d.body);return o?Gy.createPortal(e.jsx(ws.div,{...r,ref:s}),o):null});Nd.displayName=DF;var kg="rovingFocusGroup.onEntryFocus",RF={bubbles:!1,cancelable:!0},Ju="RovingFocusGroup",[my,zk,EF]=ib(Ju),[_F,Kf]=ga(Ju,[EF]),[TF,PF]=_F(Ju),Uk=g.forwardRef((t,s)=>e.jsx(my.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(my.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(OF,{...t,ref:s})})}));Uk.displayName=Ju;var OF=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:l,currentTabStopId:o,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:m,onEntryFocus:f,preventScrollOnEntryFocus:x=!1,...h}=t,p=g.useRef(null),u=Ks(s,p),w=Yu(l),[v,N]=$i({prop:o,defaultProp:d??null,onChange:m,caller:Ju}),[j,y]=g.useState(!1),C=Sr(f),S=zk(n),D=g.useRef(!1),[R,A]=g.useState(0);return g.useEffect(()=>{const L=p.current;if(L)return L.addEventListener(kg,C),()=>L.removeEventListener(kg,C)},[C]),e.jsx(TF,{scope:n,orientation:r,dir:w,loop:a,currentTabStopId:v,onItemFocus:g.useCallback(L=>N(L),[N]),onItemShiftTab:g.useCallback(()=>y(!0),[]),onFocusableItemAdd:g.useCallback(()=>A(L=>L+1),[]),onFocusableItemRemove:g.useCallback(()=>A(L=>L-1),[]),children:e.jsx(ws.div,{tabIndex:j||R===0?-1:0,"data-orientation":r,...h,ref:u,style:{outline:"none",...t.style},onMouseDown:Wt(t.onMouseDown,()=>{D.current=!0}),onFocus:Wt(t.onFocus,L=>{const $=!D.current;if(L.target===L.currentTarget&&$&&!j){const P=new CustomEvent(kg,RF);if(L.currentTarget.dispatchEvent(P),!P.defaultPrevented){const E=S().filter(Y=>Y.focusable),O=E.find(Y=>Y.active),I=E.find(Y=>Y.id===v),G=[O,I,...E].filter(Boolean).map(Y=>Y.ref.current);Wk(G,x)}}D.current=!1}),onBlur:Wt(t.onBlur,()=>y(!1))})})}),Vk="RovingFocusGroupItem",Hk=g.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:l,children:o,...d}=t,m=Ar(),f=l||m,x=PF(Vk,n),h=x.currentTabStopId===f,p=zk(n),{onFocusableItemAdd:u,onFocusableItemRemove:w,currentTabStopId:v}=x;return g.useEffect(()=>{if(r)return u(),()=>w()},[r,u,w]),e.jsx(my.ItemSlot,{scope:n,id:f,focusable:r,active:a,children:e.jsx(ws.span,{tabIndex:h?0:-1,"data-orientation":x.orientation,...d,ref:s,onMouseDown:Wt(t.onMouseDown,N=>{r?x.onItemFocus(f):N.preventDefault()}),onFocus:Wt(t.onFocus,()=>x.onItemFocus(f)),onKeyDown:Wt(t.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){x.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const j=MF(N,x.orientation,x.dir);if(j!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let C=p().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(N.currentTarget);C=x.loop?FF(C,S+1):C.slice(S+1)}setTimeout(()=>Wk(C))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:v!=null}):o})})});Hk.displayName=Vk;var LF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function IF(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function MF(t,s,n){const r=IF(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return LF[r]}function Wk(t,s=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function FF(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var Gk=Uk,Kk=Hk;function BF(t){const s=$F(t),n=g.forwardRef((r,a)=>{const{children:l,...o}=r,d=g.Children.toArray(l),m=d.find(zF);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function $F(t){const s=g.forwardRef((n,r)=>{const{children:a,...l}=n;if(g.isValidElement(a)){const o=VF(a),d=UF(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 qF=Symbol("radix.slottable");function zF(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===qF}function UF(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function VF(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 HF=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={},Dg=0,Yk=function(t){return t&&(t.host||Yk(t.parentNode))},WF=function(t,s){return s.map(function(n){if(t.contains(n))return n;var r=Yk(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})},GF=function(t,s,n,r){var a=WF(s,Array.isArray(t)?t:[t]);pm[n]||(pm[n]=new WeakMap);var l=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 x=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(p){if(d.has(p))x(p);else try{var u=p.getAttribute(r),w=u!==null&&u!=="false",v=(Bc.get(p)||0)+1,N=(l.get(p)||0)+1;Bc.set(p,v),l.set(p,N),o.push(p),v===1&&w&&fm.set(p,!0),N===1&&p.setAttribute(n,"true"),w||p.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",p,j)}})};return x(s),d.clear(),Dg++,function(){o.forEach(function(h){var p=Bc.get(h)-1,u=l.get(h)-1;Bc.set(h,p),l.set(h,u),p||(fm.has(h)||h.removeAttribute(r),fm.delete(h)),u||h.removeAttribute(n)}),Dg--,Dg||(Bc=new WeakMap,Bc=new WeakMap,fm=new WeakMap,pm={})}},Yf=function(t,s,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),a=HF(t);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),GF(r,a,n,"aria-hidden")):function(){return null}},Pi=function(){return Pi=Object.assign||function(s){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(s[l]=n[l])}return s},Pi.apply(this,arguments)};function Zk(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 KF(t,s,n){if(n||arguments.length===2)for(var r=0,a=s.length,l;r<a;r++)(l||!(r in s))&&(l||(l=Array.prototype.slice.call(s,0,r)),l[r]=s[r]);return t.concat(l||Array.prototype.slice.call(s))}var Bm="right-scroll-bar-position",$m="width-before-scroll-bar",YF="with-scroll-bars-hidden",ZF="--removed-body-scroll-bar-size";function Rg(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function QF(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 XF=typeof window<"u"?g.useLayoutEffect:g.useEffect,J1=new WeakMap;function JF(t,s){var n=QF(null,function(r){return t.forEach(function(a){return Rg(a,r)})});return XF(function(){var r=J1.get(n);if(r){var a=new Set(r),l=new Set(t),o=n.current;a.forEach(function(d){l.has(d)||Rg(d,null)}),l.forEach(function(d){a.has(d)||Rg(d,o)})}J1.set(n,t)},[t]),n}function e6(t){return t}function t6(t,s){s===void 0&&(s=e6);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(l){var o=s(l,r);return n.push(o),function(){n=n.filter(function(d){return d!==o})}},assignSyncMedium:function(l){for(r=!0;n.length;){var o=n;n=[],o.forEach(l)}n={push:function(d){return l(d)},filter:function(){return n}}},assignMedium:function(l){r=!0;var o=[];if(n.length){var d=n;n=[],d.forEach(l),o=n}var m=function(){var x=o;o=[],x.forEach(l)},f=function(){return Promise.resolve().then(m)};f(),n={push:function(x){o.push(x),f()},filter:function(x){return o=o.filter(x),n}}}};return a}function s6(t){t===void 0&&(t={});var s=t6(null);return s.options=Pi({async:!0,ssr:!1},t),s}var Qk=function(t){var s=t.sideCar,n=Zk(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,Pi({},n))};Qk.isSideCarExport=!0;function n6(t,s){return t.useMedium(s),Qk}var Xk=s6(),Eg=function(){},Zf=g.forwardRef(function(t,s){var n=g.useRef(null),r=g.useState({onScrollCapture:Eg,onWheelCapture:Eg,onTouchMoveCapture:Eg}),a=r[0],l=r[1],o=t.forwardProps,d=t.children,m=t.className,f=t.removeScrollBar,x=t.enabled,h=t.shards,p=t.sideCar,u=t.noRelative,w=t.noIsolation,v=t.inert,N=t.allowPinchZoom,j=t.as,y=j===void 0?"div":j,C=t.gapMode,S=Zk(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=p,R=JF([n,s]),A=Pi(Pi({},S),a);return g.createElement(g.Fragment,null,x&&g.createElement(D,{sideCar:Xk,removeScrollBar:f,shards:h,noRelative:u,noIsolation:w,inert:v,setCallbacks:l,allowPinchZoom:!!N,lockRef:n,gapMode:C}),o?g.cloneElement(g.Children.only(d),Pi(Pi({},A),{ref:R})):g.createElement(y,Pi({},A,{className:m,ref:R}),d))});Zf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Zf.classNames={fullWidth:$m,zeroRight:Bm};var r6=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function a6(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=r6();return s&&t.setAttribute("nonce",s),t}function i6(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function l6(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var o6=function(){var t=0,s=null;return{add:function(n){t==0&&(s=a6())&&(i6(s,n),l6(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},c6=function(){var t=o6();return function(s,n){g.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&n])}},Jk=function(){var t=c6(),s=function(n){var r=n.styles,a=n.dynamic;return t(r,a),null};return s},d6={left:0,top:0,right:0,gap:0},_g=function(t){return parseInt(t||"",10)||0},u6=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[_g(n),_g(r),_g(a)]},h6=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return d6;var s=u6(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])}},m6=Jk(),Jc="data-scroll-locked",f6=function(t,s,n,r){var a=t.left,l=t.top,o=t.right,d=t.gap;return n===void 0&&(n="margin"),`
|
||
.`.concat(YF,` {
|
||
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(l,`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(Bm,` {
|
||
right: `).concat(d,"px ").concat(r,`;
|
||
}
|
||
|
||
.`).concat($m,` {
|
||
margin-right: `).concat(d,"px ").concat(r,`;
|
||
}
|
||
|
||
.`).concat(Bm," .").concat(Bm,` {
|
||
right: 0 `).concat(r,`;
|
||
}
|
||
|
||
.`).concat($m," .").concat($m,` {
|
||
margin-right: 0 `).concat(r,`;
|
||
}
|
||
|
||
body[`).concat(Jc,`] {
|
||
`).concat(ZF,": ").concat(d,`px;
|
||
}
|
||
`)},eS=function(){var t=parseInt(document.body.getAttribute(Jc)||"0",10);return isFinite(t)?t:0},p6=function(){g.useEffect(function(){return document.body.setAttribute(Jc,(eS()+1).toString()),function(){var t=eS()-1;t<=0?document.body.removeAttribute(Jc):document.body.setAttribute(Jc,t.toString())}},[])},x6=function(t){var s=t.noRelative,n=t.noImportant,r=t.gapMode,a=r===void 0?"margin":r;p6();var l=g.useMemo(function(){return h6(a)},[a]);return g.createElement(m6,{styles:f6(l,!s,a,n?"":"!important")})},fy=!1;if(typeof window<"u")try{var xm=Object.defineProperty({},"passive",{get:function(){return fy=!0,!0}});window.addEventListener("test",xm,xm),window.removeEventListener("test",xm,xm)}catch{fy=!1}var $c=fy?{passive:!1}:!1,g6=function(t){return t.tagName==="TEXTAREA"},eD=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!g6(t)&&n[s]==="visible")},v6=function(t){return eD(t,"overflowY")},y6=function(t){return eD(t,"overflowX")},tS=function(t,s){var n=s.ownerDocument,r=s;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=tD(t,r);if(a){var l=sD(t,r),o=l[1],d=l[2];if(o>d)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},b6=function(t){var s=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[s,n,r]},j6=function(t){var s=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[s,n,r]},tD=function(t,s){return t==="v"?v6(s):y6(s)},sD=function(t,s){return t==="v"?b6(s):j6(s)},N6=function(t,s){return t==="h"&&s==="rtl"?-1:1},w6=function(t,s,n,r,a){var l=N6(t,window.getComputedStyle(s).direction),o=l*r,d=n.target,m=s.contains(d),f=!1,x=o>0,h=0,p=0;do{if(!d)break;var u=sD(t,d),w=u[0],v=u[1],N=u[2],j=v-N-l*w;(w||j)&&tD(t,d)&&(h+=j,p+=w);var y=d.parentNode;d=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!m&&d!==document.body||m&&(s.contains(d)||s===d));return(x&&Math.abs(h)<1||!x&&Math.abs(p)<1)&&(f=!0),f},gm=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},sS=function(t){return[t.deltaX,t.deltaY]},nS=function(t){return t&&"current"in t?t.current:t},S6=function(t,s){return t[0]===s[0]&&t[1]===s[1]},C6=function(t){return`
|
||
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
||
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
||
`)},A6=0,qc=[];function k6(t){var s=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),a=g.useState(A6++)[0],l=g.useState(Jk)[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=KF([t.lockRef.current],(t.shards||[]).map(nS),!0).filter(Boolean);return v.forEach(function(N){return N.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),v.forEach(function(N){return N.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var d=g.useCallback(function(v,N){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var j=gm(v),y=n.current,C="deltaX"in v?v.deltaX:y[0]-j[0],S="deltaY"in v?v.deltaY:y[1]-j[1],D,R=v.target,A=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in v&&A==="h"&&R.type==="range")return!1;var L=window.getSelection(),$=L&&L.anchorNode,P=$?$===R||$.contains(R):!1;if(P)return!1;var E=tS(A,R);if(!E)return!0;if(E?D=A:(D=A==="v"?"h":"v",E=tS(A,R)),!E)return!1;if(!r.current&&"changedTouches"in v&&(C||S)&&(r.current=D),!D)return!0;var O=r.current||D;return w6(O,N,v,O==="h"?C:S)},[]),m=g.useCallback(function(v){var N=v;if(!(!qc.length||qc[qc.length-1]!==l)){var j="deltaY"in N?sS(N):gm(N),y=s.current.filter(function(D){return D.name===N.type&&(D.target===N.target||N.target===D.shadowParent)&&S6(D.delta,j)})[0];if(y&&y.should){N.cancelable&&N.preventDefault();return}if(!y){var C=(o.current.shards||[]).map(nS).filter(Boolean).filter(function(D){return D.contains(N.target)}),S=C.length>0?d(N,C[0]):!o.current.noIsolation;S&&N.cancelable&&N.preventDefault()}}},[]),f=g.useCallback(function(v,N,j,y){var C={name:v,delta:N,target:j,should:y,shadowParent:D6(j)};s.current.push(C),setTimeout(function(){s.current=s.current.filter(function(S){return S!==C})},1)},[]),x=g.useCallback(function(v){n.current=gm(v),r.current=void 0},[]),h=g.useCallback(function(v){f(v.type,sS(v),v.target,d(v,t.lockRef.current))},[]),p=g.useCallback(function(v){f(v.type,gm(v),v.target,d(v,t.lockRef.current))},[]);g.useEffect(function(){return qc.push(l),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",m,$c),document.addEventListener("touchmove",m,$c),document.addEventListener("touchstart",x,$c),function(){qc=qc.filter(function(v){return v!==l}),document.removeEventListener("wheel",m,$c),document.removeEventListener("touchmove",m,$c),document.removeEventListener("touchstart",x,$c)}},[]);var u=t.removeScrollBar,w=t.inert;return g.createElement(g.Fragment,null,w?g.createElement(l,{styles:C6(a)}):null,u?g.createElement(x6,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function D6(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const R6=n6(Xk,k6);var eh=g.forwardRef(function(t,s){return g.createElement(Zf,Pi({},t,{ref:s,sideCar:R6}))});eh.classNames=Zf.classNames;var py=["Enter"," "],E6=["ArrowDown","PageUp","Home"],nD=["ArrowUp","PageDown","End"],_6=[...E6,...nD],T6={ltr:[...py,"ArrowRight"],rtl:[...py,"ArrowLeft"]},P6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},th="Menu",[Eu,O6,L6]=ib(th),[fc,rD]=ga(th,[L6,oo,Kf]),Qf=oo(),aD=Kf(),[I6,pc]=fc(th),[M6,sh]=fc(th),iD=t=>{const{__scopeMenu:s,open:n=!1,children:r,dir:a,onOpenChange:l,modal:o=!0}=t,d=Qf(s),[m,f]=g.useState(null),x=g.useRef(!1),h=Sr(l),p=Yu(a);return g.useEffect(()=>{const u=()=>{x.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>x.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),e.jsx(Hf,{...d,children:e.jsx(I6,{scope:s,open:n,onOpenChange:h,content:m,onContentChange:f,children:e.jsx(M6,{scope:s,onClose:g.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:x,dir:p,modal:o,children:r})})})};iD.displayName=th;var F6="MenuAnchor",pb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Qf(n);return e.jsx(Xu,{...a,...r,ref:s})});pb.displayName=F6;var xb="MenuPortal",[B6,lD]=fc(xb,{forceMount:void 0}),oD=t=>{const{__scopeMenu:s,forceMount:n,children:r,container:a}=t,l=pc(xb,s);return e.jsx(B6,{scope:s,forceMount:n,children:e.jsx(Rr,{present:n||l.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};oD.displayName=xb;var Wa="MenuContent",[$6,gb]=fc(Wa),cD=g.forwardRef((t,s)=>{const n=lD(Wa,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,l=pc(Wa,t.__scopeMenu),o=sh(Wa,t.__scopeMenu);return e.jsx(Eu.Provider,{scope:t.__scopeMenu,children:e.jsx(Rr,{present:r||l.open,children:e.jsx(Eu.Slot,{scope:t.__scopeMenu,children:o.modal?e.jsx(q6,{...a,ref:s}):e.jsx(z6,{...a,ref:s})})})})}),q6=g.forwardRef((t,s)=>{const n=pc(Wa,t.__scopeMenu),r=g.useRef(null),a=Ks(s,r);return g.useEffect(()=>{const l=r.current;if(l)return Yf(l)},[]),e.jsx(vb,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Wt(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),z6=g.forwardRef((t,s)=>{const n=pc(Wa,t.__scopeMenu);return e.jsx(vb,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),U6=BF("MenuContent.ScrollLock"),vb=g.forwardRef((t,s)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:l,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEntryFocus:m,onEscapeKeyDown:f,onPointerDownOutside:x,onFocusOutside:h,onInteractOutside:p,onDismiss:u,disableOutsideScroll:w,...v}=t,N=pc(Wa,n),j=sh(Wa,n),y=Qf(n),C=aD(n),S=O6(n),[D,R]=g.useState(null),A=g.useRef(null),L=Ks(s,A,N.onContentChange),$=g.useRef(0),P=g.useRef(""),E=g.useRef(0),O=g.useRef(null),I=g.useRef("right"),q=g.useRef(0),G=w?eh:g.Fragment,Y=w?{as:U6,allowPinchZoom:!0}:void 0,V=_=>{var X,J;const z=P.current+_,T=S().filter(ie=>!ie.disabled),F=document.activeElement,B=(X=T.find(ie=>ie.ref.current===F))==null?void 0:X.textValue,K=T.map(ie=>ie.textValue),W=t8(K,z,B),H=(J=T.find(ie=>ie.textValue===W))==null?void 0:J.ref.current;(function ie(ae){P.current=ae,window.clearTimeout($.current),ae!==""&&($.current=window.setTimeout(()=>ie(""),1e3))})(z),H&&setTimeout(()=>H.focus())};g.useEffect(()=>()=>window.clearTimeout($.current),[]),$f();const Q=g.useCallback(_=>{var T,F;return I.current===((T=O.current)==null?void 0:T.side)&&n8(_,(F=O.current)==null?void 0:F.area)},[]);return e.jsx($6,{scope:n,searchRef:P,onItemEnter:g.useCallback(_=>{Q(_)&&_.preventDefault()},[Q]),onItemLeave:g.useCallback(_=>{var z;Q(_)||((z=A.current)==null||z.focus(),R(null))},[Q]),onTriggerLeave:g.useCallback(_=>{Q(_)&&_.preventDefault()},[Q]),pointerGraceTimerRef:E,onPointerGraceIntentChange:g.useCallback(_=>{O.current=_},[]),children:e.jsx(G,{...Y,children:e.jsx(Zu,{asChild:!0,trapped:a,onMountAutoFocus:Wt(l,_=>{var z;_.preventDefault(),(z=A.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:x,onFocusOutside:h,onInteractOutside:p,onDismiss:u,children:e.jsx(Gk,{asChild:!0,...C,dir:j.dir,orientation:"vertical",loop:r,currentTabStopId:D,onCurrentTabStopIdChange:R,onEntryFocus:Wt(m,_=>{j.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Wf,{role:"menu","aria-orientation":"vertical","data-state":CD(N.open),"data-radix-menu-content":"",dir:j.dir,...y,...v,ref:L,style:{outline:"none",...v.style},onKeyDown:Wt(v.onKeyDown,_=>{const T=_.target.closest("[data-radix-menu-content]")===_.currentTarget,F=_.ctrlKey||_.altKey||_.metaKey,B=_.key.length===1;T&&(_.key==="Tab"&&_.preventDefault(),!F&&B&&V(_.key));const K=A.current;if(_.target!==K||!_6.includes(_.key))return;_.preventDefault();const H=S().filter(X=>!X.disabled).map(X=>X.ref.current);nD.includes(_.key)&&H.reverse(),J6(H)}),onBlur:Wt(t.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout($.current),P.current="")}),onPointerMove:Wt(t.onPointerMove,_u(_=>{const z=_.target,T=q.current!==_.clientX;if(_.currentTarget.contains(z)&&T){const F=_.clientX>q.current?"right":"left";I.current=F,q.current=_.clientX}}))})})})})})})});cD.displayName=Wa;var V6="MenuGroup",yb=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(ws.div,{role:"group",...r,ref:s})});yb.displayName=V6;var H6="MenuLabel",dD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(ws.div,{...r,ref:s})});dD.displayName=H6;var hf="MenuItem",rS="menu.itemSelect",Xf=g.forwardRef((t,s)=>{const{disabled:n=!1,onSelect:r,...a}=t,l=g.useRef(null),o=sh(hf,t.__scopeMenu),d=gb(hf,t.__scopeMenu),m=Ks(s,l),f=g.useRef(!1),x=()=>{const h=l.current;if(!n&&h){const p=new CustomEvent(rS,{bubbles:!0,cancelable:!0});h.addEventListener(rS,u=>r==null?void 0:r(u),{once:!0}),QA(h,p),p.defaultPrevented?f.current=!1:o.onClose()}};return e.jsx(uD,{...a,ref:m,disabled:n,onClick:Wt(t.onClick,x),onPointerDown:h=>{var p;(p=t.onPointerDown)==null||p.call(t,h),f.current=!0},onPointerUp:Wt(t.onPointerUp,h=>{var p;f.current||(p=h.currentTarget)==null||p.click()}),onKeyDown:Wt(t.onKeyDown,h=>{const p=d.searchRef.current!=="";n||p&&h.key===" "||py.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Xf.displayName=hf;var uD=g.forwardRef((t,s)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...l}=t,o=gb(hf,n),d=aD(n),m=g.useRef(null),f=Ks(s,m),[x,h]=g.useState(!1),[p,u]=g.useState("");return g.useEffect(()=>{const w=m.current;w&&u((w.textContent??"").trim())},[l.children]),e.jsx(Eu.ItemSlot,{scope:n,disabled:r,textValue:a??p,children:e.jsx(Kk,{asChild:!0,...d,focusable:!r,children:e.jsx(ws.div,{role:"menuitem","data-highlighted":x?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...l,ref:f,onPointerMove:Wt(t.onPointerMove,_u(w=>{r?o.onItemLeave(w):(o.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Wt(t.onPointerLeave,_u(w=>o.onItemLeave(w))),onFocus:Wt(t.onFocus,()=>h(!0)),onBlur:Wt(t.onBlur,()=>h(!1))})})})}),W6="MenuCheckboxItem",hD=g.forwardRef((t,s)=>{const{checked:n=!1,onCheckedChange:r,...a}=t;return e.jsx(gD,{scope:t.__scopeMenu,checked:n,children:e.jsx(Xf,{role:"menuitemcheckbox","aria-checked":mf(n)?"mixed":n,...a,ref:s,"data-state":jb(n),onSelect:Wt(a.onSelect,()=>r==null?void 0:r(mf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});hD.displayName=W6;var mD="MenuRadioGroup",[G6,K6]=fc(mD,{value:void 0,onValueChange:()=>{}}),fD=g.forwardRef((t,s)=>{const{value:n,onValueChange:r,...a}=t,l=Sr(r);return e.jsx(G6,{scope:t.__scopeMenu,value:n,onValueChange:l,children:e.jsx(yb,{...a,ref:s})})});fD.displayName=mD;var pD="MenuRadioItem",xD=g.forwardRef((t,s)=>{const{value:n,...r}=t,a=K6(pD,t.__scopeMenu),l=n===a.value;return e.jsx(gD,{scope:t.__scopeMenu,checked:l,children:e.jsx(Xf,{role:"menuitemradio","aria-checked":l,...r,ref:s,"data-state":jb(l),onSelect:Wt(r.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,n)},{checkForDefaultPrevented:!1})})})});xD.displayName=pD;var bb="MenuItemIndicator",[gD,Y6]=fc(bb,{checked:!1}),vD=g.forwardRef((t,s)=>{const{__scopeMenu:n,forceMount:r,...a}=t,l=Y6(bb,n);return e.jsx(Rr,{present:r||mf(l.checked)||l.checked===!0,children:e.jsx(ws.span,{...a,ref:s,"data-state":jb(l.checked)})})});vD.displayName=bb;var Z6="MenuSeparator",yD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t;return e.jsx(ws.div,{role:"separator","aria-orientation":"horizontal",...r,ref:s})});yD.displayName=Z6;var Q6="MenuArrow",bD=g.forwardRef((t,s)=>{const{__scopeMenu:n,...r}=t,a=Qf(n);return e.jsx(Gf,{...a,...r,ref:s})});bD.displayName=Q6;var X6="MenuSub",[_Y,jD]=fc(X6),fu="MenuSubTrigger",ND=g.forwardRef((t,s)=>{const n=pc(fu,t.__scopeMenu),r=sh(fu,t.__scopeMenu),a=jD(fu,t.__scopeMenu),l=gb(fu,t.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:d,onPointerGraceIntentChange:m}=l,f={__scopeMenu:t.__scopeMenu},x=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>x,[x]),g.useEffect(()=>{const h=d.current;return()=>{window.clearTimeout(h),m(null)}},[d,m]),e.jsx(pb,{asChild:!0,...f,children:e.jsx(uD,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":CD(n.open),...t,ref:Xr(s,a.onTriggerChange),onClick:h=>{var p;(p=t.onClick)==null||p.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Wt(t.onPointerMove,_u(h=>{l.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(l.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),x()},100))})),onPointerLeave:Wt(t.onPointerLeave,_u(h=>{var u,w;x();const p=(u=n.content)==null?void 0:u.getBoundingClientRect();if(p){const v=(w=n.content)==null?void 0:w.dataset.side,N=v==="right",j=N?-5:5,y=p[N?"left":"right"],C=p[N?"right":"left"];l.onPointerGraceIntentChange({area:[{x:h.clientX+j,y:h.clientY},{x:y,y:p.top},{x:C,y:p.top},{x:C,y:p.bottom},{x:y,y:p.bottom}],side:v}),window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(h),h.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:Wt(t.onKeyDown,h=>{var u;const p=l.searchRef.current!=="";t.disabled||p&&h.key===" "||T6[r.dir].includes(h.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),h.preventDefault())})})})});ND.displayName=fu;var wD="MenuSubContent",SD=g.forwardRef((t,s)=>{const n=lD(Wa,t.__scopeMenu),{forceMount:r=n.forceMount,...a}=t,l=pc(Wa,t.__scopeMenu),o=sh(Wa,t.__scopeMenu),d=jD(wD,t.__scopeMenu),m=g.useRef(null),f=Ks(s,m);return e.jsx(Eu.Provider,{scope:t.__scopeMenu,children:e.jsx(Rr,{present:r||l.open,children:e.jsx(Eu.Slot,{scope:t.__scopeMenu,children:e.jsx(vb,{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:x=>{var h;o.isUsingKeyboardRef.current&&((h=m.current)==null||h.focus()),x.preventDefault()},onCloseAutoFocus:x=>x.preventDefault(),onFocusOutside:Wt(t.onFocusOutside,x=>{x.target!==d.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:Wt(t.onEscapeKeyDown,x=>{o.onClose(),x.preventDefault()}),onKeyDown:Wt(t.onKeyDown,x=>{var u;const h=x.currentTarget.contains(x.target),p=P6[o.dir].includes(x.key);h&&p&&(l.onOpenChange(!1),(u=d.trigger)==null||u.focus(),x.preventDefault())})})})})})});SD.displayName=wD;function CD(t){return t?"open":"closed"}function mf(t){return t==="indeterminate"}function jb(t){return mf(t)?"indeterminate":t?"checked":"unchecked"}function J6(t){const s=document.activeElement;for(const n of t)if(n===s||(n.focus(),document.activeElement!==s))return}function e8(t,s){return t.map((n,r)=>t[(s+r)%t.length])}function t8(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,l=n?t.indexOf(n):-1;let o=e8(t,Math.max(l,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 s8(t,s){const{x:n,y:r}=t;let a=!1;for(let l=0,o=s.length-1;l<s.length;o=l++){const d=s[l],m=s[o],f=d.x,x=d.y,h=m.x,p=m.y;x>r!=p>r&&n<(h-f)*(r-x)/(p-x)+f&&(a=!a)}return a}function n8(t,s){if(!s)return!1;const n={x:t.clientX,y:t.clientY};return s8(n,s)}function _u(t){return s=>s.pointerType==="mouse"?t(s):void 0}var r8=iD,a8=pb,i8=oD,l8=cD,o8=yb,c8=dD,d8=Xf,u8=hD,h8=fD,m8=xD,f8=vD,p8=yD,x8=bD,g8=ND,v8=SD,Jf="DropdownMenu",[y8]=ga(Jf,[rD]),ea=rD(),[b8,AD]=y8(Jf),kD=t=>{const{__scopeDropdownMenu:s,children:n,dir:r,open:a,defaultOpen:l,onOpenChange:o,modal:d=!0}=t,m=ea(s),f=g.useRef(null),[x,h]=$i({prop:a,defaultProp:l??!1,onChange:o,caller:Jf});return e.jsx(b8,{scope:s,triggerId:Ar(),triggerRef:f,contentId:Ar(),open:x,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(p=>!p),[h]),modal:d,children:e.jsx(r8,{...m,open:x,onOpenChange:h,dir:r,modal:d,children:n})})};kD.displayName=Jf;var DD="DropdownMenuTrigger",RD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,l=AD(DD,n),o=ea(n);return e.jsx(a8,{asChild:!0,...o,children:e.jsx(ws.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Xr(s,l.triggerRef),onPointerDown:Wt(t.onPointerDown,d=>{!r&&d.button===0&&d.ctrlKey===!1&&(l.onOpenToggle(),l.open||d.preventDefault())}),onKeyDown:Wt(t.onKeyDown,d=>{r||(["Enter"," "].includes(d.key)&&l.onOpenToggle(),d.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})});RD.displayName=DD;var j8="DropdownMenuPortal",ED=t=>{const{__scopeDropdownMenu:s,...n}=t,r=ea(s);return e.jsx(i8,{...r,...n})};ED.displayName=j8;var _D="DropdownMenuContent",TD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=AD(_D,n),l=ea(n),o=g.useRef(!1);return e.jsx(l8,{id:a.contentId,"aria-labelledby":a.triggerId,...l,...r,ref:s,onCloseAutoFocus:Wt(t.onCloseAutoFocus,d=>{var m;o.current||(m=a.triggerRef.current)==null||m.focus(),o.current=!1,d.preventDefault()}),onInteractOutside:Wt(t.onInteractOutside,d=>{const m=d.detail.originalEvent,f=m.button===0&&m.ctrlKey===!0,x=m.button===2||f;(!a.modal||x)&&(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)"}})});TD.displayName=_D;var N8="DropdownMenuGroup",w8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(o8,{...a,...r,ref:s})});w8.displayName=N8;var S8="DropdownMenuLabel",PD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(c8,{...a,...r,ref:s})});PD.displayName=S8;var C8="DropdownMenuItem",OD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(d8,{...a,...r,ref:s})});OD.displayName=C8;var A8="DropdownMenuCheckboxItem",LD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(u8,{...a,...r,ref:s})});LD.displayName=A8;var k8="DropdownMenuRadioGroup",D8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(h8,{...a,...r,ref:s})});D8.displayName=k8;var R8="DropdownMenuRadioItem",E8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(m8,{...a,...r,ref:s})});E8.displayName=R8;var _8="DropdownMenuItemIndicator",ID=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(f8,{...a,...r,ref:s})});ID.displayName=_8;var T8="DropdownMenuSeparator",MD=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(p8,{...a,...r,ref:s})});MD.displayName=T8;var P8="DropdownMenuArrow",O8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(x8,{...a,...r,ref:s})});O8.displayName=P8;var L8="DropdownMenuSubTrigger",I8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(g8,{...a,...r,ref:s})});I8.displayName=L8;var M8="DropdownMenuSubContent",F8=g.forwardRef((t,s)=>{const{__scopeDropdownMenu:n,...r}=t,a=ea(n);return e.jsx(v8,{...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)"}})});F8.displayName=M8;var B8=kD,$8=RD,q8=ED,z8=TD,U8=PD,V8=OD,H8=LD,W8=ID,G8=MD;function Nb({...t}){return e.jsx(B8,{"data-slot":"dropdown-menu",...t})}function wb({...t}){return e.jsx($8,{"data-slot":"dropdown-menu-trigger",...t})}function Sb({className:t,sideOffset:s=4,...n}){return e.jsx(q8,{children:e.jsx(z8,{"data-slot":"dropdown-menu-content",sideOffset:s,className:jt("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 FD({className:t,inset:s,variant:n="default",...r}){return e.jsx(V8,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":n,className:jt("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 K8({className:t,children:s,checked:n,...r}){return e.jsxs(H8,{"data-slot":"dropdown-menu-checkbox-item",className:jt("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(W8,{children:e.jsx(Wn,{className:"size-4"})})}),s]})}function Y8({className:t,inset:s,...n}){return e.jsx(U8,{"data-slot":"dropdown-menu-label","data-inset":s,className:jt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function Z8({className:t,...s}){return e.jsx(G8,{"data-slot":"dropdown-menu-separator",className:jt("bg-border -mx-1 my-1 h-px",t),...s})}const Q8=Zy("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 Ce({className:t,variant:s,asChild:n=!1,...r}){const a=n?UA:"span";return e.jsx(a,{"data-slot":"badge",className:jt(Q8({variant:s}),t),...r})}const vm="/communication",Qo={getNotifications:async(t,s)=>{let n=`${vm}/notifications`;return t&&s&&(n+=`?page=${t}&limit=${s}`),(await $e.get(n)).data},markAsRead:async t=>(await $e.patch(`${vm}/notifications/${t}/read`)).data,markAllAsRead:async()=>(await $e.patch(`${vm}/notifications/read-all`)).data,updatePushSubscription:async t=>(await $e.post(`${vm}/notifications/subscribe`,{subscription:t})).data},qi=Object.create(null);qi.open="0";qi.close="1";qi.ping="2";qi.pong="3";qi.message="4";qi.upgrade="5";qi.noop="6";const qm=Object.create(null);Object.keys(qi).forEach(t=>{qm[qi[t]]=t});const xy={type:"error",data:"parser error"},BD=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",$D=typeof ArrayBuffer=="function",qD=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Cb=({type:t,data:s},n,r)=>BD&&s instanceof Blob?n?r(s):aS(s,r):$D&&(s instanceof ArrayBuffer||qD(s))?n?r(s):aS(new Blob([s]),r):r(qi[t]+(s||"")),aS=(t,s)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];s("b"+(r||""))},n.readAsDataURL(t)};function iS(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let Tg;function X8(t,s){if(BD&&t.data instanceof Blob)return t.data.arrayBuffer().then(iS).then(s);if($D&&(t.data instanceof ArrayBuffer||qD(t.data)))return s(iS(t.data));Cb(t,!1,n=>{Tg||(Tg=new TextEncoder),s(Tg.encode(n))})}const lS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pu=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<lS.length;t++)pu[lS.charCodeAt(t)]=t;const J8=t=>{let s=t.length*.75,n=t.length,r,a=0,l,o,d,m;t[t.length-1]==="="&&(s--,t[t.length-2]==="="&&s--);const f=new ArrayBuffer(s),x=new Uint8Array(f);for(r=0;r<n;r+=4)l=pu[t.charCodeAt(r)],o=pu[t.charCodeAt(r+1)],d=pu[t.charCodeAt(r+2)],m=pu[t.charCodeAt(r+3)],x[a++]=l<<2|o>>4,x[a++]=(o&15)<<4|d>>2,x[a++]=(d&3)<<6|m&63;return f},e9=typeof ArrayBuffer=="function",Ab=(t,s)=>{if(typeof t!="string")return{type:"message",data:zD(t,s)};const n=t.charAt(0);return n==="b"?{type:"message",data:t9(t.substring(1),s)}:qm[n]?t.length>1?{type:qm[n],data:t.substring(1)}:{type:qm[n]}:xy},t9=(t,s)=>{if(e9){const n=J8(t);return zD(n,s)}else return{base64:!0,data:t}},zD=(t,s)=>{switch(s){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},UD="",s9=(t,s)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((l,o)=>{Cb(l,!1,d=>{r[o]=d,++a===n&&s(r.join(UD))})})},n9=(t,s)=>{const n=t.split(UD),r=[];for(let a=0;a<n.length;a++){const l=Ab(n[a],s);if(r.push(l),l.type==="error")break}return r};function r9(){return new TransformStream({transform(t,s){X8(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 l=new DataView(a.buffer);l.setUint8(0,126),l.setUint16(1,r)}else{a=new Uint8Array(9);const l=new DataView(a.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),s.enqueue(a),s.enqueue(n)})}})}let Pg;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 a9(t,s){Pg||(Pg=new TextDecoder);const n=[];let r=0,a=-1,l=!1;return new TransformStream({transform(o,d){for(n.push(o);;){if(r===0){if(ym(n)<1)break;const m=bm(n,1);l=(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),x=f.getUint32(0);if(x>Math.pow(2,21)-1){d.enqueue(xy);break}a=x*Math.pow(2,32)+f.getUint32(4),r=3}else{if(ym(n)<a)break;const m=bm(n,a);d.enqueue(Ab(l?m:Pg.decode(m),s)),r=0}if(a===0||a>t){d.enqueue(xy);break}}}})}const VD=4;function ir(t){if(t)return i9(t)}function i9(t){for(var s in ir.prototype)t[s]=ir.prototype[s];return t}ir.prototype.on=ir.prototype.addEventListener=function(t,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(s),this};ir.prototype.once=function(t,s){function n(){this.off(t,n),s.apply(this,arguments)}return n.fn=s,this.on(t,n),this};ir.prototype.off=ir.prototype.removeListener=ir.prototype.removeAllListeners=ir.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};ir.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};ir.prototype.emitReserved=ir.prototype.emit;ir.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};ir.prototype.hasListeners=function(t){return!!this.listeners(t).length};const ep=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,n)=>n(s,0),Va=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),l9="arraybuffer";function HD(t,...s){return s.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const o9=Va.setTimeout,c9=Va.clearTimeout;function tp(t,s){s.useNativeTimers?(t.setTimeoutFn=o9.bind(Va),t.clearTimeoutFn=c9.bind(Va)):(t.setTimeoutFn=Va.setTimeout.bind(Va),t.clearTimeoutFn=Va.clearTimeout.bind(Va))}const d9=1.33;function u9(t){return typeof t=="string"?h9(t):Math.ceil((t.byteLength||t.size)*d9)}function h9(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 WD(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function m9(t){let s="";for(let n in t)t.hasOwnProperty(n)&&(s.length&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return s}function f9(t){let s={},n=t.split("&");for(let r=0,a=n.length;r<a;r++){let l=n[r].split("=");s[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return s}class p9 extends Error{constructor(s,n,r){super(s),this.description=n,this.context=r,this.type="TransportError"}}class kb extends ir{constructor(s){super(),this.writable=!1,tp(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 p9(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=Ab(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=m9(s);return n.length?"?"+n:""}}class x9 extends kb{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)};n9(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,s9(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]=WD()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(s,n)}}let GD=!1;try{GD=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const g9=GD;function v9(){}class y9 extends x9{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,l)=>{this.onError("xhr post error",a,l)})}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 Bi extends ir{constructor(s,n,r){super(),this.createRequest=s,tp(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=HD(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=Bi.requestsCount++,Bi.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=v9,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Bi.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()}}Bi.requestsCount=0;Bi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",oS);else if(typeof addEventListener=="function"){const t="onpagehide"in Va?"pagehide":"unload";addEventListener(t,oS,!1)}}function oS(){for(let t in Bi.requests)Bi.requests.hasOwnProperty(t)&&Bi.requests[t].abort()}const b9=(function(){const t=KD({xdomain:!1});return t&&t.responseType!==null})();class j9 extends y9{constructor(s){super(s);const n=s&&s.forceBase64;this.supportsBinary=b9&&!n}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Bi(KD,this.uri(),s)}}function KD(t){const s=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||g9))return new XMLHttpRequest}catch{}if(!s)try{return new Va[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const YD=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class N9 extends kb{get name(){return"websocket"}doOpen(){const s=this.uri(),n=this.opts.protocols,r=YD?{}:HD(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;Cb(r,this.supportsBinary,l=>{try{this.doWrite(r,l)}catch{}a&&ep(()=>{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]=WD()),this.supportsBinary||(n.b64=1),this.createUri(s,n)}}const Og=Va.WebSocket||Va.MozWebSocket;class w9 extends N9{createSocket(s,n,r){return YD?new Og(s,n,r):n?new Og(s,n):new Og(s)}doWrite(s,n){this.ws.send(n)}}class S9 extends kb{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=a9(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=s.readable.pipeThrough(n).getReader(),a=r9();a.readable.pipeTo(s.writable),this._writer=a.writable.getWriter();const l=()=>{r.read().then(({done:d,value:m})=>{d||(this.onPacket(m),l())}).catch(d=>{})};l();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&&ep(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const C9={websocket:w9,webtransport:S9,polling:j9},A9=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,k9=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function gy(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=A9.exec(t||""),l={},o=14;for(;o--;)l[k9[o]]=a[o]||"";return n!=-1&&r!=-1&&(l.source=s,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=D9(l,l.path),l.queryKey=R9(l,l.query),l}function D9(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 R9(t,s){const n={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,l){a&&(n[a]=l)}),n}const vy=typeof addEventListener=="function"&&typeof removeEventListener=="function",zm=[];vy&&addEventListener("offline",()=>{zm.forEach(t=>t())},!1);class Xl extends ir{constructor(s,n){if(super(),this.binaryType=l9,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=gy(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=gy(n.host).host);tp(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=f9(this.opts.query)),vy&&(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"})},zm.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const n=Object.assign({},this.opts.query);n.EIO=VD,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&&Xl.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",Xl.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+=u9(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,ep(()=>{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 l={type:s,data:n,options:r};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),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(Xl.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(),vy&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=zm.indexOf(this._offlineEventListener);r!==-1&&zm.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,n),this.writeBuffer=[],this._prevBufferLen=0}}}Xl.protocol=VD;class E9 extends Xl{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;Xl.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;Xl.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(x(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const p=new Error("probe error");p.transport=n.name,this.emitReserved("upgradeError",p)}}))};function l(){r||(r=!0,x(),n.close(),n=null)}const o=h=>{const p=new Error("probe error: "+h);p.transport=n.name,l(),this.emitReserved("upgradeError",p)};function d(){o("transport closed")}function m(){o("socket closed")}function f(h){n&&h.name!==n.name&&l()}const x=()=>{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 _9=class extends E9{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=>C9[a]).filter(a=>!!a)),super(s,r)}};function T9(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=gy(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 l=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+l+":"+r.port+s,r.href=r.protocol+"://"+l+(n&&n.port===r.port?"":":"+r.port),r}const P9=typeof ArrayBuffer=="function",O9=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,ZD=Object.prototype.toString,L9=typeof Blob=="function"||typeof Blob<"u"&&ZD.call(Blob)==="[object BlobConstructor]",I9=typeof File=="function"||typeof File<"u"&&ZD.call(File)==="[object FileConstructor]";function Db(t){return P9&&(t instanceof ArrayBuffer||O9(t))||L9&&t instanceof Blob||I9&&t instanceof File}function Um(t,s){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Um(t[n]))return!0;return!1}if(Db(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Um(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Um(t[n]))return!0;return!1}function M9(t){const s=[],n=t.data,r=t;return r.data=yy(n,s),r.attachments=s.length,{packet:r,buffers:s}}function yy(t,s){if(!t)return t;if(Db(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]=yy(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]=yy(t[r],s));return n}return t}function F9(t,s){return t.data=by(t.data,s),delete t.attachments,t}function by(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]=by(t[n],s);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=by(t[n],s));return t}const B9=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var pn;(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"})(pn||(pn={}));class $9{constructor(s){this.replacer=s}encode(s){return(s.type===pn.EVENT||s.type===pn.ACK)&&Um(s)?this.encodeAsBinary({type:s.type===pn.EVENT?pn.BINARY_EVENT:pn.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let n=""+s.type;return(s.type===pn.BINARY_EVENT||s.type===pn.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=M9(s),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class Rb extends ir{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===pn.BINARY_EVENT;r||n.type===pn.BINARY_ACK?(n.type=r?pn.EVENT:pn.ACK,this.reconstructor=new q9(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Db(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(pn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===pn.BINARY_EVENT||r.type===pn.BINARY_ACK){const l=n+1;for(;s.charAt(++n)!=="-"&&n!=s.length;);const o=s.substring(l,n);if(o!=Number(o)||s.charAt(n)!=="-")throw new Error("Illegal attachments");const d=Number(o);if(!z9(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 l=n+1;for(;++n&&!(s.charAt(n)===","||n===s.length););r.nsp=s.substring(l,n)}else r.nsp="/";const a=s.charAt(n+1);if(a!==""&&Number(a)==a){const l=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(l,n+1))}if(s.charAt(++n)){const l=this.tryParse(s.substr(n));if(Rb.isPayloadValid(r.type,l))r.data=l;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 pn.CONNECT:return cS(n);case pn.DISCONNECT:return n===void 0;case pn.CONNECT_ERROR:return typeof n=="string"||cS(n);case pn.EVENT:case pn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&B9.indexOf(n[0])===-1);case pn.ACK:case pn.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class q9{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=F9(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const z9=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function cS(t){return Object.prototype.toString.call(t)==="[object Object]"}const U9=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Rb,Encoder:$9,get PacketType(){return pn}},Symbol.toStringTag,{value:"Module"}));function ci(t,s,n){return t.on(s,n),function(){t.off(s,n)}}const V9=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class QD extends ir{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=[ci(s,"open",this.onopen.bind(this)),ci(s,"packet",this.onpacket.bind(this)),ci(s,"error",this.onerror.bind(this)),ci(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,l;if(V9.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:pn.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const x=this.ids++,h=n.pop();this._registerAckCallback(x,h),o.id=x}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&&!(!((l=this.io.engine)===null||l===void 0)&&l._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 l=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(l),n.apply(this,d)};o.withError=!0,this.acks[s]=o}emitWithAck(s,...n){return new Promise((r,a)=>{const l=(o,d)=>o?a(o):r(d);l.withError=!0,n.push(l),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,...l)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...l)),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:pn.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 pn.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 pn.EVENT:case pn.BINARY_EVENT:this.onevent(s);break;case pn.ACK:case pn.BINARY_ACK:this.onack(s);break;case pn.DISCONNECT:this.ondisconnect();break;case pn.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:pn.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:pn.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 jy extends ir{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,tp(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||U9;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 _9(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=ci(n,"open",function(){r.onopen(),s&&s()}),l=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),s?s(d):this.maybeReconnectOnOpen()},o=ci(n,"error",l);if(this._timeout!==!1){const d=this._timeout,m=this.setTimeoutFn(()=>{a(),l(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(ci(s,"ping",this.onping.bind(this)),ci(s,"data",this.ondata.bind(this)),ci(s,"error",this.onerror.bind(this)),ci(s,"close",this.onclose.bind(this)),ci(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){ep(()=>{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 QD(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 nu={};function Vm(t,s){typeof t=="object"&&(s=t,t=void 0),s=s||{};const n=T9(t,s.path||"/socket.io"),r=n.source,a=n.id,l=n.path,o=nu[a]&&l in nu[a].nsps,d=s.forceNew||s["force new connection"]||s.multiplex===!1||o;let m;return d?m=new jy(r,s):(nu[a]||(nu[a]=new jy(r,s)),m=nu[a]),n.query&&!s.query&&(s.query=n.queryKey),m.socket(n.path,s)}Object.assign(Vm,{Manager:jy,Socket:QD,io:Vm,connect:Vm});const XD=g.createContext({socket:null,isConnected:!1}),JD=()=>g.useContext(XD),H9=({children:t})=>{const[s,n]=g.useState(null),[r,a]=g.useState(!1),{user:l}=Fn(o=>o.auth);return g.useEffect(()=>{let o="https://dealeronboarding-uat.royalenfield.com/api";o.endsWith("/api")&&(o=o.replace(/\/api$/,""));const d=Vm(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&&(l!=null&&l.id))return s.emit("join_room",`user_${l.id}`),console.log(`Joined private notification room: user_${l.id}`),()=>{s.emit("leave_room",`user_${l.id}`)}},[s,r,l==null?void 0:l.id]),e.jsx(XD.Provider,{value:{socket:s,isConnected:r},children:t})};function Hs(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 xa(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Zr(t,s){const n=Hs(t);return isNaN(s)?xa(t,NaN):(s&&n.setDate(n.getDate()+s),n)}function gi(t,s){const n=Hs(t);if(isNaN(s))return xa(t,NaN);if(!s)return n;const r=n.getDate(),a=xa(t,n.getTime());a.setMonth(n.getMonth()+s+1,0);const l=a.getDate();return r>=l?a:(n.setFullYear(a.getFullYear(),a.getMonth(),r),n)}const Eb=6048e5,W9=864e5,jm=43200,dS=1440;let G9={};function Sd(){return G9}function zi(t,s){var d,m,f,x;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??((x=(f=n.locale)==null?void 0:f.options)==null?void 0:x.weekStartsOn)??0,a=Hs(t),l=a.getDay(),o=(l<r?7:0)+l-r;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function lc(t){return zi(t,{weekStartsOn:1})}function eR(t){const s=Hs(t),n=s.getFullYear(),r=xa(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=lc(r),l=xa(t,0);l.setFullYear(n,0,4),l.setHours(0,0,0,0);const o=lc(l);return s.getTime()>=a.getTime()?n+1:s.getTime()>=o.getTime()?n:n-1}function od(t){const s=Hs(t);return s.setHours(0,0,0,0),s}function cd(t){const s=Hs(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 Mi(t,s){const n=od(t),r=od(s),a=+n-cd(n),l=+r-cd(r);return Math.round((a-l)/W9)}function K9(t){const s=eR(t),n=xa(t,0);return n.setFullYear(s,0,4),n.setHours(0,0,0,0),lc(n)}function Ny(t,s){const n=s*7;return Zr(t,n)}function Y9(t,s){return gi(t,s*12)}function Z9(t){let s;return t.forEach(function(n){const r=Hs(n);(s===void 0||s<r||isNaN(Number(r)))&&(s=r)}),s||new Date(NaN)}function Q9(t){let s;return t.forEach(n=>{const r=Hs(n);(!s||s>r||isNaN(+r))&&(s=r)}),s||new Date(NaN)}function Hm(t,s){const n=Hs(t),r=Hs(s),a=n.getTime()-r.getTime();return a<0?-1:a>0?1:a}function X9(t){return xa(t,Date.now())}function ha(t,s){const n=od(t),r=od(s);return+n==+r}function _b(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function J9(t){if(!_b(t)&&typeof t!="number")return!1;const s=Hs(t);return!isNaN(Number(s))}function dd(t,s){const n=Hs(t),r=Hs(s),a=n.getFullYear()-r.getFullYear(),l=n.getMonth()-r.getMonth();return a*12+l}function eB(t,s,n){const r=zi(t,n),a=zi(s,n),l=+r-cd(r),o=+a-cd(a);return Math.round((l-o)/Eb)}function tB(t){return s=>{const r=(t?Math[t]:Math.trunc)(s);return r===0?0:r}}function sB(t,s){return+Hs(t)-+Hs(s)}function nB(t){const s=Hs(t);return s.setHours(23,59,59,999),s}function sp(t){const s=Hs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(23,59,59,999),s}function rB(t){const s=Hs(t);return+nB(s)==+sp(s)}function aB(t,s){const n=Hs(t),r=Hs(s),a=Hm(n,r),l=Math.abs(dd(n,r));let o;if(l<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*l);let d=Hm(n,r)===-a;rB(Hs(t))&&l===1&&Hm(t,r)===1&&(d=!1),o=a*(l-Number(d))}return o===0?0:o}function iB(t,s,n){const r=sB(t,s)/1e3;return tB(n==null?void 0:n.roundingMethod)(r)}function pa(t){const s=Hs(t);return s.setDate(1),s.setHours(0,0,0,0),s}function tR(t){const s=Hs(t),n=xa(t,0);return n.setFullYear(s.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Tb(t,s){var d,m,f,x;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??((x=(f=n.locale)==null?void 0:f.options)==null?void 0:x.weekStartsOn)??0,a=Hs(t),l=a.getDay(),o=(l<r?-7:0)+6-(l-r);return a.setDate(a.getDate()+o),a.setHours(23,59,59,999),a}function sR(t){return Tb(t,{weekStartsOn:1})}const lB={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"}},oB=(t,s,n)=>{let r;const a=lB[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 Lg(t){return(s={})=>{const n=s.width?String(s.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const cB={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},dB={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},uB={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hB={date:Lg({formats:cB,defaultWidth:"full"}),time:Lg({formats:dB,defaultWidth:"full"}),dateTime:Lg({formats:uB,defaultWidth:"full"})},mB={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},fB=(t,s,n,r)=>mB[t];function ru(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 l=t.argumentCallback?t.argumentCallback(s):s;return a[l]}}const pB={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xB={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},gB={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"]},vB={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"]},yB={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"}},bB={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"}},jB=(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"},NB={ordinalNumber:jB,era:ru({values:pB,defaultWidth:"wide"}),quarter:ru({values:xB,defaultWidth:"wide",argumentCallback:t=>t-1}),month:ru({values:gB,defaultWidth:"wide"}),day:ru({values:vB,defaultWidth:"wide"}),dayPeriod:ru({values:yB,defaultWidth:"wide",formattingValues:bB,defaultFormattingWidth:"wide"})};function au(t){return(s,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],l=s.match(a);if(!l)return null;const o=l[0],d=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(d)?SB(d,h=>h.test(o)):wB(d,h=>h.test(o));let f;f=t.valueCallback?t.valueCallback(m):m,f=n.valueCallback?n.valueCallback(f):f;const x=s.slice(o.length);return{value:f,rest:x}}}function wB(t,s){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s(t[n]))return n}function SB(t,s){for(let n=0;n<t.length;n++)if(s(t[n]))return n}function CB(t){return(s,n={})=>{const r=s.match(t.matchPattern);if(!r)return null;const a=r[0],l=s.match(t.parsePattern);if(!l)return null;let o=t.valueCallback?t.valueCallback(l[0]):l[0];o=n.valueCallback?n.valueCallback(o):o;const d=s.slice(a.length);return{value:o,rest:d}}}const AB=/^(\d+)(th|st|nd|rd)?/i,kB=/\d+/i,DB={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},RB={any:[/^b/i,/^(a|c)/i]},EB={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},_B={any:[/1/i,/2/i,/3/i,/4/i]},TB={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},PB={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]},OB={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},LB={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]},IB={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},MB={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}},FB={ordinalNumber:CB({matchPattern:AB,parsePattern:kB,valueCallback:t=>parseInt(t,10)}),era:au({matchPatterns:DB,defaultMatchWidth:"wide",parsePatterns:RB,defaultParseWidth:"any"}),quarter:au({matchPatterns:EB,defaultMatchWidth:"wide",parsePatterns:_B,defaultParseWidth:"any",valueCallback:t=>t+1}),month:au({matchPatterns:TB,defaultMatchWidth:"wide",parsePatterns:PB,defaultParseWidth:"any"}),day:au({matchPatterns:OB,defaultMatchWidth:"wide",parsePatterns:LB,defaultParseWidth:"any"}),dayPeriod:au({matchPatterns:IB,defaultMatchWidth:"any",parsePatterns:MB,defaultParseWidth:"any"})},Pb={code:"en-US",formatDistance:oB,formatLong:hB,formatRelative:fB,localize:NB,match:FB,options:{weekStartsOn:0,firstWeekContainsDate:1}};function BB(t){const s=Hs(t);return Mi(s,tR(s))+1}function nR(t){const s=Hs(t),n=+lc(s)-+K9(s);return Math.round(n/Eb)+1}function rR(t,s){var x,h,p,u;const n=Hs(t),r=n.getFullYear(),a=Sd(),l=(s==null?void 0:s.firstWeekContainsDate)??((h=(x=s==null?void 0:s.locale)==null?void 0:x.options)==null?void 0:h.firstWeekContainsDate)??a.firstWeekContainsDate??((u=(p=a.locale)==null?void 0:p.options)==null?void 0:u.firstWeekContainsDate)??1,o=xa(t,0);o.setFullYear(r+1,0,l),o.setHours(0,0,0,0);const d=zi(o,s),m=xa(t,0);m.setFullYear(r,0,l),m.setHours(0,0,0,0);const f=zi(m,s);return n.getTime()>=d.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function $B(t,s){var d,m,f,x;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??((x=(f=n.locale)==null?void 0:f.options)==null?void 0:x.firstWeekContainsDate)??1,a=rR(t,s),l=xa(t,0);return l.setFullYear(a,0,r),l.setHours(0,0,0,0),zi(l,s)}function aR(t,s){const n=Hs(t),r=+zi(n,s)-+$B(n,s);return Math.round(r/Eb)+1}function Rn(t,s){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(s,"0");return n+r}const Gl={y(t,s){const n=t.getFullYear(),r=n>0?n:1-n;return Rn(s==="yy"?r%100:r,s.length)},M(t,s){const n=t.getMonth();return s==="M"?String(n+1):Rn(n+1,2)},d(t,s){return Rn(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 Rn(t.getHours()%12||12,s.length)},H(t,s){return Rn(t.getHours(),s.length)},m(t,s){return Rn(t.getMinutes(),s.length)},s(t,s){return Rn(t.getSeconds(),s.length)},S(t,s){const n=s.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return Rn(a,s.length)}},zc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},uS={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 Gl.y(t,s)},Y:function(t,s,n,r){const a=rR(t,r),l=a>0?a:1-a;if(s==="YY"){const o=l%100;return Rn(o,2)}return s==="Yo"?n.ordinalNumber(l,{unit:"year"}):Rn(l,s.length)},R:function(t,s){const n=eR(t);return Rn(n,s.length)},u:function(t,s){const n=t.getFullYear();return Rn(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 Rn(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 Rn(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 Gl.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 Rn(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=aR(t,r);return s==="wo"?n.ordinalNumber(a,{unit:"week"}):Rn(a,s.length)},I:function(t,s,n){const r=nR(t);return s==="Io"?n.ordinalNumber(r,{unit:"week"}):Rn(r,s.length)},d:function(t,s,n){return s==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Gl.d(t,s)},D:function(t,s,n){const r=BB(t);return s==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Rn(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(),l=(a-r.weekStartsOn+8)%7||7;switch(s){case"e":return String(l);case"ee":return Rn(l,2);case"eo":return n.ordinalNumber(l,{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(),l=(a-r.weekStartsOn+8)%7||7;switch(s){case"c":return String(l);case"cc":return Rn(l,s.length);case"co":return n.ordinalNumber(l,{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 Rn(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 Gl.h(t,s)},H:function(t,s,n){return s==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Gl.H(t,s)},K:function(t,s,n){const r=t.getHours()%12;return s==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Rn(r,s.length)},k:function(t,s,n){let r=t.getHours();return r===0&&(r=24),s==="ko"?n.ordinalNumber(r,{unit:"hour"}):Rn(r,s.length)},m:function(t,s,n){return s==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Gl.m(t,s)},s:function(t,s,n){return s==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Gl.s(t,s)},S:function(t,s){return Gl.S(t,s)},X:function(t,s,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(s){case"X":return mS(r);case"XXXX":case"XX":return Ho(r);case"XXXXX":case"XXX":default:return Ho(r,":")}},x:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"x":return mS(r);case"xxxx":case"xx":return Ho(r);case"xxxxx":case"xxx":default:return Ho(r,":")}},O:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+hS(r,":");case"OOOO":default:return"GMT"+Ho(r,":")}},z:function(t,s,n){const r=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+hS(r,":");case"zzzz":default:return"GMT"+Ho(r,":")}},t:function(t,s,n){const r=Math.trunc(t.getTime()/1e3);return Rn(r,s.length)},T:function(t,s,n){const r=t.getTime();return Rn(r,s.length)}};function hS(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),l=r%60;return l===0?n+String(a):n+String(a)+s+Rn(l,2)}function mS(t,s){return t%60===0?(t>0?"-":"+")+Rn(Math.abs(t)/60,2):Ho(t,s)}function Ho(t,s=""){const n=t>0?"-":"+",r=Math.abs(t),a=Rn(Math.trunc(r/60),2),l=Rn(r%60,2);return n+a+s+l}const fS=(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"})}},iR=(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"})}},qB=(t,s)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return fS(t,s);let l;switch(r){case"P":l=s.dateTime({width:"short"});break;case"PP":l=s.dateTime({width:"medium"});break;case"PPP":l=s.dateTime({width:"long"});break;case"PPPP":default:l=s.dateTime({width:"full"});break}return l.replace("{{date}}",fS(r,s)).replace("{{time}}",iR(a,s))},zB={p:iR,P:qB},UB=/^D+$/,VB=/^Y+$/,HB=["D","DD","YY","YYYY"];function WB(t){return UB.test(t)}function GB(t){return VB.test(t)}function KB(t,s,n){const r=YB(t,s,n);if(console.warn(r),HB.includes(t))throw new RangeError(r)}function YB(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 ZB=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,QB=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,XB=/^'([^]*?)'?$/,JB=/''/g,e$=/[a-zA-Z]/;function Ka(t,s,n){var x,h,p,u,w,v,N,j;const r=Sd(),a=(n==null?void 0:n.locale)??r.locale??Pb,l=(n==null?void 0:n.firstWeekContainsDate)??((h=(x=n==null?void 0:n.locale)==null?void 0:x.options)==null?void 0:h.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(p=r.locale)==null?void 0:p.options)==null?void 0:u.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((v=(w=n==null?void 0:n.locale)==null?void 0:w.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((j=(N=r.locale)==null?void 0:N.options)==null?void 0:j.weekStartsOn)??0,d=Hs(t);if(!J9(d))throw new RangeError("Invalid time value");let m=s.match(QB).map(y=>{const C=y[0];if(C==="p"||C==="P"){const S=zB[C];return S(y,a.formatLong)}return y}).join("").match(ZB).map(y=>{if(y==="''")return{isToken:!1,value:"'"};const C=y[0];if(C==="'")return{isToken:!1,value:t$(y)};if(uS[C])return{isToken:!0,value:y};if(C.match(e$))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:y}});a.localize.preprocessor&&(m=a.localize.preprocessor(d,m));const f={firstWeekContainsDate:l,weekStartsOn:o,locale:a};return m.map(y=>{if(!y.isToken)return y.value;const C=y.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&GB(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&WB(C))&&KB(C,s,String(t));const S=uS[C[0]];return S(d,C,a.localize,f)}).join("")}function t$(t){const s=t.match(XB);return s?s[1].replace(JB,"'"):t}function s$(t,s,n){const r=Sd(),a=(n==null?void 0:n.locale)??r.locale??Pb,l=2520,o=Hm(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=Hs(s),f=Hs(t)):(m=Hs(t),f=Hs(s));const x=iB(f,m),h=(cd(f)-cd(m))/1e3,p=Math.round((x-h)/60);let u;if(p<2)return n!=null&&n.includeSeconds?x<5?a.formatDistance("lessThanXSeconds",5,d):x<10?a.formatDistance("lessThanXSeconds",10,d):x<20?a.formatDistance("lessThanXSeconds",20,d):x<40?a.formatDistance("halfAMinute",0,d):x<60?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",1,d):p===0?a.formatDistance("lessThanXMinutes",1,d):a.formatDistance("xMinutes",p,d);if(p<45)return a.formatDistance("xMinutes",p,d);if(p<90)return a.formatDistance("aboutXHours",1,d);if(p<dS){const w=Math.round(p/60);return a.formatDistance("aboutXHours",w,d)}else{if(p<l)return a.formatDistance("xDays",1,d);if(p<jm){const w=Math.round(p/dS);return a.formatDistance("xDays",w,d)}else if(p<jm*2)return u=Math.round(p/jm),a.formatDistance("aboutXMonths",u,d)}if(u=aB(f,m),u<12){const w=Math.round(p/jm);return a.formatDistance("xMonths",w,d)}else{const w=u%12,v=Math.trunc(u/12);return w<3?a.formatDistance("aboutXYears",v,d):w<9?a.formatDistance("overXYears",v,d):a.formatDistance("almostXYears",v+1,d)}}function lR(t,s){return s$(t,X9(t),s)}function n$(t){const s=Hs(t),n=s.getFullYear(),r=s.getMonth(),a=xa(t,0);return a.setFullYear(n,r+1,0),a.setHours(0,0,0,0),a.getDate()}function r$(t){return Math.trunc(+Hs(t)/1e3)}function a$(t){const s=Hs(t),n=s.getMonth();return s.setFullYear(s.getFullYear(),n+1,0),s.setHours(0,0,0,0),s}function i$(t,s){return eB(a$(t),pa(t),s)+1}function wy(t,s){const n=Hs(t),r=Hs(s);return n.getTime()>r.getTime()}function oR(t,s){const n=Hs(t),r=Hs(s);return+n<+r}function Ob(t,s){const n=Hs(t),r=Hs(s);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function l$(t,s){const n=Hs(t),r=Hs(s);return n.getFullYear()===r.getFullYear()}function Ig(t,s){return Zr(t,-s)}function Mg(t,s){const n=Hs(t),r=n.getFullYear(),a=n.getDate(),l=xa(t,0);l.setFullYear(r,s,15),l.setHours(0,0,0,0);const o=n$(l);return n.setMonth(s,Math.min(a,o)),n}function pS(t,s){const n=Hs(t);return isNaN(+n)?xa(t,NaN):(n.setFullYear(s),n)}function o$({title:t,subtitle:s,onRefresh:n}){const{user:r}=Fn(h=>h.auth),{socket:a}=JD(),[l,o]=g.useState([]),[d,m]=g.useState(0);g.useEffect(()=>{(async()=>{try{const p=await Qo.getNotifications(1,15);p.success&&(o(p.data),p.pagination&&p.pagination.unreadCount!==void 0?m(p.pagination.unreadCount):m(p.data.filter(u=>!u.isRead).length))}catch(p){console.error("Fetch notifications error:",p)}})()},[]),g.useEffect(()=>{if(a)return a.on("notification",h=>{o(p=>[h,...p].slice(0,15)),m(p=>p+1),ee(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 Qo.markAsRead(h.id)).success&&(o(u=>u.map(w=>w.id===h.id?{...w,isRead:!0}:w)),m(u=>Math.max(0,u-1))),h.link&&(window.location.href=h.link)}catch(p){console.error("Notification click error:",p)}},x=async()=>{try{(await Qo.markAllAsRead()).success&&(o(p=>p.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(Ir,{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(se,{variant:"outline",size:"icon",onClick:n,title:"Refresh",children:e.jsx(pr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"outline",size:"icon",title:"Help",children:e.jsx(uk,{className:"w-4 h-4"})}),e.jsxs(Nb,{children:[e.jsx(wb,{asChild:!0,children:e.jsxs(se,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(ku,{className:"w-4 h-4"}),d>0&&e.jsx(Ce,{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(Sb,{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:x,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:l.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500",children:"No notifications yet"}):l.map(h=>e.jsxs(FD,{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:lR(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 Le({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:jt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",t),...s})}function Qe({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:jt("@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 et({className:t,...s}){return e.jsx("h4",{"data-slot":"card-title",className:jt("leading-none",t),...s})}function Qt({className:t,...s}){return e.jsx("p",{"data-slot":"card-description",className:jt("text-muted-foreground",t),...s})}function Fe({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:jt("px-6 [&:last-child]:pb-6",t),...s})}function Sy(t,[s,n]){return Math.min(n,Math.max(s,t))}function c$(t,s){return g.useReducer((n,r)=>s[n][r]??n,t)}var Lb="ScrollArea",[cR]=ga(Lb),[d$,Ya]=cR(Lb),dR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:l=600,...o}=t,[d,m]=g.useState(null),[f,x]=g.useState(null),[h,p]=g.useState(null),[u,w]=g.useState(null),[v,N]=g.useState(null),[j,y]=g.useState(0),[C,S]=g.useState(0),[D,R]=g.useState(!1),[A,L]=g.useState(!1),$=Ks(s,E=>m(E)),P=Yu(a);return e.jsx(d$,{scope:n,type:r,dir:P,scrollHideDelay:l,scrollArea:d,viewport:f,onViewportChange:x,content:h,onContentChange:p,scrollbarX:u,onScrollbarXChange:w,scrollbarXEnabled:D,onScrollbarXEnabledChange:R,scrollbarY:v,onScrollbarYChange:N,scrollbarYEnabled:A,onScrollbarYEnabledChange:L,onCornerWidthChange:y,onCornerHeightChange:S,children:e.jsx(ws.div,{dir:P,...o,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...t.style}})})});dR.displayName=Lb;var uR="ScrollAreaViewport",hR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,children:r,nonce:a,...l}=t,o=Ya(uR,n),d=g.useRef(null),m=Ks(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(ws.div,{"data-radix-scroll-area-viewport":"",...l,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})})]})});hR.displayName=uR;var Hi="ScrollAreaScrollbar",mR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ya(Hi,t.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:o}=a,d=t.orientation==="horizontal";return g.useEffect(()=>(d?l(!0):o(!0),()=>{d?l(!1):o(!1)}),[d,l,o]),a.type==="hover"?e.jsx(u$,{...r,ref:s,forceMount:n}):a.type==="scroll"?e.jsx(h$,{...r,ref:s,forceMount:n}):a.type==="auto"?e.jsx(fR,{...r,ref:s,forceMount:n}):a.type==="always"?e.jsx(Ib,{...r,ref:s}):null});mR.displayName=Hi;var u$=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ya(Hi,t.__scopeScrollArea),[l,o]=g.useState(!1);return g.useEffect(()=>{const d=a.scrollArea;let m=0;if(d){const f=()=>{window.clearTimeout(m),o(!0)},x=()=>{m=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return d.addEventListener("pointerenter",f),d.addEventListener("pointerleave",x),()=>{window.clearTimeout(m),d.removeEventListener("pointerenter",f),d.removeEventListener("pointerleave",x)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(Rr,{present:n||l,children:e.jsx(fR,{"data-state":l?"visible":"hidden",...r,ref:s})})}),h$=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=Ya(Hi,t.__scopeScrollArea),l=t.orientation==="horizontal",o=rp(()=>m("SCROLL_END"),100),[d,m]=c$("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,x=l?"scrollLeft":"scrollTop";if(f){let h=f[x];const p=()=>{const u=f[x];h!==u&&(m("SCROLL"),o()),h=u};return f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[a.viewport,l,m,o]),e.jsx(Rr,{present:n||d!=="hidden",children:e.jsx(Ib,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:s,onPointerEnter:Wt(t.onPointerEnter,()=>m("POINTER_ENTER")),onPointerLeave:Wt(t.onPointerLeave,()=>m("POINTER_LEAVE"))})})}),fR=g.forwardRef((t,s)=>{const n=Ya(Hi,t.__scopeScrollArea),{forceMount:r,...a}=t,[l,o]=g.useState(!1),d=t.orientation==="horizontal",m=rp(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,x=n.viewport.offsetHeight<n.viewport.scrollHeight;o(d?f:x)}},10);return ud(n.viewport,m),ud(n.content,m),e.jsx(Rr,{present:r||l,children:e.jsx(Ib,{"data-state":l?"visible":"hidden",...a,ref:s})})}),Ib=g.forwardRef((t,s)=>{const{orientation:n="vertical",...r}=t,a=Ya(Hi,t.__scopeScrollArea),l=g.useRef(null),o=g.useRef(0),[d,m]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=yR(d.viewport,d.content),x={...r,sizes:d,onSizesChange:m,hasThumb:f>0&&f<1,onThumbChange:p=>l.current=p,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:p=>o.current=p};function h(p,u){return v$(p,o.current,d,u)}return n==="horizontal"?e.jsx(m$,{...x,ref:s,onThumbPositionChange:()=>{if(a.viewport&&l.current){const p=a.viewport.scrollLeft,u=xS(p,d,a.dir);l.current.style.transform=`translate3d(${u}px, 0, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollLeft=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollLeft=h(p,a.dir))}}):n==="vertical"?e.jsx(f$,{...x,ref:s,onThumbPositionChange:()=>{if(a.viewport&&l.current){const p=a.viewport.scrollTop,u=xS(p,d);l.current.style.transform=`translate3d(0, ${u}px, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollTop=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollTop=h(p))}}):null}),m$=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,l=Ya(Hi,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Ks(s,m,l.onScrollbarXChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(xR,{"data-orientation":"horizontal",...a,ref:f,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":np(n)+"px",...t.style},onThumbPointerDown:x=>t.onThumbPointerDown(x.x),onDragScroll:x=>t.onDragScroll(x.x),onWheelScroll:(x,h)=>{if(l.viewport){const p=l.viewport.scrollLeft+x.deltaX;t.onWheelScroll(p),jR(p,h)&&x.preventDefault()}},onResize:()=>{m.current&&l.viewport&&o&&r({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:m.current.clientWidth,paddingStart:pf(o.paddingLeft),paddingEnd:pf(o.paddingRight)}})}})}),f$=g.forwardRef((t,s)=>{const{sizes:n,onSizesChange:r,...a}=t,l=Ya(Hi,t.__scopeScrollArea),[o,d]=g.useState(),m=g.useRef(null),f=Ks(s,m,l.onScrollbarYChange);return g.useEffect(()=>{m.current&&d(getComputedStyle(m.current))},[m]),e.jsx(xR,{"data-orientation":"vertical",...a,ref:f,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":np(n)+"px",...t.style},onThumbPointerDown:x=>t.onThumbPointerDown(x.y),onDragScroll:x=>t.onDragScroll(x.y),onWheelScroll:(x,h)=>{if(l.viewport){const p=l.viewport.scrollTop+x.deltaY;t.onWheelScroll(p),jR(p,h)&&x.preventDefault()}},onResize:()=>{m.current&&l.viewport&&o&&r({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:m.current.clientHeight,paddingStart:pf(o.paddingTop),paddingEnd:pf(o.paddingBottom)}})}})}),[p$,pR]=cR(Hi),xR=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:l,onThumbPointerUp:o,onThumbPointerDown:d,onThumbPositionChange:m,onDragScroll:f,onWheelScroll:x,onResize:h,...p}=t,u=Ya(Hi,n),[w,v]=g.useState(null),N=Ks(s,$=>v($)),j=g.useRef(null),y=g.useRef(""),C=u.viewport,S=r.content-r.viewport,D=Sr(x),R=Sr(m),A=rp(h,10);function L($){if(j.current){const P=$.clientX-j.current.left,E=$.clientY-j.current.top;f({x:P,y:E})}}return g.useEffect(()=>{const $=P=>{const E=P.target;(w==null?void 0:w.contains(E))&&D(P,S)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[C,w,S,D]),g.useEffect(R,[r,R]),ud(w,A),ud(u.content,A),e.jsx(p$,{scope:n,scrollbar:w,hasThumb:a,onThumbChange:Sr(l),onThumbPointerUp:Sr(o),onThumbPositionChange:R,onThumbPointerDown:Sr(d),children:e.jsx(ws.div,{...p,ref:N,style:{position:"absolute",...p.style},onPointerDown:Wt(t.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),j.current=w.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",u.viewport&&(u.viewport.style.scrollBehavior="auto"),L($))}),onPointerMove:Wt(t.onPointerMove,L),onPointerUp:Wt(t.onPointerUp,$=>{const P=$.target;P.hasPointerCapture($.pointerId)&&P.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=y.current,u.viewport&&(u.viewport.style.scrollBehavior=""),j.current=null})})})}),ff="ScrollAreaThumb",gR=g.forwardRef((t,s)=>{const{forceMount:n,...r}=t,a=pR(ff,t.__scopeScrollArea);return e.jsx(Rr,{present:n||a.hasThumb,children:e.jsx(x$,{ref:s,...r})})}),x$=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,style:r,...a}=t,l=Ya(ff,n),o=pR(ff,n),{onThumbPositionChange:d}=o,m=Ks(s,h=>o.onThumbChange(h)),f=g.useRef(void 0),x=rp(()=>{f.current&&(f.current(),f.current=void 0)},100);return g.useEffect(()=>{const h=l.viewport;if(h){const p=()=>{if(x(),!f.current){const u=y$(h,d);f.current=u,d()}};return d(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[l.viewport,x,d]),e.jsx(ws.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:Wt(t.onPointerDownCapture,h=>{const u=h.target.getBoundingClientRect(),w=h.clientX-u.left,v=h.clientY-u.top;o.onThumbPointerDown({x:w,y:v})}),onPointerUp:Wt(t.onPointerUp,o.onThumbPointerUp)})});gR.displayName=ff;var Mb="ScrollAreaCorner",vR=g.forwardRef((t,s)=>{const n=Ya(Mb,t.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?e.jsx(g$,{...t,ref:s}):null});vR.displayName=Mb;var g$=g.forwardRef((t,s)=>{const{__scopeScrollArea:n,...r}=t,a=Ya(Mb,n),[l,o]=g.useState(0),[d,m]=g.useState(0),f=!!(l&&d);return ud(a.scrollbarX,()=>{var h;const x=((h=a.scrollbarX)==null?void 0:h.offsetHeight)||0;a.onCornerHeightChange(x),m(x)}),ud(a.scrollbarY,()=>{var h;const x=((h=a.scrollbarY)==null?void 0:h.offsetWidth)||0;a.onCornerWidthChange(x),o(x)}),f?e.jsx(ws.div,{...r,ref:s,style:{width:l,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function pf(t){return t?parseInt(t,10):0}function yR(t,s){const n=t/s;return isNaN(n)?0:n}function np(t){const s=yR(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,r=(t.scrollbar.size-n)*s;return Math.max(r,18)}function v$(t,s,n,r="ltr"){const a=np(n),l=a/2,o=s||l,d=a-o,m=n.scrollbar.paddingStart+o,f=n.scrollbar.size-n.scrollbar.paddingEnd-d,x=n.content-n.viewport,h=r==="ltr"?[0,x]:[x*-1,0];return bR([m,f],h)(t)}function xS(t,s,n="ltr"){const r=np(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,l=s.scrollbar.size-a,o=s.content-s.viewport,d=l-r,m=n==="ltr"?[0,o]:[o*-1,0],f=Sy(t,m);return bR([0,o],[0,d])(f)}function bR(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 jR(t,s){return t>0&&t<s}var y$=(t,s=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},r=0;return(function a(){const l={left:t.scrollLeft,top:t.scrollTop},o=n.left!==l.left,d=n.top!==l.top;(o||d)&&s(),n=l,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function rp(t,s){const n=Sr(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=Sr(s);cr(()=>{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 b$=dR,j$=hR,N$=vR;function ap({className:t,children:s,...n}){return e.jsxs(b$,{"data-slot":"scroll-area",className:jt("relative",t),...n,children:[e.jsx(j$,{"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(w$,{}),e.jsx(N$,{})]})}function w$({className:t,orientation:s="vertical",...n}){return e.jsx(mR,{"data-slot":"scroll-area-scrollbar",orientation:s,className:jt("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(gR,{"data-slot":"scroll-area-thumb",className:jt("relative flex-1 rounded-full",s==="vertical"&&"bg-border",s==="horizontal"&&"bg-slate-200/70")})})}function S$({onNavigate:t}){const s=[{title:"Total Applications",value:_i.totalApplications,icon:Ns,color:"bg-blue-500",trend:{value:12,isPositive:!0},filter:"all"},{title:"LOA Issued",value:_i.loaIssued,icon:fn,color:"bg-green-500",trend:{value:8,isPositive:!0},filter:"Approved"},{title:"Level 1 Pending",value:_i.level1Pending,icon:yn,color:"bg-red-500",trend:{value:3,isPositive:!1},filter:"Level 1 Pending"},{title:"Level 2 Pending",value:_i.level2Pending,icon:oM,color:"bg-purple-500",trend:{value:5,isPositive:!0},filter:"Level 2 Pending"},{title:"Level 3 Pending",value:_i.level3Pending,icon:ok,color:"bg-indigo-500",trend:{value:2,isPositive:!1},filter:"Level 3 Pending"},{title:"EOR In Progress",value:_i.eorInProgress,icon:an,color:"bg-cyan-500",trend:{value:1,isPositive:!0},filter:"EOR In Progress"},{title:"Disqualified",value:_i.disqualified,icon:mi,color:"bg-red-500",trend:{value:4,isPositive:!1},filter:"Disqualified"},{title:"Pending Reminders",value:_i.pendingReminders,icon:Dr,color:"bg-orange-500",trend:{value:7,isPositive:!1},filter:"Questionnaire Pending"},{title:"Shortlisted Today",value:_i.shortlistedToday,icon:fn,color:"bg-teal-500",trend:{value:5,isPositive:!0},filter:"Shortlisted"},{title:"Pending Shortlisting",value:_i.pendingShortlisting,icon:HI,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(l=>l.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(l=>{const o=l.icon,d=l.trend.isPositive?hl:Zo;return e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>t(l.action||"applications",l.filter),children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(et,{className:"text-slate-600",children:l.title}),e.jsx("div",{className:`${l.color} p-2 rounded-lg`,children:e.jsx(o,{className:"w-5 h-5 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"flex items-end justify-between",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:l.value}),e.jsxs("div",{className:`flex items-center gap-1 mt-1 ${l.trend.isPositive?"text-green-600":"text-red-600"}`,children:[e.jsx(d,{className:"w-3 h-3"}),e.jsxs("span",{children:[l.trend.value,"% from last month"]})]})]})})})]},l.title)})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Application Status Distribution"})}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:n.map(l=>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:l.color}}),e.jsx("span",{className:"text-slate-700",children:l.status})]}),e.jsx("span",{className:"text-slate-900",children:l.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:`${l.count/150*100}%`,backgroundColor:l.color}})})]},l.status))})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Applications by Location"})}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-3",children:r.map(l=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24 text-slate-700",children:l.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:`${l.count/a*100}%`},children:e.jsx("span",{className:"text-white",children:l.count})})})]},l.location))})})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Recent Activity"})}),e.jsx(Fe,{children:e.jsx(ap,{className:"h-80",children:e.jsx("div",{className:"space-y-4",children:VM.map(l=>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:[l.action==="Approved"&&e.jsx(fn,{className:"w-5 h-5 text-green-600"}),l.action==="Interview Scheduled"&&e.jsx(yn,{className:"w-5 h-5 text-blue-600"}),l.action==="Document Uploaded"&&e.jsx(Ns,{className:"w-5 h-5 text-purple-600"}),l.action==="Reminder Sent"&&e.jsx(Dr,{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(Ce,{variant:"outline",children:l.applicationId}),e.jsx("span",{className:"text-slate-700",children:l.action})]}),e.jsxs("p",{className:"text-slate-500 mt-1",children:["by ",l.user]})]}),e.jsx("div",{className:"text-slate-500 flex-shrink-0",children:l.timestamp})]},l.id))})})})]})]})}var ip="Tabs",[C$]=ga(ip,[Kf]),NR=Kf(),[A$,Fb]=C$(ip),wR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:l,orientation:o="horizontal",dir:d,activationMode:m="automatic",...f}=t,x=Yu(d),[h,p]=$i({prop:r,onChange:a,defaultProp:l??"",caller:ip});return e.jsx(A$,{scope:n,baseId:Ar(),value:h,onValueChange:p,orientation:o,dir:x,activationMode:m,children:e.jsx(ws.div,{dir:x,"data-orientation":o,...f,ref:s})})});wR.displayName=ip;var SR="TabsList",CR=g.forwardRef((t,s)=>{const{__scopeTabs:n,loop:r=!0,...a}=t,l=Fb(SR,n),o=NR(n);return e.jsx(Gk,{asChild:!0,...o,orientation:l.orientation,dir:l.dir,loop:r,children:e.jsx(ws.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:s})})});CR.displayName=SR;var AR="TabsTrigger",kR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...l}=t,o=Fb(AR,n),d=NR(n),m=ER(o.baseId,r),f=_R(o.baseId,r),x=r===o.value;return e.jsx(Kk,{asChild:!0,...d,focusable:!a,active:x,children:e.jsx(ws.button,{type:"button",role:"tab","aria-selected":x,"aria-controls":f,"data-state":x?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:m,...l,ref:s,onMouseDown:Wt(t.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?o.onValueChange(r):h.preventDefault()}),onKeyDown:Wt(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(r)}),onFocus:Wt(t.onFocus,()=>{const h=o.activationMode!=="manual";!x&&!a&&h&&o.onValueChange(r)})})})});kR.displayName=AR;var DR="TabsContent",RR=g.forwardRef((t,s)=>{const{__scopeTabs:n,value:r,forceMount:a,children:l,...o}=t,d=Fb(DR,n),m=ER(d.baseId,r),f=_R(d.baseId,r),x=r===d.value,h=g.useRef(x);return g.useEffect(()=>{const p=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(p)},[]),e.jsx(Rr,{present:a||x,children:({present:p})=>e.jsx(ws.div,{"data-state":x?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":m,hidden:!p,id:f,tabIndex:0,...o,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:p&&l})})});RR.displayName=DR;function ER(t,s){return`${t}-trigger-${s}`}function _R(t,s){return`${t}-content-${s}`}var k$=wR,D$=CR,R$=kR,E$=RR;function $n({className:t,...s}){return e.jsx(k$,{"data-slot":"tabs",className:jt("flex flex-col gap-2",t),...s})}function qn({className:t,...s}){return e.jsx(D$,{"data-slot":"tabs-list",className:jt("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-xl p-[3px] flex",t),...s})}function zt({className:t,...s}){return e.jsx(R$,{"data-slot":"tabs-trigger",className:jt("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 qt({className:t,...s}){return e.jsx(E$,{"data-slot":"tabs-content",className:jt("flex-1 outline-none",t),...s})}function _$(t){const s=T$(t),n=g.forwardRef((r,a)=>{const{children:l,...o}=r,d=g.Children.toArray(l),m=d.find(O$);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function T$(t){const s=g.forwardRef((n,r)=>{const{children:a,...l}=n;if(g.isValidElement(a)){const o=I$(a),d=L$(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 P$=Symbol("radix.slottable");function O$(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===P$}function L$(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function I$(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 lp="Dialog",[TR,PR]=ga(lp),[M$,wi]=TR(lp),OR=t=>{const{__scopeDialog:s,children:n,open:r,defaultOpen:a,onOpenChange:l,modal:o=!0}=t,d=g.useRef(null),m=g.useRef(null),[f,x]=$i({prop:r,defaultProp:a??!1,onChange:l,caller:lp});return e.jsx(M$,{scope:s,triggerRef:d,contentRef:m,contentId:Ar(),titleId:Ar(),descriptionId:Ar(),open:f,onOpenChange:x,onOpenToggle:g.useCallback(()=>x(h=>!h),[x]),modal:o,children:n})};OR.displayName=lp;var LR="DialogTrigger",IR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=wi(LR,n),l=Ks(s,a.triggerRef);return e.jsx(ws.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":qb(a.open),...r,ref:l,onClick:Wt(t.onClick,a.onOpenToggle)})});IR.displayName=LR;var Bb="DialogPortal",[F$,MR]=TR(Bb,{forceMount:void 0}),FR=t=>{const{__scopeDialog:s,forceMount:n,children:r,container:a}=t,l=wi(Bb,s);return e.jsx(F$,{scope:s,forceMount:n,children:g.Children.map(r,o=>e.jsx(Rr,{present:n||l.open,children:e.jsx(Nd,{asChild:!0,container:a,children:o})}))})};FR.displayName=Bb;var xf="DialogOverlay",BR=g.forwardRef((t,s)=>{const n=MR(xf,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,l=wi(xf,t.__scopeDialog);return l.modal?e.jsx(Rr,{present:r||l.open,children:e.jsx($$,{...a,ref:s})}):null});BR.displayName=xf;var B$=_$("DialogOverlay.RemoveScroll"),$$=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=wi(xf,n);return e.jsx(eh,{as:B$,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(ws.div,{"data-state":qb(a.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),oc="DialogContent",$R=g.forwardRef((t,s)=>{const n=MR(oc,t.__scopeDialog),{forceMount:r=n.forceMount,...a}=t,l=wi(oc,t.__scopeDialog);return e.jsx(Rr,{present:r||l.open,children:l.modal?e.jsx(q$,{...a,ref:s}):e.jsx(z$,{...a,ref:s})})});$R.displayName=oc;var q$=g.forwardRef((t,s)=>{const n=wi(oc,t.__scopeDialog),r=g.useRef(null),a=Ks(s,n.contentRef,r);return g.useEffect(()=>{const l=r.current;if(l)return Yf(l)},[]),e.jsx(qR,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Wt(t.onCloseAutoFocus,l=>{var o;l.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Wt(t.onPointerDownOutside,l=>{const o=l.detail.originalEvent,d=o.button===0&&o.ctrlKey===!0;(o.button===2||d)&&l.preventDefault()}),onFocusOutside:Wt(t.onFocusOutside,l=>l.preventDefault())})}),z$=g.forwardRef((t,s)=>{const n=wi(oc,t.__scopeDialog),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(qR,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,l),l.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),l.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:l=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,l),l.defaultPrevented||(r.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=l.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})}),qR=g.forwardRef((t,s)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:l,...o}=t,d=wi(oc,n),m=g.useRef(null),f=Ks(s,m);return $f(),e.jsxs(e.Fragment,{children:[e.jsx(Zu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:e.jsx(yd,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":qb(d.open),...o,ref:f,onDismiss:()=>d.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(V$,{titleId:d.titleId}),e.jsx(W$,{contentRef:m,descriptionId:d.descriptionId})]})]})}),$b="DialogTitle",zR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=wi($b,n);return e.jsx(ws.h2,{id:a.titleId,...r,ref:s})});zR.displayName=$b;var UR="DialogDescription",VR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=wi(UR,n);return e.jsx(ws.p,{id:a.descriptionId,...r,ref:s})});VR.displayName=UR;var HR="DialogClose",WR=g.forwardRef((t,s)=>{const{__scopeDialog:n,...r}=t,a=wi(HR,n);return e.jsx(ws.button,{type:"button",...r,ref:s,onClick:Wt(t.onClick,()=>a.onOpenChange(!1))})});WR.displayName=HR;function qb(t){return t?"open":"closed"}var GR="DialogTitleWarning",[U$,KR]=hI(GR,{contentName:oc,titleName:$b,docsSlug:"dialog"}),V$=({titleId:t})=>{const s=KR(GR),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},H$="DialogDescriptionWarning",W$=({contentRef:t,descriptionId:s})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${KR(H$).contentName}}.`;return g.useEffect(()=>{var l;const a=(l=t.current)==null?void 0:l.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(r))},[r,t,s]),null},zb=OR,YR=IR,Ub=FR,op=BR,cp=$R,ZR=zR,QR=VR,Vb=WR;function ls({...t}){return e.jsx(zb,{"data-slot":"dialog",...t})}function co({...t}){return e.jsx(YR,{"data-slot":"dialog-trigger",...t})}function G$({...t}){return e.jsx(Ub,{"data-slot":"dialog-portal",...t})}const XR=g.forwardRef(({className:t,...s},n)=>e.jsx(op,{ref:n,"data-slot":"dialog-overlay",className:jt("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}));XR.displayName=op.displayName;const as=g.forwardRef(({className:t,children:s,...n},r)=>e.jsxs(G$,{"data-slot":"dialog-portal",children:[e.jsx(XR,{}),e.jsxs(cp,{ref:r,"data-slot":"dialog-content",className:jt("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(Vb,{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"})]})]})]}));as.displayName=cp.displayName;function fs({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-header",className:jt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function xn({className:t,...s}){return e.jsx("div",{"data-slot":"dialog-footer",className:jt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function us({className:t,...s}){return e.jsx(ZR,{"data-slot":"dialog-title",className:jt("text-lg leading-none font-semibold",t),...s})}function bs({className:t,...s}){return e.jsx(QR,{"data-slot":"dialog-description",className:jt("text-muted-foreground text-sm",t),...s})}function K$(t){const s=Y$(t),n=g.forwardRef((r,a)=>{const{children:l,...o}=r,d=g.Children.toArray(l),m=d.find(Q$);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function Y$(t){const s=g.forwardRef((n,r)=>{const{children:a,...l}=n;if(g.isValidElement(a)){const o=J$(a),d=X$(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 Z$=Symbol("radix.slottable");function Q$(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Z$}function X$(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function J$(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 JR=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"}),e7="VisuallyHidden",eE=g.forwardRef((t,s)=>e.jsx(ws.span,{...t,ref:s,style:{...JR,...t.style}}));eE.displayName=e7;var t7=eE,s7=[" ","Enter","ArrowUp","ArrowDown"],n7=[" ","Enter"],cc="Select",[dp,up,r7]=ib(cc),[Cd]=ga(cc,[r7,oo]),hp=oo(),[a7,uo]=Cd(cc),[i7,l7]=Cd(cc),tE=t=>{const{__scopeSelect:s,children:n,open:r,defaultOpen:a,onOpenChange:l,value:o,defaultValue:d,onValueChange:m,dir:f,name:x,autoComplete:h,disabled:p,required:u,form:w}=t,v=hp(s),[N,j]=g.useState(null),[y,C]=g.useState(null),[S,D]=g.useState(!1),R=Yu(f),[A,L]=$i({prop:r,defaultProp:a??!1,onChange:l,caller:cc}),[$,P]=$i({prop:o,defaultProp:d,onChange:m,caller:cc}),E=g.useRef(null),O=N?w||!!N.closest("form"):!0,[I,q]=g.useState(new Set),G=Array.from(I).map(Y=>Y.props.value).join(";");return e.jsx(Hf,{...v,children:e.jsxs(a7,{required:u,scope:s,trigger:N,onTriggerChange:j,valueNode:y,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:D,contentId:Ar(),value:$,onValueChange:P,open:A,onOpenChange:L,dir:R,triggerPointerDownPosRef:E,disabled:p,children:[e.jsx(dp.Provider,{scope:s,children:e.jsx(i7,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(Y=>{q(V=>new Set(V).add(Y))},[]),onNativeOptionRemove:g.useCallback(Y=>{q(V=>{const Q=new Set(V);return Q.delete(Y),Q})},[]),children:n})}),O?e.jsxs(CE,{"aria-hidden":!0,required:u,tabIndex:-1,name:x,autoComplete:h,value:$,onChange:Y=>P(Y.target.value),disabled:p,form:w,children:[$===void 0?e.jsx("option",{value:""}):null,Array.from(I)]},G):null]})})};tE.displayName=cc;var sE="SelectTrigger",nE=g.forwardRef((t,s)=>{const{__scopeSelect:n,disabled:r=!1,...a}=t,l=hp(n),o=uo(sE,n),d=o.disabled||r,m=Ks(s,o.onTriggerChange),f=up(n),x=g.useRef("touch"),[h,p,u]=kE(v=>{const N=f().filter(C=>!C.disabled),j=N.find(C=>C.value===o.value),y=DE(N,v,j);y!==void 0&&o.onValueChange(y.value)}),w=v=>{d||(o.onOpenChange(!0),u()),v&&(o.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return e.jsx(Xu,{asChild:!0,...l,children:e.jsx(ws.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":AE(o.value)?"":void 0,...a,ref:m,onClick:Wt(a.onClick,v=>{v.currentTarget.focus(),x.current!=="mouse"&&w(v)}),onPointerDown:Wt(a.onPointerDown,v=>{x.current=v.pointerType;const N=v.target;N.hasPointerCapture(v.pointerId)&&N.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:Wt(a.onKeyDown,v=>{const N=h.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&p(v.key),!(N&&v.key===" ")&&s7.includes(v.key)&&(w(),v.preventDefault())})})})});nE.displayName=sE;var rE="SelectValue",aE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,children:l,placeholder:o="",...d}=t,m=uo(rE,n),{onValueNodeHasChildrenChange:f}=m,x=l!==void 0,h=Ks(s,m.onValueNodeChange);return cr(()=>{f(x)},[f,x]),e.jsx(ws.span,{...d,ref:h,style:{pointerEvents:"none"},children:AE(m.value)?e.jsx(e.Fragment,{children:o}):l})});aE.displayName=rE;var o7="SelectIcon",iE=g.forwardRef((t,s)=>{const{__scopeSelect:n,children:r,...a}=t;return e.jsx(ws.span,{"aria-hidden":!0,...a,ref:s,children:r||"▼"})});iE.displayName=o7;var c7="SelectPortal",lE=t=>e.jsx(Nd,{asChild:!0,...t});lE.displayName=c7;var dc="SelectContent",oE=g.forwardRef((t,s)=>{const n=uo(dc,t.__scopeSelect),[r,a]=g.useState();if(cr(()=>{a(new DocumentFragment)},[]),!n.open){const l=r;return l?Uu.createPortal(e.jsx(cE,{scope:t.__scopeSelect,children:e.jsx(dp.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),l):null}return e.jsx(dE,{...t,ref:s})});oE.displayName=dc;var oi=10,[cE,ho]=Cd(dc),d7="SelectContentImpl",u7=K$("SelectContent.RemoveScroll"),dE=g.forwardRef((t,s)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:l,onPointerDownOutside:o,side:d,sideOffset:m,align:f,alignOffset:x,arrowPadding:h,collisionBoundary:p,collisionPadding:u,sticky:w,hideWhenDetached:v,avoidCollisions:N,...j}=t,y=uo(dc,n),[C,S]=g.useState(null),[D,R]=g.useState(null),A=Ks(s,X=>S(X)),[L,$]=g.useState(null),[P,E]=g.useState(null),O=up(n),[I,q]=g.useState(!1),G=g.useRef(!1);g.useEffect(()=>{if(C)return Yf(C)},[C]),$f();const Y=g.useCallback(X=>{const[J,...ie]=O().map(ce=>ce.ref.current),[ae]=ie.slice(-1),xe=document.activeElement;for(const ce of X)if(ce===xe||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===J&&D&&(D.scrollTop=0),ce===ae&&D&&(D.scrollTop=D.scrollHeight),ce==null||ce.focus(),document.activeElement!==xe))return},[O,D]),V=g.useCallback(()=>Y([L,C]),[Y,L,C]);g.useEffect(()=>{I&&V()},[I,V]);const{onOpenChange:Q,triggerPointerDownPosRef:_}=y;g.useEffect(()=>{if(C){let X={x:0,y:0};const J=ae=>{var xe,ce;X={x:Math.abs(Math.round(ae.pageX)-(((xe=_.current)==null?void 0:xe.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((ce=_.current)==null?void 0:ce.y)??0))}},ie=ae=>{X.x<=10&&X.y<=10?ae.preventDefault():C.contains(ae.target)||Q(!1),document.removeEventListener("pointermove",J),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",ie,{capture:!0})}}},[C,Q,_]),g.useEffect(()=>{const X=()=>Q(!1);return window.addEventListener("blur",X),window.addEventListener("resize",X),()=>{window.removeEventListener("blur",X),window.removeEventListener("resize",X)}},[Q]);const[z,T]=kE(X=>{const J=O().filter(xe=>!xe.disabled),ie=J.find(xe=>xe.ref.current===document.activeElement),ae=DE(J,X,ie);ae&&setTimeout(()=>ae.ref.current.focus())}),F=g.useCallback((X,J,ie)=>{const ae=!G.current&&!ie;(y.value!==void 0&&y.value===J||ae)&&($(X),ae&&(G.current=!0))},[y.value]),B=g.useCallback(()=>C==null?void 0:C.focus(),[C]),K=g.useCallback((X,J,ie)=>{const ae=!G.current&&!ie;(y.value!==void 0&&y.value===J||ae)&&E(X)},[y.value]),W=r==="popper"?Cy:uE,H=W===Cy?{side:d,sideOffset:m,align:f,alignOffset:x,arrowPadding:h,collisionBoundary:p,collisionPadding:u,sticky:w,hideWhenDetached:v,avoidCollisions:N}:{};return e.jsx(cE,{scope:n,content:C,viewport:D,onViewportChange:R,itemRefCallback:F,selectedItem:L,onItemLeave:B,itemTextRefCallback:K,focusSelectedItem:V,selectedItemText:P,position:r,isPositioned:I,searchRef:z,children:e.jsx(eh,{as:u7,allowPinchZoom:!0,children:e.jsx(Zu,{asChild:!0,trapped:y.open,onMountAutoFocus:X=>{X.preventDefault()},onUnmountAutoFocus:Wt(a,X=>{var J;(J=y.trigger)==null||J.focus({preventScroll:!0}),X.preventDefault()}),children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:X=>X.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:e.jsx(W,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:X=>X.preventDefault(),...j,...H,onPlaced:()=>q(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Wt(j.onKeyDown,X=>{const J=X.ctrlKey||X.altKey||X.metaKey;if(X.key==="Tab"&&X.preventDefault(),!J&&X.key.length===1&&T(X.key),["ArrowUp","ArrowDown","Home","End"].includes(X.key)){let ae=O().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);if(["ArrowUp","End"].includes(X.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(X.key)){const xe=X.target,ce=ae.indexOf(xe);ae=ae.slice(ce+1)}setTimeout(()=>Y(ae)),X.preventDefault()}})})})})})})});dE.displayName=d7;var h7="SelectItemAlignedPosition",uE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onPlaced:r,...a}=t,l=uo(dc,n),o=ho(dc,n),[d,m]=g.useState(null),[f,x]=g.useState(null),h=Ks(s,A=>x(A)),p=up(n),u=g.useRef(!1),w=g.useRef(!0),{viewport:v,selectedItem:N,selectedItemText:j,focusSelectedItem:y}=o,C=g.useCallback(()=>{if(l.trigger&&l.valueNode&&d&&f&&v&&N&&j){const A=l.trigger.getBoundingClientRect(),L=f.getBoundingClientRect(),$=l.valueNode.getBoundingClientRect(),P=j.getBoundingClientRect();if(l.dir!=="rtl"){const xe=P.left-L.left,ce=$.left-xe,we=A.left-ce,ke=A.width+we,Xe=Math.max(ke,L.width),Ot=window.innerWidth-oi,bt=Sy(ce,[oi,Math.max(oi,Ot-Xe)]);d.style.minWidth=ke+"px",d.style.left=bt+"px"}else{const xe=L.right-P.right,ce=window.innerWidth-$.right-xe,we=window.innerWidth-A.right-ce,ke=A.width+we,Xe=Math.max(ke,L.width),Ot=window.innerWidth-oi,bt=Sy(ce,[oi,Math.max(oi,Ot-Xe)]);d.style.minWidth=ke+"px",d.style.right=bt+"px"}const E=p(),O=window.innerHeight-oi*2,I=v.scrollHeight,q=window.getComputedStyle(f),G=parseInt(q.borderTopWidth,10),Y=parseInt(q.paddingTop,10),V=parseInt(q.borderBottomWidth,10),Q=parseInt(q.paddingBottom,10),_=G+Y+I+Q+V,z=Math.min(N.offsetHeight*5,_),T=window.getComputedStyle(v),F=parseInt(T.paddingTop,10),B=parseInt(T.paddingBottom,10),K=A.top+A.height/2-oi,W=O-K,H=N.offsetHeight/2,X=N.offsetTop+H,J=G+Y+X,ie=_-J;if(J<=K){const xe=E.length>0&&N===E[E.length-1].ref.current;d.style.bottom="0px";const ce=f.clientHeight-v.offsetTop-v.offsetHeight,we=Math.max(W,H+(xe?B:0)+ce+V),ke=J+we;d.style.height=ke+"px"}else{const xe=E.length>0&&N===E[0].ref.current;d.style.top="0px";const we=Math.max(K,G+v.offsetTop+(xe?F:0)+H)+ie;d.style.height=we+"px",v.scrollTop=J-K+v.offsetTop}d.style.margin=`${oi}px 0`,d.style.minHeight=z+"px",d.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[p,l.trigger,l.valueNode,d,f,v,N,j,l.dir,r]);cr(()=>C(),[C]);const[S,D]=g.useState();cr(()=>{f&&D(window.getComputedStyle(f).zIndex)},[f]);const R=g.useCallback(A=>{A&&w.current===!0&&(C(),y==null||y(),w.current=!1)},[C,y]);return e.jsx(f7,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:u,onScrollButtonChange:R,children:e.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:e.jsx(ws.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});uE.displayName=h7;var m7="SelectPopperPosition",Cy=g.forwardRef((t,s)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=oi,...l}=t,o=hp(n);return e.jsx(Wf,{...o,...l,ref:s,align:r,collisionPadding:a,style:{boxSizing:"border-box",...l.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)"}})});Cy.displayName=m7;var[f7,Hb]=Cd(dc,{}),Ay="SelectViewport",hE=g.forwardRef((t,s)=>{const{__scopeSelect:n,nonce:r,...a}=t,l=ho(Ay,n),o=Hb(Ay,n),d=Ks(s,l.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(dp.Slot,{scope:n,children:e.jsx(ws.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Wt(a.onScroll,f=>{const x=f.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:p}=o;if(p!=null&&p.current&&h){const u=Math.abs(m.current-x.scrollTop);if(u>0){const w=window.innerHeight-oi*2,v=parseFloat(h.style.minHeight),N=parseFloat(h.style.height),j=Math.max(v,N);if(j<w){const y=j+u,C=Math.min(w,y),S=y-C;h.style.height=C+"px",h.style.bottom==="0px"&&(x.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}m.current=x.scrollTop})})})]})});hE.displayName=Ay;var mE="SelectGroup",[p7,x7]=Cd(mE),fE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=Ar();return e.jsx(p7,{scope:n,id:a,children:e.jsx(ws.div,{role:"group","aria-labelledby":a,...r,ref:s})})});fE.displayName=mE;var pE="SelectLabel",xE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=x7(pE,n);return e.jsx(ws.div,{id:a.id,...r,ref:s})});xE.displayName=pE;var gf="SelectItem",[g7,gE]=Cd(gf),vE=g.forwardRef((t,s)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:l,...o}=t,d=uo(gf,n),m=ho(gf,n),f=d.value===r,[x,h]=g.useState(l??""),[p,u]=g.useState(!1),w=Ks(s,y=>{var C;return(C=m.itemRefCallback)==null?void 0:C.call(m,y,r,a)}),v=Ar(),N=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(g7,{scope:n,value:r,disabled:a,textId:v,isSelected:f,onItemTextChange:g.useCallback(y=>{h(C=>C||((y==null?void 0:y.textContent)??"").trim())},[]),children:e.jsx(dp.ItemSlot,{scope:n,value:r,disabled:a,textValue:x,children:e.jsx(ws.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":f&&p,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:w,onFocus:Wt(o.onFocus,()=>u(!0)),onBlur:Wt(o.onBlur,()=>u(!1)),onClick:Wt(o.onClick,()=>{N.current!=="mouse"&&j()}),onPointerUp:Wt(o.onPointerUp,()=>{N.current==="mouse"&&j()}),onPointerDown:Wt(o.onPointerDown,y=>{N.current=y.pointerType}),onPointerMove:Wt(o.onPointerMove,y=>{var C;N.current=y.pointerType,a?(C=m.onItemLeave)==null||C.call(m):N.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Wt(o.onPointerLeave,y=>{var C;y.currentTarget===document.activeElement&&((C=m.onItemLeave)==null||C.call(m))}),onKeyDown:Wt(o.onKeyDown,y=>{var S;((S=m.searchRef)==null?void 0:S.current)!==""&&y.key===" "||(n7.includes(y.key)&&j(),y.key===" "&&y.preventDefault())})})})})});vE.displayName=gf;var xu="SelectItemText",yE=g.forwardRef((t,s)=>{const{__scopeSelect:n,className:r,style:a,...l}=t,o=uo(xu,n),d=ho(xu,n),m=gE(xu,n),f=l7(xu,n),[x,h]=g.useState(null),p=Ks(s,j=>h(j),m.onItemTextChange,j=>{var y;return(y=d.itemTextRefCallback)==null?void 0:y.call(d,j,m.value,m.disabled)}),u=x==null?void 0:x.textContent,w=g.useMemo(()=>e.jsx("option",{value:m.value,disabled:m.disabled,children:u},m.value),[m.disabled,m.value,u]),{onNativeOptionAdd:v,onNativeOptionRemove:N}=f;return cr(()=>(v(w),()=>N(w)),[v,N,w]),e.jsxs(e.Fragment,{children:[e.jsx(ws.span,{id:m.textId,...l,ref:p}),m.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Uu.createPortal(l.children,o.valueNode):null]})});yE.displayName=xu;var bE="SelectItemIndicator",jE=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return gE(bE,n).isSelected?e.jsx(ws.span,{"aria-hidden":!0,...r,ref:s}):null});jE.displayName=bE;var ky="SelectScrollUpButton",NE=g.forwardRef((t,s)=>{const n=ho(ky,t.__scopeSelect),r=Hb(ky,t.__scopeSelect),[a,l]=g.useState(!1),o=Ks(s,r.onScrollButtonChange);return cr(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollTop>0;l(f)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(SE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop-m.offsetHeight)}}):null});NE.displayName=ky;var Dy="SelectScrollDownButton",wE=g.forwardRef((t,s)=>{const n=ho(Dy,t.__scopeSelect),r=Hb(Dy,t.__scopeSelect),[a,l]=g.useState(!1),o=Ks(s,r.onScrollButtonChange);return cr(()=>{if(n.viewport&&n.isPositioned){let d=function(){const f=m.scrollHeight-m.clientHeight,x=Math.ceil(m.scrollTop)<f;l(x)};const m=n.viewport;return d(),m.addEventListener("scroll",d),()=>m.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),a?e.jsx(SE,{...t,ref:o,onAutoScroll:()=>{const{viewport:d,selectedItem:m}=n;d&&m&&(d.scrollTop=d.scrollTop+m.offsetHeight)}}):null});wE.displayName=Dy;var SE=g.forwardRef((t,s)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=t,l=ho("SelectScrollButton",n),o=g.useRef(null),d=up(n),m=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>m(),[m]),cr(()=>{var x;const f=d().find(h=>h.ref.current===document.activeElement);(x=f==null?void 0:f.ref.current)==null||x.scrollIntoView({block:"nearest"})},[d]),e.jsx(ws.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Wt(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Wt(a.onPointerMove,()=>{var f;(f=l.onItemLeave)==null||f.call(l),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Wt(a.onPointerLeave,()=>{m()})})}),v7="SelectSeparator",y7=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t;return e.jsx(ws.div,{"aria-hidden":!0,...r,ref:s})});y7.displayName=v7;var Ry="SelectArrow",b7=g.forwardRef((t,s)=>{const{__scopeSelect:n,...r}=t,a=hp(n),l=uo(Ry,n),o=ho(Ry,n);return l.open&&o.position==="popper"?e.jsx(Gf,{...a,...r,ref:s}):null});b7.displayName=Ry;var j7="SelectBubbleInput",CE=g.forwardRef(({__scopeSelect:t,value:s,...n},r)=>{const a=g.useRef(null),l=Ks(r,a),o=Xy(s);return g.useEffect(()=>{const d=a.current;if(!d)return;const m=window.HTMLSelectElement.prototype,x=Object.getOwnPropertyDescriptor(m,"value").set;if(o!==s&&x){const h=new Event("change",{bubbles:!0});x.call(d,s),d.dispatchEvent(h)}},[o,s]),e.jsx(ws.select,{...n,style:{...JR,...n.style},ref:l,defaultValue:s})});CE.displayName=j7;function AE(t){return t===""||t===void 0}function kE(t){const s=Sr(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]),l=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,l]}function DE(t,s,n){const a=s.length>1&&Array.from(s).every(f=>f===s[0])?s[0]:s,l=n?t.indexOf(n):-1;let o=N7(t,Math.max(l,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 N7(t,s){return t.map((n,r)=>t[(s+r)%t.length])}var w7=tE,S7=nE,C7=aE,A7=iE,k7=lE,D7=oE,R7=hE,E7=fE,_7=xE,RE=vE,EE=yE,_E=jE,T7=NE,P7=wE;function At({...t}){return e.jsx(w7,{"data-slot":"select",...t})}function gS({...t}){return e.jsx(E7,{"data-slot":"select-group",...t})}function kt({...t}){return e.jsx(C7,{"data-slot":"select-value",...t})}function Dt({className:t,size:s="default",children:n,...r}){return e.jsxs(S7,{"data-slot":"select-trigger","data-size":s,className:jt("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(A7,{asChild:!0,children:e.jsx(Aa,{className:"size-4 opacity-50"})})]})}function Rt({className:t,children:s,position:n="popper",...r}){return e.jsx(k7,{children:e.jsxs(D7,{"data-slot":"select-content",className:jt("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(L7,{}),e.jsx(R7,{className:jt("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(I7,{})]})})}function O7({className:t,...s}){return e.jsx(_7,{"data-slot":"select-label",className:jt("text-muted-foreground px-2 py-1.5 text-xs",t),...s})}function Me({className:t,children:s,...n}){return e.jsxs(RE,{"data-slot":"select-item",className:jt("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(_E,{children:e.jsx(Wn,{className:"size-4"})})}),e.jsx(EE,{children:s})]})}function L7({className:t,...s}){return e.jsx(T7,{"data-slot":"select-scroll-up-button",className:jt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(bu,{className:"size-4"})})}function I7({className:t,...s}){return e.jsx(P7,{"data-slot":"select-scroll-down-button",className:jt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Aa,{className:"size-4"})})}function Ps({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:jt("w-full caption-bottom text-sm",t),...s})})}function Os({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:jt("[&_tr]:border-b",t),...s})}function Ls({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:jt("[&_tr:last-child]:border-0",t),...s})}function lt({className:t,...s}){return e.jsx("tr",{"data-slot":"table-row",className:jt("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...s})}function fe({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:jt("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 ue({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:jt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}const TE={getOnboardingPayments:async()=>{var s,n;const t=await Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 Ee.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 M7({onNavigate:t,onViewPaymentDetails:s,onViewAuditDetails:n,onViewFnFDetails:r}){var T,F,B,K;const[a,l]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[x,h]=g.useState(!0);g.useEffect(()=>{p()},[]);const p=async()=>{try{h(!0);const[W,H]=await Promise.all([TE.getFnFSettlements(),ds.getApplications()]),X=H.data||[],J=[];X.forEach(ae=>{const xe=ae.overallStatus||ae.status,ce=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(xe),we=ae.securityDeposits||[];we.length>0?we.forEach(ke=>{J.push({...ke,application:ae,paymentStatus:ke.status,paymentType:ke.depositType,amount:ke.amount,id:ke.id,applicationId:ae.applicationId||ae.id,createdAt:ke.createdAt,verificationDate:ke.verifiedAt})}):ce&&(["Payment Pending","Security Deposit","Security Details","LOI In Progress"].includes(xe)?J.push({id:`virtual-${ae.id}-sd`,applicationId:ae.applicationId||ae.id,application:ae,paymentStatus:"Pending",paymentType:"SECURITY_DEPOSIT",amount:5e5,createdAt:ae.updatedAt,isVirtual:!0}):["LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(xe)&&J.push({id:`virtual-${ae.id}-ff`,applicationId:ae.applicationId||ae.id,application:ae,paymentStatus:"Pending",paymentType:"FIRST_FILL",amount:15e5,createdAt:ae.updatedAt,isVirtual:!0}))}),l(J),d(W);const ie=X.filter(ae=>ae.status==="FDD_VERIFICATION"||ae.overallStatus==="FDD Verification"||ae.currentStage==="FDD");f(ie)}catch(W){console.error("Fetch error:",W),ee.error("Failed to load dashboard data")}finally{h(!1)}},[u,w]=g.useState(!1),[v,N]=g.useState(!1),[j,y]=g.useState(null),[C,S]=g.useState([]),[D,R]=g.useState({department:"",description:"",type:"receivable",amount:""}),[A,L]=g.useState(""),$=()=>{const W=C.filter(J=>J.type==="receivable").reduce((J,ie)=>J+ie.amount,0),H=C.filter(J=>J.type==="payable").reduce((J,ie)=>J+ie.amount,0),X=H-W;return{totalReceivable:W,totalPayable:H,netAmount:X}},P=async()=>{if(C.length===0){ee.error("Please add at least one line item");return}if(!A){ee.error("Please add final remarks");return}try{h(!0),ee.success("Finance summary submitted successfully"),w(!1),y(null),S([]),L(""),p()}catch{ee.error("Failed to submit summary")}finally{h(!1)}},E=W=>{const H=String(W||"").trim().toLowerCase();return H==="paid"||H==="verified"},O=a.filter(W=>!E(W.paymentStatus)),I=a.filter(W=>E(W.paymentStatus)),q=o.filter(W=>W.status==="Initiated"||W.status==="Calculated"),G=o.filter(W=>W.status==="Completed"||W.status==="Cleared"),Y=()=>{if(!D.department||!D.description||!D.amount){ee.error("Please fill in all line item fields");return}const W={id:Date.now().toString(),department:D.department,description:D.description,type:D.type,amount:parseFloat(D.amount)};S([...C,W]),R({department:"",description:"",type:"receivable",amount:""}),ee.success("Line item added")},V=W=>{S(C.filter(H=>H.id!==W)),ee.info("Line item removed")},{totalReceivable:Q,totalPayable:_,netAmount:z}=$();return x?e.jsxs("div",{className:"flex items-center justify-center p-20 text-re-red",children:[e.jsx(yn,{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(Le,{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(Qe,{className:"pb-3",children:[e.jsx(Qt,{className:"text-re-red font-bold",children:"Pending Audits"}),e.jsx(et,{className:"text-3xl text-re-red",children:m.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600 text-xs font-medium",children:"FDD Sign-offs"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2 text-xs",children:"Review Now →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-yellow-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Pending Verification"}),e.jsx(et,{className:"text-3xl text-yellow-600",children:O.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Onboarding Payments"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-onboarding"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Verified"}),e.jsx(et,{className:"text-3xl text-green-600",children:I.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Total Validated"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-orange-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Pending F&F Summary"}),e.jsx(et,{className:"text-3xl text-orange-600",children:q.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Offboarding Cases"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]}),e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow border-green-200",onClick:()=>t==null?void 0:t("finance-fnf"),children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"F&F Completed"}),e.jsx(et,{className:"text-3xl text-green-600",children:G.length})]}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-slate-600",children:"Settlements Done"}),e.jsx(se,{variant:"link",className:"p-0 h-auto text-re-red mt-2",children:"View All →"})]})]})]}),e.jsxs($n,{defaultValue:"onboarding",className:"w-full",children:[e.jsxs(qn,{className:"grid w-full grid-cols-2",children:[e.jsxs(zt,{value:"onboarding",children:[e.jsx(ka,{className:"w-4 h-4 mr-2"}),"Onboarding"]}),e.jsxs(zt,{value:"fnf",children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"F&F Settlement"]})]}),e.jsx(qt,{value:"onboarding",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Payment Verification"}),e.jsx(Qt,{children:"Verify dealer advance payments for onboarding applications"})]}),e.jsx(Fe,{children:e.jsxs($n,{defaultValue:"pending",className:"w-full",children:[e.jsxs(qn,{children:[e.jsxs(zt,{value:"pending",children:["Pending (",O.length,")"]}),e.jsxs(zt,{value:"verified",children:["Verified (",I.length,")"]})]}),e.jsx(qt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[O.map(W=>{var H,X;return e.jsx(Le,{className:"border-yellow-200 bg-yellow-50/30",children:e.jsx(Fe,{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:((H=W.application)==null?void 0:H.applicationId)||"N/A"}),e.jsx(Ce,{className:"bg-yellow-100 text-yellow-700 border-yellow-300",children:W.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:(X=W.application)==null?void 0:X.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:W.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":W.paymentType==="FIRST_FILL"?"First Fill":W.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(W.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Created On"}),e.jsx("p",{children:Gt(W.createdAt)})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{s&&s(W.applicationId||W.id)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(se,{size:"sm",className:"bg-green-600 hover:bg-green-700 font-bold",onClick:()=>{s&&s(W.applicationId||W.id)},children:[e.jsx(fn,{className:"w-4 h-4 mr-2"}),"Verify Payment"]})]})]})})},W.id)}),O.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(fn,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No pending payment verifications"})]})]})}),e.jsx(qt,{value:"verified",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:I.map(W=>{var H,X;return e.jsx(Le,{className:"border-green-200 bg-green-50/30",children:e.jsx(Fe,{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:((H=W.application)==null?void 0:H.applicationId)||"N/A"}),e.jsx(Ce,{className:"bg-green-100 text-green-700 border-green-300",children:W.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:(X=W.application)==null?void 0:X.applicantName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:W.paymentType==="SECURITY_DEPOSIT"?"Security Deposit":W.paymentType==="FIRST_FILL"?"First Fill":W.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(W.amount).toLocaleString("en-IN")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Verified On"}),e.jsx("p",{children:W.verificationDate?Gt(W.verificationDate):"N/A"})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{s&&s(W.applicationId||W.id)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},W.id)})})})]})})]})}),e.jsx(qt,{value:"fnf",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"F&F Financial Summary"}),e.jsx(Qt,{children:"Create financial settlement summaries for resignation and termination cases"})]}),e.jsx(Fe,{children:e.jsxs($n,{defaultValue:"pending",className:"w-full",children:[e.jsxs(qn,{children:[e.jsxs(zt,{value:"pending",children:["Pending Summary (",q.length,")"]}),e.jsxs(zt,{value:"completed",children:["Completed (",G.length,")"]})]}),e.jsx(qt,{value:"pending",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[q.map(W=>{var H,X,J,ie,ae,xe,ce;return e.jsx(Le,{className:"border-orange-200 bg-orange-50/30",children:e.jsx(Fe,{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:((H=W.resignation)==null?void 0:H.resignationId)||W.id}),e.jsx(Ce,{variant:"outline",children:W.resignation?"Resignation":W.terminationRequest?"Termination":"General"}),e.jsx(Ce,{className:"bg-orange-100 text-orange-700 border-orange-300",children:W.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:((J=(X=W.outlet)==null?void 0:X.dealer)==null?void 0:J.fullName)||((ie=W.outlet)==null?void 0:ie.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-re-red",children:((ae=W.outlet)==null?void 0:ae.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:[((xe=W.outlet)==null?void 0:xe.city)||"N/A",", ",((ce=W.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(fn,{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:(W.clearances||[]).filter(we=>we.status==="NOC Submitted"||we.status==="Dues Pending").length}),"/16 Departments Cleared"]})]})]})]}),e.jsxs("div",{className:"ml-4 flex flex-col gap-2",children:[e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{y(W),N(!0)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]}),e.jsxs(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{y(W),S([]),L(""),w(!0)},children:[e.jsx(lk,{className:"w-4 h-4 mr-2"}),"Create Summary"]})]})]})})},W.id)}),q.length===0&&e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ns,{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(qt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:G.map(W=>e.jsx(Le,{className:"border-green-200 bg-green-50/30",children:e.jsx(Fe,{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:W.id}),e.jsx(Ce,{variant:"outline",children:W.type}),e.jsx(Ce,{className:"bg-green-100 text-green-700 border-green-300",children:W.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:W.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:W.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Net Settlement"}),e.jsxs("p",{className:W.netAmount&&W.netAmount>=0?"text-green-700":"text-red-700",children:["₹",W.netAmount?Math.abs(W.netAmount).toLocaleString("en-IN"):"0"]}),e.jsx("p",{className:"text-xs text-slate-500",children:W.netAmount&&W.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:W.completedOn})]})]})]}),e.jsx("div",{className:"ml-4",children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>{r&&r(W.id)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},W.id))})})]})})]})})]}),e.jsx(ls,{open:u,onOpenChange:w,children:e.jsxs(as,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Create Financial Settlement Summary"}),e.jsxs(bs,{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(de,{className:"text-xs",children:"Department"}),e.jsx(at,{placeholder:"e.g., Warranty",value:D.department,onChange:W=>R({...D,department:W.target.value})})]}),e.jsxs("div",{className:"col-span-4",children:[e.jsx(de,{className:"text-xs",children:"Description"}),e.jsx(at,{placeholder:"e.g., Pending warranty claims",value:D.description,onChange:W=>R({...D,description:W.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-xs",children:"Type"}),e.jsxs(At,{value:D.type,onValueChange:W=>R({...D,type:W}),children:[e.jsx(Dt,{children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"receivable",children:"Receivable"}),e.jsx(Me,{value:"payable",children:"Payable"})]})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-xs",children:"Amount (₹)"}),e.jsx(at,{type:"number",placeholder:"0",value:D.amount,onChange:W=>R({...D,amount:W.target.value})})]}),e.jsx("div",{className:"col-span-1 flex items-end",children:e.jsx(se,{size:"sm",onClick:Y,className:"w-full bg-re-red hover:bg-re-red-hover",children:e.jsx(Dn,{className:"w-4 h-4"})})})]})]}),C.length>0&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-center",children:"Type"}),e.jsx(fe,{className:"text-right",children:"Amount"}),e.jsx(fe,{className:"w-16"})]})}),e.jsx(Ls,{children:C.map(W=>e.jsxs(lt,{children:[e.jsx(ue,{children:W.department}),e.jsx(ue,{children:W.description}),e.jsx(ue,{className:"text-center",children:e.jsx(Ce,{className:W.type==="receivable"?"bg-red-100 text-red-700 border-red-200":"bg-green-100 text-green-700 border-green-200",children:W.type==="receivable"?"Receivable":"Payable"})}),e.jsxs(ue,{className:`text-right font-medium ${W.type==="receivable"?"text-red-700":"text-green-700"}`,children:["₹",W.amount.toLocaleString("en-IN")]}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"ghost",onClick:()=>V(W.id),children:e.jsx(ar,{className:"w-4 h-4 text-red-600"})})})]},W.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:["₹",_.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:["₹",Q.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(de,{className:"font-bold",children:["Summary Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Gs,{placeholder:"Add your final reconciliation remarks here...",rows:4,value:A,onChange:W=>L(W.target.value)})]})]}),e.jsxs(xn,{className:"border-t pt-4",children:[e.jsx(se,{variant:"outline",onClick:()=>w(!1),children:"Discard"}),e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:P,disabled:C.length===0,children:[e.jsx(pl,{className:"w-4 h-4 mr-2"}),"Finalize & Submit Summary"]})]})]})}),e.jsx(ls,{open:v,onOpenChange:N,children:e.jsxs(as,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Full Settlement Details"}),e.jsxs(bs,{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(Le,{className:"bg-slate-50 border-none",children:e.jsxs(Fe,{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:((B=j.outlet)==null?void 0:B.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(Ce,{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(Le,{className:"border-red-100",children:[e.jsx(Qe,{className:"bg-red-50/50 pb-2",children:e.jsxs(et,{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(hl,{className:"w-4 h-4 text-re-red"}),"Receivables Check"]})}),e.jsxs(Fe,{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-re-red-hover",children:[e.jsx("span",{children:"Total Payables"}),e.jsxs("span",{children:["₹",parseFloat(j.totalPayables||0).toLocaleString("en-IN")]})]})]})]}),e.jsxs(Le,{className:"border-red-100 shadow-sm",children:[e.jsx(Qe,{className:"bg-red-50/30 pb-2 border-b border-red-50",children:e.jsxs(et,{className:"text-sm font-bold flex items-center gap-2 text-red-700",children:[e.jsx(Zo,{className:"w-4 h-4"}),"Receivables Check"]})}),e.jsxs(Fe,{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(ka,{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(se,{className:"bg-re-red hover:bg-re-red-hover px-6 font-bold shadow-md transition-all active:scale-95",children:"Generate PDF Summary"})]})]}),e.jsx(xn,{children:e.jsx(se,{onClick:()=>N(!1),children:"Close Overview"})})]})})]})}const Jl={getDashboardData:async()=>{var t;try{const s=await Ee.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 Ee.getConstitutionalChanges()).data}catch(t){throw console.error("Get constitutional changes error:",t),t}},submitConstitutionalChange:async t=>{try{return(await Ee.createConstitutionalChange(t)).data}catch(s){throw console.error("Submit constitutional change error:",s),s}},getRelocationRequests:async()=>{try{return(await Ee.getRelocationRequests()).data}catch(t){throw console.error("Get relocation requests error:",t),t}},submitRelocationRequest:async t=>{try{return(await Ee.createRelocationRequest(t)).data}catch(s){throw console.error("Submit relocation request error:",s),s}}};function F7({currentUser:t,onNavigate:s}){var u,w;const[n,r]=g.useState(!0),[a,l]=g.useState(null);if(g.useEffect(()=>{(async()=>{try{const N=await Jl.getDashboardData();l(N)}catch(N){console.error("Failed to fetch dashboard:",N)}finally{r(!1)}})()},[]),n)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px]",children:[e.jsx(es,{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||[],x=((u=o.outlets)==null?void 0:u[0])||{},h=[{title:"Constitutional Changes",value:m.constitutional,icon:fl,color:"bg-blue-500",change:"Active Requests",onClick:()=>s("dealer-constitutional")},{title:"Relocation Requests",value:m.relocation,icon:Vr,color:"bg-re-red",change:"Active Requests",onClick:()=>s("dealer-relocation")},{title:"My Outlets",value:((w=o.outlets)==null?void 0:w.length)||0,icon:JI,color:"bg-purple-500",change:"Registered",onClick:()=>{}},{title:"Total Requests",value:m.total,icon:hl,color:"bg-green-500",change:"All time",onClick:()=>{}}],p=[{title:"Constitutional Change",description:"Request change in business structure",icon:fl,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:Vr,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:[x.name," • ",x.location]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-white",children:"Active Dealership"}),e.jsxs(Ce,{className:"bg-green-500 text-white border-0 mt-2",children:[e.jsx(fn,{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,N)=>{const j=v.icon;return e.jsxs(Le,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:v.onClick,children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(et,{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(Fe,{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})]})]},N)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Quick Actions"}),e.jsx(Qt,{children:"Submit new requests and manage your dealership"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:p.map((v,N)=>{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})]})]})},N)})})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"My Recent Requests"}),e.jsx(Qt,{children:"Track the status of your submitted requests"})]}),e.jsx(Fe,{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(Ce,{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(Ce,{className:`border ${v.color}`,children:v.status}),e.jsx(se,{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(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"w-5 h-5 text-re-red"}),"Important Reminders"]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(an,{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(an,{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(fn,{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(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-5 h-5 text-blue-600"}),"Support & Help"]})}),e.jsx(Fe,{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(se,{variant:"outline",className:"w-full mt-2",children:"Contact Support"})]})})]})]})]})}function B7({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),[l,o]=g.useState(!0),[d,m]=g.useState([]),[f,x]=g.useState(""),[h,p]=g.useState(null),[u,w]=g.useState(!1),[v,N]=g.useState(!1),j={panNumber:"",gstNumber:"",registeredAddress:"",bankName:"",accountNumber:"",ifscCode:"",branchName:"",accountHolderName:""},[y,C]=g.useState(j),[S,D]=g.useState(j),R=JSON.stringify(y)!==JSON.stringify(S),A=new Set(d.map(I=>String(I.documentType||"").trim().toLowerCase())),L=f?A.has(f.toLowerCase()):!1;g.useEffect(()=>{$()},[t]);const $=async()=>{var I,q;o(!0);try{const[G,Y]=await Promise.all([Ee.getApplicationById(t),Ee.getDocuments(t)]);if((I=G.data)!=null&&I.success){const V=G.data.data,Q={panNumber:V.panNumber||"",gstNumber:V.gstNumber||"",registeredAddress:V.registeredAddress||V.address||"",bankName:V.bankName||"",accountNumber:V.accountNumber||"",ifscCode:V.ifscCode||"",branchName:V.branchName||"",accountHolderName:V.accountHolderName||V.applicantName||""};a(V),C(Q),D(Q)}((q=Y.data)!=null&&q.success||Y.ok)&&m(Y.data.data||[])}catch(G){console.error("Failed to fetch details:",G),ee.error("Failed to load application details")}finally{o(!1)}},P=async()=>{var I;N(!0);try{console.log("Saving business details for:",t,y);const q=await Ee.updateApplication(t,y);if(q.ok)ee.success("Business details saved successfully"),await $();else{const G=((I=q.data)==null?void 0:I.message)||"Failed to update business details";ee.error(G),console.error("Update failed:",q)}}catch(q){console.error("Save details fatal error:",q),ee.error(q.message||"A network error occurred while saving")}finally{N(!1)}},E=I=>{I.target.files&&I.target.files[0]&&p(I.target.files[0])},O=async()=>{var q,G,Y;if(!h||!f){ee.error("Please select a document type and file");return}const I=new FormData;I.append("file",h),I.append("documentType",f),w(!0);try{const V=await Ee.uploadDocument(t,I);if((q=V.data)!=null&&q.success||V.ok){ee.success("Document uploaded successfully"),p(null),x("");const Q=document.getElementById("file-upload");Q&&(Q.value="");const _=await Ee.getDocuments(t);((G=_.data)!=null&&G.success||_.ok)&&m(_.data.data||[])}else ee.error(((Y=V.data)==null?void 0:Y.message)||"Upload failed")}catch(V){console.error("Upload error:",V),ee.error("Upload failed")}finally{w(!1)}};return l?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(pr,{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(lo,{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(_a,{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(Ir,{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(Vr,{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(yn,{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(Gu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Details"]}),e.jsxs("button",{onClick:P,disabled:v,className:`text-xs text-white px-3 py-1 rounded font-bold transition-all flex items-center gap-1 disabled:opacity-50 ${R?"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(pr,{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:y.accountHolderName,onChange:I=>C({...y,accountHolderName:I.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:y.panNumber,onChange:I=>C({...y,panNumber:I.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:y.gstNumber,onChange:I=>C({...y,gstNumber:I.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:y.registeredAddress,onChange:I=>C({...y,registeredAddress:I.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(hk,{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:y.bankName,onChange:I=>C({...y,bankName:I.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:y.accountNumber,onChange:I=>C({...y,accountNumber:I.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:y.ifscCode,onChange:I=>C({...y,ifscCode:I.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:y.branchName,onChange:I=>C({...y,branchName:I.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(or,{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:L?"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 ${L?"text-green-600":"text-slate-300"}`}),e.jsxs(At,{value:f,onValueChange:x,disabled:u,children:[e.jsx(Dt,{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(kt,{placeholder:"Choose document type"})}),e.jsx(Rt,{className:"rounded-xl border-slate-200 shadow-lg","data-testid":"onboarding-prospective-details-doc-type-content",children:n.map(I=>{const q=A.has(I.toLowerCase());return e.jsxs(RE,{value:I,textValue:I,className:jt("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-${I.replace(/\s+/g,"-").toLowerCase()}`,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(_E,{children:e.jsx(Wn,{className:"size-4"})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(Hn,{className:jt("h-4 w-4 shrink-0",q?"text-green-600":"text-slate-300"),"aria-hidden":!0}),e.jsx(EE,{children:I})]})]},I)})})]})]})]}),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:E,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:O,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(pr,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(or,{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(af,{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((I,q)=>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-${q}`,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(af,{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-${q}`,children:I.documentType}),e.jsx("p",{className:"text-[10px] text-slate-400 truncate w-32",children:I.fileName})]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 rounded-full font-black uppercase tracking-tighter ${I.status==="Approved"?"bg-green-100 text-green-700":"bg-red-50 text-re-red"}`,"data-testid":`onboarding-prospective-details-doc-status-${q}`,children:I.status||"Pending"})]},I.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(_a,{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 $7(){var f;const t=Iu(),s=tr(),n=Ui(),{user:r}=Fn(x=>x.auth),[a,l]=g.useState(!1),[o,d]=g.useState("applicant"),m=()=>{t(kA()),ee.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:()=>l(!1),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Expand sidebar",children:e.jsx(ji,{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:()=>l(!0),className:"p-1 hover:bg-slate-800 rounded transition-colors",title:"Collapse sidebar",children:e.jsx(lo,{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(Ns,{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(fk,{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(Ir,{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(pr,{className:"w-4 h-4 text-slate-600"})})]})]})}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs(ey,{children:[e.jsx(Rs,{path:"/",element:e.jsx(q7,{})}),e.jsx(Rs,{path:"/application/:id",element:e.jsx(z7,{})})]})})]})]})}function q7(){const t=tr(),{user:s}=Fn(l=>l.auth),[n,r]=g.useState([]);g.useEffect(()=>{s!=null&&s.id&&a()},[s==null?void 0:s.id]);const a=async()=>{var l;try{const o=await Ee.getApplications();(l=o.data)!=null&&l.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(Ns,{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(l=>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/${l.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(Ns,{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:l.applicationId}),e.jsxs("p",{className:"text-slate-500 text-sm mb-4 font-medium",children:[l.city,", ",l.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:Gt(l.createdAt)})]})})]},l.id))})]})})}function z7(){const{id:t}=gd(),s=tr();return t?e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsx(B7,{id:t,onBack:()=>s("/prospective-dashboard")})}):null}function U7(){const t=tr(),[s,n]=g.useState([]),[r,a]=g.useState(!0),[l,o]=g.useState("");g.useEffect(()=>{d()},[]);const d=async()=>{var f;a(!0);try{const x=await Ee.getApplications();(f=x.data)!=null&&f.success&&n(x.data.data)}catch(x){console.error("Failed to fetch FDD applications:",x),ee.error("Failed to load assigned applications")}finally{a(!1)}},m=s.filter(f=>{var x;return f.applicationId.toLowerCase().includes(l.toLowerCase())||f.applicantName.toLowerCase().includes(l.toLowerCase())||((x=f.city)==null?void 0:x.toLowerCase().includes(l.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(pr,{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(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Fe,{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(Ns,{className:"w-5 h-5"})})]})})}),e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Fe,{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(yn,{className:"w-5 h-5"})})]})})}),e.jsx(Le,{className:"bg-white border-slate-200 shadow-sm",children:e.jsx(Fe,{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(Le,{className:"shadow-sm border-slate-200 overflow-hidden",children:[e.jsxs(Qe,{className:"bg-white border-b border-slate-100 px-6 py-4 flex flex-row items-center justify-between",children:[e.jsxs(et,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Ns,{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(Ta,{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:l,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(sb,{className:"w-4 h-4 text-slate-600"})})]})]}),e.jsx(Fe,{className:"p-0",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6",children:[e.jsx(pr,{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(an,{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(Ce,{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(Yo,{className:"w-5 h-5"})})})]},f.id))})]})})})]})]})}const V7="modulepreload",H7=function(t){return"/"+t},vS={},Xo=function(s,n,r){let a=Promise.resolve();if(n&&n.length>0){let o=function(f){return Promise.all(f.map(x=>Promise.resolve(x).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=H7(f),f in vS)return;vS[f]=!0;const x=f.endsWith(".css"),h=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const p=document.createElement("link");if(p.rel=x?"stylesheet":V7,x||(p.as="script"),p.crossOrigin="",p.href=f,m&&p.setAttribute("nonce",m),document.head.appendChild(p),x)return new Promise((u,w)=>{p.addEventListener("load",u),p.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(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"&&l(d.reason);return s().catch(l)})};function W7(t,s=[]){let n=[];function r(l,o){const d=g.createContext(o);d.displayName=l+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:p,children:u,...w}=h,v=((j=p==null?void 0:p[t])==null?void 0:j[m])||d,N=g.useMemo(()=>w,Object.values(w));return e.jsx(v.Provider,{value:N,children:u})};f.displayName=l+"Provider";function x(h,p){var v;const u=((v=p==null?void 0:p[t])==null?void 0:v[m])||d,w=g.useContext(u);if(w)return w;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${l}\``)}return[f,x]}const a=()=>{const l=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||l;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,G7(a,...s)]}function G7(...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(l){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(l)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var K7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wb=K7.reduce((t,s)=>{const n=Wu(`Primitive.${s}`),r=g.forwardRef((a,l)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Fg={exports:{}},Bg={};/**
|
||
* @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 yS;function Y7(){if(yS)return Bg;yS=1;var t=fd();function s(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var n=typeof Object.is=="function"?Object.is:s,r=t.useState,a=t.useEffect,l=t.useLayoutEffect,o=t.useDebugValue;function d(h,p){var u=p(),w=r({inst:{value:u,getSnapshot:p}}),v=w[0].inst,N=w[1];return l(function(){v.value=u,v.getSnapshot=p,m(v)&&N({inst:v})},[h,u,p]),a(function(){return m(v)&&N({inst:v}),h(function(){m(v)&&N({inst:v})})},[h]),o(u),u}function m(h){var p=h.getSnapshot;h=h.value;try{var u=p();return!n(h,u)}catch{return!0}}function f(h,p){return p()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return Bg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Bg}var bS;function Z7(){return bS||(bS=1,Fg.exports=Y7()),Fg.exports}var Q7=Z7();function X7(){return Q7.useSyncExternalStore(J7,()=>!0,()=>!1)}function J7(){return()=>{}}var Gb="Avatar",[eq]=W7(Gb),[tq,PE]=eq(Gb),OE=g.forwardRef((t,s)=>{const{__scopeAvatar:n,...r}=t,[a,l]=g.useState("idle");return e.jsx(tq,{scope:n,imageLoadingStatus:a,onImageLoadingStatusChange:l,children:e.jsx(Wb.span,{...r,ref:s})})});OE.displayName=Gb;var LE="AvatarImage",sq=g.forwardRef((t,s)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:a=()=>{},...l}=t,o=PE(LE,n),d=nq(r,l),m=Sr(f=>{a(f),o.onImageLoadingStatusChange(f)});return cr(()=>{d!=="idle"&&m(d)},[d,m]),d==="loaded"?e.jsx(Wb.img,{...l,ref:s,src:r}):null});sq.displayName=LE;var IE="AvatarFallback",ME=g.forwardRef((t,s)=>{const{__scopeAvatar:n,delayMs:r,...a}=t,l=PE(IE,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&&l.imageLoadingStatus!=="loaded"?e.jsx(Wb.span,{...a,ref:s}):null});ME.displayName=IE;function jS(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function nq(t,{referrerPolicy:s,crossOrigin:n}){const r=X7(),a=g.useRef(null),l=r?(a.current||(a.current=new window.Image),a.current):null,[o,d]=g.useState(()=>jS(l,t));return cr(()=>{d(jS(l,t))},[l,t]),cr(()=>{const m=h=>()=>{d(h)};if(!l)return;const f=m("loaded"),x=m("error");return l.addEventListener("load",f),l.addEventListener("error",x),s&&(l.referrerPolicy=s),typeof n=="string"&&(l.crossOrigin=n),()=>{l.removeEventListener("load",f),l.removeEventListener("error",x)}},[l,n,s]),o}var rq=OE,aq=ME;function Nm({className:t,...s}){return e.jsx(rq,{"data-slot":"avatar",className:jt("relative flex size-10 shrink-0 overflow-hidden rounded-full",t),...s})}function wm({className:t,...s}){return e.jsx(aq,{"data-slot":"avatar-fallback",className:jt("bg-muted flex size-full items-center justify-center rounded-full",t),...s})}const Sm="/collaboration",Cm={getWorknotes:async(t,s)=>(await $e.get(`${Sm}/worknotes`,{requestId:t,requestType:s})).data,addWorknote:async t=>(await $e.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 $e.post(`${Sm}/upload`,r,{headers:{"Content-Type":"multipart/form-data"}})).data},revokeParticipant:async(t,s)=>(await $e.delete(`${Sm}/participants/${t}`,{data:{reason:s}})).data},iu=t=>[...t].sort((s,n)=>new Date(s.createdAt).getTime()-new Date(n.createdAt).getTime()),$g=t=>{var s,n,r,a,l;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)||((l=t==null?void 0:t.author)==null?void 0:l.roleCode)||"")}},iq=new Set(["internal","workflow","system","audit","status"]),lq=t=>iq.has(String(t.noteType||"").toLowerCase()),oq=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"},cq=t=>{const s=String(t.noteType||"").toLowerCase();return s==="internal"?"APPROVAL":s==="workflow"?"WORKFLOW":s==="system"?"SYSTEM":s==="audit"?"AUDIT":s==="status"?"STATUS":"ACTIVITY"},NS=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 FE(t){var Ys,Xs,Js,Ws,Z;const{user:s}=Fn(oe=>oe.auth),{id:n,type:r}=gd(),a=Ui(),l=tr(),o=t.requestId||n||"",d=t.requestType||r||((Ys=a.state)==null?void 0:Ys.requestType)||"application",m=t.mode||((Xs=a.state)==null?void 0:Xs.mode)||"page",[f,x]=g.useState(t.applicationName||((Js=a.state)==null?void 0:Js.applicationName)||"Application"),[h,p]=g.useState(t.registrationNumber||((Ws=a.state)==null?void 0:Ws.registrationNumber)||""),u=t.onBack||(()=>l(-1)),w=t.participants||((Z=a.state)==null?void 0:Z.participants)||[],[v,N]=g.useState(w),[j,y]=g.useState([]),[C,S]=g.useState(""),[D,R]=g.useState(!1),[A,L]=g.useState(""),[$,P]=g.useState(0),[E,O]=g.useState(!0),[I,q]=g.useState(!1),[G,Y]=g.useState([]),[V,Q]=g.useState(!1),[_,z]=g.useState(!0),[T,F]=g.useState(""),[B,K]=g.useState(""),[W,H]=g.useState(null),[X,J]=g.useState(""),[ie,ae]=g.useState(!1),{socket:xe}=JD(),ce=g.useRef(null),we=g.useRef(null),[ke,Xe]=g.useState(null),Ot=(oe,Ne)=>oe.startsWith("image/")&&Ne?e.jsx("img",{src:`${Uc}/${Ne.replace(/\\/g,"/")}`,className:"w-full h-full object-cover rounded",alt:"Thumbnail"}):oe.startsWith("image/")?e.jsx(D1,{className:"w-5 h-5 text-blue-500"}):oe==="application/pdf"?e.jsx(Ns,{className:"w-5 h-5 text-red-500"}):e.jsx(af,{className:"w-5 h-5 text-slate-500"}),bt=["😊","😂","🤣","❤️","👍","🙏","🔥","✨","😍","🥰","😎","🤔","😅","🙌","👏","🎉","✅","❌","📌","📎","📍","💡","🔔","📢","⭐","🌟","💪","🚀","👀","💯","🌈","☀️","😢","😭","😞","😔","😟","😕","😠","😡","🤬","😤","😲","🙄","🤨","😓","😩","😫","🤐","😴","🤢","🤮","😱","🤡","💀","👻","🤝","👋","✌️","👌","✋","🍎","🍕","☕","💻","📱","⌚","📁","📄","📅","🔒","🔑","🛠️","⚙️","💬","💭","🌊","🍀","✈️","🏠"],te=oe=>oe.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().substring(0,2),ve=oe=>{const Ne=["bg-green-600","bg-blue-600","bg-purple-600","bg-re-red","bg-pink-600","bg-indigo-600","bg-teal-600"],Oe=oe.length%Ne.length;return Ne[Oe]},qe=[],ge=new Set;v.forEach(oe=>{var De,ye,Ve,Ge,st,Kt,Xt;const Ne=((De=oe.user)==null?void 0:De.id)||oe.userId||"",Oe=oe.id;if(Ne&&!ge.has(Ne)){ge.add(Ne);const ot=((ye=oe.user)==null?void 0:ye.fullName)||((Ve=oe.user)==null?void 0:Ve.name)||oe.fullName||oe.name||"Unknown User",ft=((Ge=oe.user)==null?void 0:Ge.email)||oe.email||"",Es=((st=oe.user)==null?void 0:st.roleCode)||oe.roleCode||((Kt=oe.user)==null?void 0:Kt.role)||oe.role||"Participant";qe.push({id:Ne,recordId:Oe,name:ot,email:ft,initials:te(ot),color:ve(ot),role:Es,isOnline:!1,revokedAt:(Xt=oe.metadata)==null?void 0:Xt.revokedAt})}});const Be=async()=>{try{O(!0);const oe=await Cm.getWorknotes(o,d);if(oe.success){const Ne=oe.data.map(Oe=>({id:Oe.id,noteText:Oe.noteText,noteType:Oe.noteType,createdAt:Oe.createdAt,userId:Oe.userId,author:Oe.author?$g(Oe):{name:"System",email:"",role:"system"},attachments:Oe.attachments||[]}));y(iu(Ne))}}catch(oe){console.error("Fetch notes error:",oe),ee.error("Failed to load work notes")}finally{O(!1)}};g.useEffect(()=>{if(Be(),xe)return xe.emit("join_room",o),xe.on("new_worknote",oe=>{const Ne={id:oe.id,noteText:oe.noteText,noteType:oe.noteType,createdAt:oe.createdAt,userId:oe.userId,author:oe.author?$g(oe):{name:"System",email:"",role:"system"},attachments:oe.attachments||[]};y(Oe=>{if(Oe.some(Ve=>Ve.id===Ne.id))return Oe;const ye=Oe.findIndex(Ve=>{var Ge,st;return Ve.id.startsWith("temp-")&&Ve.noteText===Ne.noteText&&((Ge=Ve.author.email)==null?void 0:Ge.toLowerCase())===((st=Ne.author.email)==null?void 0:st.toLowerCase())});if(ye!==-1){const Ve=[...Oe];return Ve[ye]=Ne,iu(Ve)}return iu([...Oe,Ne])})}),()=>{xe.emit("leave_room",o),xe.off("new_worknote")}},[o,d,xe]),g.useEffect(()=>{if(!o||!d)return;(async()=>{var Ne,Oe,De,ye,Ve,Ge,st,Kt,Xt,ot;try{let ft=null;if(d==="application")ft=await ds.getApplicationById(o),ft&&(v.length===0&&ft.participants&&N(ft.participants),(!f||f==="Application")&&x(ft.companyName||"Application"),h||p(ft.registrationNumber||""));else if(d==="termination"){const{API:Es}=await Xo(async()=>{const{API:vs}=await Promise.resolve().then(()=>cm);return{API:vs}},void 0),ts=await Es.getTerminationById(o);(Ne=ts.data)!=null&&Ne.success&&(ft=ts.data.termination,v.length===0&&ft.participants&&N(ft.participants),(!f||f==="Application"||f==="Termination")&&x(((Oe=ft.dealer)==null?void 0:Oe.businessName)||"Termination"),h||p(ft.requestId||""))}else if(d==="constitutional"||d==="constitutional-change"){const{API:Es}=await Xo(async()=>{const{API:vs}=await Promise.resolve().then(()=>cm);return{API:vs}},void 0),ts=await Es.getConstitutionalChangeById(o);(De=ts.data)!=null&&De.success&&(ft=ts.data.request,v.length===0&&ft.participants&&N(ft.participants),(!f||f==="Application"||f==="Constitutional Change")&&x(((ye=ft.outlet)==null?void 0:ye.name)||"Constitutional Change"),h||p(ft.requestId||""))}else if(d==="resignation"){const{API:Es}=await Xo(async()=>{const{API:vs}=await Promise.resolve().then(()=>cm);return{API:vs}},void 0),ts=await Es.getResignationById(o);(Ve=ts.data)!=null&&Ve.success&&(ft=ts.data.resignation,v.length===0&&ft.participants&&N(ft.participants),(!f||f==="Application"||f==="Resignation")&&x(((Ge=ft.dealer)==null?void 0:Ge.businessName)||"Resignation"),h||p(ft.resignationId||""))}else if(d==="fnf"){const{API:Es}=await Xo(async()=>{const{API:vs}=await Promise.resolve().then(()=>cm);return{API:vs}},void 0),ts=await Es.getFnFSettlementById(o);if((st=ts.data)!=null&&st.success){ft=ts.data.fnf,v.length===0&&ft.participants&&N(ft.participants||[]);const vs=((Xt=(Kt=ft.outlet)==null?void 0:Kt.dealer)==null?void 0:Xt.fullName)||((ot=ft.dealer)==null?void 0:ot.fullName)||"F&F Settlement";(!f||f==="Application"||f==="F&F Settlement")&&x(vs),h||p(ft.settlementId||"")}}}catch(ft){console.error(`Failed to fetch ${d} details:`,ft)}})()},[o,d,v.length,f,h]);const ut=g.useRef(null);g.useEffect(()=>{ut.current&&ut.current.scrollIntoView({behavior:"smooth"})},[j]);const ht=oe=>{const Ne=oe.target.value,Oe=oe.target.selectionStart||0;S(Ne),P(Oe);const De=Ne.substring(0,Oe),ye=De.lastIndexOf("@");if(ye!==-1&&ye===De.length-1)R(!0),L("");else if(ye!==-1){const Ve=De.substring(ye+1);Ve.includes(" ")?R(!1):(R(!0),L(Ve))}else R(!1)},it=oe=>{var Ge;const Oe=C.substring(0,$).lastIndexOf("@"),De=C.substring($),ye=`@${oe.name}`,Ve=C.substring(0,Oe)+ye+" "+De;S(Ve),R(!1),(Ge=ce.current)==null||Ge.focus()},Tt=oe=>{var De,ye;const Ne=((De=ce.current)==null?void 0:De.selectionStart)||C.length,Oe=C.substring(0,Ne)+oe+C.substring(Ne);S(Oe),q(!1),(ye=ce.current)==null||ye.focus()},It=async oe=>{const Ne=oe.target.files;if(!(!Ne||Ne.length===0)){Q(!0);try{for(const Oe of Array.from(Ne)){const De=await Cm.uploadAttachment(Oe,o,d);De.success&&Y(ye=>[...ye,De.data])}}catch(Oe){console.error("File upload error:",Oe),ee.error("Failed to upload attachment")}finally{Q(!1),we.current&&(we.current.value="")}}},he=oe=>{Y(Ne=>Ne.filter(Oe=>Oe.id!==oe))},vt=async()=>{if(!C.trim()&&G.length===0)return;const oe=C,Ne=G;S(""),Y([]);let Oe=oe;const De=[];qe.forEach(ye=>{if(ye.id&&ye.name){const Ve=ye.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ge=new RegExp(`@${Ve}\\b`,"gi");Oe.match(Ge)&&(De.push(ye.id),Oe=Oe.replace(Ge,`@[${ye.name}](user:${ye.id})`))}});try{const ye=`temp-${Date.now()}`,Ve={id:ye,noteText:Oe,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:Ne};y(st=>iu([...st,Ve]));const Ge=await Cm.addWorknote({requestId:o,requestType:d,noteText:Oe,noteType:"General",tags:De,attachmentDocIds:Ne.map(st=>st.id)});if(Ge.success&&Ge.data){const st=Ge.data,Kt={id:st.id,noteText:st.noteText,noteType:st.noteType,createdAt:st.createdAt,userId:st.userId,author:st.author?$g(st):{name:"System",email:"",role:"system"},attachments:st.attachments||[]};y(Xt=>iu(Xt.map(ot=>ot.id===ye?Kt:ot)))}}catch(ye){console.error("Send message error:",ye),ee.error("Failed to send message")}},mt=oe=>{if(!["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")){ee.error("Only authorized roles can revoke participants");return}H(oe),J("")},_e=async()=>{if(W){ae(!0);try{const oe=await Cm.revokeParticipant(W.recordId,X);oe.success&&(ee.success(oe.message),H(null),N([]))}catch{ee.error("Error revoking participant")}finally{ae(!1)}}},Vt=oe=>{oe.key==="Enter"&&!oe.shiftKey&&(oe.preventDefault(),vt())},Et=oe=>{if(!oe)return"";const Ne=/(@\[[^\]]+\]\([^\)]+\))/g;return oe.split(Ne).map((De,ye)=>{const Ve=De.match(/@\[([^\]]+)\]\(([^\)]+)\)/);if(Ve){const Ge=Ve[1];return e.jsxs("span",{className:"text-blue-600 font-medium hover:underline cursor-pointer",children:["@",Ge]},ye)}return De})},Ds=B.trim().toLowerCase(),ln=Ds?j.filter(oe=>{var Ne;return(oe.noteText||"").toLowerCase().includes(Ds)||(((Ne=oe.author)==null?void 0:Ne.name)||"").toLowerCase().includes(Ds)||(oe.noteType||"").toLowerCase().includes(Ds)}):j,Bs=qe.filter(oe=>{const Ne=oe.name.toLowerCase().includes(A.toLowerCase()),Oe=oe.id&&(s==null?void 0:s.id)&&String(oe.id)===String(s.id)||oe.email&&(s==null?void 0:s.email)&&oe.email.toLowerCase()===s.email.toLowerCase();return Ne&&!Oe});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(se,{variant:"ghost",size:"icon",onClick:u,className:"hover:bg-slate-100","data-testid":"onboarding-worknotes-back-btn",children:e.jsx(Jr,{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(Ga,{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:[qe.slice(0,3).map((oe,Ne)=>e.jsx(Nm,{className:"w-8 h-8 border-2 border-white ring-1 ring-slate-100","data-testid":`onboarding-worknotes-avatar-${Ne}`,children:e.jsx(wm,{className:`${oe.color} text-white text-[10px]`,children:oe.initials})},Ne)),qe.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:["+",qe.length-3]})})]}),e.jsxs(se,{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:E,"data-testid":"onboarding-worknotes-sync-btn",children:[e.jsx(fl,{className:`w-4 h-4 ${E?"animate-spin":""}`}),e.jsx("span",{className:"text-xs font-medium hidden md:inline",children:"Sync"})]}),e.jsxs(se,{variant:_?"secondary":"ghost",size:"sm",onClick:()=>z(!_),className:`flex items-center gap-1.5 px-2 h-9 rounded-lg transition-all ${_?"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(Ra,{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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(at,{type:"search",value:B,onChange:oe=>K(oe.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"})]})}),ln.map((oe,Ne)=>{var De,ye,Ve,Ge,st,Kt,Xt;if(lq(oe)){const ot=((De=oe.author)==null?void 0:De.name)||"System",ft=(ye=oe.author)!=null&&ye.role&&oe.author.role!=="0"&&oe.author.role!==""?oe.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-${Ne}`,children:e.jsxs("div",{role:"status",title:oq(oe),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-${Ne}`,children:cq(oe)}),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-${Ne}`,children:ot}),ft?e.jsxs("span",{className:"text-xs font-normal text-slate-500",children:[" · ",ft]}):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-${Ne}`,children:Et(oe.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:oe.createdAt,"data-testid":`onboarding-worknotes-activity-time-${Ne}`,children:NS(oe.createdAt)})]})},oe.id)}const Oe=((Ve=oe==null?void 0:oe.author)==null?void 0:Ve.email)&&(s==null?void 0:s.email)&&oe.author.email.toLowerCase()===s.email.toLowerCase()||(oe==null?void 0:oe.userId)&&(s==null?void 0:s.id)&&String(oe.userId)===String(s.id)||oe.id.startsWith("temp-");return e.jsx("div",{className:`flex w-full ${Oe?"justify-end":"justify-start"}`,"data-testid":`onboarding-worknotes-message-row-${Ne}`,children:e.jsxs("div",{className:`flex gap-3 max-w-[min(85%,36rem)] ${Oe?"flex-row-reverse":""}`,children:[e.jsx(Nm,{className:"w-10 h-10 flex-shrink-0 mt-1","data-testid":`onboarding-worknotes-message-avatar-${Ne}`,children:e.jsx(wm,{className:`${ve(((Ge=oe==null?void 0:oe.author)==null?void 0:Ge.name)||"System")} text-white`,children:te(((st=oe==null?void 0:oe.author)==null?void 0:st.name)||"S")})}),e.jsxs("div",{className:`flex flex-col min-w-0 ${Oe?"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 ${Oe?"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-${Ne}`,children:Oe?"You":((Kt=oe==null?void 0:oe.author)==null?void 0:Kt.name)||"Unknown"}),e.jsx("span",{className:"text-slate-400 text-[10px] uppercase tracking-wide",children:(Xt=oe==null?void 0:oe.author)!=null&&Xt.role&&oe.author.role!=="0"&&oe.author.role!==""?`(${oe.author.role})`:""}),e.jsx("span",{className:"text-slate-400 text-[10px] tabular-nums","data-testid":`onboarding-worknotes-message-time-${Ne}`,children:NS(oe.createdAt)})]}),e.jsxs("div",{className:`rounded-2xl border px-4 py-2.5 shadow-sm relative text-left ${Oe?"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-${Ne}`,children:[e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words","data-testid":`onboarding-worknotes-message-text-${Ne}`,children:Et(oe.noteText)}),oe.attachments&&oe.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-${Ne}`,children:oe.attachments.map((ot,ft)=>{const Es=ot.mimeType.startsWith("image/");return e.jsx("div",{className:"flex items-center gap-2","data-testid":`onboarding-worknotes-message-attachment-${Ne}-${ft}`,children:Es?e.jsx("div",{className:"rounded-lg overflow-hidden border border-slate-100 max-w-[200px]",children:e.jsx("img",{src:`${Uc}/${ot.filePath.replace(/\\/g,"/")}`,alt:ot.fileName,className:"w-full h-auto cursor-pointer",onClick:()=>Xe(ot),"data-testid":`onboarding-worknotes-message-attachment-img-${Ne}-${ft}`})}):ot.mimeType==="application/pdf"?e.jsxs("button",{type:"button",onClick:()=>Xe(ot),className:"flex items-center gap-2 text-xs text-blue-600 hover:underline","data-testid":`onboarding-worknotes-message-attachment-preview-${Ne}-${ft}`,children:[e.jsx(ju,{className:"w-3 h-3"}),ot.fileName," (Preview)"]}):e.jsxs("a",{href:`${Uc}/${ot.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-${Ne}-${ft}`,children:[e.jsx(ju,{className:"w-3 h-3"}),ot.fileName]})},ot.id)})})]})]})]})},oe.id)}),j.length===0&&!E&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"onboarding-worknotes-empty-state",children:[e.jsx(Ga,{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&&ln.length===0&&!E&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center text-slate-500 text-sm",children:['No messages match "',B.trim(),'". Clear the search box to see the full thread.']}),E&&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:ut})]})}),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:[G.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mb-3","data-testid":"onboarding-worknotes-attached-files",children:G.map((oe,Ne)=>{const Oe=oe.mimeType.startsWith("image/")||oe.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-${Ne}`,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:Ot(oe.mimeType,oe.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 ${Oe?"hover:text-blue-600 cursor-pointer hover:underline":""}`,onClick:()=>Oe&&Xe(oe),children:oe.fileName}),e.jsx("button",{onClick:()=>he(oe.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-${Ne}`,children:e.jsx(id,{className:"w-3 h-3"})})]})]},oe.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&&Bs.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:Bs.map((oe,Ne)=>e.jsxs("button",{onClick:()=>it(oe),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-${Ne}`,children:[e.jsx(Nm,{className:"w-8 h-8",children:e.jsx(wm,{className:`${oe.color} text-white text-xs`,children:oe.initials})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-slate-900 text-sm font-medium",children:oe.name})})]},oe.id))}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("input",{type:"file",ref:we,className:"hidden",multiple:!0,onChange:It}),e.jsx(se,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var oe;return(oe=we.current)==null?void 0:oe.click()},"data-testid":"onboarding-worknotes-attachment-btn",children:e.jsx(ju,{className:"w-5 h-5"})}),e.jsxs(se,{variant:"ghost",size:"icon",className:`w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl relative ${I?"bg-blue-50 text-blue-600":""}`,onClick:()=>q(!I),"data-testid":"onboarding-worknotes-emoji-btn",children:[e.jsx(sM,{className:"w-5 h-5"}),I&&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:()=>q(!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:bt.map((oe,Ne)=>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:Oe=>{Oe.stopPropagation(),Tt(oe)},"data-testid":`onboarding-worknotes-emoji-item-${Ne}`,children:oe},oe))})]})]}),e.jsx(se,{variant:"ghost",size:"icon",className:"w-9 h-9 text-slate-400 hover:text-blue-600 hover:bg-blue-50 rounded-xl",onClick:()=>{var oe;return(oe=we.current)==null?void 0:oe.click()},children:e.jsx(D1,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 relative",children:e.jsx(at,{ref:ce,type:"text",placeholder:"Type your message... Use @username to mention someone",value:C,onChange:ht,onKeyPress:Vt,className:"w-full pr-4 border-none focus-visible:ring-0 px-0"})}),e.jsx(se,{onClick:vt,disabled:!C.trim()&&G.length===0||V,className:"bg-blue-600 hover:bg-blue-700 text-white rounded-xl h-10 w-10 p-0",children:V?e.jsx("div",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):e.jsx(Ku,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-slate-400 text-[10px] px-1 flex items-center gap-1",children:[e.jsx(_a,{className:"w-3 h-3"}),e.jsxs("span",{children:["Press Enter to send • Use @ to mention • ",V?"Uploading files...":"Files attached appear above"]})]})]})})]}),_&&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(Ra,{className:"w-4 h-4 text-blue-600"}),"Participants",e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-slate-600 ml-1",children:qe.length})]}),e.jsx(se,{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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search people...",value:T,onChange:oe=>F(oe.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:[qe.filter(oe=>{var Ne;return oe.name.toLowerCase().includes(T.toLowerCase())||((Ne=oe.role)==null?void 0:Ne.toLowerCase().includes(T.toLowerCase()))}).map(oe=>{const Ne=!!oe.revokedAt,Oe=["DD Lead","DD Head","NBH","DD Admin","Super Admin"].includes((s==null?void 0:s.roleCode)||"")&&!Ne&&oe.id!==(s==null?void 0:s.id);return e.jsxs("div",{className:jt("group flex items-start gap-3 p-3 rounded-xl transition-all cursor-default border border-transparent",Ne?"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:jt("w-10 h-10 ring-2 ring-transparent transition-all",!Ne&&"group-hover:ring-blue-100"),children:e.jsx(wm,{className:`${oe.color} text-white text-xs font-bold`,children:oe.initials})}),oe.isOnline&&!Ne&&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"}),Ne&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-100 rounded-full p-0.5 border border-white",children:e.jsx(bg,{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:jt("text-sm font-semibold truncate",Ne?"text-slate-500 line-through":"text-slate-900"),children:oe.name}),Ne&&e.jsx(Ce,{variant:"outline",className:"text-[8px] h-3.5 px-1 bg-red-50 text-red-600 border-red-100",children:"Revoked"})]}),oe.id===(s==null?void 0:s.id)&&e.jsx(Ce,{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:oe.role}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate italic",children:oe.email})]}),Oe&&e.jsx(se,{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:()=>mt(oe),children:e.jsx(bg,{className:"w-3.5 h-3.5"})}),!Oe&&!Ne&&e.jsx(ji,{className:"w-4 h-4 text-slate-300 group-hover:text-slate-400 opacity-0 group-hover:opacity-100 transition-all self-center"})]},oe.id)}),qe.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center opacity-50",children:[e.jsx(Ra,{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(yn,{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(ls,{open:!!ke,onOpenChange:oe=>!oe&&Xe(null),children:e.jsxs(as,{className:"max-w-6xl h-[90vh] flex flex-col p-4",children:[e.jsx(fs,{children:e.jsxs(us,{className:"flex items-center gap-2",children:[ke&&Ot(ke.mimeType),e.jsx("span",{className:"truncate",children:ke==null?void 0:ke.fileName})]})}),e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg bg-slate-100 flex items-center justify-center p-4",children:ke!=null&&ke.mimeType.startsWith("image/")?e.jsx("img",{src:`${Uc}/${ke.filePath.replace(/\\/g,"/")}`,className:"max-w-full max-h-full object-contain",alt:"Preview"}):(ke==null?void 0:ke.mimeType)==="application/pdf"?e.jsx("iframe",{src:`${Uc}/${ke.filePath.replace(/\\/g,"/")}`,className:"w-full h-full border-none",title:"PDF Preview"}):e.jsxs("div",{className:"text-center",children:[e.jsx(af,{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}/${ke==null?void 0:ke.filePath.replace(/\\/g,"/")}`,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline text-sm",children:"Open in new tab"})]})})]})}),e.jsx(ls,{open:!!W,onOpenChange:oe=>!oe&&H(null),children:e.jsxs(as,{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(bg,{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:W==null?void 0:W.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(at,{value:X,onChange:oe=>J(oe.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(se,{variant:"outline",className:"flex-1 h-11 border-slate-200 text-slate-600 hover:bg-slate-50",onClick:()=>H(null),children:"Cancel"}),e.jsxs(se,{className:"flex-1 h-11 bg-red-600 hover:bg-red-700 text-white font-bold shadow-lg shadow-red-200",onClick:_e,disabled:ie,children:[ie?e.jsx(fl,{className:"w-4 h-4 animate-spin mr-2"}):null,"Revoke Access"]})]})]})]})})]})}const Kb="!w-[80vw] !max-w-[80vw] sm:!max-w-[80vw]",mo=({isOpen:t,onClose:s,document:n})=>{var l;const a=n?`http://localhost:5000${n.filePath.startsWith("/")?"":"/"}${n.filePath}`:"";return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsx(as,{className:`${Kb} 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(bn,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(us,{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(se,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:()=>window.open(a,"_blank"),children:[e.jsx(Ni,{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:(l=n.fileName)!=null&&l.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 dq(){var V,Q,_,z;const{id:t}=gd(),s=tr(),[n,r]=g.useState(null),[a,l]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState(!1),[x,h]=g.useState(""),[p,u]=g.useState("details"),[w,v]=g.useState(!1),[N,j]=g.useState(null),[y,C]=g.useState(!1),[S,D]=g.useState(!1),[R,A]=g.useState(""),L=Fn(T=>T.auth.user),$=(L==null?void 0:L.role)==="FDD";g.useEffect(()=>{t&&P()},[t]);const P=async()=>{var T,F,B,K;d(!0);try{const[W,H]=await Promise.all([Ee.getApplicationById(t),Ee.getFddAssignment(t)]);(T=W.data)!=null&&T.success&&r(W.data.data),(F=H.data)!=null&&F.success&&l(H.data.data)}catch(W){console.error("Error fetching application:",W);const H=((K=(B=W.response)==null?void 0:B.data)==null?void 0:K.message)||"Access Denied: Not authorized for FDD access";ee.error(H),s("/fdd-dashboard")}finally{d(!1)}},E=async T=>{var K,W,H;const F=(K=T.target.files)==null?void 0:K[0];if(!F||!x){x||ee.error("Please select a document type first");return}f(!0);const B=new FormData;B.append("file",F),B.append("documentType",x),B.append("stage","FDD"),B.append("applicationId",t),B.append("requestType","application");try{const X=await Ee.uploadDocument(t,B);if((W=X.data)!=null&&W.success){if(x==="FDD Final Audit Report"){const J=((H=X.data.data)==null?void 0:H.id)||X.data.id;await Ee.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:J,findings:"Final Audit Report submitted.",recommendation:"REVIEW_PENDING"})}ee.success(`${x} uploaded successfully`),P(),h("")}}catch{ee.error("Failed to upload document")}finally{f(!1)}},O=T=>{if(!T||!T.filePath){ee.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(es,{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 I=n.currentStage==="FDD_VERIFICATION"||n.currentStage==="FDD",q=(a==null?void 0:a.status)==="Report Submitted",G=!I&&(n.overallStatus!=="Active"||n.currentProgress>=75)||q,Y=!I&&n.currentProgress<70&&!q;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(Ha,{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(Jr,{className:"w-5 h-5"})}),"Back to Dashboard"]}),e.jsx("div",{className:"flex items-center gap-3",children:Y?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(yn,{className:"w-4 h-4"}),"Awaiting Previous Stages"]}):G?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:$&&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(Ha,{className:"w-4 h-4"}),"Flag Non-Responsive"]})})})]}),e.jsx(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-header",children:e.jsx(Fe,{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(Ce,{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 ${p==="details"?"text-blue-600":"text-slate-500 hover:text-slate-700"}`,"data-testid":"onboarding-fdd-details-tab-workspace",children:["Workspace",p==="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 ${p==="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"}),p==="worknotes"&&e.jsx("div",{className:"absolute bottom-[-1px] left-0 right-0 h-0.5 bg-blue-600"})]})]}),p==="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(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-workspace-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 py-4",children:e.jsxs(et,{className:"text-base font-bold flex items-center gap-2 text-slate-800",children:[e.jsx(or,{className:"w-4 h-4 text-slate-500"}),G?"Finalized Financial Reports":Y?"Audit Workspace":"Financial Report Submission"]})}),e.jsxs(Fe,{className:"p-6",children:[Y&&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(yn,{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"]})]}),G&&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."})]})]}),!G&&!Y&&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(Ns,{className:"w-6 h-6"})}),e.jsx("p",{className:"text-slate-600 font-medium mb-1","data-testid":"onboarding-fdd-details-upload-title",children:$?"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:$?"PDF or JPG formats accepted (Max 10MB)":"You are in View-Only mode for this Audit"}),$&&e.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[e.jsxs("select",{value:x,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(es,{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:E,disabled:!x,"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 ${x?"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:[(V=n.uploadedDocuments)==null?void 0:V.filter(T=>!T.uploader||T.uploader.roleCode!=="FDD").map((T,F)=>{var B;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(Ns,{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," • ",Gt(T.createdAt),((B=T.uploader)==null?void 0:B.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>O(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(bn,{className:"w-4 h-4"})})})]},F)}),((Q=n.uploadedDocuments)==null?void 0:Q.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:[(_=n.uploadedDocuments)==null?void 0:_.filter(T=>{var F;return((F=T.uploader)==null?void 0:F.roleCode)==="FDD"}).map((T,F)=>{var B;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(Ns,{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," • ",Gt(T.createdAt),((B=T.uploader)==null?void 0:B.fullName)&&` • by ${T.uploader.fullName}`]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>O(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(bn,{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(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-profile-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(et,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Applicant Profile"})}),e.jsxs(Fe,{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(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-statutory-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(et,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Statutory Details"})}),e.jsx(Fe,{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(Le,{className:"border border-slate-200 shadow-sm bg-white","data-testid":"onboarding-fdd-details-bank-card",children:[e.jsx(Qe,{className:"border-b border-slate-100 px-6 pt-4 pb-2.5",children:e.jsx(et,{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Bank Details"})}),e.jsx(Fe,{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(FE,{onBack:()=>u("details"),requestId:t,requestType:"application"})}),e.jsx(mo,{isOpen:w,onClose:()=>v(!1),document:N}),e.jsx(ls,{open:y,onOpenChange:C,children:e.jsxs(as,{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(no,{className:"w-8 h-8 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(fs,{children:[e.jsx(us,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-finalize-title",children:"Submit Audit Report"}),e.jsxs(bs,{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(_a,{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(de,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Detailed Audit Findings & Remarks"}),e.jsx(Gs,{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:R,onChange:T=>A(T.target.value),"data-testid":"onboarding-fdd-details-finalize-remarks"})]})}),e.jsxs(xn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(se,{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(se,{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(!R.trim()){ee.error("Please provide findings.");return}f(!0);const B=(T=a==null?void 0:a.reports)==null?void 0:T[0];(F=(await Ee.submitFddReport({assignmentId:a==null?void 0:a.id,applicationId:t,reportDocumentId:B==null?void 0:B.reportDocumentId,findings:R,recommendation:null})).data)!=null&&F.success&&(ee.success("FDD Report submitted successfully."),C(!1),P())}catch{ee.error("Failed to submit report")}finally{f(!1)}},disabled:m,children:m?e.jsx(es,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ls,{open:S,onOpenChange:D,children:e.jsxs(as,{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(Ha,{className:"w-8 h-8 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsxs(fs,{children:[e.jsx(us,{className:"text-2xl font-bold text-slate-900 text-center","data-testid":"onboarding-fdd-details-flag-modal-title",children:"Flag Applicant"}),e.jsxs(bs,{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(xn,{className:"flex flex-col sm:flex-row gap-3 pt-4 sm:pt-6",children:[e.jsx(se,{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(se,{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 Ee.flagNonResponsive({applicationId:t,remarks:"Applicant is non-responsive to FDD queries."}),ee.error("Application flagged for non-responsiveness."),D(!1),P()}catch{ee.error("Action failed")}finally{f(!1)}},disabled:m,children:m?e.jsx(es,{className:"w-5 h-5 animate-spin"}):"Flag Applicant"})]})]})]})})]})}const Zl={getOperationsDashboard:async t=>(await Ee.getSlaOperationsDashboard(t)).data,getBatchStatus:async t=>(await Ee.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 l=await a.blob(),o=URL.createObjectURL(l),d=document.createElement("a");d.href=o,d.download=`sla-queue-${Date.now()}.csv`,d.click(),URL.revokeObjectURL(o)},getQuestionnaireReminderSettings:async()=>(await Ee.getQuestionnaireReminderSettings()).data,updateQuestionnaireReminderSettings:async t=>(await Ee.updateQuestionnaireReminderSettings(t)).data},uq={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"},hq={healthy:"On track",warning:"Due soon",critical:"At risk",breached:"Breached"};function kr({status:t,compact:s}){if(!t)return null;const n=t.isPaused?"warning":t.bucket,r=t.isPaused?"Paused":hq[t.bucket];return e.jsx(Ce,{variant:"outline",className:`text-[10px] font-semibold ${uq[n]} ${s?"px-1.5":""}`,title:`${t.stageName} · ${t.remainingLabel} (${t.percentUsed}% of TAT)`,children:s?r:`${r} · ${t.remainingLabel}`})}function mq(t,s=[]){let n=[];function r(l,o){const d=g.createContext(o);d.displayName=l+"Context";const m=n.length;n=[...n,o];const f=h=>{var j;const{scope:p,children:u,...w}=h,v=((j=p==null?void 0:p[t])==null?void 0:j[m])||d,N=g.useMemo(()=>w,Object.values(w));return e.jsx(v.Provider,{value:N,children:u})};f.displayName=l+"Provider";function x(h,p){var v;const u=((v=p==null?void 0:p[t])==null?void 0:v[m])||d,w=g.useContext(u);if(w)return w;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${l}\``)}return[f,x]}const a=()=>{const l=n.map(o=>g.createContext(o));return function(d){const m=(d==null?void 0:d[t])||l;return g.useMemo(()=>({[`__scope${t}`]:{...d,[t]:m}}),[d,m])}};return a.scopeName=t,[r,fq(a,...s)]}function fq(...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(l){const o=r.reduce((d,{useScope:m,scopeName:f})=>{const h=m(l)[`__scope${f}`];return{...d,...h}},{});return g.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return n.scopeName=s.scopeName,n}var pq=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BE=pq.reduce((t,s)=>{const n=Wu(`Primitive.${s}`),r=g.forwardRef((a,l)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Yb="Progress",Zb=100,[xq]=mq(Yb),[gq,vq]=xq(Yb),$E=g.forwardRef((t,s)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:l=yq,...o}=t;(a||a===0)&&!wS(a)&&console.error(bq(`${a}`,"Progress"));const d=wS(a)?a:Zb;r!==null&&!SS(r,d)&&console.error(jq(`${r}`,"Progress"));const m=SS(r,d)?r:null,f=vf(m)?l(m,d):void 0;return e.jsx(gq,{scope:n,value:m,max:d,children:e.jsx(BE.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":vf(m)?m:void 0,"aria-valuetext":f,role:"progressbar","data-state":UE(m,d),"data-value":m??void 0,"data-max":d,...o,ref:s})})});$E.displayName=Yb;var qE="ProgressIndicator",zE=g.forwardRef((t,s)=>{const{__scopeProgress:n,...r}=t,a=vq(qE,n);return e.jsx(BE.div,{"data-state":UE(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:s})});zE.displayName=qE;function yq(t,s){return`${Math.round(t/s*100)}%`}function UE(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function vf(t){return typeof t=="number"}function wS(t){return vf(t)&&!isNaN(t)&&t>0}function SS(t,s){return vf(t)&&!isNaN(t)&&t<=s&&t>=0}function bq(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Zb}\`.`}function jq(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 ${Zb} if no \`max\` prop is set)
|
||
- \`null\` or \`undefined\` if the progress is indeterminate.
|
||
|
||
Defaulting to \`null\`.`}var Nq=$E,wq=zE;function uc({className:t,indicatorClassName:s,value:n,...r}){return e.jsx(Nq,{"data-slot":"progress",className:jt("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...r,children:e.jsx(wq,{"data-slot":"progress-indicator",className:jt("bg-primary h-full w-full flex-1 transition-all",s),style:{transform:`translateX(-${100-(n||0)}%)`}})})}const Sq=["Rejected","Revoked","Withdrawn"];function Ad(t,s){const n=String(t||""),r=String(s||"");return Sq.some(a=>n.includes(a)||r===a)}function Qb(t,s){const n=String(t||""),r=String(s||"");return n==="Completed"||r==="Completed"||n==="Settled"||n==="Onboarded"||n==="Verified"||n==="Closed"}function Cq(t,s){return Qb(t,s)?"success":Ad(t,s)?"negative":"inProgress"}const fr={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 VE(t,s){return fr[Cq(t,s)]}function vi(t,s){return VE(t,s).bar}function Aq(t,s){return VE(t,s).barBadge}function kq(t){return t>=100?fr.success.bar:fr.inProgress.bar}function Dq(t){return t>=100?fr.success.barBadge:fr.inProgress.barBadge}function HE(t){const s=String(t||""),n=s.toUpperCase();return s.includes("Rejected")||n.includes("DOCUMENT_REJECTED")?fr.negative.badge:s==="Verified"||s==="Completed"||n.includes("DOCUMENT_VERIFIED")?fr.success.badge:s.includes("Pending")||s.includes("Review")||s==="In Progress"?fr.inProgress.badge:fr.neutral.badge}function Xb(t,s){return Qb(t,s)?fr.success.badge:(Ad(t,s),fr.negative.badge)}function Jb(t,s){return Qb(t,s)?fr.success.badgeSolid:(Ad(t,s),fr.negative.badgeSolid)}function eo(t,s){const n=String(t||""),r=String(s||"");return Ad(r,n)||/rejected|revoked/i.test(n)?fr.negative.badge:n==="Completed"||r==="Completed"||n==="Closed"?fr.success.badge:fr.negative.badge}function mp({value:t,status:s,currentStage:n,barClassName:r="h-2 w-20 bg-status-progress-soft",showPercent:a=!1,percentClassName:l="text-slate-600 shrink-0","data-testid":o}){return e.jsxs("div",{className:jt("flex items-center gap-2 min-w-0",a&&"w-full max-w-[8rem]"),"data-testid":o?`${o}-container`:void 0,children:[e.jsx(uc,{value:t,className:r,indicatorClassName:vi(s,n),"data-testid":o}),a&&e.jsxs("span",{className:l,"data-testid":o?`${o}-text`:void 0,children:[t,"%"]})]})}function fo({className:t,...s}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:jt("mx-auto flex w-full justify-center",t),...s})}function po({className:t,...s}){return e.jsx("ul",{"data-slot":"pagination-content",className:jt("flex flex-row items-center gap-1",t),...s})}function Sn({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function Wi({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:jt(nd({variant:s?"outline":"ghost",size:n}),t),...r})}function xo({className:t,...s}){return e.jsxs(Wi,{"aria-label":"Go to previous page",size:"default",className:jt("gap-1 px-2.5 sm:pl-2.5",t),...s,children:[e.jsx(lo,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function go({className:t,...s}){return e.jsxs(Wi,{"aria-label":"Go to next page",size:"default",className:jt("gap-1 px-2.5 sm:pr-2.5",t),...s,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(ji,{})]})}function vo({className:t,...s}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:jt("flex size-9 items-center justify-center",t),...s,children:[e.jsx(YI,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}function Rq({onViewDetails:t,initialFilter:s}){const{user:n}=Fn(z=>z.auth),[r,a]=g.useState(""),[l,o]=g.useState("all"),[d,m]=g.useState(s||"all"),[f,x]=g.useState([]),[h,p]=g.useState(!1),[u]=g.useState("date"),[w,v]=g.useState(!1),[N,j]=g.useState(!1),[y,C]=g.useState([]),[S,D]=g.useState({}),[R,A]=g.useState([]),[L,$]=g.useState(1),[P,E]=g.useState(null),O=10;g.useEffect(()=>{I()},[L,l,d,r]);const I=async()=>{try{const z=await ds.getApplications({page:L,limit:O,status:d!=="all"?d:void 0,location:l!=="all"?l:void 0,search:r||void 0,ddLeadShortlisted:"true",isShortlisted:"true",assignedTo:N?n==null?void 0:n.id:void 0}),T=z.data||[];E(z.meta);const F=T.map(B=>({id:B.id,registrationNumber:B.applicationId||"N/A",name:B.applicantName,email:B.email,phone:B.phone,age:B.age,education:B.education,residentialAddress:B.address||B.city||"",businessAddress:B.address||"",preferredLocation:B.preferredLocation,state:B.state,ownsBike:B.ownRoyalEnfield==="yes",pastExperience:B.experienceYears?`${B.experienceYears} years`:B.description||"",status:B.overallStatus,questionnaireMarks:0,rank:0,totalApplicantsAtLocation:0,submissionDate:B.createdAt,assignedUsers:[],assignedTo:B.assignedTo,progress:B.progressPercentage||0,isShortlisted:B.ddLeadShortlisted||B.isShortlisted||!1,companyName:B.companyName,source:B.source,existingDealer:B.existingDealer,royalEnfieldModel:B.royalEnfieldModel,description:B.description,pincode:B.pincode,locationType:B.locationType,ownRoyalEnfield:B.ownRoyalEnfield,address:B.address}));if(C(F),F.length>0?Zl.getBatchStatus(F.map(B=>({entityType:"application",entityId:B.id}))).then(B=>{if(B!=null&&B.success){const K={};F.forEach(W=>{K[W.id]=B.data[`application:${W.id}`]??null}),D(K)}}).catch(()=>D({})):D({}),R.length===0){const B=Array.from(new Set(F.map(K=>K.preferredLocation))).filter(Boolean);A(B)}}catch(z){console.error("Failed to fetch applications",z)}finally{}},q=y.sort((z,T)=>u==="date"?new Date(T.submissionDate).getTime()-new Date(z.submissionDate).getTime():0),G=z=>{x(T=>T.includes(z)?T.filter(F=>F!==z):[...T,z])},Y=()=>{f.length===q.length?x([]):x(q.map(z=>z.id))},V=async()=>{if(f.length!==0)try{p(!0);const z=await ds.sendBulkReminders(f);z.success&&(ee.success(z.message||`Reminder emails sent to ${f.length} applicant(s)`),x([]))}catch(z){console.error("Failed to send reminders:",z),ee.error(z.message||"Failed to send reminders")}finally{p(!1)}},Q=()=>{alert("Exporting applications to CSV...")},_=z=>{const T=String(z||"");return T==="Rejected"||T==="Disqualified"||T.includes("Rejected")?"bg-red-50 text-re-red-hover border border-red-200":T==="Approved"||T==="Onboarded"||T==="Completed"?"bg-slate-900 text-white border border-transparent":"bg-slate-200 text-slate-800 border border-slate-300"};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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{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(At,{value:l,onValueChange:o,children:[e.jsx(Dt,{className:"w-full lg:w-48","data-testid":"onboarding-applications-location-filter",children:e.jsx(kt,{placeholder:"All Locations"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),R.map(z=>e.jsx(Me,{value:z,children:z},z))]})]}),e.jsxs(At,{value:d,onValueChange:m,children:[e.jsx(Dt,{className:"w-full lg:w-48","data-testid":"onboarding-applications-status-filter",children:e.jsx(kt,{placeholder:"All Statuses"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Statuses"}),e.jsx(Me,{value:"Questionnaire Pending",children:"Questionnaire Pending"}),e.jsx(Me,{value:"Shortlisted",children:"Shortlisted"}),e.jsx(Me,{value:"Level 1 Pending",children:"Level 1 Pending"}),e.jsx(Me,{value:"Level 2 Pending",children:"Level 2 Pending"}),e.jsx(Me,{value:"Level 3 Pending",children:"Level 3 Pending"}),e.jsx(Me,{value:"EOR In Progress",children:"EOR In Progress"}),e.jsx(Me,{value:"Approved",children:"Approved"}),e.jsx(Me,{value:"Rejected",children:"Rejected"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:"my-assignments",checked:N,onCheckedChange:z=>j(z),"data-testid":"onboarding-applications-assignments-checkbox"}),e.jsx(de,{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(se,{variant:"outline",size:"sm",onClick:Q,"data-testid":"onboarding-applications-export-button",children:[e.jsx(Ni,{className:"w-4 h-4 mr-2"}),"Export"]}),f.length>0&&e.jsxs(se,{variant:"outline",size:"sm",onClick:V,disabled:h,"data-testid":"onboarding-applications-reminders-button",children:[h?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Dr,{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:[P?P.total:q.length," application",(P==null?void 0:P.total)!==1?"s":""]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-slate-200",children:[e.jsxs(Ps,{"data-testid":"onboarding-applications-table",children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Tn,{checked:f.length===q.length&&q.length>0,onCheckedChange:Y,"data-testid":"onboarding-applications-header-checkbox"})}),e.jsx(fe,{children:"ID"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Preferred Location"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"SLA"}),e.jsx(fe,{children:"Applicant Location"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Applied On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:q.map((z,T)=>e.jsxs(lt,{"data-testid":`onboarding-application-row-${T}`,children:[e.jsx(ue,{children:e.jsx(Tn,{checked:f.includes(z.id),onCheckedChange:()=>G(z.id),"data-testid":`onboarding-application-checkbox-${T}`})}),e.jsx(ue,{"data-testid":`onboarding-application-id-${T}`,children:z.registrationNumber}),e.jsx(ue,{"data-testid":`onboarding-application-name-${T}`,children:z.name}),e.jsx(ue,{"data-testid":`onboarding-application-pref-location-${T}`,children:z.preferredLocation}),e.jsx(ue,{children:e.jsx(Ce,{className:_(z.status),"data-testid":`onboarding-application-status-${T}`,children:z.status})}),e.jsx(ue,{children:e.jsx(kr,{status:S[z.id],compact:!0})}),e.jsx(ue,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-application-addr-${T}`,children:z.residentialAddress}),e.jsx(ue,{children:e.jsx(mp,{value:z.progress,status:z.status,showPercent:!0,"data-testid":`onboarding-application-progress-bar-${T}`})}),e.jsx(ue,{"data-testid":`onboarding-application-date-${T}`,children:Gt(z.submissionDate)}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>t(z.id),"data-testid":`onboarding-application-view-btn-${T}`,children:"View"})})]},z.id))})]}),P&&P.totalPages>1&&e.jsx("div",{className:"py-4 border-t px-4 flex justify-center",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>$(z=>Math.max(1,z-1)),className:L===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(P.totalPages)].map((z,T)=>{const F=T+1;return F===1||F===P.totalPages||F>=L-1&&F<=L+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:L===F,onClick:()=>$(F),className:"cursor-pointer",children:F})},F):F===2&&L>3||F===P.totalPages-1&&L<P.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},F):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>$(z=>Math.min(P.totalPages,z+1)),className:L===P.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ls,{open:w,onOpenChange:v,children:e.jsxs(as,{className:"max-w-2xl","data-testid":"onboarding-new-app-modal",children:[e.jsx(fs,{children:e.jsx(us,{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(de,{children:"Name"}),e.jsx(at,{placeholder:"Full Name","data-testid":"onboarding-new-app-name"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Email"}),e.jsx(at,{type:"email",placeholder:"email@example.com","data-testid":"onboarding-new-app-email"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Phone"}),e.jsx(at,{placeholder:"+91 XXXXX XXXXX","data-testid":"onboarding-new-app-phone"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Preferred Location"}),e.jsxs(At,{children:[e.jsx(Dt,{"data-testid":"onboarding-new-app-location-select",children:e.jsx(kt,{placeholder:"Select location"})}),e.jsx(Rt,{children:R.map(z=>e.jsx(Me,{value:z,children:z},z))})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(se,{variant:"outline",onClick:()=>v(!1),"data-testid":"onboarding-new-app-cancel",children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-new-app-submit",children:"Create Application"})]})]})]})})]})}function WE({application:t,onViewDetails:s}){var r;const n=a=>{const l=String(a||"");return l==="Rejected"||l==="Disqualified"||l.includes("Rejected")?"bg-red-50 text-re-red-hover border border-red-200":l==="Approved"||l==="Onboarded"||l==="Completed"?"bg-slate-900 text-white border border-transparent":"bg-slate-200 text-slate-800 border border-slate-300"};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(Ce,{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(Ce,{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(Vr,{className:"w-4 h-4"}),e.jsx("span",{"data-testid":"onboarding-application-card-location",children:t.preferredLocation}),t.rank&&t.totalApplicantsAtLocation&&e.jsxs(Ce,{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(Dr,{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(nb,{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(ik,{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(dr,{className:"w-4 h-4"}),e.jsxs("span",{"data-testid":"onboarding-application-card-submission-date",children:["Submitted: ",Gt(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(mp,{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: ",Gt(t.deadline)]})}),e.jsx(se,{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 Eq({onViewDetails:t,initialFilter:s="all"}){const[n,r]=g.useState("grid"),[a,l]=g.useState(""),[o,d]=g.useState(s),[m,f]=g.useState("all"),[x,h]=g.useState("all"),[p,u]=g.useState([]),[w,v]=g.useState(!1),[N,j]=g.useState(""),[y,C]=g.useState([]),[S,D]=g.useState(!0),[R,A]=g.useState([]),[L,$]=g.useState([]),[P,E]=g.useState(1),[O,I]=g.useState(null);g.useEffect(()=>{G()},[P,a,o,m,x]),g.useEffect(()=>{E(1)},[a,o,m,x]),g.useEffect(()=>{q()},[]);const q=async()=>{try{const B=await Fs.getStates(),W=(Array.isArray(B)?B:(B==null?void 0:B.data)||(B==null?void 0:B.states)||[]).map(H=>typeof H=="string"?H:H.name||H.stateName).filter(Boolean);A(W)}catch(B){console.error("Failed to fetch states:",B)}},G=async()=>{try{D(!0);const B=await ds.getApplications({page:P,limit:10,search:a,status:o==="all"?void 0:o,location:m!=="all"?m:void 0,state:x!=="all"?x:void 0,isShortlisted:void 0}),K=B.data||[];I(B.meta);const W=K.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||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}));C(W);const H=Array.from(new Set(W.map(X=>X.preferredLocation))).filter(Boolean);$(H)}catch(B){console.error("Failed to fetch applications:",B),ee.error("Failed to load applications")}finally{D(!1)}},Y=y,V=B=>{u(B?Y.map(K=>K.id):[])},Q=(B,K)=>{u(K?[...p,B]:p.filter(W=>W!==B))},_=()=>{if(p.length===0){ee.error("Please select at least one application to shortlist");return}v(!0)},z=async()=>{try{ee.success(`${p.length} application(s) shortlisted successfully!`),v(!1),G()}catch{ee.error("Failed to shortlist")}},T=["Submitted","Questionnaire Pending","Questionnaire Completed"],F=B=>({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"})[B]||"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(an,{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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search by name or registration number...",value:a,onChange:B=>l(B.target.value),className:"pl-10","data-testid":"onboarding-all-apps-search-input"})]}),e.jsxs(At,{value:o,onValueChange:d,children:[e.jsx(Dt,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-status-filter",children:e.jsx(kt,{placeholder:"Filter by status"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Statuses"}),T.map(B=>e.jsx(Me,{value:B,children:B},B))]})]}),e.jsxs(At,{value:x,onValueChange:h,children:[e.jsx(Dt,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-state-filter",children:e.jsx(kt,{placeholder:"Filter by state"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All States"}),R.map(B=>e.jsx(Me,{value:B,children:B},B))]})]}),e.jsxs(At,{value:m,onValueChange:f,children:[e.jsx(Dt,{className:"w-full md:w-48","data-testid":"onboarding-all-apps-location-filter",children:e.jsx(kt,{placeholder:"Filter by location"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),L.map(B=>e.jsx(Me,{value:B,children:B},B))]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{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(dk,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(se,{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(mk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(se,{variant:"outline",size:"sm","data-testid":"onboarding-all-apps-export-btn",children:[e.jsx(Ni,{className:"w-4 h-4 mr-2"}),"Export"]}),p.length>0&&e.jsx(e.Fragment,{children:e.jsxs(se,{size:"sm",onClick:_,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-all-apps-shortlist-btn",children:[e.jsx(fn,{className:"w-4 h-4 mr-2"}),"Shortlist (",p.length,")"]})}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Ce,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-all-apps-pending-badge",children:[(O==null?void 0:O.total)||Y.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(es,{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:Y.map((B,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:p.includes(B.id),onCheckedChange:W=>Q(B.id,W),className:"bg-white","data-testid":`onboarding-all-apps-grid-checkbox-${K}`})}),B.isShortlisted&&e.jsx("div",{className:"absolute top-4 right-4 z-10",children:e.jsx(Ce,{className:"bg-green-600","data-testid":`onboarding-all-apps-grid-shortlisted-badge-${K}`,children:"Shortlisted"})}),e.jsx(WE,{application:B,onViewDetails:t})]},B.id))}):e.jsx("div",{className:"bg-white rounded-lg border border-slate-200",children:e.jsxs(Ps,{"data-testid":"onboarding-all-apps-table",children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Tn,{checked:p.length===Y.length&&Y.length>0,onCheckedChange:V,"data-testid":"onboarding-all-apps-header-checkbox"})}),e.jsx(fe,{children:"Registration"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Location"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Shortlisted"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Submitted"})]})}),e.jsx(Ls,{children:Y.map((B,K)=>e.jsxs(lt,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(B.id),"data-testid":`onboarding-all-apps-row-${K}`,children:[e.jsx(ue,{onClick:W=>W.stopPropagation(),children:e.jsx(Tn,{checked:p.includes(B.id),onCheckedChange:W=>Q(B.id,W),"data-testid":`onboarding-all-apps-checkbox-${K}`})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-reg-id-${K}`,children:B.registrationNumber})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-all-apps-name-${K}`,children:B.name})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-location-${K}`,children:B.preferredLocation})}),e.jsx(ue,{children:e.jsx(Ce,{className:F(B.status),"data-testid":`onboarding-all-apps-status-${K}`,children:B.status})}),e.jsx(ue,{children:B.isShortlisted?e.jsx(Ce,{className:"bg-green-600","data-testid":`onboarding-all-apps-shortlisted-yes-${K}`,children:"Yes"}):e.jsx(Ce,{variant:"outline","data-testid":`onboarding-all-apps-shortlisted-no-${K}`,children:"No"})}),e.jsx(ue,{children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(mp,{value:B.progress,status:B.status,showPercent:!0,"data-testid":`onboarding-all-apps-progress-bar-${K}`})})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-all-apps-date-${K}`,children:Gt(B.submissionDate)})})]},B.id))})]})}),O&&O.totalPages>1&&e.jsx("div",{className:"py-6 border-t border-slate-200 bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>E(B=>Math.max(1,B-1)),className:P===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(O.totalPages)].map((B,K)=>{const W=K+1;return W===1||W===O.totalPages||W>=P-1&&W<=P+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:P===W,onClick:()=>E(W),className:"cursor-pointer",children:W})},W):W===P-2||W===P+2?e.jsx(Sn,{children:e.jsx(vo,{})},W):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>E(B=>Math.min(O.totalPages,B+1)),className:P===O.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),e.jsx(ls,{open:w,onOpenChange:v,children:e.jsxs(as,{"data-testid":"onboarding-all-apps-shortlist-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{"data-testid":"onboarding-all-apps-shortlist-title",children:"Shortlist Applications"}),e.jsxs(bs,{"data-testid":"onboarding-all-apps-shortlist-desc",children:["You are about to shortlist ",p.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(de,{htmlFor:"shortlist-remark",children:"Shortlisting Remark (Optional)"}),e.jsx(Gs,{id:"shortlist-remark",placeholder:"Enter reason for shortlisting these applications...",value:N,onChange:B=>j(B.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-all-apps-shortlist-remark"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>v(!1),"data-testid":"onboarding-all-apps-shortlist-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:z,"data-testid":"onboarding-all-apps-shortlist-confirm",children:"Confirm Shortlist"})]})]})]})})]})}function _q(t){const s=Tq(t),n=g.forwardRef((r,a)=>{const{children:l,...o}=r,d=g.Children.toArray(l),m=d.find(Oq);if(m){const f=m.props.children,x=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,x):null})}return e.jsx(s,{...o,ref:a,children:l})});return n.displayName=`${t}.Slot`,n}function Tq(t){const s=g.forwardRef((n,r)=>{const{children:a,...l}=n;if(g.isValidElement(a)){const o=Iq(a),d=Lq(l,a.props);return a.type!==g.Fragment&&(d.ref=r?Xr(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 Pq=Symbol("radix.slottable");function Oq(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Pq}function Lq(t,s){const n={...s};for(const r in s){const a=t[r],l=s[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const m=l(...d);return a(...d),m}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...t,...n}}function Iq(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 fp="Popover",[GE]=ga(fp,[oo]),nh=oo(),[Mq,yo]=GE(fp),KE=t=>{const{__scopePopover:s,children:n,open:r,defaultOpen:a,onOpenChange:l,modal:o=!1}=t,d=nh(s),m=g.useRef(null),[f,x]=g.useState(!1),[h,p]=$i({prop:r,defaultProp:a??!1,onChange:l,caller:fp});return e.jsx(Hf,{...d,children:e.jsx(Mq,{scope:s,contentId:Ar(),triggerRef:m,open:h,onOpenChange:p,onOpenToggle:g.useCallback(()=>p(u=>!u),[p]),hasCustomAnchor:f,onCustomAnchorAdd:g.useCallback(()=>x(!0),[]),onCustomAnchorRemove:g.useCallback(()=>x(!1),[]),modal:o,children:n})})};KE.displayName=fp;var YE="PopoverAnchor",Fq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=yo(YE,n),l=nh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:d}=a;return g.useEffect(()=>(o(),()=>d()),[o,d]),e.jsx(Xu,{...l,...r,ref:s})});Fq.displayName=YE;var ZE="PopoverTrigger",QE=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=yo(ZE,n),l=nh(n),o=Ks(s,a.triggerRef),d=e.jsx(ws.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":s_(a.open),...r,ref:o,onClick:Wt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?d:e.jsx(Xu,{asChild:!0,...l,children:d})});QE.displayName=ZE;var ej="PopoverPortal",[Bq,$q]=GE(ej,{forceMount:void 0}),XE=t=>{const{__scopePopover:s,forceMount:n,children:r,container:a}=t,l=yo(ej,s);return e.jsx(Bq,{scope:s,forceMount:n,children:e.jsx(Rr,{present:n||l.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};XE.displayName=ej;var hd="PopoverContent",JE=g.forwardRef((t,s)=>{const n=$q(hd,t.__scopePopover),{forceMount:r=n.forceMount,...a}=t,l=yo(hd,t.__scopePopover);return e.jsx(Rr,{present:r||l.open,children:l.modal?e.jsx(zq,{...a,ref:s}):e.jsx(Uq,{...a,ref:s})})});JE.displayName=hd;var qq=_q("PopoverContent.RemoveScroll"),zq=g.forwardRef((t,s)=>{const n=yo(hd,t.__scopePopover),r=g.useRef(null),a=Ks(s,r),l=g.useRef(!1);return g.useEffect(()=>{const o=r.current;if(o)return Yf(o)},[]),e.jsx(eh,{as:qq,allowPinchZoom:!0,children:e.jsx(e_,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Wt(t.onCloseAutoFocus,o=>{var d;o.preventDefault(),l.current||(d=n.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Wt(t.onPointerDownOutside,o=>{const d=o.detail.originalEvent,m=d.button===0&&d.ctrlKey===!0,f=d.button===2||m;l.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Wt(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Uq=g.forwardRef((t,s)=>{const n=yo(hd,t.__scopePopover),r=g.useRef(!1),a=g.useRef(!1);return e.jsx(e_,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var o,d;(o=t.onCloseAutoFocus)==null||o.call(t,l),l.defaultPrevented||(r.current||(d=n.triggerRef.current)==null||d.focus(),l.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:l=>{var m,f;(m=t.onInteractOutside)==null||m.call(t,l),l.defaultPrevented||(r.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=l.target;((f=n.triggerRef.current)==null?void 0:f.contains(o))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})}),e_=g.forwardRef((t,s)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:o,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onInteractOutside:x,...h}=t,p=yo(hd,n),u=nh(n);return $f(),e.jsx(Zu,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:x,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:f,onDismiss:()=>p.onOpenChange(!1),children:e.jsx(Wf,{"data-state":s_(p.open),role:"dialog",id:p.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)"}})})})}),t_="PopoverClose",Vq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=yo(t_,n);return e.jsx(ws.button,{type:"button",...r,ref:s,onClick:Wt(t.onClick,()=>a.onOpenChange(!1))})});Vq.displayName=t_;var Hq="PopoverArrow",Wq=g.forwardRef((t,s)=>{const{__scopePopover:n,...r}=t,a=nh(n);return e.jsx(Gf,{...a,...r,ref:s})});Wq.displayName=Hq;function s_(t){return t?"open":"closed"}var Gq=KE,Kq=QE,Yq=XE,Zq=JE;function Tu({...t}){return e.jsx(Gq,{"data-slot":"popover",...t})}function Pu({...t}){return e.jsx(Kq,{"data-slot":"popover-trigger",...t})}function Ou({className:t,align:s="center",sideOffset:n=4,...r}){return e.jsx(Yq,{children:e.jsx(Zq,{"data-slot":"popover-content",align:s,sideOffset:n,className:jt("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 l in n)Object.prototype.hasOwnProperty.call(n,l)&&(s[l]=n[l])}return s},qs.apply(this,arguments)};function Qq(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 n_(t,s,n){for(var r=0,a=s.length,l;r<a;r++)(l||!(r in s))&&(l||(l=Array.prototype.slice.call(s,0,r)),l[r]=s[r]);return t.concat(l||Array.prototype.slice.call(s))}function rh(t){return t.mode==="multiple"}function ah(t){return t.mode==="range"}function pp(t){return t.mode==="single"}var Xq={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 Jq(t,s){return Ka(t,"LLLL y",s)}function ez(t,s){return Ka(t,"d",s)}function tz(t,s){return Ka(t,"LLLL",s)}function sz(t){return"".concat(t)}function nz(t,s){return Ka(t,"cccccc",s)}function rz(t,s){return Ka(t,"yyyy",s)}var az=Object.freeze({__proto__:null,formatCaption:Jq,formatDay:ez,formatMonthCaption:tz,formatWeekNumber:sz,formatWeekdayName:nz,formatYearCaption:rz}),iz=function(t,s,n){return Ka(t,"do MMMM (EEEE)",n)},lz=function(){return"Month: "},oz=function(){return"Go to next month"},cz=function(){return"Go to previous month"},dz=function(t,s){return Ka(t,"cccc",s)},uz=function(t){return"Week n. ".concat(t)},hz=function(){return"Year: "},mz=Object.freeze({__proto__:null,labelDay:iz,labelMonthDropdown:lz,labelNext:oz,labelPrevious:cz,labelWeekNumber:uz,labelWeekday:dz,labelYearDropdown:hz});function fz(){var t="buttons",s=Xq,n=Pb,r={},a={},l=1,o={},d=new Date;return{captionLayout:t,classNames:s,formatters:az,labels:mz,locale:n,modifiersClassNames:r,modifiers:a,numberOfMonths:l,styles:o,today:d,mode:"default"}}function pz(t){var s=t.fromYear,n=t.toYear,r=t.fromMonth,a=t.toMonth,l=t.fromDate,o=t.toDate;return r?l=pa(r):s&&(l=new Date(s,0,1)),a?o=sp(a):n&&(o=new Date(n,11,31)),{fromDate:l?od(l):void 0,toDate:o?od(o):void 0}}var r_=g.createContext(void 0);function xz(t){var s,n=t.initialProps,r=fz(),a=pz(n),l=a.fromDate,o=a.toDate,d=(s=n.captionLayout)!==null&&s!==void 0?s:r.captionLayout;d!=="buttons"&&(!l||!o)&&(d="buttons");var m;(pp(n)||rh(n)||ah(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:l,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(r_.Provider,{value:f,children:t.children})}function Pn(){var t=g.useContext(r_);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function a_(t){var s=Pn(),n=s.locale,r=s.classNames,a=s.styles,l=s.formatters.formatCaption;return e.jsx("div",{className:r.caption_label,style:a.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:l(t.displayMonth,{locale:n})})}function gz(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 i_(t){var s,n,r=t.onChange,a=t.value,l=t.children,o=t.caption,d=t.className,m=t.style,f=Pn(),x=(n=(s=f.components)===null||s===void 0?void 0:s.IconDropdown)!==null&&n!==void 0?n:gz;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:l}),e.jsxs("div",{className:f.classNames.caption_label,style:f.styles.caption_label,"aria-hidden":"true",children:[o,e.jsx(x,{className:f.classNames.dropdown_icon,style:f.styles.dropdown_icon})]})]})}function vz(t){var s,n=Pn(),r=n.fromDate,a=n.toDate,l=n.styles,o=n.locale,d=n.formatters.formatMonthCaption,m=n.classNames,f=n.components,x=n.labels.labelMonthDropdown;if(!r)return e.jsx(e.Fragment,{});if(!a)return e.jsx(e.Fragment,{});var h=[];if(l$(r,a))for(var p=pa(r),u=r.getMonth();u<=a.getMonth();u++)h.push(Mg(p,u));else for(var p=pa(new Date),u=0;u<=11;u++)h.push(Mg(p,u));var w=function(N){var j=Number(N.target.value),y=Mg(pa(t.displayMonth),j);t.onChange(y)},v=(s=f==null?void 0:f.Dropdown)!==null&&s!==void 0?s:i_;return e.jsx(v,{name:"months","aria-label":x(),className:m.dropdown_month,style:l.dropdown_month,onChange:w,value:t.displayMonth.getMonth(),caption:d(t.displayMonth,{locale:o}),children:h.map(function(N){return e.jsx("option",{value:N.getMonth(),children:d(N,{locale:o})},N.getMonth())})})}function yz(t){var s,n=t.displayMonth,r=Pn(),a=r.fromDate,l=r.toDate,o=r.locale,d=r.styles,m=r.classNames,f=r.components,x=r.formatters.formatYearCaption,h=r.labels.labelYearDropdown,p=[];if(!a)return e.jsx(e.Fragment,{});if(!l)return e.jsx(e.Fragment,{});for(var u=a.getFullYear(),w=l.getFullYear(),v=u;v<=w;v++)p.push(pS(tR(new Date),v));var N=function(y){var C=pS(pa(n),Number(y.target.value));t.onChange(C)},j=(s=f==null?void 0:f.Dropdown)!==null&&s!==void 0?s:i_;return e.jsx(j,{name:"years","aria-label":h(),className:m.dropdown_year,style:d.dropdown_year,onChange:N,value:n.getFullYear(),caption:x(n,{locale:o}),children:p.map(function(y){return e.jsx("option",{value:y.getFullYear(),children:x(y,{locale:o})},y.getFullYear())})})}function bz(t,s){var n=g.useState(t),r=n[0],a=n[1],l=s===void 0?r:s;return[l,a]}function jz(t){var s=t.month,n=t.defaultMonth,r=t.today,a=s||n||r||new Date,l=t.toDate,o=t.fromDate,d=t.numberOfMonths,m=d===void 0?1:d;if(l&&dd(l,a)<0){var f=-1*(m-1);a=gi(l,f)}return o&&dd(a,o)<0&&(a=o),pa(a)}function Nz(){var t=Pn(),s=jz(t),n=bz(s,t.month),r=n[0],a=n[1],l=function(o){var d;if(!t.disableNavigation){var m=pa(o);a(m),(d=t.onMonthChange)===null||d===void 0||d.call(t,m)}};return[r,l]}function wz(t,s){for(var n=s.reverseMonths,r=s.numberOfMonths,a=pa(t),l=pa(gi(a,r)),o=dd(l,a),d=[],m=0;m<o;m++){var f=gi(a,m);d.push(f)}return n&&(d=d.reverse()),d}function Sz(t,s){if(!s.disableNavigation){var n=s.toDate,r=s.pagedNavigation,a=s.numberOfMonths,l=a===void 0?1:a,o=r?l:1,d=pa(t);if(!n)return gi(d,o);var m=dd(n,t);if(!(m<l))return gi(d,o)}}function Cz(t,s){if(!s.disableNavigation){var n=s.fromDate,r=s.pagedNavigation,a=s.numberOfMonths,l=a===void 0?1:a,o=r?l:1,d=pa(t);if(!n)return gi(d,-o);var m=dd(d,n);if(!(m<=0))return gi(d,-o)}}var l_=g.createContext(void 0);function Az(t){var s=Pn(),n=Nz(),r=n[0],a=n[1],l=wz(r,s),o=Sz(r,s),d=Cz(r,s),m=function(h){return l.some(function(p){return Ob(h,p)})},f=function(h,p){m(h)||(p&&oR(h,p)?a(gi(h,1+s.numberOfMonths*-1)):a(h))},x={currentMonth:r,displayMonths:l,goToMonth:a,goToDate:f,previousMonth:d,nextMonth:o,isDateDisplayed:m};return e.jsx(l_.Provider,{value:x,children:t.children})}function ih(){var t=g.useContext(l_);if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function CS(t){var s,n=Pn(),r=n.classNames,a=n.styles,l=n.components,o=ih().goToMonth,d=function(x){o(gi(x,t.displayIndex?-t.displayIndex:0))},m=(s=l==null?void 0:l.CaptionLabel)!==null&&s!==void 0?s:a_,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(vz,{onChange:d,displayMonth:t.displayMonth}),e.jsx(yz,{onChange:d,displayMonth:t.displayMonth})]})}function kz(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 Dz(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 yf=g.forwardRef(function(t,s){var n=Pn(),r=n.classNames,a=n.styles,l=[r.button_reset,r.button];t.className&&l.push(t.className);var o=l.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 Rz(t){var s,n,r=Pn(),a=r.dir,l=r.locale,o=r.classNames,d=r.styles,m=r.labels,f=m.labelPrevious,x=m.labelNext,h=r.components;if(!t.nextMonth&&!t.previousMonth)return e.jsx(e.Fragment,{});var p=f(t.previousMonth,{locale:l}),u=[o.nav_button,o.nav_button_previous].join(" "),w=x(t.nextMonth,{locale:l}),v=[o.nav_button,o.nav_button_next].join(" "),N=(s=h==null?void 0:h.IconRight)!==null&&s!==void 0?s:Dz,j=(n=h==null?void 0:h.IconLeft)!==null&&n!==void 0?n:kz;return e.jsxs("div",{className:o.nav,style:d.nav,children:[!t.hidePrevious&&e.jsx(yf,{name:"previous-month","aria-label":p,className:u,style:d.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:a==="rtl"?e.jsx(N,{className:o.nav_icon,style:d.nav_icon}):e.jsx(j,{className:o.nav_icon,style:d.nav_icon})}),!t.hideNext&&e.jsx(yf,{name:"next-month","aria-label":w,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(N,{className:o.nav_icon,style:d.nav_icon})})]})}function AS(t){var s=Pn().numberOfMonths,n=ih(),r=n.previousMonth,a=n.nextMonth,l=n.goToMonth,o=n.displayMonths,d=o.findIndex(function(w){return Ob(t.displayMonth,w)}),m=d===0,f=d===o.length-1,x=s>1&&(m||!f),h=s>1&&(f||!m),p=function(){r&&l(r)},u=function(){a&&l(a)};return e.jsx(Rz,{displayMonth:t.displayMonth,hideNext:x,hidePrevious:h,nextMonth:a,previousMonth:r,onPreviousClick:p,onNextClick:u})}function Ez(t){var s,n=Pn(),r=n.classNames,a=n.disableNavigation,l=n.styles,o=n.captionLayout,d=n.components,m=(s=d==null?void 0:d.CaptionLabel)!==null&&s!==void 0?s:a_,f;return a?f=e.jsx(m,{id:t.id,displayMonth:t.displayMonth}):o==="dropdown"?f=e.jsx(CS,{displayMonth:t.displayMonth,id:t.id}):o==="dropdown-buttons"?f=e.jsxs(e.Fragment,{children:[e.jsx(CS,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(AS,{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(AS,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:r.caption,style:l.caption,children:f})}function _z(t){var s=Pn(),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 Tz(t,s,n){for(var r=n?lc(new Date):zi(new Date,{locale:t,weekStartsOn:s}),a=[],l=0;l<7;l++){var o=Zr(r,l);a.push(o)}return a}function Pz(){var t=Pn(),s=t.classNames,n=t.styles,r=t.showWeekNumber,a=t.locale,l=t.weekStartsOn,o=t.ISOWeek,d=t.formatters.formatWeekdayName,m=t.labels.labelWeekday,f=Tz(a,l,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(x,h){return e.jsx("th",{scope:"col",className:s.head_cell,style:n.head_cell,"aria-label":m(x,{locale:a}),children:d(x,{locale:a})},h)})]})}function Oz(){var t,s=Pn(),n=s.classNames,r=s.styles,a=s.components,l=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:Pz;return e.jsx("thead",{style:r.head,className:n.head,children:e.jsx(l,{})})}function Lz(t){var s=Pn(),n=s.locale,r=s.formatters.formatDay;return e.jsx(e.Fragment,{children:r(t.date,{locale:n})})}var tj=g.createContext(void 0);function Iz(t){if(!rh(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(tj.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=s.min,l=s.max,o=function(f,x,h){var p,u;(p=s.onDayClick)===null||p===void 0||p.call(s,f,x,h);var w=!!(x.selected&&a&&(r==null?void 0:r.length)===a);if(!w){var v=!!(!x.selected&&l&&(r==null?void 0:r.length)===l);if(!v){var N=r?n_([],r):[];if(x.selected){var j=N.findIndex(function(y){return ha(f,y)});N.splice(j,1)}else N.push(f);(u=s.onSelect)===null||u===void 0||u.call(s,N,f,x,h)}}},d={disabled:[]};r&&d.disabled.push(function(f){var x=l&&r.length>l-1,h=r.some(function(p){return ha(p,f)});return!!(x&&!h)});var m={selected:r,onDayClick:o,modifiers:d};return e.jsx(tj.Provider,{value:m,children:n})}function sj(){var t=g.useContext(tj);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Fz(t,s){var n=s||{},r=n.from,a=n.to;return r&&a?ha(a,t)&&ha(r,t)?void 0:ha(a,t)?{from:a,to:void 0}:ha(r,t)?void 0:wy(r,t)?{from:t,to:a}:{from:r,to:t}:a?wy(t,a)?{from:a,to:t}:{from:t,to:a}:r?oR(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var nj=g.createContext(void 0);function Bz(t){if(!ah(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(nj.Provider,{value:s,children:t.children})}return e.jsx($z,{initialProps:t.initialProps,children:t.children})}function $z(t){var s=t.initialProps,n=t.children,r=s.selected,a=r||{},l=a.from,o=a.to,d=s.min,m=s.max,f=function(u,w,v){var N,j;(N=s.onDayClick)===null||N===void 0||N.call(s,u,w,v);var y=Fz(u,r);(j=s.onSelect)===null||j===void 0||j.call(s,y,u,w,v)},x={range_start:[],range_end:[],range_middle:[],disabled:[]};if(l?(x.range_start=[l],o?(x.range_end=[o],ha(l,o)||(x.range_middle=[{after:l,before:o}])):x.range_end=[l]):o&&(x.range_start=[o],x.range_end=[o]),d&&(l&&!o&&x.disabled.push({after:Ig(l,d-1),before:Zr(l,d-1)}),l&&o&&x.disabled.push({after:l,before:Zr(l,d-1)}),!l&&o&&x.disabled.push({after:Ig(o,d-1),before:Zr(o,d-1)})),m){if(l&&!o&&(x.disabled.push({before:Zr(l,-m+1)}),x.disabled.push({after:Zr(l,m-1)})),l&&o){var h=Mi(o,l)+1,p=m-h;x.disabled.push({before:Ig(l,p)}),x.disabled.push({after:Zr(o,p)})}!l&&o&&(x.disabled.push({before:Zr(o,-m+1)}),x.disabled.push({after:Zr(o,m-1)}))}return e.jsx(nj.Provider,{value:{selected:r,onDayClick:f,modifiers:x},children:n})}function rj(){var t=g.useContext(nj);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Wm(t){return Array.isArray(t)?n_([],t):t!==void 0?[t]:[]}function qz(t){var s={};return Object.entries(t).forEach(function(n){var r=n[0],a=n[1];s[r]=Wm(a)}),s}var yi;(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"})(yi||(yi={}));var zz=yi.Selected,ol=yi.Disabled,Uz=yi.Hidden,Vz=yi.Today,qg=yi.RangeEnd,zg=yi.RangeMiddle,Ug=yi.RangeStart,Hz=yi.Outside;function Wz(t,s,n){var r,a=(r={},r[zz]=Wm(t.selected),r[ol]=Wm(t.disabled),r[Uz]=Wm(t.hidden),r[Vz]=[t.today],r[qg]=[],r[zg]=[],r[Ug]=[],r[Hz]=[],r);return t.fromDate&&a[ol].push({before:t.fromDate}),t.toDate&&a[ol].push({after:t.toDate}),rh(t)?a[ol]=a[ol].concat(s.modifiers[ol]):ah(t)&&(a[ol]=a[ol].concat(n.modifiers[ol]),a[Ug]=n.modifiers[Ug],a[zg]=n.modifiers[zg],a[qg]=n.modifiers[qg]),a}var o_=g.createContext(void 0);function Gz(t){var s=Pn(),n=sj(),r=rj(),a=Wz(s,n,r),l=qz(s.modifiers),o=qs(qs({},a),l);return e.jsx(o_.Provider,{value:o,children:t.children})}function c_(){var t=g.useContext(o_);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Kz(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function Yz(t){return!!(t&&typeof t=="object"&&"from"in t)}function Zz(t){return!!(t&&typeof t=="object"&&"after"in t)}function Qz(t){return!!(t&&typeof t=="object"&&"before"in t)}function Xz(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function Jz(t,s){var n,r=s.from,a=s.to;if(r&&a){var l=Mi(a,r)<0;l&&(n=[a,r],r=n[0],a=n[1]);var o=Mi(t,r)>=0&&Mi(a,t)>=0;return o}return a?ha(a,t):r?ha(r,t):!1}function eU(t){return _b(t)}function tU(t){return Array.isArray(t)&&t.every(_b)}function sU(t,s){return s.some(function(n){if(typeof n=="boolean")return n;if(eU(n))return ha(t,n);if(tU(n))return n.includes(t);if(Yz(n))return Jz(t,n);if(Xz(n))return n.dayOfWeek.includes(t.getDay());if(Kz(n)){var r=Mi(n.before,t),a=Mi(n.after,t),l=r>0,o=a<0,d=wy(n.before,n.after);return d?o&&l:l||o}return Zz(n)?Mi(t,n.after)>0:Qz(n)?Mi(n.before,t)>0:typeof n=="function"?n(t):!1})}function aj(t,s,n){var r=Object.keys(s).reduce(function(l,o){var d=s[o];return sU(t,d)&&l.push(o),l},[]),a={};return r.forEach(function(l){return a[l]=!0}),n&&!Ob(t,n)&&(a.outside=!0),a}function nU(t,s){for(var n=pa(t[0]),r=sp(t[t.length-1]),a,l,o=n;o<=r;){var d=aj(o,s),m=!d.disabled&&!d.hidden;if(!m){o=Zr(o,1);continue}if(d.selected)return o;d.today&&!l&&(l=o),a||(a=o),o=Zr(o,1)}return l||a}var rU=365;function d_(t,s){var n=s.moveBy,r=s.direction,a=s.context,l=s.modifiers,o=s.retry,d=o===void 0?{count:0,lastFocused:t}:o,m=a.weekStartsOn,f=a.fromDate,x=a.toDate,h=a.locale,p={day:Zr,week:Ny,month:gi,year:Y9,startOfWeek:function(N){return a.ISOWeek?lc(N):zi(N,{locale:h,weekStartsOn:m})},endOfWeek:function(N){return a.ISOWeek?sR(N):Tb(N,{locale:h,weekStartsOn:m})}},u=p[n](t,r==="after"?1:-1);r==="before"&&f?u=Z9([f,u]):r==="after"&&x&&(u=Q9([x,u]));var w=!0;if(l){var v=aj(u,l);w=!v.disabled&&!v.hidden}return w?u:d.count>rU?d.lastFocused:d_(u,{moveBy:n,direction:r,context:a,modifiers:l,retry:qs(qs({},d),{count:d.count+1})})}var u_=g.createContext(void 0);function aU(t){var s=ih(),n=c_(),r=g.useState(),a=r[0],l=r[1],o=g.useState(),d=o[0],m=o[1],f=nU(s.displayMonths,n),x=a??(d&&s.isDateDisplayed(d))?d:f,h=function(){m(a),l(void 0)},p=function(N){l(N)},u=Pn(),w=function(N,j){if(a){var y=d_(a,{moveBy:N,direction:j,context:u,modifiers:n});ha(a,y)||(s.goToDate(y,a),p(y))}},v={focusedDay:a,focusTarget:x,blur:h,focus:p,focusDayAfter:function(){return w("day","after")},focusDayBefore:function(){return w("day","before")},focusWeekAfter:function(){return w("week","after")},focusWeekBefore:function(){return w("week","before")},focusMonthBefore:function(){return w("month","before")},focusMonthAfter:function(){return w("month","after")},focusYearBefore:function(){return w("year","before")},focusYearAfter:function(){return w("year","after")},focusStartOfWeek:function(){return w("startOfWeek","before")},focusEndOfWeek:function(){return w("endOfWeek","after")}};return e.jsx(u_.Provider,{value:v,children:t.children})}function ij(){var t=g.useContext(u_);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function iU(t,s){var n=c_(),r=aj(t,n,s);return r}var lj=g.createContext(void 0);function lU(t){if(!pp(t.initialProps)){var s={selected:void 0};return e.jsx(lj.Provider,{value:s,children:t.children})}return e.jsx(oU,{initialProps:t.initialProps,children:t.children})}function oU(t){var s=t.initialProps,n=t.children,r=function(l,o,d){var m,f,x;if((m=s.onDayClick)===null||m===void 0||m.call(s,l,o,d),o.selected&&!s.required){(f=s.onSelect)===null||f===void 0||f.call(s,void 0,l,o,d);return}(x=s.onSelect)===null||x===void 0||x.call(s,l,l,o,d)},a={selected:s.selected,onDayClick:r};return e.jsx(lj.Provider,{value:a,children:n})}function h_(){var t=g.useContext(lj);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function cU(t,s){var n=Pn(),r=h_(),a=sj(),l=rj(),o=ij(),d=o.focusDayAfter,m=o.focusDayBefore,f=o.focusWeekAfter,x=o.focusWeekBefore,h=o.blur,p=o.focus,u=o.focusMonthBefore,w=o.focusMonthAfter,v=o.focusYearBefore,N=o.focusYearAfter,j=o.focusStartOfWeek,y=o.focusEndOfWeek,C=function(V){var Q,_,z,T;pp(n)?(Q=r.onDayClick)===null||Q===void 0||Q.call(r,t,s,V):rh(n)?(_=a.onDayClick)===null||_===void 0||_.call(a,t,s,V):ah(n)?(z=l.onDayClick)===null||z===void 0||z.call(l,t,s,V):(T=n.onDayClick)===null||T===void 0||T.call(n,t,s,V)},S=function(V){var Q;p(t),(Q=n.onDayFocus)===null||Q===void 0||Q.call(n,t,s,V)},D=function(V){var Q;h(),(Q=n.onDayBlur)===null||Q===void 0||Q.call(n,t,s,V)},R=function(V){var Q;(Q=n.onDayMouseEnter)===null||Q===void 0||Q.call(n,t,s,V)},A=function(V){var Q;(Q=n.onDayMouseLeave)===null||Q===void 0||Q.call(n,t,s,V)},L=function(V){var Q;(Q=n.onDayPointerEnter)===null||Q===void 0||Q.call(n,t,s,V)},$=function(V){var Q;(Q=n.onDayPointerLeave)===null||Q===void 0||Q.call(n,t,s,V)},P=function(V){var Q;(Q=n.onDayTouchCancel)===null||Q===void 0||Q.call(n,t,s,V)},E=function(V){var Q;(Q=n.onDayTouchEnd)===null||Q===void 0||Q.call(n,t,s,V)},O=function(V){var Q;(Q=n.onDayTouchMove)===null||Q===void 0||Q.call(n,t,s,V)},I=function(V){var Q;(Q=n.onDayTouchStart)===null||Q===void 0||Q.call(n,t,s,V)},q=function(V){var Q;(Q=n.onDayKeyUp)===null||Q===void 0||Q.call(n,t,s,V)},G=function(V){var Q;switch(V.key){case"ArrowLeft":V.preventDefault(),V.stopPropagation(),n.dir==="rtl"?d():m();break;case"ArrowRight":V.preventDefault(),V.stopPropagation(),n.dir==="rtl"?m():d();break;case"ArrowDown":V.preventDefault(),V.stopPropagation(),f();break;case"ArrowUp":V.preventDefault(),V.stopPropagation(),x();break;case"PageUp":V.preventDefault(),V.stopPropagation(),V.shiftKey?v():u();break;case"PageDown":V.preventDefault(),V.stopPropagation(),V.shiftKey?N():w();break;case"Home":V.preventDefault(),V.stopPropagation(),j();break;case"End":V.preventDefault(),V.stopPropagation(),y();break}(Q=n.onDayKeyDown)===null||Q===void 0||Q.call(n,t,s,V)},Y={onClick:C,onFocus:S,onBlur:D,onKeyDown:G,onKeyUp:q,onMouseEnter:R,onMouseLeave:A,onPointerEnter:L,onPointerLeave:$,onTouchCancel:P,onTouchEnd:E,onTouchMove:O,onTouchStart:I};return Y}function dU(){var t=Pn(),s=h_(),n=sj(),r=rj(),a=pp(t)?s.selected:rh(t)?n.selected:ah(t)?r.selected:void 0;return a}function uU(t){return Object.values(yi).includes(t)}function hU(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(uU(r)){var l=t.classNames["day_".concat(r)];l&&n.push(l)}}),n}function mU(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 fU(t,s,n){var r,a,l,o=Pn(),d=ij(),m=iU(t,s),f=cU(t,m),x=dU(),h=!!(o.onDayClick||o.mode!=="default");g.useEffect(function(){var R;m.outside||d.focusedDay&&h&&ha(d.focusedDay,t)&&((R=n.current)===null||R===void 0||R.focus())},[d.focusedDay,t,n,h,m.outside]);var p=hU(o,m).join(" "),u=mU(o,m),w=!!(m.outside&&!o.showOutsideDays||m.hidden),v=(l=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&l!==void 0?l:Lz,N=e.jsx(v,{date:t,displayMonth:s,activeModifiers:m}),j={style:u,className:p,children:N,role:"gridcell"},y=d.focusTarget&&ha(d.focusTarget,t)&&!m.outside,C=d.focusedDay&&ha(d.focusedDay,t),S=qs(qs(qs({},j),(r={disabled:m.disabled,role:"gridcell"},r["aria-selected"]=m.selected,r.tabIndex=C||y?0:-1,r)),f),D={isButton:h,isHidden:w,activeModifiers:m,selectedDays:x,buttonProps:S,divProps:j};return D}function pU(t){var s=g.useRef(null),n=fU(t.date,t.displayMonth,s);return n.isHidden?e.jsx("div",{role:"gridcell"}):n.isButton?e.jsx(yf,qs({name:"day",ref:s},n.buttonProps)):e.jsx("div",qs({},n.divProps))}function xU(t){var s=t.number,n=t.dates,r=Pn(),a=r.onWeekNumberClick,l=r.styles,o=r.classNames,d=r.locale,m=r.labels.labelWeekNumber,f=r.formatters.formatWeekNumber,x=f(Number(s),{locale:d});if(!a)return e.jsx("span",{className:o.weeknumber,style:l.weeknumber,children:x});var h=m(Number(s),{locale:d}),p=function(u){a(s,n,u)};return e.jsx(yf,{name:"week-number","aria-label":h,className:o.weeknumber,style:l.weeknumber,onClick:p,children:x})}function gU(t){var s,n,r=Pn(),a=r.styles,l=r.classNames,o=r.showWeekNumber,d=r.components,m=(s=d==null?void 0:d.Day)!==null&&s!==void 0?s:pU,f=(n=d==null?void 0:d.WeekNumber)!==null&&n!==void 0?n:xU,x;return o&&(x=e.jsx("td",{className:l.cell,style:a.cell,children:e.jsx(f,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:l.row,style:a.row,children:[x,t.dates.map(function(h){return e.jsx("td",{className:l.cell,style:a.cell,role:"presentation",children:e.jsx(m,{displayMonth:t.displayMonth,date:h})},r$(h))})]})}function kS(t,s,n){for(var r=n!=null&&n.ISOWeek?sR(s):Tb(s,n),a=n!=null&&n.ISOWeek?lc(t):zi(t,n),l=Mi(r,a),o=[],d=0;d<=l;d++)o.push(Zr(a,d));var m=o.reduce(function(f,x){var h=n!=null&&n.ISOWeek?nR(x):aR(x,n),p=f.find(function(u){return u.weekNumber===h});return p?(p.dates.push(x),f):(f.push({weekNumber:h,dates:[x]}),f)},[]);return m}function vU(t,s){var n=kS(pa(t),sp(t),s);if(s!=null&&s.useFixedWeeks){var r=i$(t,s);if(r<6){var a=n[n.length-1],l=a.dates[a.dates.length-1],o=Ny(l,6-r),d=kS(Ny(l,1),o,s);n.push.apply(n,d)}}return n}function yU(t){var s,n,r,a=Pn(),l=a.locale,o=a.classNames,d=a.styles,m=a.hideHead,f=a.fixedWeeks,x=a.components,h=a.weekStartsOn,p=a.firstWeekContainsDate,u=a.ISOWeek,w=vU(t.displayMonth,{useFixedWeeks:!!f,ISOWeek:u,locale:l,weekStartsOn:h,firstWeekContainsDate:p}),v=(s=x==null?void 0:x.Head)!==null&&s!==void 0?s:Oz,N=(n=x==null?void 0:x.Row)!==null&&n!==void 0?n:gU,j=(r=x==null?void 0:x.Footer)!==null&&r!==void 0?r:_z;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:w.map(function(y){return e.jsx(N,{displayMonth:t.displayMonth,dates:y.dates,weekNumber:y.weekNumber},y.weekNumber)})}),e.jsx(j,{displayMonth:t.displayMonth})]})}function bU(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var jU=bU()?g.useLayoutEffect:g.useEffect,Vg=!1,NU=0;function DS(){return"react-day-picker-".concat(++NU)}function wU(t){var s,n=t??(Vg?DS():null),r=g.useState(n),a=r[0],l=r[1];return jU(function(){a===null&&l(DS())},[]),g.useEffect(function(){Vg===!1&&(Vg=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function SU(t){var s,n,r=Pn(),a=r.dir,l=r.classNames,o=r.styles,d=r.components,m=ih().displayMonths,f=wU(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),x=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,h=[l.month],p=o.month,u=t.displayIndex===0,w=t.displayIndex===m.length-1,v=!u&&!w;a==="rtl"&&(s=[u,w],w=s[0],u=s[1]),u&&(h.push(l.caption_start),p=qs(qs({},p),o.caption_start)),w&&(h.push(l.caption_end),p=qs(qs({},p),o.caption_end)),v&&(h.push(l.caption_between),p=qs(qs({},p),o.caption_between));var N=(n=d==null?void 0:d.Caption)!==null&&n!==void 0?n:Ez;return e.jsxs("div",{className:h.join(" "),style:p,children:[e.jsx(N,{id:f,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(yU,{id:x,"aria-labelledby":f,displayMonth:t.displayMonth})]},t.displayIndex)}function CU(t){var s=Pn(),n=s.classNames,r=s.styles;return e.jsx("div",{className:n.months,style:r.months,children:t.children})}function AU(t){var s,n,r=t.initialProps,a=Pn(),l=ij(),o=ih(),d=g.useState(!1),m=d[0],f=d[1];g.useEffect(function(){a.initialFocus&&l.focusTarget&&(m||(l.focus(l.focusTarget),f(!0)))},[a.initialFocus,m,l.focus,l.focusTarget,l]);var x=[a.classNames.root,a.className];a.numberOfMonths>1&&x.push(a.classNames.multiple_months),a.showWeekNumber&&x.push(a.classNames.with_weeknumber);var h=qs(qs({},a.styles.root),a.style),p=Object.keys(r).filter(function(w){return w.startsWith("data-")}).reduce(function(w,v){var N;return qs(qs({},w),(N={},N[v]=r[v],N))},{}),u=(n=(s=r.components)===null||s===void 0?void 0:s.Months)!==null&&n!==void 0?n:CU;return e.jsx("div",qs({className:x.join(" "),style:h,dir:a.dir,id:a.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:e.jsx(u,{children:o.displayMonths.map(function(w,v){return e.jsx(SU,{displayIndex:v,displayMonth:w},v)})})}))}function kU(t){var s=t.children,n=Qq(t,["children"]);return e.jsx(xz,{initialProps:n,children:e.jsx(Az,{children:e.jsx(lU,{initialProps:n,children:e.jsx(Iz,{initialProps:n,children:e.jsx(Bz,{initialProps:n,children:e.jsx(Gz,{children:e.jsx(aU,{children:s})})})})})})})}function DU(t){return e.jsx(kU,qs({},t,{children:e.jsx(AU,{initialProps:t})}))}function bf({className:t,classNames:s,showOutsideDays:n=!0,...r}){return e.jsx(DU,{showOutsideDays:n,className:jt("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:jt(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:jt("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:jt(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,...l})=>e.jsx(lo,{className:jt("size-4",a),...l}),IconRight:({className:a,...l})=>e.jsx(ji,{className:jt("size-4",a),...l})},...r})}function RU({onViewDetails:t}){const[s,n]=g.useState("table"),[r,a]=g.useState(""),[l,o]=g.useState("all"),[d,m]=g.useState("all"),[f,x]=g.useState("all"),[h,p]=g.useState(""),[u,w]=g.useState(""),[v,N]=g.useState("date-desc"),[j,y]=g.useState(1),[C,S]=g.useState(null),[D,R]=g.useState([]),[A,L]=g.useState(!1),[$,P]=g.useState(!1),[E,O]=g.useState(""),[I,q]=g.useState([]),[G,Y]=g.useState([]),[V,Q]=g.useState([]),[_,z]=g.useState(!0);g.useEffect(()=>{F()},[h,u,l,r,j,d,f]),g.useEffect(()=>{y(1)},[h,u,l,r,d,f]),g.useEffect(()=>{T()},[]);const T=async()=>{try{const ce=await Fs.getStates(),ke=(Array.isArray(ce)?ce:(ce==null?void 0:ce.data)||(ce==null?void 0:ce.states)||[]).map(Xe=>typeof Xe=="string"?Xe:Xe.name||Xe.stateName).filter(Boolean);q(ke)}catch(ce){console.error("Failed to fetch states:",ce)}},F=async()=>{try{z(!0);const ce=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],we=await ds.getApplications({fromDate:h,toDate:u,status:l==="all"?ce.join(","):l,location:d!=="all"?d:void 0,state:f!=="all"?f:void 0,ddLeadShortlisted:"false",isShortlisted:"true",search:r,page:j,limit:10}),ke=we.data||[];S(we.meta);const Xe=ke.map(te=>({id:te.id,registrationNumber:te.applicationId||"N/A",name:te.applicantName,email:te.email,phone:te.phone,age:te.age,education:te.education,residentialAddress:te.address||te.city||"",businessAddress:te.address||"",preferredLocation:te.preferredLocation,state:te.state,ownsBike:te.ownRoyalEnfield==="yes",pastExperience:te.experienceYears?`${te.experienceYears} years`:te.description||"",status:te.overallStatus,questionnaireMarks:te.score||te.questionnaireMarks||0,rank:0,totalApplicantsAtLocation:0,submissionDate:te.createdAt,assignedUsers:[],progress:te.progressPercentage||0,isShortlisted:te.isShortlisted,ddLeadShortlisted:te.ddLeadShortlisted,companyName:te.companyName,source:te.source,existingDealer:te.existingDealer,royalEnfieldModel:te.royalEnfieldModel,description:te.description,pincode:te.pincode,locationType:te.locationType,ownRoyalEnfield:te.ownRoyalEnfield,address:te.address}));Q(Xe);const Ot=Array.from(new Set(Xe.map(te=>te.preferredLocation))).filter(Boolean);Y(te=>Array.from(new Set([...te,...Ot])));const bt=Array.from(new Set(Xe.map(te=>te.state))).filter(Boolean);q(te=>Array.from(new Set([...te,...bt])))}catch(ce){console.error("Failed to fetch applications:",ce),ee.error("Failed to load opportunity requests")}finally{z(!1)}},B=V.sort((ce,we)=>v==="score-desc"?(we.questionnaireMarks||0)-(ce.questionnaireMarks||0):v==="score-asc"?(ce.questionnaireMarks||0)-(we.questionnaireMarks||0):v==="date-desc"?new Date(we.submissionDate).getTime()-new Date(ce.submissionDate).getTime():v==="date-asc"?new Date(ce.submissionDate).getTime()-new Date(we.submissionDate).getTime():0),K=ce=>{R(ce?B.map(we=>we.id):[])},W=(ce,we)=>{R(we?[...D,ce]:D.filter(ke=>ke!==ce))},H=()=>{if(D.length===0){ee.error("Please select at least one application to shortlist");return}P(!0)},X=async()=>{try{const ce=await ds.shortlistApplications(D,[],E);if(ce&&ce.success)await F(),R([]),P(!1),O(""),ee.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),ee.error(ce.message||"Failed to process shortlisting")}},J=async()=>{if(D.length===0){ee.error("Please select at least one application");return}try{L(!0);const ce=await ds.sendBulkReminders(D);ce.success&&(ee.success(ce.message||`Reminder emails sent to ${D.length} applicant(s)`),R([]))}catch(ce){console.error("Failed to send reminders:",ce),ee.error(ce.message||"Failed to send reminders")}finally{L(!1)}},ie=async()=>{const ce=B.filter(Xe=>Xe.status!=="Questionnaire Pending"),we=ce.filter(Xe=>D.includes(Xe.id));let ke=[];if(D.length>0){if(we.length===0){ee.error('Selected applications are in "Questionnaire Pending" status and cannot be exported.');return}ke=we.map(Xe=>Xe.id),we.length<D.length&&ee.info(`Skipping ${D.length-we.length} applications with pending questionnaires.`)}else ke=ce.map(Xe=>Xe.id);if(ke.length===0){ee.error("No applications with completed questionnaires available for export");return}try{const Xe=ee.loading("Preparing Excel export..."),Ot=await ds.exportResponses(ke);if(ee.dismiss(Xe),!Ot||Ot.length===0){ee.error("No response data found");return}const bt=Object.keys(Ot[0]),ve=[bt.join(","),...Ot.map(ut=>bt.map(ht=>{const it=ut[ht]??"";return`"${String(it).replace(/"/g,'""')}"`}).join(","))].join(`
|
||
`),qe=new Blob([ve],{type:"text/csv;charset=utf-8;"}),ge=URL.createObjectURL(qe),Be=document.createElement("a");Be.setAttribute("href",ge),Be.setAttribute("download",`onboarding_responses_${new Date().toISOString().split("T")[0]}.xlsx`),document.body.appendChild(Be),Be.click(),document.body.removeChild(Be),ee.success(`Exported ${ke.length} records to Excel successfully`)}catch(Xe){console.error("Export failed:",Xe),ee.error(Xe.message||"Failed to export responses")}},ae=["Questionnaire Pending","Questionnaire Completed","Shortlisted"],xe=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 _?e.jsx("div",{className:"flex justify-center items-center h-96",children:e.jsx(es,{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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{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(At,{value:l,onValueChange:o,children:[e.jsx(Dt,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-status-select",children:e.jsx(kt,{placeholder:"Filter by status"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Statuses"}),ae.map(ce=>e.jsx(Me,{value:ce,children:ce},ce))]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-9",onClick:()=>{p(""),w(""),o("all"),m("all"),x("all"),a("")},"data-testid":"onboarding-opp-requests-clear-filters",children:"Clear Filters"}),e.jsxs(At,{value:f,onValueChange:x,children:[e.jsx(Dt,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-state-select",children:e.jsx(kt,{placeholder:"Filter by state"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All States"}),I.map(ce=>e.jsx(Me,{value:ce,children:ce},ce))]})]}),e.jsxs(At,{value:d,onValueChange:m,children:[e.jsx(Dt,{className:"w-full md:w-48","data-testid":"onboarding-opp-requests-location-select",children:e.jsx(kt,{placeholder:"Filter by location"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),G.map(ce=>e.jsx(Me,{value:ce,children:ce},ce))]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 md:flex-none",children:[e.jsxs(Tu,{children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:jt("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(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),h?Ka(new Date(h),"PPP"):e.jsx("span",{className:"text-xs",children:"From Date"})]})}),e.jsx(Ou,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:h?new Date(h):void 0,onSelect:ce=>p(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(Tu,{children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:jt("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(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),u?Ka(new Date(u),"PPP"):e.jsx("span",{className:"text-xs",children:"To Date"})]})}),e.jsx(Ou,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:u?new Date(u):void 0,onSelect:ce=>w(ce?ce.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(At,{value:v,onValueChange:N,children:[e.jsx(Dt,{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(PI,{className:"w-4 h-4 text-slate-400"}),e.jsx(kt,{placeholder:"Sort by"})]})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"date-desc",children:"Newest Applied"}),e.jsx(Me,{value:"date-asc",children:"Oldest Applied"}),e.jsx(Me,{value:"score-desc",children:"Highest Score"}),e.jsx(Me,{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(se,{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(dk,{className:"w-4 h-4 mr-2"}),"Grid"]}),e.jsxs(se,{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(mk,{className:"w-4 h-4 mr-2"}),"Table"]})]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:ie,"data-testid":"onboarding-opp-requests-export-btn",children:[e.jsx(Ni,{className:"w-4 h-4 mr-2"}),"Export"]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{variant:"outline",size:"sm",onClick:J,disabled:A,"data-testid":"onboarding-opp-requests-bulk-reminder-btn",children:[A?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Send Reminders (",D.length,")"]}),e.jsxs(se,{size:"sm",onClick:H,className:"bg-green-600 hover:bg-green-700","data-testid":"onboarding-opp-requests-bulk-shortlist-btn",children:[e.jsx(fn,{className:"w-4 h-4 mr-2"}),"Shortlist (",D.length,")"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Ce,{variant:"outline",className:"text-slate-600","data-testid":"onboarding-opp-requests-pending-count",children:[(C==null?void 0:C.total)||B.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:[B.map((ce,we)=>e.jsxs("div",{className:"relative","data-testid":`onboarding-opp-requests-grid-item-${we}`,children:[e.jsx("div",{className:"absolute top-4 left-4 z-10",children:e.jsx(Tn,{checked:D.includes(ce.id),onCheckedChange:ke=>W(ce.id,ke),className:"bg-white","data-testid":`onboarding-opp-requests-grid-checkbox-${we}`})}),e.jsx(WE,{application:ce,onViewDetails:t})]},ce.id)),B.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(fn,{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(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Tn,{checked:D.length===B.length&&B.length>0,onCheckedChange:K,"data-testid":"onboarding-opp-requests-table-select-all"})}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-reg",children:"Registration"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-name",children:"Name"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-pref-loc",children:"Preferred Location"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-status",children:"Status"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-score",children:"Score"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-app-loc",children:"Applicant Location"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-shortlisted",children:"Shortlisted"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-progress",children:"Progress"}),e.jsx(fe,{"data-testid":"onboarding-opp-requests-th-date",children:"Applied On"})]})}),e.jsxs(Ls,{children:[B.map((ce,we)=>e.jsxs(lt,{className:"cursor-pointer hover:bg-slate-50",onClick:()=>t(ce.id),"data-testid":`onboarding-opp-requests-row-${we}`,children:[e.jsx(ue,{onClick:ke=>ke.stopPropagation(),children:e.jsx(Tn,{checked:D.includes(ce.id),onCheckedChange:ke=>W(ce.id,ke),"data-testid":`onboarding-opp-requests-table-select-item-${ce.id}`})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-reg-${we}`,children:ce.registrationNumber})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900","data-testid":`onboarding-opp-requests-name-${we}`,children:ce.name})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-pref-loc-${we}`,children:ce.preferredLocation})}),e.jsx(ue,{children:e.jsx(Ce,{className:xe(ce.status),"data-testid":`onboarding-opp-requests-status-${we}`,children:ce.status})}),e.jsx(ue,{children:e.jsx("span",{className:"font-semibold text-slate-900","data-testid":`onboarding-opp-requests-score-${we}`,children:ce.questionnaireMarks})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-app-loc-${we}`,children:ce.businessAddress})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline","data-testid":`onboarding-opp-requests-shortlisted-badge-${we}`,children:"No"})}),e.jsx(ue,{children:e.jsx(mp,{value:ce.progress,status:ce.status,showPercent:!0,"data-testid":`onboarding-opp-requests-progress-${we}`})}),e.jsx(ue,{children:e.jsx("span",{className:"text-slate-600","data-testid":`onboarding-opp-requests-date-${we}`,children:Gt(ce.submissionDate)})})]},ce.id)),B.length===0&&e.jsx(lt,{children:e.jsxs(ue,{colSpan:9,className:"text-center py-12 text-slate-500","data-testid":"onboarding-opp-requests-table-empty",children:[e.jsx(fn,{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(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>y(ce=>Math.max(1,ce-1)),className:j===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(C.totalPages)].map((ce,we)=>{const ke=we+1;return ke===1||ke===C.totalPages||ke>=j-1&&ke<=j+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:j===ke,onClick:()=>y(ke),className:"cursor-pointer",children:ke})},ke):ke===j-2||ke===j+2?e.jsx(Sn,{children:e.jsx(vo,{})},ke):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>y(ce=>Math.min(C.totalPages,ce+1)),className:j===C.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),e.jsx(ls,{open:$,onOpenChange:P,children:e.jsxs(as,{className:"overflow-visible","data-testid":"onboarding-opp-requests-shortlist-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{"data-testid":"onboarding-opp-requests-shortlist-modal-title",children:"Shortlist Applications"}),e.jsxs(bs,{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(de,{children:"Shortlisting Remark (Optional)"}),e.jsx(Gs,{placeholder:"Enter reason for shortlisting these applications...",value:E,onChange:ce=>O(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(se,{variant:"outline",className:"flex-1",onClick:()=>{P(!1),O("")},"data-testid":"onboarding-opp-requests-shortlist-cancel-btn",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-green-600 hover:bg-green-700",onClick:X,"data-testid":"onboarding-opp-requests-shortlist-confirm-btn",children:"Confirm Shortlist"})]})]})]})})]})}function EU({onViewDetails:t}){var V,Q;const[s,n]=g.useState(""),[r,a]=g.useState("all"),[l,o]=g.useState("all"),[d,m]=g.useState(""),[f,x]=g.useState(""),[h,p]=g.useState(1),[u,w]=g.useState(null),[v,N]=g.useState([]),[j,y]=g.useState(!0),[C,S]=g.useState([]),[D,R]=g.useState([]),[A,L]=g.useState([]),[$,P]=g.useState(!1),E=async()=>{var _,z,T,F;if(A.length!==0)try{P(!0);const B=await ds.bulkConvertToOpportunity({ids:A});B!=null&&B.success&&((((_=B.data)==null?void 0:_.success)>0||!B.data)&&ee.success(B.message||`Successfully converted ${((z=B.data)==null?void 0:z.success)||A.length} leads.`),((T=B.data)==null?void 0:T.failed)>0&&((F=B.data)!=null&&F.errors)&&B.data.errors.forEach(K=>{ee.error(K,{duration:5e3})}),L([]),await G())}catch(B){console.error("Bulk conversion error:",B),ee.error(B.message||"Failed to perform bulk conversion")}finally{P(!1)}},O=()=>{A.length===Y.length?L([]):L(Y.map(_=>_.id))},I=_=>{L(z=>z.includes(_)?z.filter(T=>T!==_):[...z,_])};g.useEffect(()=>{G()},[d,f,s,h,r,l]),g.useEffect(()=>{p(1)},[d,f,s,r,l]),g.useEffect(()=>{q()},[]);const q=async()=>{try{const _=await Fs.getStates(),T=(Array.isArray(_)?_:(_==null?void 0:_.data)||(_==null?void 0:_.states)||[]).map(F=>typeof F=="string"?F:F.name||F.stateName).filter(Boolean);S(T)}catch(_){console.error("Failed to fetch states:",_)}},G=async()=>{try{y(!0);const _=await ds.getApplications({fromDate:d,toDate:f,search:s,status:"Submitted",isShortlisted:"false",location:r!=="all"?r:void 0,state:l!=="all"?l:void 0,page:h,limit:10}),z=_.data||[];w(_.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}));N(T);const F=Array.from(new Set(T.map(K=>K.preferredLocation))).filter(Boolean);R(K=>Array.from(new Set([...K,...F])));const B=Array.from(new Set(T.map(K=>K.state))).filter(Boolean);S(K=>Array.from(new Set([...K,...B])))}catch(_){console.error("Failed to fetch applications:",_),ee.error("Failed to load non-opportunity requests")}finally{y(!1)}},Y=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(ny,{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:((V=u==null?void 0:u.stats)==null?void 0:V.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:((Q=u==null?void 0:u.stats)==null?void 0:Q.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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{type:"text",placeholder:"Search by name, email, phone, or registration number...",value:s,onChange:_=>n(_.target.value),className:"pl-10","data-testid":"onboarding-non-opps-search-input"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Tu,{children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:jt("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(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),d?Ka(new Date(d),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"From Date"})]})}),e.jsx(Ou,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:d?new Date(d):void 0,onSelect:_=>m(_?_.toISOString().split("T")[0]:""),initialFocus:!0})})]}),e.jsx("span",{className:"text-slate-400",children:"to"}),e.jsxs(Tu,{children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:jt("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(dr,{className:"mr-2 h-4 w-4 text-slate-400"}),f?Ka(new Date(f),"PP"):e.jsx("span",{className:"text-xs text-slate-500",children:"To Date"})]})}),e.jsx(Ou,{className:"w-auto p-0",align:"start",children:e.jsx(bf,{mode:"single",selected:f?new Date(f):void 0,onSelect:_=>x(_?_.toISOString().split("T")[0]:""),initialFocus:!0})})]})]}),e.jsxs(At,{value:r,onValueChange:a,children:[e.jsx(Dt,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-location-select",children:e.jsx(kt,{placeholder:"All Locations"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Locations"}),D.map(_=>e.jsx(Me,{value:_,children:_},_))]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-slate-500 hover:text-slate-700 h-10 px-3",onClick:()=>{m(""),x(""),a("all"),o("all"),n("")},"data-testid":"onboarding-non-opps-clear-filters",children:"Clear Filters"}),e.jsxs(At,{value:l,onValueChange:o,children:[e.jsx(Dt,{className:"w-full lg:w-48","data-testid":"onboarding-non-opps-state-select",children:e.jsx(kt,{placeholder:"All States"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All States"}),C.map(_=>e.jsx(Me,{value:_,children:_},_))]})]}),e.jsx(se,{variant:"outline",size:"icon","data-testid":"onboarding-non-opps-export-btn",children:e.jsx(Ni,{className:"w-4 h-4"})}),A.length>0&&e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover font-bold",onClick:E,disabled:$,children:[$?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(II,{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(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{className:"w-12",children:e.jsx(Tn,{checked:Y.length>0&&A.length===Y.length,onCheckedChange:O})}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-name",children:"Name"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-phone",children:"Phone"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-email",children:"Email"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-loc",children:"Preferred Location"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-address",children:"Main Address"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-age",children:"Age"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-exp",children:"Experience"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-edu",children:"Education"}),e.jsx(fe,{"data-testid":"onboarding-non-opps-th-date",children:"Applied On"}),e.jsx(fe,{className:"text-right","data-testid":"onboarding-non-opps-th-actions",children:"Actions"})]})}),e.jsx(Ls,{children:j?e.jsx(lt,{children:e.jsxs(ue,{colSpan:11,className:"text-center py-20",children:[e.jsx(es,{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..."})]})}):Y.length===0?e.jsx(lt,{children:e.jsxs(ue,{colSpan:11,className:"text-center py-12 text-slate-500","data-testid":"onboarding-non-opps-empty-state",children:[e.jsx(ny,{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"})]})}):Y.map((_,z)=>e.jsxs(lt,{"data-testid":`onboarding-non-opps-row-${z}`,className:A.includes(_.id)?"bg-red-50/50":"",children:[e.jsx(ue,{children:e.jsx(Tn,{checked:A.includes(_.id),onCheckedChange:()=>I(_.id)})}),e.jsx(ue,{children:e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900","data-testid":`onboarding-non-opps-name-${z}`,children:_.name}),e.jsx("p",{className:"text-slate-500 text-sm","data-testid":`onboarding-non-opps-id-${z}`,children:_.registrationNumber})]})}),e.jsx(ue,{className:"text-slate-900","data-testid":`onboarding-non-opps-phone-${z}`,children:_.phone}),e.jsx(ue,{className:"text-slate-600","data-testid":`onboarding-non-opps-email-${z}`,children:_.email}),e.jsx(ue,{children:e.jsxs("div",{"data-testid":`onboarding-non-opps-pref-loc-${z}`,children:[e.jsx("p",{className:"text-slate-900",children:_.preferredLocation}),e.jsx("p",{className:"text-slate-500 text-sm",children:_.state})]})}),e.jsx(ue,{className:"text-slate-600 max-w-xs truncate","data-testid":`onboarding-non-opps-address-${z}`,children:_.residentialAddress}),e.jsx(ue,{className:"text-slate-900","data-testid":`onboarding-non-opps-age-${z}`,children:_.age}),e.jsx(ue,{className:"text-slate-600","data-testid":`onboarding-non-opps-experience-${z}`,children:_.pastExperience}),e.jsx(ue,{className:"text-slate-900","data-testid":`onboarding-non-opps-education-${z}`,children:_.education}),e.jsx(ue,{className:"text-slate-600","data-testid":`onboarding-non-opps-date-${z}`,children:Gt(_.submissionDate)}),e.jsx(ue,{className:"text-right",children:e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(se,{variant:"outline",size:"sm",onClick:()=>t(_.id),"data-testid":`onboarding-non-opps-view-btn-${z}`,children:"View"})})})]},_.id))})]}),u&&u.totalPages>1&&e.jsx("div",{className:"py-4 border-t border-slate-200",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>p(_=>Math.max(1,_-1)),className:h===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(u.totalPages)].map((_,z)=>{const T=z+1;return T===1||T===u.totalPages||T>=h-1&&T<=h+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:h===T,onClick:()=>p(T),className:"cursor-pointer",children:T})},T):T===h-2||T===h+2?e.jsx(Sn,{children:e.jsx(vo,{})},T):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>p(_=>Math.min(u.totalPages,_+1)),className:h===u.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})}function _U({application:t,slaStatus:s,isNonResponsive:n,isAdmin:r,onBack:a,onOpenWorknotes:l}){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(xk,{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(se,{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(se,{variant:"outline",size:"icon",onClick:a,className:"shrink-0","data-testid":"onboarding-details-back-button",children:e.jsx(Jr,{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(kr,{status:s})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(se,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:l,"data-testid":"onboarding-details-view-work-notes",children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]})]})}var TU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],PU=TU.reduce((t,s)=>{const n=Wu(`Primitive.${s}`),r=g.forwardRef((a,l)=>{const{asChild:o,...d}=a,m=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...d,ref:l})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),OU="Separator",RS="horizontal",LU=["horizontal","vertical"],m_=g.forwardRef((t,s)=>{const{decorative:n,orientation:r=RS,...a}=t,l=IU(r)?r:RS,d=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return e.jsx(PU.div,{"data-orientation":l,...d,...a,ref:s})});m_.displayName=OU;function IU(t){return LU.includes(t)}var MU=m_;function tc({className:t,orientation:s="horizontal",decorative:n=!0,...r}){return e.jsx(MU,{"data-slot":"separator-root",decorative:n,orientation:s,className:jt("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 FU({application:t,canEditStatutory:s,isEditingStatutory:n,isSavingStatutory:r,statutoryForm:a,onEditFirmType:l,onEditStatutory:o,onCancelEditStatutory:d,onSaveStatutory:m,onStatutoryFormChange:f}){return e.jsxs(Le,{"data-testid":"onboarding-applicant-info-card",children:[e.jsx(Qe,{children:e.jsx(et,{children:"Applicant Information"})}),e.jsxs(Fe,{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(Ir,{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(Dr,{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(nb,{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(Ir,{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(VI,{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(Vr,{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(Vr,{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(so,{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:l,"data-testid":"onboarding-applicant-info-edit-firm-type",children:["Proposed Firm Type",e.jsx(iy,{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(C1,{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(C1,{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(Ir,{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(Ir,{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(ac,{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(ik,{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(tc,{}),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(Gu,{className:"w-4 h-4 text-re-red"})," Statutory & Bank Information"]}),s&&!n&&e.jsxs(se,{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(iy,{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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Legal Entity Name"}),e.jsx(at,{value:a.accountHolderName,onChange:x=>f({...a,accountHolderName:x.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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"PAN Number"}),e.jsx(at,{value:a.panNumber,onChange:x=>f({...a,panNumber:x.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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"GST Number"}),e.jsx(at,{value:a.gstNumber,onChange:x=>f({...a,gstNumber:x.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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Registered Address"}),e.jsx(at,{value:a.registeredAddress,onChange:x=>f({...a,registeredAddress:x.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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Bank Name"}),e.jsx(at,{value:a.bankName,onChange:x=>f({...a,bankName:x.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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"Account Number"}),e.jsx(at,{value:a.accountNumber,onChange:x=>f({...a,accountNumber:x.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(de,{className:"text-[10px] uppercase font-bold text-slate-500",children:"IFSC Code"}),e.jsx(at,{value:a.ifscCode,onChange:x=>f({...a,ifscCode:x.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(se,{variant:"outline",size:"sm",onClick:d,disabled:r,"data-testid":"onboarding-applicant-info-statutory-cancel",children:"Cancel"}),e.jsx(se,{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(es,{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 BU=({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(ac,{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 l,o;return(((l=r.question)==null?void 0:l.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(ac,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900",children:"Questionnaire Responses"})]}),n!==void 0&&e.jsxs(Ce,{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 l=r.question,o=(l==null?void 0:l.questionText)||"Unknown Question",d=r.responseValue||"No Answer",m=(l==null?void 0:l.sectionName)||"General",f=(l==null?void 0:l.questionOptions)||[],x=f.find(v=>v.optionText===d),h=x?x.score:0,p=Math.max(...f.map(v=>v.score||0),0),u=typeof d=="string"&&d.startsWith("data:"),w=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(Ce,{variant:"outline",className:"text-slate-600 bg-slate-50","data-testid":`onboarding-questionnaire-item-section-${a}`,children:m}),f.length>0&&p>0&&e.jsxs(Ce,{className:h>0?"bg-green-600":"bg-slate-400","data-testid":`onboarding-questionnaire-item-score-${a}`,children:[h,"/",p]})]}),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:w?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)})})]})},$U=Zy("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 di({className:t,variant:s,...n}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:jt($U({variant:s}),t),...n})}function Ti({className:t,...s}){return e.jsx("div",{"data-slot":"alert-title",className:jt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s})}function ui({className:t,...s}){return e.jsx("div",{"data-slot":"alert-description",className:jt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s})}var qU={};function zU(t){const{application:s,activeTab:n,setActiveTab:r,processStages:a,documents:l,interviews:o,expandedBranches:d,setExpandedBranches:m,setSelectedStage:f,setShowDocumentsModal:x,setShowUploadForm:h,handleRetriggerEvaluators:p,handleRescheduleInterview:u,setSelectedEvaluationForView:w,setShowFeedbackDetailsModal:v,renderFddAuditContent:N,eorProgress:j,eorData:y,eorChecklist:C,setUploadDocType:S,isAdmin:D,canViewFinanceTabs:R,fetchApplication:A,fetchEorData:L,deposits:$,getDeposit:P,paymentConfigs:E,setPreviewDoc:O,setShowPreviewModal:I,auditLoading:q,auditLogs:G,auditLogActionBadgeClass:Y}=t;g.useEffect(()=>{!R&&(n==="fdd"||n==="payments")&&r("progress")},[R,n,r]);const V=_=>String(_||"").trim().toLowerCase().replace(/[_\s-]+/g," "),Q=(_,z)=>{var B,K,W;const T=[(B=_==null?void 0:_.user)==null?void 0:B.role,(K=_==null?void 0:_.user)==null?void 0:K.roleCode,(W=_==null?void 0:_.metadata)==null?void 0:W.role].map(V),F=z.map(V);return T.some(H=>F.includes(H))};return e.jsx(Le,{"data-testid":"onboarding-details-tabs-container",children:e.jsxs($n,{value:n,onValueChange:r,children:[e.jsx(Qe,{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(qn,{className:"w-max min-w-full justify-start h-11 bg-slate-100/80 p-1","data-testid":"onboarding-tabs-list",children:[e.jsx(zt,{value:"questionnaire",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-questionnaire",children:"Questionnaire"}),e.jsx(zt,{value:"progress",className:"min-w-[80px]","data-testid":"onboarding-tab-trigger-progress",children:"Progress"}),e.jsx(zt,{value:"documents",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-documents",children:"Documents"}),e.jsx(zt,{value:"interviews",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-interviews",children:"Interviews"}),R&&e.jsx(zt,{value:"fdd",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-fdd",children:"FDD Audit"}),e.jsx(zt,{value:"eor",className:"min-w-[120px]","data-testid":"onboarding-tab-trigger-eor",children:"EOR Checklist"}),R&&e.jsx(zt,{value:"payments",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-payments",children:"Payments"}),e.jsx(zt,{value:"audit",className:"min-w-[100px]","data-testid":"onboarding-tab-trigger-audit",children:"Audit Trail"})]})})}),e.jsxs(Fe,{children:[e.jsx(qt,{value:"questionnaire",className:"space-y-6","data-testid":"onboarding-tab-content-questionnaire",children:e.jsx(BU,{application:s})}),e.jsxs(qt,{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(Ce,{className:Aq(s.status),"data-testid":"onboarding-progress-percentage-badge",children:[s.progress,"% Complete"]})]}),e.jsx(uc,{value:s.progress,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:vi(s.status),"data-testid":"onboarding-progress-bar"})]}),e.jsx("div",{className:"relative status-progress-ui","data-testid":"onboarding-progress-stages-container",children:(()=>{const _={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},z={LOI_APPROVAL:["DD Head","NBH"],LOA_APPROVAL:["DD Head","NBH"]},T=B=>(s.participants||[]).filter(W=>{var X,J,ie,ae,xe,ce,we,ke,Xe,Ot,bt,te;return((X=W.metadata)==null?void 0:X.stageCode)===B||((ie=(J=W.metadata)==null?void 0:J.allAssignments)==null?void 0:ie.includes(B))||typeof B=="number"&&(((ae=W.metadata)==null?void 0:ae.interviewLevel)===B||((xe=W.metadata)==null?void 0:xe.interviewLevel)===String(B)||((we=(ce=W.metadata)==null?void 0:ce.allAssignments)==null?void 0:we.includes(B))||((Xe=(ke=W.metadata)==null?void 0:ke.allAssignments)==null?void 0:Xe.includes(String(B))))||typeof B=="string"&&!isNaN(Number(B))&&(((Ot=W.metadata)==null?void 0:Ot.interviewLevel)===Number(B)||((te=(bt=W.metadata)==null?void 0:bt.allAssignments)==null?void 0:te.includes(Number(B))))?!0:typeof B=="number"?Q(W,_[B]||[]):Q(W,z[B]||[])}).map(W=>{var J,ie,ae,xe,ce;const H=typeof B=="number"?`INTERVIEW_LEVEL_${B}`:B,X=(s.stageApprovals||[]).find(we=>we.stageCode===H&&String(we.actorUserId)===String(W.userId));return{name:((J=W.user)==null?void 0:J.name)||((ie=W.user)==null?void 0:ie.fullName)||"Unknown",role:((ae=W.user)==null?void 0:ae.role)||((xe=W.user)==null?void 0:xe.roleCode)||((ce=W.metadata)==null?void 0:ce.role)||"Reviewer",status:X?X.decision==="Approved"?"approved":"rejected":"pending"}}),F=(B,K)=>{const H={"1st Level Interview":1,"2nd Level Interview":2,"3rd Level Interview":3,"LOI Approval":"LOI_APPROVAL",LOA:"LOA_APPROVAL"}[B];if(!H)return null;const X=T(H);return X.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-2 mt-3","data-testid":`onboarding-stage-approvers-${K}`,children:X.map((J,ie)=>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-${K}-${ie}`,children:[e.jsx("div",{className:jt("w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold text-white",J.status==="approved"?"bg-green-500":J.status==="rejected"?"bg-red-500":"bg-slate-300"),children:J.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:J.name}),e.jsx("span",{className:"text-[8px] text-slate-500 leading-none mt-0.5",children:J.role})]}),e.jsx("div",{className:jt("absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full border border-white",J.status==="approved"?"bg-green-500":J.status==="rejected"?"bg-red-500":"bg-status-progress"),"data-testid":`onboarding-stage-approver-status-dot-${K}-${ie}`}),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:[J.role,": ",J.status.toUpperCase()]})]},ie))})};return a.map((B,K)=>e.jsxs("div",{"data-testid":`onboarding-progress-stage-${K}`,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 ${B.status==="completed"?"bg-green-500 border-green-500 text-white shadow-md":B.status==="active"?B.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-${K}`,children:B.isParallel?e.jsx(ry,{className:"w-5 h-5"}):B.isLocked?e.jsxs("div",{className:"group relative",children:[e.jsx(ay,{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(an,{className:"w-3 h-3"})," Stage Locked"]}),e.jsx("span",{children:B.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:B.status==="completed"?e.jsx(Hn,{className:"w-6 h-6"}):B.status==="active"?e.jsx(yn,{className:"w-5 h-5 text-white"}):e.jsx("div",{className:"w-3 h-3 bg-slate-300 rounded-full"})})}),K<a.length-1&&!B.isParallel&&e.jsx("div",{className:`absolute top-10 left-1/2 -translate-x-1/2 w-0.5 h-full z-0 ${B.status==="completed"?"bg-green-500/30":"bg-slate-200"}`,"data-testid":`onboarding-progress-stage-connector-${K}`})]}),e.jsxs("div",{className:"flex-1 pt-1",children:[e.jsx("p",{className:jt("font-bold transition-colors",B.status==="completed"?"text-green-700":B.status==="active"?"text-status-progress-muted":"text-slate-900"),"data-testid":`onboarding-progress-stage-name-${K}`,children:B.name}),B.description&&e.jsx("p",{className:"text-slate-600 text-sm mt-0.5 leading-relaxed","data-testid":`onboarding-progress-stage-desc-${K}`,children:B.description}),F(B.name,K),B.evaluators&&B.evaluators.length>0&&!["LOI Approval","LOA","1st Level Interview","2nd Level Interview","3rd Level Interview"].includes(B.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-${K}`,children:[e.jsx(Ir,{className:"w-3 h-3"}),"Evaluators: ",B.evaluators.join(" + ")]}),(()=>{var ce;const W={3:2,4:2,5:2,6:2,8:2,13:2},H=Number(B.id),X=W[H],ie={3:1,4:1,5:2,6:3,8:"LOI_APPROVAL",13:"LOA_APPROVAL"}[H],ae=ie?T(ie).length:((ce=B.evaluators)==null?void 0:ce.length)||0,xe=H===3?B.status==="completed":B.status!=="pending";return X&&ae<X&&s.status!=="Rejected"&&xe?e.jsx("div",{className:"mt-2","data-testid":`onboarding-progress-stage-warning-${K}`,children:e.jsxs(di,{variant:"destructive",className:"py-2 px-3 border-red-200 bg-red-50 text-red-800",children:[e.jsx(an,{className:"h-4 w-4 text-re-red"}),e.jsx(Ti,{className:"text-xs font-semibold",children:"Missing Evaluators"}),e.jsxs(ui,{className:"text-xs",children:[ae===0?"Respective role users were not found for this location.":`Some roles (${ae}/${X}) are missing for this location.`,e.jsxs(se,{variant:"link",size:"sm",className:"h-auto p-0 ml-1 text-xs text-re-red-hover underline",onClick:p,"data-testid":`onboarding-progress-stage-retrigger-${K}`,children:[e.jsx(pr,{className:"w-3 h-3 mr-1"}),"Re-trigger Assignment"]})]})]})}):null})(),(()=>{const W=l.filter(X=>{var J;return X.stage===B.name||!X.stage&&((J=X.documentType)==null?void 0:J.toLowerCase().includes(B.name.toLowerCase().split(" ")[0]))}).length,H=B.status==="active"&&!B.isLocked;return W===0&&!H?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(B.name),x(!0),W===0&&H&&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-${K}`,children:[e.jsx(Ns,{className:"w-3.5 h-3.5"}),W>0?`${W} Documents`:"Upload"]})})})(),e.jsxs("p",{className:"text-slate-500 mt-1 text-xs","data-testid":`onboarding-progress-stage-status-text-${K}`,children:[B.status==="completed"&&B.date&&`Completed: ${Gt(B.date)}`,B.status==="active"&&"In Progress",B.status==="pending"&&"Pending"]})]})]}),B.isParallel&&B.branches&&e.jsxs("div",{className:"ml-5 mb-8","data-testid":`onboarding-progress-parallel-branches-${K}`,children:[B.branches.map((W,H)=>{const X=W.name.toLowerCase().replace(/\s+/g,"-"),J=d[X],ie=W.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,[X]:!ae[X]})),className:`flex-1 flex items-center gap-3 p-4 rounded-lg border-2 transition-all hover:shadow-md ${ie==="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-${X}`,children:[J?e.jsx(Aa,{className:`w-5 h-5 ${ie==="blue"?"text-blue-600":"text-green-600"}`}):e.jsx(ji,{className:`w-5 h-5 ${ie==="blue"?"text-blue-600":"text-green-600"}`}),e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${ie==="blue"?"bg-blue-200":"bg-green-200"}`,children:e.jsx(ry,{className:`w-4 h-4 ${ie==="blue"?"text-blue-700":"text-green-700"}`})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:`${ie==="blue"?"text-blue-900":"text-green-900"} font-semibold tracking-tight`,children:W.name}),e.jsxs("p",{className:`text-[10px] uppercase font-bold tracking-wider ${ie==="blue"?"text-blue-500":"text-green-500"}`,children:[W.stages.length," SUB-STEPS"]})]})]})}),J&&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-${X}`,children:W.stages.map((ae,xe)=>e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex gap-4 text-xs","data-testid":`onboarding-progress-branch-stage-${X}-${xe}`,children:(()=>{const ce=l.filter(ke=>{var Xe;return((Xe=ke.documentType)==null?void 0:Xe.toLowerCase().includes(ae.name.toLowerCase().split(" ")[0]))||ke.stage===ae.name}),we=ae.status==="completed"||ce.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 ${we?`${ie==="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-${X}-${xe}`,children:we?e.jsx(Wn,{className:"w-4 h-4 text-white",strokeWidth:3}):ae.status==="active"?e.jsx(yn,{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-${X}-${xe}`,children:ae.name}),ae.description&&e.jsx("p",{className:"text-slate-500 text-xs mt-0.5",children:ae.description}),(()=>{const ke=ae.status==="active";return ce.length===0&&!ke?null:e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("button",{onClick:()=>{f(ae.name),x(!0),ce.length===0&&ke&&h(!0)},className:jt("text-[10px] font-medium flex items-center gap-1 transition-colors",ie==="blue"?"text-blue-600 hover:text-blue-800":"text-green-600 hover:text-green-800"),"data-testid":`onboarding-progress-branch-stage-docs-${X}-${xe}`,children:[e.jsx(Ns,{className:"w-2.5 h-2.5"}),ce.length>0?`${ce.length} Docs`:"Upload"]})})})(),e.jsx("p",{className:"text-slate-400 text-[10px] mt-1","data-testid":`onboarding-progress-branch-stage-status-${X}-${xe}`,children:we&&ae.date?`Done: ${Gt(ae.date)}`:we&&ce.length>0?`Uploaded: ${Gt(ce[0].updatedAt||ce[0].createdAt)}`:"Pending"})]})]})})()})},ae.id))})]},H)}),e.jsx("div",{className:"h-8 w-0.5 bg-slate-300 ml-5 opacity-50"})]})]},B.id))})()})]}),e.jsxs(qt,{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(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover","data-testid":"onboarding-documents-upload-tab-button",onClick:()=>{f(null),x(!0),h(!0)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ps,{"data-testid":"onboarding-documents-table",children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{className:"min-w-[200px]",children:"File Name"}),e.jsx(fe,{className:"min-w-[120px]",children:"Type"}),e.jsx(fe,{className:"min-w-[120px]",children:"Upload Date"}),e.jsx(fe,{className:"min-w-[150px]",children:"Uploader"}),e.jsx(fe,{className:"text-right min-w-[100px]",children:"Actions"})]})}),e.jsx(Ls,{children:l.length===0?e.jsx(lt,{"data-testid":"onboarding-documents-empty-row",children:e.jsx(ue,{colSpan:5,className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})}):l.map((_,z)=>{var T;return e.jsxs(lt,{"data-testid":`onboarding-document-row-${z}`,children:[e.jsxs(ue,{className:"flex items-center gap-2",children:[e.jsx(Ns,{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-${z}`,children:_.fileName})]}),e.jsx(ue,{"data-testid":`onboarding-document-type-${z}`,children:_.documentType}),e.jsx(ue,{children:Gt(_.createdAt)}),e.jsx(ue,{"data-testid":`onboarding-document-uploader-${z}`,children:((T=_.uploader)==null?void 0:T.fullName)||(_.uploadedBy?"Unknown User":"Applicant")}),e.jsx(ue,{children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{size:"sm",variant:"outline","data-testid":`onboarding-document-preview-${z}`,onClick:()=>{O(_),I(!0)},children:e.jsx(bn,{className:"w-3 h-3 text-slate-500"})}),e.jsx(se,{size:"sm",variant:"outline","data-testid":`onboarding-document-download-${z}`,onClick:()=>{const F=qU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${F}/${_.filePath}`,"_blank")},children:e.jsx(Ni,{className:"w-3 h-3 text-slate-500"})})]})})]},_.id)})})]})})]}),e.jsxs(qt,{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(Ps,{"data-testid":"onboarding-interviews-scheduled-table",children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{className:"min-w-[100px]",children:"Level"}),e.jsx(fe,{className:"min-w-[180px]",children:"Date & Time"}),e.jsx(fe,{className:"min-w-[100px]",children:"Type"}),e.jsx(fe,{className:"min-w-[200px]",children:"Location/Link"}),e.jsx(fe,{className:"min-w-[120px]",children:"Status"}),e.jsx(fe,{className:"min-w-[150px]",children:"Scheduled By"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:!o||o.length===0?e.jsx(lt,{"data-testid":"onboarding-interviews-empty-row",children:e.jsx(ue,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No interviews scheduled yet"})}):(Array.isArray(o)?o:[]).map((_,z)=>{var T,F;return e.jsxs(lt,{"data-testid":`onboarding-interview-row-${z}`,children:[e.jsxs(ue,{className:"font-medium",children:["Level ",_.level]}),e.jsx(ue,{children:_.scheduleDate?new Date(_.scheduleDate).toLocaleString():"N/A"}),e.jsx(ue,{className:"capitalize",children:_.interviewType}),e.jsx(ue,{children:(T=_.interviewType)!=null&&T.toLowerCase().includes("virtual")?e.jsx("a",{href:_.linkOrLocation,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline","data-testid":`onboarding-interview-link-${z}`,children:"Join Meeting"}):e.jsx("span",{"data-testid":`onboarding-interview-location-${z}`,children:_.linkOrLocation})}),e.jsx(ue,{children:e.jsx(Ce,{variant:_.status==="Completed"?"default":"secondary","data-testid":`onboarding-interview-status-${z}`,children:_.status})}),e.jsx(ue,{children:((F=_.scheduler)==null?void 0:F.fullName)||_.scheduledBy||"N/A"}),e.jsx(ue,{className:"text-right",children:(_.status==="Scheduled"||_.status==="scheduled")&&e.jsx(se,{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-${z}`,onClick:()=>u(_),children:"Reschedule"})})]},_.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((_,z)=>e.jsxs("div",{className:"mb-6 border p-4 rounded-lg bg-slate-50/50","data-testid":`onboarding-interview-feedback-block-${z}`,children:[e.jsxs("h4",{className:"font-semibold text-slate-800 mb-2",children:["Level ",_.level," Interview",e.jsxs("span",{className:"font-normal text-slate-500 text-sm ml-2",children:["(",Gt(_.scheduleDate)," - ",_.interviewType,")"]})]}),_.evaluations&&_.evaluations.length>0?e.jsxs(Ps,{"data-testid":`onboarding-interview-evaluations-table-${z}`,children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Interviewer"}),e.jsx(fe,{children:"Role"}),e.jsx(fe,{children:_.level===1?"Score (KT Matrix)":"Overall Score"}),e.jsx(fe,{children:"Remarks"}),e.jsx(fe,{children:"Recommendation"})]})}),e.jsx(Ls,{children:_.evaluations.map((T,F)=>{var B,K,W;return e.jsxs(lt,{"data-testid":`onboarding-interview-evaluation-row-${z}-${F}`,children:[e.jsx(ue,{className:"font-medium",children:(B=T.evaluator)==null?void 0:B.fullName}),e.jsx(ue,{children:((W=(K=T.evaluator)==null?void 0:K.role)==null?void 0:W.roleName)||"N/A"}),e.jsx(ue,{children:T.ktMatrixScore?e.jsxs(Ce,{variant:_.level===1?Number(T.ktMatrixScore)>=50?"outline":"destructive":Number(T.ktMatrixScore)>=5?"outline":"destructive","data-testid":`onboarding-interview-evaluation-score-${z}-${F}`,children:[T.ktMatrixScore,"/",_.level===1?"100":"10"]}):"N/A"}),e.jsx(ue,{className:"max-w-xs truncate",title:T.remarks||T.qualitativeFeedback,children:T.remarks?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-slate-800",children:T.remarks}),T.feedbackDetails&&T.feedbackDetails.length>0&&e.jsx(se,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 text-xs w-fit","data-testid":`onboarding-interview-evaluation-details-btn-${z}-${F}`,onClick:()=>{w({...T,interview:_}),v(!0)},children:"View Detailed Feedback"})]}):T.feedbackDetails&&T.feedbackDetails.length>0?e.jsx(se,{variant:"link",className:"p-0 h-auto font-normal text-blue-600","data-testid":`onboarding-interview-evaluation-details-btn-${z}-${F}`,onClick:()=>{w({...T,interview:_}),v(!0)},children:"View Detailed Feedback"}):T.qualitativeFeedback||"-"}),e.jsx(ue,{"data-testid":`onboarding-interview-evaluation-rec-${z}-${F}`,children:T.recommendation||"-"})]},T.id)})})]}):e.jsx("p",{className:"text-sm text-slate-500 italic pl-2",children:"No feedback recorded yet."})]},_.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"})]})]})]}),R&&e.jsx(qt,{value:"fdd",className:"space-y-6","data-testid":"onboarding-tab-content-fdd",children:N()}),e.jsxs(qt,{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(Ce,{className:Dq(j),"data-testid":"onboarding-eor-progress-badge",children:[Math.round(j),"% Complete"]})]}),e.jsx(uc,{value:j,className:"h-3 mb-6 bg-status-progress-soft",indicatorClassName:kq(j),"data-testid":"onboarding-eor-progress-bar"}),e.jsx("div",{className:"space-y-3","data-testid":"onboarding-eor-checklist",children:((y==null?void 0:y.items)||C).map((_,z)=>{const T=_.description||_.item,F=!!_.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-${z}`,children:[e.jsx(Tn,{checked:_.isCompliant||_.completed,className:"pointer-events-none shrink-0","data-testid":`onboarding-eor-checkbox-${z}`}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-0 cursor-pointer","data-testid":`onboarding-eor-clickable-${z}`,onClick:()=>{f(`EOR: ${T}`),S(T),x(!0),h(!F)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:_.isCompliant||_.completed?"text-slate-900 font-bold":"text-slate-600 font-medium",children:T}),F&&!_.isCompliant&&e.jsx(Ce,{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"})]}),F&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-blue-600 font-semibold mt-1",children:[e.jsx(Ns,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"truncate",children:_.proofDocument.fileName})]}),!F&&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:[F&&!_.isCompliant&&D&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(se,{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-${z}`,onClick:async()=>{await(await Xo(async()=>{const{eorService:B}=await Promise.resolve().then(()=>Wg);return{eorService:B}},void 0)).eorService.updateItem(y.id,{..._,isCompliant:!0}),L(),ee.success(`${T} verified!`)},children:"Verify"}),e.jsx(se,{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-${z}`,onClick:async()=>{await(await Xo(async()=>{const{eorService:B}=await Promise.resolve().then(()=>Wg);return{eorService:B}},void 0)).eorService.updateItem(y.id,{..._,isCompliant:!1,proofDocumentId:null}),L(),ee.success(`${T} rejected.`)},children:"Reject"})]}),(_.isCompliant||_.completed)&&e.jsx("div",{className:"bg-green-100 p-1.5 rounded-full","data-testid":`onboarding-eor-done-icon-${z}`,children:e.jsx(fn,{className:"w-4 h-4 text-green-600"})}),!F&&e.jsx("div",{className:"p-2 text-slate-300 group-hover:text-re-red transition-colors","data-testid":`onboarding-eor-upload-hint-${z}`,children:e.jsx(or,{className:"w-4 h-4"})})]})]},_.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(no,{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(se,{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 _=y==null?void 0:y.id;if(!_)throw new Error("Checklist ID not found");await(await Xo(async()=>{const{eorService:z}=await Promise.resolve().then(()=>Wg);return{eorService:z}},void 0)).eorService.submitAudit(_,{status:"Completed",overallComments:"EOR Checklist verified and audit completed."}),ee.success("EOR Audit completed successfully!"),A(),L()}catch(_){ee.error(_.message||"Failed to complete EOR audit")}},children:"Complete Audit & Proceed"})]})})]}),R&&e.jsxs(qt,{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(Ce,{variant:"outline",className:"bg-slate-50 text-slate-500 border-slate-200","data-testid":"onboarding-payments-count-badge",children:[$.length," Payment Record(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(()=>{const _=P("SECURITY_DEPOSIT"),z=E.SECURITY_DEPOSIT,T=(z==null?void 0:z.amount)||5e5;return e.jsx(Le,{className:jt("border-l-4",(_==null?void 0:_.status)==="Verified"?"border-l-green-500":(_==null?void 0:_.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-security",children:e.jsxs(Fe,{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(ac,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"Security Deposit"})]}),e.jsx(Ce,{className:jt((_==null?void 0:_.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(_==null?void 0:_.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:(_==null?void 0:_.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((_==null?void 0:_.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:["₹",T.toLocaleString()]})]}),(_==null?void 0:_.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: ",_.paymentReference]}),_.verifiedAt&&e.jsx("span",{children:Gt(_.verifiedAt)})]}),(_==null?void 0:_.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:['"',_.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:[l.filter(F=>{var B,K;return((B=F.documentType)==null?void 0:B.toLowerCase().includes("security"))&&((K=F.documentType)==null?void 0:K.toLowerCase().includes("deposit"))}).map((F,B)=>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-${B}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(Ns,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:F.fileName||F.name})]}),e.jsx(se,{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-${B}`,onClick:()=>{O(F),I(!0)},children:"View"})]},B)),l.filter(F=>{var B,K;return((B=F.documentType)==null?void 0:B.toLowerCase().includes("security"))&&((K=F.documentType)==null?void 0:K.toLowerCase().includes("deposit"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})(),(()=>{const _=P("FIRST_FILL"),z=E.FIRST_FILL,T=(z==null?void 0:z.amount)||15e5;return e.jsx(Le,{className:jt("border-l-4",(_==null?void 0:_.status)==="Verified"?"border-l-green-500":(_==null?void 0:_.status)==="Rejected"?"border-l-red-500":"border-l-re-red"),"data-testid":"onboarding-payment-card-first-fill",children:e.jsxs(Fe,{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(no,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-semibold text-slate-700",children:"First Fill"})]}),e.jsx(Ce,{className:jt((_==null?void 0:_.status)==="Verified"?"bg-green-100 text-green-700 hover:bg-green-100":(_==null?void 0:_.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:(_==null?void 0:_.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((_==null?void 0:_.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:["₹",T.toLocaleString()]})]}),(_==null?void 0:_.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: ",_.paymentReference]}),_.verifiedAt&&e.jsx("span",{children:Gt(_.verifiedAt)})]}),(_==null?void 0:_.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:['"',_.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:[l.filter(F=>{var B,K;return((B=F.documentType)==null?void 0:B.toLowerCase().includes("first"))&&((K=F.documentType)==null?void 0:K.toLowerCase().includes("fill"))}).map((F,B)=>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-${B}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(Ns,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-[10px] font-medium text-slate-700 truncate",children:F.fileName||F.name})]}),e.jsx(se,{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-${B}`,onClick:()=>{O(F),I(!0)},children:"View"})]},B)),l.filter(F=>{var B,K;return((B=F.documentType)==null?void 0:B.toLowerCase().includes("first"))&&((K=F.documentType)==null?void 0:K.toLowerCase().includes("fill"))}).length===0&&e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"No proof uploaded"})]})]})]})]})})})()]})]}),e.jsx(qt,{value:"audit","data-testid":"onboarding-tab-content-audit",children:e.jsx(ap,{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:q?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…"})]}):G.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."}):G.map((_,z)=>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-${z}`,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(Ce,{variant:"outline",className:jt("shrink-0 text-[10px] font-semibold uppercase tracking-wide",Y(_.action)),"data-testid":`onboarding-audit-log-action-${z}`,children:String(_.action||"EVENT").replace(/_/g," ")}),_.stage?e.jsx("span",{className:"max-w-[200px] truncate text-[11px] text-slate-500",title:_.stage,"data-testid":`onboarding-audit-log-stage-${z}`,children:_.stage}):null]}),e.jsx("time",{className:"shrink-0 text-xs tabular-nums text-slate-400",dateTime:_.timestamp,"data-testid":`onboarding-audit-log-time-${z}`,children:Gt(_.timestamp)})]}),e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-slate-800","data-testid":`onboarding-audit-log-desc-${z}`,children:_.description||"—"}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(Ir,{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-${z}`,children:_.userName||"System"}),_.userEmail?e.jsxs("span",{className:"text-slate-400","data-testid":`onboarding-audit-log-email-${z}`,children:[" · ",_.userEmail]}):null]})]})]},_.id))})})})]})]})})}const ES={LOI:"LOI Documents",Statutory:"Statutory & Compliance",Architecture:"Architecture Inputs",FDD:"FDD / Financial",Other:"Other"};function UU(t){const s=String(t||"").toLowerCase();return s.startsWith("loi")?"LOI":s.startsWith("statutory")?"Statutory":s.startsWith("architecture")?"Architecture":s.startsWith("fdd")?"FDD":"Other"}function VU({open:t,onClose:s,applicationId:n,applicantName:r,documentConfigs:a,uploadedDocuments:l}){const[o,d]=g.useState(new Set),[m,f]=g.useState(14),[x,h]=g.useState(""),[p,u]=g.useState(!1),w=g.useMemo(()=>new Set((l||[]).map(C=>C.documentType)),[l]),v=g.useMemo(()=>{const C={LOI:[],Statutory:[],Architecture:[],FDD:[],Other:[]},S=new Set;for(const D of a||[])!(D!=null&&D.documentType)||S.has(D.documentType)||(S.add(D.documentType),C[UU(D.stageCode)].push(D));return C},[a]),N=C=>{d(S=>{const D=new Set(S);return D.has(C)?D.delete(C):D.add(C),D})},j=async()=>{const C=Array.from(o);if(C.length===0){ee.warning("Pick at least one document to request");return}u(!0);try{const S=await ds.requestProspectDocuments(n,{documentTypes:C,dueDays:m,customMessage:x.trim()||void 0}),D=((S==null?void 0:S.emailsSent)||[]).filter(L=>L.status==="sent"),R=((S==null?void 0:S.emailsSent)||[]).filter(L=>L.status==="failed"),A=(S==null?void 0:S.skippedAlreadyUploaded)||[];D.length>0?ee.success(`Sent ${D.length} email${D.length===1?"":"s"} to ${r}`+(A.length?` — ${A.length} already uploaded, skipped`:"")):A.length&&ee.info("No email sent — all selected documents were already uploaded."),R.length&&ee.error(`Some email categories failed: ${R.map(L=>L.category).join(", ")}`),d(new Set),h(""),s()}catch(S){ee.error((S==null?void 0:S.message)||"Failed to send document request")}finally{u(!1)}},y=Object.values(v).reduce((C,S)=>C+S.length,0);return e.jsx(ls,{open:t,onOpenChange:C=>{C||s()},children:e.jsxs(as,{className:"sm:max-w-2xl",children:[e.jsxs(fs,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(Dr,{className:"w-5 h-5 text-re-red"}),"Request Documents from Prospect"]}),e.jsxs(bs,{children:["Pick the documents you want ",r||"the prospect"," to upload. We'll send one email per category. Anything already uploaded is shown for context and skipped automatically."]})]}),y===0?e.jsxs("div",{className:"py-10 text-center text-slate-500 flex flex-col items-center gap-2",children:[e.jsx($I,{className:"w-8 h-8"}),e.jsx("p",{children:"No document configurations available for this application."})]}):e.jsx(ap,{className:"max-h-[55vh] pr-3",children:e.jsx("div",{className:"space-y-5",children:Object.keys(ES).map(C=>{const S=v[C];return S.length===0?null:e.jsxs("div",{className:"border rounded-lg p-3 bg-slate-50",children:[e.jsx("h4",{className:"font-medium text-slate-700 mb-2 text-sm uppercase tracking-wide",children:ES[C]}),e.jsx("div",{className:"space-y-2",children:S.map(D=>{const R=w.has(D.documentType);return e.jsxs("div",{className:`flex items-start gap-3 p-2 rounded ${R?"bg-green-50 border border-green-100":"bg-white border border-slate-200"}`,children:[R?e.jsx(Hn,{className:"w-5 h-5 text-green-600 mt-0.5 shrink-0"}):e.jsx(Tn,{id:`req-doc-${D.documentType}`,checked:o.has(D.documentType),onCheckedChange:()=>N(D.documentType),className:"mt-0.5"}),e.jsxs(de,{htmlFor:`req-doc-${D.documentType}`,className:`flex-1 cursor-pointer text-sm leading-snug ${R?"text-slate-500 line-through":"text-slate-800"}`,children:[e.jsx("span",{className:"font-medium",children:D.documentType}),D.isMandatory&&!R&&e.jsx(Ce,{className:"ml-2 bg-red-100 text-red-700 text-[10px]",children:"Mandatory"}),R&&e.jsx(Ce,{className:"ml-2 bg-green-100 text-green-700 text-[10px]",children:"Uploaded"}),D.description&&e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:D.description})]})]},`${C}-${D.documentType}`)})})]},C)})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 pt-2 border-t",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx(de,{htmlFor:"req-doc-due-days",className:"text-xs text-slate-600",children:"Due in (days)"}),e.jsx(at,{id:"req-doc-due-days",type:"number",min:1,max:60,value:m,onChange:C=>f(Math.max(1,Number(C.target.value)||14)),className:"mt-1"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(de,{htmlFor:"req-doc-message",className:"text-xs text-slate-600",children:"Custom message (optional)"}),e.jsx(Gs,{id:"req-doc-message",placeholder:"Add a short note for the prospect…",value:x,onChange:C=>h(C.target.value),rows:2,className:"mt-1"})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:s,disabled:p,children:"Cancel"}),e.jsx(se,{onClick:j,disabled:p||o.size===0,className:"bg-re-red hover:bg-re-red/90 text-white",children:p?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}),"Sending…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Send Request (",o.size,")"]})})]})]})})}const HU=new Set(["Security Deposit","Security Details","Payment Pending","LOI Issuance Pending","LOI Issued","Dealer Code Generation","Architecture Team Assigned","Architecture Document Upload","Architecture Team Completion","Statutory GST","Statutory PAN","Statutory Nodal","Statutory Check","Statutory Partnership","Statutory Firm Reg","Statutory Virtual Code","Statutory Domain","Statutory MSD","Statutory LOI Ack","LOA Pending"]),WU=new Set(["DD Admin","Super Admin","DD Lead","DD Head"]);function GU(t){var ie;const{application:s,permissions:n,getDeposit:r,isNonResponsive:a,isAdmin:l,currentUserStageAction:o,currentUserEvaluation:d,onOpenApproveModal:m,onOpenRejectModal:f,onOpenWorknote:x,onOpenScheduleModal:h,currentUser:p,handleGenerateDealerCodes:u,onOpenAssignArchitectureModal:w,onOpenAssignFdd:v,showAssignFddModal:N,setShowAssignFddModal:j,fddAgencies:y,selectedAgencyId:C,setSelectedAgencyId:S,isAssigningAgency:D,handleAssignAgency:R,activeInterviewForUser:A,hasSubmittedFeedback:L,setSelectedInterviewForFeedback:$,setShowKTMatrixModal:P,setShowLevel2FeedbackModal:E,setShowLevel3FeedbackModal:O,onGoToDashboard:I,showAssignModal:q,setShowAssignModal:G,selectedUser:Y,setSelectedUser:V,users:Q,participantType:_,setParticipantType:z,handleAddParticipant:T,isAssigningParticipant:F,documents:B=[],documentConfigs:K=[]}=t,[W,H]=g.useState(!1),X=(p==null?void 0:p.roleCode)||(p==null?void 0:p.role)||"",J=WU.has(X)&&HU.has((s==null?void 0:s.status)||"");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{"data-testid":"onboarding-details-summary-card",children:[e.jsx(Qe,{children:e.jsx(et,{children:"Summary"})}),e.jsxs(Fe,{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(Ce,{className:jt("mt-1",Jb(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(uc,{value:s.progress,className:"flex-1 bg-red-50",indicatorClassName:vi(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:Gt(s.deadline)})]})]})]}),(s.isShortlisted!==!1||s.status==="Submitted")&&e.jsxs(Le,{"data-testid":"onboarding-details-actions-card",children:[e.jsx(Qe,{children:e.jsx(et,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[n.isLoaLocked&&e.jsxs(di,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-loa-locked-alert",children:[e.jsx(ay,{className:"w-4 h-4 text-re-red"}),e.jsx(Ti,{className:"text-red-900 font-semibold",children:"LOA approval locked"}),e.jsxs(ui,{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."]})]}),((ie=r("FIRST_FILL"))==null?void 0:ie.status)==="Verified"&&s.status!=="LOA Pending"&&!["LOA Issued","EOR In Progress","EOR Complete","Inauguration","Approved","Onboarded","Rejected"].includes(s.status)&&e.jsxs(di,{className:"mb-4 border-violet-200 bg-violet-50/90 text-violet-950","data-testid":"onboarding-details-first-fill-verified-alert",children:[e.jsx(_a,{className:"h-4 w-4 text-violet-700"}),e.jsx(Ti,{className:"font-semibold",children:"First Fill verified on file"}),e.jsxs(ui,{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(di,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-security-locked-alert",children:[e.jsx(ay,{className:"w-4 h-4 text-re-red"}),e.jsx(Ti,{className:"text-red-900 font-semibold",children:"Security Deposit approval locked"}),e.jsxs(ui,{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(di,{className:"mb-4 border-sky-200 bg-sky-50/90 text-sky-900","data-testid":"onboarding-details-security-review-alert",children:[e.jsx(_a,{className:"h-4 w-4 text-sky-700"}),e.jsx(Ti,{className:"text-sky-950 font-semibold",children:"Security Deposit review"}),e.jsxs(ui,{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&&l&&e.jsxs(di,{variant:"destructive",className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-non-responsive-alert",children:[e.jsx(an,{className:"w-4 h-4 text-red-600"}),e.jsx(Ti,{className:"text-red-900 font-black uppercase tracking-tighter",children:"⚠️ Non-Responsive Flag"}),e.jsx(ui,{className:"text-red-800 text-xs font-bold leading-tight",children:"FDD Audit has flagged this applicant. Review audit logs before approval."})]}),l&&(s.status==="Level 3 Approved"||s.status==="FDD Verification")&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(di,{className:"mb-4 bg-red-50 border-red-200 text-red-800","data-testid":"onboarding-details-fdd-assignment-alert",children:[e.jsx(an,{className:"w-4 h-4 text-re-red"}),e.jsx(Ti,{className:"text-red-900 font-bold",children:"FDD Assignment Required"}),e.jsx(ui,{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(se,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:m,"data-testid":"onboarding-details-approve-button",children:[e.jsx(fn,{className:"w-4 h-4 mr-2"}),["Inauguration","Approved"].includes(s.status)?"Onboard Dealer":"Approve"]}),n.canReject&&e.jsxs(se,{variant:"destructive",className:"w-full font-bold",onClick:f,"data-testid":"onboarding-details-reject-button",children:[e.jsx(mi,{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(tc,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:x,"data-testid":"onboarding-details-worknote-button",children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"Work Note"]}),n.canSchedule&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:h,"data-testid":"onboarding-details-schedule-button",children:[e.jsx(dr,{className:"w-4 h-4 mr-2"}),"Schedule Interview"]}),J&&e.jsxs(se,{variant:"outline",className:"w-full border-amber-300 hover:bg-amber-50 text-amber-700",onClick:()=>H(!0),"data-testid":"onboarding-details-request-documents",children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"Request Documents"]}),p&&["DD Admin","Super Admin"].includes(p.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(se,{className:"w-full bg-re-red hover:bg-re-red-hover",onClick:u,"data-testid":"onboarding-details-generate-dealer-codes",children:[e.jsx(E1,{className:"w-4 h-4 mr-2"}),"Generate Dealer Codes"]}),s.dealerCode&&!s.architectureAssignedTo&&e.jsxs(se,{variant:"outline",className:"w-full border-red-200 hover:bg-red-50 text-re-red",onClick:w,"data-testid":"onboarding-details-assign-architecture",children:[e.jsx(ry,{className:"w-4 h-4 mr-2"}),"Assign Architecture Team"]})]}),l&&["Level 3 Approved","Level 3 Recommended","FDD Verification","FDD In Progress"].includes(s.status)&&(!s.fddAssignments||s.fddAssignments.length===0)&&e.jsxs(ls,{open:N,onOpenChange:j,children:[e.jsxs(se,{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(ok,{className:"w-4 h-4 mr-2"}),"Assign FDD"]}),e.jsxs(as,{"data-testid":"onboarding-details-assign-fdd-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Assign FDD Agency"}),e.jsx(bs,{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(de,{children:"FDD Agency"}),e.jsxs(At,{value:C,onValueChange:S,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-details-assign-fdd-select",children:e.jsx(kt,{placeholder:y!=null&&y.length?"Choose partner agency...":"No agencies available"})}),e.jsx(Rt,{children:(y||[]).map(ae=>e.jsxs(Me,{value:ae.id,children:[ae.fullName||ae.name," (",ae.email,")"]},ae.id))})]})]}),e.jsx(se,{className:"w-full bg-re-red hover:bg-re-red-hover font-bold h-11",onClick:R,disabled:D||!C,"data-testid":"onboarding-details-assign-fdd-submit",children:D?"Assigning...":"Assign Agency"})]})]})]}),A&&!L&&e.jsxs(Nb,{children:[e.jsx(wb,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-feedback-dropdown-trigger",children:[e.jsx(nM,{className:"w-4 h-4 mr-2"}),"Interview Feedback",e.jsx(Aa,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(Sb,{className:"w-56","data-testid":"onboarding-details-feedback-dropdown-content",children:e.jsxs(FD,{"data-testid":`onboarding-details-feedback-item-${A.id}`,onClick:()=>{$(A),A.level===1?P(!0):A.level===2?E(!0):O(!0)},children:["Level ",A.level," - ",A.interviewType]},A.id)})]}),s.status==="Questionnaire Pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-send-reminder",children:[e.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Send Reminder"]}),e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-extend-deadline",children:[e.jsx(yn,{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(fn,{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(se,{className:"w-full bg-green-600 hover:bg-green-700 text-white",onClick:I,"data-testid":"onboarding-details-goto-dashboard",children:[e.jsx(E1,{className:"w-4 h-4 mr-2"}),"Go to Dealer Dashboard"]})]}),p&&["DD Admin","Super Admin"].includes(p.role)&&e.jsxs(ls,{open:q,onOpenChange:G,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{variant:"outline",className:"w-full","data-testid":"onboarding-details-assign-user-trigger",children:[e.jsx(Ir,{className:"w-4 h-4 mr-2"}),"Assign User"]})}),e.jsxs(as,{"data-testid":"onboarding-details-assign-user-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Assign User to Application"}),e.jsx(bs,{children:"Select a user and their role for this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Select User"}),e.jsxs(At,{value:Y,onValueChange:V,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-details-assign-user-select",children:e.jsx(kt,{placeholder:"Search users..."})}),e.jsx(Rt,{children:Q.map(ae=>e.jsxs(Me,{value:ae.id,children:[ae.fullName," (",ae.email,")"]},ae.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Assignment Role"}),e.jsxs(At,{value:_,onValueChange:z,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-details-assign-role-select",children:e.jsx(kt,{placeholder:"Select role"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"owner",children:"Owner"}),e.jsx(Me,{value:"contributor",children:"Contributor"}),e.jsx(Me,{value:"reviewer",children:"Reviewer"})]})]})]}),e.jsx(se,{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"})]})]})]})]})]}),e.jsx(VU,{open:W,onClose:()=>H(!1),applicationId:(s==null?void 0:s.id)||"",applicantName:(s==null?void 0:s.name)||(s==null?void 0:s.applicantName)||"the prospect",documentConfigs:K,uploadedDocuments:B})]})}function KU(t){const{application:s,fetchApplication:n,showApproveModal:r,setShowApproveModal:a,approvalRemark:l,setApprovalRemark:o,setApprovalFile:d,isApproving:m,handleApprove:f,showOnboardModal:x,setShowOnboardModal:h,isOnboarding:p,setIsOnboarding:u,showRejectModal:w,setShowRejectModal:v,rejectionReason:N,setRejectionReason:j,isRejecting:y,handleReject:C,showScheduleModal:S,setShowScheduleModal:D,showCancelInterviewModal:R,setShowCancelInterviewModal:A,setInterviewIdToCancel:L,isCancellingInterview:$,handleConfirmCancelInterview:P,interviewToReschedule:E,setInterviewToReschedule:O,interviewType:I,setInterviewType:q,interviewMode:G,setInterviewMode:Y,interviewDate:V,setInterviewDate:Q,meetingLink:_,setMeetingLink:z,location:T,setLocation:F,isInterviewCompleted:B,isInterviewActive:K,users:W,selectedInterviewerId:H,setSelectedInterviewerId:X,handleAddInterviewer:J,scheduledInterviewParticipants:ie,handleRemoveInterviewer:ae,isScheduling:xe,handleScheduleInterview:ce,showAssignArchitectureModal:we,setShowAssignArchitectureModal:ke,architectureLeadId:Xe,setArchitectureLeadId:Ot,isAssigningArchitecture:bt,handleAssignArchitecture:te,showArchitectureStatusModal:ve,setShowArchitectureStatusModal:qe,architectureStatus:ge,setArchitectureStatus:Be,architectureRemarks:ut,setArchitectureRemarks:ht,isUpdatingArchitecture:it,handleUpdateArchitectureStatus:Tt}=t,It=he=>{var vt,mt;return(he==null?void 0:he.__stageRole)||((vt=he==null?void 0:he.role)==null?void 0:vt.roleName)||((mt=he==null?void 0:he.role)==null?void 0:mt.roleCode)||(he==null?void 0:he.roleCode)||(he==null?void 0:he.role)||"Panelist"};return e.jsxs(e.Fragment,{children:[e.jsx(ls,{open:r,onOpenChange:a,children:e.jsxs(as,{"data-testid":"onboarding-approve-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Approve Application"}),e.jsx(bs,{children:"Provide approval remarks and optionally attach supporting documents."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Remark ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Gs,{placeholder:"Enter approval remarks...",value:l,onChange:he=>o(he.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-approve-remark-textarea"})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Attach File (Optional)"}),e.jsx(at,{type:"file",className:"mt-2",onChange:he=>d(he.target.files?he.target.files[0]:null),"data-testid":"onboarding-approve-file-input"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>a(!1),disabled:m,"data-testid":"onboarding-approve-cancel-button",children:"Cancel"}),e.jsx(se,{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(es,{className:"w-4 h-4 mr-2 animate-spin"}),"Approving..."]}):"Submit Approval"})]})]})]})}),e.jsx(ls,{open:x,onOpenChange:h,children:e.jsxs(as,{className:"max-w-md","data-testid":"onboarding-onboard-modal",children:[e.jsxs(fs,{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(fn,{className:"w-8 h-8 text-green-600"})}),e.jsx(us,{className:"text-center text-xl font-bold",children:"Finalize Onboarding"}),e.jsxs(bs,{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(Wn,{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(Wn,{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(Wn,{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(se,{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 ds.createDealer({applicationId:s.id}),ee.success("Dealer profile and login account created successfully!"),h(!1),n()}catch{ee.error("Failed to create dealer profile")}finally{u(!1)}},disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-5 h-5 mr-2 animate-spin"}),"Processing Onboarding..."]}):"Confirm & Onboard Dealer"}),e.jsx(se,{variant:"ghost",className:"w-full text-slate-500 hover:text-slate-700",onClick:()=>h(!1),disabled:p,"data-testid":"onboarding-onboard-cancel-button",children:"Cancel"})]})]})}),e.jsx(ls,{open:w,onOpenChange:v,children:e.jsxs(as,{"data-testid":"onboarding-reject-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Reject Application"}),e.jsx(bs,{children:"Please provide a clear reason for rejecting this application."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{children:["Reason for Rejection ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Gs,{placeholder:"Enter rejection reason...",value:N,onChange:he=>j(he.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-reject-remark-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>v(!1),disabled:y,"data-testid":"onboarding-reject-cancel-button",children:"Cancel"}),e.jsx(se,{variant:"destructive",className:"flex-1",onClick:C,disabled:y,"data-testid":"onboarding-reject-submit-button",children:y?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}),"Rejecting..."]}):"Confirm Rejection"})]})]})]})}),e.jsx(ls,{open:S,onOpenChange:he=>{D(he),he||O(null)},children:e.jsxs(as,{"data-testid":"onboarding-schedule-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:E?"Reschedule Interview":"Schedule Interview"}),e.jsx(bs,{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(de,{children:"Interview Type"}),e.jsxs(At,{value:I,onValueChange:q,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-schedule-type-select",children:e.jsx(kt,{placeholder:"Select interview type"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"level1",disabled:B(1)||K(1),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 1"}),B(1)&&e.jsx(fn,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(1)&&e.jsx(yn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Me,{value:"level2",disabled:!B(1)||B(2)||K(2),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 2"}),!B(1)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L1)"}),B(2)&&e.jsx(fn,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(2)&&e.jsx(yn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})}),e.jsx(Me,{value:"level3",disabled:!B(2)||B(3)||K(3),children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{children:"Level 3"}),!B(2)&&e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"(Prerequisite: L2)"}),B(3)&&e.jsx(fn,{className:"w-4 h-4 text-green-500 ml-2 inline"}),K(3)&&e.jsx(yn,{className:"w-4 h-4 text-re-red ml-2 inline"})]})})]})]})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interview Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:G,onValueChange:Y,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-schedule-mode-select",children:e.jsx(kt,{placeholder:"Select interview mode"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"virtual",children:"Virtual"}),e.jsx(Me,{value:"physical",children:"Physical"})]})]})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Date & Time ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"datetime-local",className:"mt-2",value:V,onChange:he=>Q(he.target.value),"data-testid":"onboarding-schedule-date-input"})]}),G==="virtual"&&e.jsxs("div",{children:[e.jsx(de,{children:"Meeting Link"}),e.jsx(at,{placeholder:"https://meet.google.com/...",className:"mt-2",value:_,onChange:he=>z(he.target.value),"data-testid":"onboarding-schedule-link-input"})]}),G==="physical"&&e.jsxs("div",{children:[e.jsx(de,{children:"Location"}),e.jsx(at,{placeholder:"Enter interview location address",className:"mt-2",value:T,onChange:he=>F(he.target.value),"data-testid":"onboarding-schedule-location-input"})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interviewers ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(At,{value:H,onValueChange:X,children:[e.jsx(Dt,{className:"flex-1","data-testid":"onboarding-schedule-interviewer-select",children:e.jsx(kt,{placeholder:"Select interviewer"})}),e.jsx(Rt,{children:W.map(he=>{var vt;return e.jsxs(Me,{value:he.id,children:[he.fullName||he.name," (",((vt=he.role)==null?void 0:vt.roleName)||he.roleCode,")"]},he.id)})})]}),e.jsx(se,{onClick:J,type:"button",variant:"secondary","data-testid":"onboarding-schedule-add-interviewer-button",children:"Add"})]}),ie.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(de,{className:"text-xs text-muted-foreground",children:"Selected Interviewers:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ie.map(he=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-2 py-1 rounded text-sm","data-testid":`onboarding-schedule-participant-${he.id}`,children:[e.jsx("span",{children:he.fullName||he.name||"Unknown"}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",It(he),")"]}),e.jsx("button",{onClick:()=>ae(he.id),className:"text-muted-foreground hover:text-destructive","data-testid":`onboarding-schedule-remove-participant-${he.id}`,children:"×"})]},he.id))})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>{D(!1),O(null)},disabled:xe,"data-testid":"onboarding-schedule-cancel-button",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-primary-600 hover:bg-primary-700",onClick:ce,disabled:xe,"data-testid":"onboarding-schedule-submit-button",children:xe?E?"Rescheduling...":"Scheduling...":E?"Reschedule":"Schedule"})]})]})]})}),e.jsx(ls,{open:R,onOpenChange:he=>{A(he),he||L("")},children:e.jsxs(as,{"data-testid":"onboarding-cancel-interview-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Cancel Interview"}),e.jsx(bs,{children:"Are you sure you want to cancel this interview?"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>{A(!1),L("")},disabled:$,"data-testid":"onboarding-cancel-interview-close",children:"No"}),e.jsx(se,{variant:"destructive",className:"flex-1",onClick:P,disabled:$,"data-testid":"onboarding-cancel-interview-confirm",children:$?"Cancelling...":"Yes, Cancel"})]})]})}),e.jsx(ls,{open:we,onOpenChange:ke,children:e.jsxs(as,{"data-testid":"onboarding-architecture-assign-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Assign Architecture Team"}),e.jsx(bs,{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(de,{children:["Select Architecture Lead ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:Xe,onValueChange:Ot,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-architecture-lead-select",children:e.jsx(kt,{placeholder:"Search users..."})}),e.jsxs(Rt,{children:[W.filter(he=>{var vt;return he.roleCode==="ARCHITECTURE"||((vt=he.role)==null?void 0:vt.roleCode)==="ARCHITECTURE"||he.role==="Architecture"||he.role==="Architecture Team"}).map(he=>e.jsxs(Me,{value:he.id,children:[he.fullName," (",he.email,")"]},he.id)),W.filter(he=>{var vt;return he.roleCode==="ARCHITECTURE"||((vt=he.role)==null?void 0:vt.roleCode)==="ARCHITECTURE"||he.role==="Architecture"||he.role==="Architecture Team"}).length===0&&W.map(he=>e.jsxs(Me,{value:he.id,children:[he.fullName," (",he.roleCode||he.role,")"]},he.id))]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>ke(!1),disabled:bt,"data-testid":"onboarding-architecture-assign-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:te,disabled:bt,"data-testid":"onboarding-architecture-assign-submit",children:bt?"Assigning...":"Assign Team"})]})]})]})}),e.jsx(ls,{open:ve,onOpenChange:qe,children:e.jsxs(as,{"data-testid":"onboarding-architecture-status-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Update Architecture Status"}),e.jsx(bs,{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(de,{children:["Status ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:ge,onValueChange:Be,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-architecture-status-select",children:e.jsx(kt,{placeholder:"Select status"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"COMPLETED",children:"Completed"}),e.jsx(Me,{value:"REJECTED",children:"Rejected / Needs Revision"})]})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Remarks (Optional)"}),e.jsx(Gs,{placeholder:"Enter any planning or site-visit remarks...",value:ut,onChange:he=>ht(he.target.value),className:"mt-2",rows:4,"data-testid":"onboarding-architecture-remarks-textarea"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>qe(!1),disabled:it,"data-testid":"onboarding-architecture-status-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-blue-600 hover:bg-blue-700",onClick:Tt,disabled:it,"data-testid":"onboarding-architecture-status-submit",children:it?"Updating...":"Update Status"})]})]})]})})]})}function YU(t){var Xs,Js,Ws,Z,oe,Ne,Oe,De;const{application:s,ktCriteria:n,l2Fields:r,l3Fields:a,showKTMatrixModal:l,setShowKTMatrixModal:o,ktMatrixSelectedValues:d,handleKTMatrixChange:m,ktMatrixRemarks:f,setKtMatrixRemarks:x,ktMatrixRecommendation:h,setKtMatrixRecommendation:p,calculateKTScore:u,handleSubmitKTMatrix:w,isSubmittingKT:v,showLevel2FeedbackModal:N,setShowLevel2FeedbackModal:j,level2Feedback:y,handleLevel2Change:C,level2Recommendation:S,setLevel2Recommendation:D,handleSubmitLevel2Feedback:R,isSubmittingLevel2:A,showFeedbackDetailsModal:L,setShowFeedbackDetailsModal:$,selectedEvaluationForView:P,selectedInterviewForFeedback:E,showLevel3FeedbackModal:O,setShowLevel3FeedbackModal:I,level3Feedback:q,handleLevel3Change:G,level3Recommendation:Y,setLevel3Recommendation:V,handleSubmitLevel3Feedback:Q,isSubmittingLevel3:_,showDocumentsModal:z,setShowDocumentsModal:T,showUploadForm:F,setShowUploadForm:B,selectedStage:K,getDocumentsForStage:W,setPreviewDoc:H,setShowPreviewModal:X,uploadDocType:J,setUploadDocType:ie,setUploadFile:ae,isUploading:xe,handleUpload:ce,uploadFile:we,showPreviewModal:ke,previewDoc:Xe,showFddFinalizeModal:Ot,setShowFddFinalizeModal:bt,currentUser:te,fddAuditRecommendation:ve,setFddAuditRecommendation:qe,fddAuditFindings:ge,setFddAuditFindings:Be,isFinalizingFdd:ut,setIsFinalizingFdd:ht,fetchApplication:it,showFddFlagModal:Tt,setShowFddFlagModal:It,isFddFlagging:he,setIsFddFlagging:vt,showFirmTypeModal:mt,setShowFirmTypeModal:_e,tempFirmType:Vt,setTempFirmType:Et,updatingFirmType:Ds,handleUpdateFirmType:ln}=t,Bs=E!=null&&E.scheduleDate?new Date(E.scheduleDate).toISOString().split("T")[0]:"",Ys=(te==null?void 0:te.fullName)||(te==null?void 0:te.name)||"";return e.jsxs(e.Fragment,{children:[e.jsx(ls,{open:l,onOpenChange:o,children:e.jsxs(as,{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(fs,{className:"shrink-0 space-y-2 border-b px-5 py-4 text-left",children:[e.jsx(us,{className:"text-base",children:"KT matrix"}),e.jsxs(bs,{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((ye,Ve)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{htmlFor:`kt-matrix-${Ve}`,className:"block text-sm font-medium leading-relaxed text-foreground",children:[e.jsxs("span",{className:"text-muted-foreground",children:[Ve+1,"."]})," ",ye.name," ",e.jsx("span",{className:"text-red-500",children:"*"})," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",ye.weight,"%)"]})]}),e.jsxs(At,{value:d[ye.name]??void 0,onValueChange:Ge=>{const st=ye.options.find(Kt=>Kt.value===Ge);st&&m(ye.name,st.value,st.score)},children:[e.jsx(Dt,{id:`kt-matrix-${Ve}`,className:"h-10 w-full text-left text-sm font-normal","data-testid":`onboarding-kt-matrix-select-${Ve}`,children:e.jsx(kt,{placeholder:"Choose an option…"})}),e.jsx(Rt,{position:"popper",className:"max-h-72 w-[var(--radix-select-trigger-width)]",children:ye.options.map(Ge=>e.jsxs(Me,{value:Ge.value,className:"py-2.5 text-sm leading-snug","data-testid":`onboarding-kt-matrix-option-${Ve}-${Ge.value}`,children:[Ge.label," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",Ge.score,")"]})]},Ge.value))})]})]},ye.name)),e.jsxs("div",{className:"space-y-2 border-t border-border pt-6",children:[e.jsxs(de,{htmlFor:"kt-matrix-remarks",className:"text-sm font-medium",children:["Remarks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Gs,{id:"kt-matrix-remarks",placeholder:"Enter remarks...",className:"min-h-[96px] resize-y text-sm leading-relaxed",value:f,onChange:ye=>x(ye.target.value),"data-testid":"onboarding-kt-matrix-remarks-textarea"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{className:"text-sm font-medium",children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:h,onValueChange:p,children:[e.jsx(Dt,{"data-testid":"onboarding-kt-matrix-recommendation-select",children:e.jsx(kt,{placeholder:"Select recommendation"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Approve",children:"Approve"}),e.jsx(Me,{value:"Reject",children:"Reject"}),e.jsx(Me,{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(se,{variant:"outline",onClick:()=>o(!1),"data-testid":"onboarding-kt-matrix-cancel",children:"Cancel"}),e.jsx(se,{onClick:w,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(ls,{open:N,onOpenChange:j,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level2-feedback-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Level 2 Interview Feedback"}),e.jsx(bs,{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(de,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"date",className:"mt-2",value:y.interviewDate||Bs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{placeholder:"Enter your name",className:"mt-2",value:y.interviewerName||Ys,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:y.overallScore,onValueChange:ye=>C("overallScore",ye),children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-level2-overall-score-select",children:e.jsx(kt,{placeholder:"Select score"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Me,{value:"8",children:"Excellent (7-8)"}),e.jsx(Me,{value:"6",children:"Good (5-6)"}),e.jsx(Me,{value:"4",children:"Average (3-4)"}),e.jsx(Me,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsx(tc,{}),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((ye,Ve)=>e.jsxs("div",{children:[e.jsxs(de,{children:[ye.label,ye.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),ye.type==="select"?e.jsxs(At,{value:y[ye.itemKey]||"",onValueChange:Ge=>C(ye.itemKey,Ge),children:[e.jsx(Dt,{className:"mt-2",children:e.jsx(kt,{placeholder:`Select ${ye.label}...`})}),e.jsx(Rt,{children:(ye.options||[]).map((Ge,st)=>e.jsx(Me,{value:Ge.optionValue||Ge.value,children:Ge.optionLabel||Ge.label},st))})]}):ye.type==="number"?e.jsx(at,{type:"number",className:"mt-2",value:y[ye.itemKey]||"",onChange:Ge=>C(ye.itemKey,Ge.target.value)}):e.jsx(Gs,{placeholder:`Enter ${ye.label.toLowerCase()}...`,className:"mt-2",rows:3,value:y[ye.itemKey]||"",onChange:Ge=>C(ye.itemKey,Ge.target.value)})]},ye.itemKey||Ve)),e.jsxs("div",{children:[e.jsxs(de,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:S,onValueChange:D,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-level2-recommendation-select",children:e.jsx(kt,{placeholder:"Select recommendation"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Approve",children:"Approve"}),e.jsx(Me,{value:"Reject",children:"Reject"}),e.jsx(Me,{value:"Hold",children:"Hold"})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>j(!1),"data-testid":"onboarding-level2-feedback-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:R,disabled:A||r.length===0,"data-testid":"onboarding-level2-feedback-submit",children:A?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ls,{open:L,onOpenChange:$,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-feedback-details-modal",children:[e.jsx(fs,{children:e.jsx(us,{children:"Interview Feedback Details"})}),P&&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:(Xs=P.evaluator)==null?void 0:Xs.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:((Ws=(Js=P.evaluator)==null?void 0:Js.role)==null?void 0:Ws.roleName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-500",children:((Z=P.interview)==null?void 0:Z.level)===1?"Score (KT Matrix)":"Overall Score"}),e.jsx("p",{className:"font-bold text-lg","data-testid":"onboarding-feedback-details-score",children:P.ktMatrixScore?`${P.ktMatrixScore}/${((oe=P.interview)==null?void 0:oe.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(Ce,{variant:(Ne=P.recommendation)!=null&&Ne.toLowerCase().includes("reject")?"destructive":(Oe=P.recommendation)!=null&&Oe.toLowerCase().includes("hold")?"secondary":"default","data-testid":"onboarding-feedback-details-recommendation",children:P.recommendation||"N/A"})]})]}),e.jsx(tc,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Detailed Feedback"}),((De=P.feedbackDetails)==null?void 0:De.length)>0?e.jsx("div",{className:"space-y-4",children:P.feedbackDetails.map((ye,Ve)=>e.jsxs("div",{className:"border-b last:border-0 pb-3 last:pb-0","data-testid":`onboarding-feedback-detail-item-${Ve}`,children:[e.jsx("p",{className:"font-medium text-slate-900",children:ye.feedbackType}),e.jsx("p",{className:"text-slate-700 mt-1 whitespace-pre-wrap text-sm",children:ye.comments})]},Ve))}):e.jsx("p",{className:"text-slate-500 italic",children:"No detailed feedback available."})]})]})]})}),e.jsx(ls,{open:O,onOpenChange:I,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"onboarding-level3-feedback-modal",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Level 3 Interview Feedback"}),e.jsx(bs,{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(de,{children:["Interview Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"date",className:"mt-2",value:q.interviewDate||Bs,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Interviewer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{placeholder:"Enter your name",className:"mt-2",value:q.interviewerName||Ys,disabled:!0})]}),e.jsxs("div",{children:[e.jsxs(de,{children:["Overall Performance Score ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:q.overallScore,onValueChange:ye=>G("overallScore",ye),children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-level3-overall-score-select",children:e.jsx(kt,{placeholder:"Select score"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"10",children:"Outstanding (9-10)"}),e.jsx(Me,{value:"8",children:"Excellent (7-8)"}),e.jsx(Me,{value:"6",children:"Good (5-6)"}),e.jsx(Me,{value:"4",children:"Average (3-4)"}),e.jsx(Me,{value:"2",children:"Below Average (1-2)"})]})]})]}),e.jsx(tc,{}),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((ye,Ve)=>e.jsxs("div",{children:[e.jsxs(de,{children:[ye.label,ye.isRequired&&e.jsx("span",{className:"text-red-500",children:"*"})]}),ye.type==="select"?e.jsxs(At,{value:q[ye.itemKey]||"",onValueChange:Ge=>G(ye.itemKey,Ge),children:[e.jsx(Dt,{className:"mt-2",children:e.jsx(kt,{placeholder:`Select ${ye.label}...`})}),e.jsx(Rt,{children:(ye.options||[]).map((Ge,st)=>e.jsx(Me,{value:Ge.optionValue||Ge.value,children:Ge.optionLabel||Ge.label},st))})]}):ye.type==="number"?e.jsx(at,{type:"number",className:"mt-2",value:q[ye.itemKey]||"",onChange:Ge=>G(ye.itemKey,Ge.target.value)}):e.jsx(Gs,{placeholder:`Enter ${ye.label.toLowerCase()}...`,className:"mt-2",rows:3,value:q[ye.itemKey]||"",onChange:Ge=>G(ye.itemKey,Ge.target.value)})]},ye.itemKey||Ve)),e.jsxs("div",{children:[e.jsxs(de,{children:["Recommendation ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:Y,onValueChange:V,children:[e.jsx(Dt,{className:"mt-2","data-testid":"onboarding-level3-recommendation-select",children:e.jsx(kt,{placeholder:"Select recommendation"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Approve",children:"Approve"}),e.jsx(Me,{value:"Reject",children:"Reject"}),e.jsx(Me,{value:"Hold",children:"Hold"})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>I(!1),"data-testid":"onboarding-level3-feedback-cancel",children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-black hover:bg-zinc-800 text-white",onClick:Q,disabled:_||a.length===0,"data-testid":"onboarding-level3-feedback-submit",children:_?"Submitting...":"Submit Feedback"})]})]})]})}),e.jsx(ls,{open:z,onOpenChange:ye=>{T(ye),ye||B(!1)},children:e.jsxs(as,{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(fs,{className:"pb-4",children:[e.jsxs(us,{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Documents - ",K||"General"]}),e.jsx(bs,{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(de,{className:"text-slate-700 font-semibold px-1",children:["Document Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{type:"text",placeholder:"Enter document name",value:J,onChange:ye=>ie(ye.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(de,{className:"text-slate-700 font-semibold px-1",children:["Select File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{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:ye=>{const Ve=ye.target.files?ye.target.files[0]:null;if(ae(Ve),Ve){const Ge=Ve.name.replace(/\.[^/.]+$/,"");ie(Ge)}},"data-testid":"onboarding-documents-file-input"})]})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-4",children:[e.jsx(se,{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:()=>B(!1),disabled:xe,"data-testid":"onboarding-documents-upload-cancel",children:"Cancel"}),e.jsx(se,{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(),B(!1)},disabled:!we||!J||xe,"data-testid":"onboarding-documents-upload-submit",children:xe?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(or,{className:"w-5 h-5"}),"Confirm Upload"]})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 space-y-4",children:[W(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(Ps,{className:"w-full table-auto",children:[e.jsx(Os,{className:"bg-slate-50/80 sticky top-0 z-10",children:e.jsxs(lt,{className:"hover:bg-transparent border-b",children:[e.jsx(fe,{className:"w-[45%] min-w-[150px] font-semibold text-slate-900 py-3",children:"Document Name"}),e.jsx(fe,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Type"}),e.jsx(fe,{className:"w-[15%] min-w-[100px] font-semibold text-slate-900 py-3",children:"Upload Date"}),e.jsx(fe,{className:"w-[15%] min-w-[140px] font-semibold text-slate-900 py-3",children:"Uploaded By"}),e.jsx(fe,{className:"text-right w-[10%] min-w-[80px] font-semibold text-slate-900 py-3",children:"Actions"})]})}),e.jsx(Ls,{children:W(K||"").map((ye,Ve)=>{var Ge,st;return e.jsxs(lt,{className:"hover:bg-slate-50/50 transition-colors","data-testid":`onboarding-document-row-${Ve}`,children:[e.jsx(ue,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate font-medium text-slate-700",title:ye.fileName,"data-testid":`onboarding-document-name-${Ve}`,children:ye.fileName})]})}),e.jsx(ue,{className:"py-3",children:e.jsx(Ce,{variant:"outline",className:"capitalize whitespace-nowrap font-normal border-slate-200 bg-white","data-testid":`onboarding-document-type-${Ve}`,children:((Ge=ye.documentType)==null?void 0:Ge.toLowerCase())||"Other"})}),e.jsx(ue,{className:"py-3 whitespace-nowrap text-slate-600",children:Gt(ye.createdAt)}),e.jsx(ue,{className:"py-3 text-slate-600",children:((st=ye.uploader)==null?void 0:st.fullName)||(ye.uploadedBy?"System User":"Applicant")}),e.jsx(ue,{className:"text-right py-3",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-full",onClick:()=>{H(ye),X(!0)},"data-testid":`onboarding-document-preview-${Ve}`,children:e.jsx(bn,{className:"w-4 h-4"})}),e.jsx(se,{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/${ye.filePath}`,"_blank")},"data-testid":`onboarding-document-download-${Ve}`,children:e.jsx(Ni,{className:"w-4 h-4"})})]})})]},ye.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(Ns,{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(se,{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:()=>B(!0),"data-testid":"onboarding-documents-upload-button",children:[e.jsx(or,{className:"w-5 h-5 mr-3"}),"Upload Document"]}),e.jsx(se,{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(mo,{isOpen:ke,onClose:()=>X(!1),document:Xe}),e.jsx(ls,{open:Ot,onOpenChange:bt,children:e.jsxs(as,{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(no,{className:"w-10 h-10 text-re-red"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white",children:[e.jsxs(fs,{children:[e.jsx(us,{className:"text-2xl font-black text-slate-900 text-center tracking-tight",children:"Finalize FDD Audit"}),e.jsxs(bs,{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:[(te==null?void 0:te.role)!=="FDD"&&(te==null?void 0:te.roleCode)!=="FDD"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{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(ye=>e.jsx(se,{variant:ve===ye?"default":"outline",className:jt("flex-1 h-10 font-bold text-[9px] uppercase tracking-wider rounded-xl transition-all",ve===ye&&ye==="Recommended"&&"bg-emerald-600 hover:bg-emerald-700",ve===ye&&ye==="Qualified with Observations"&&"bg-red-500 hover:bg-re-red",ve===ye&&ye==="Not Recommended"&&"bg-red-600 hover:bg-red-700"),onClick:()=>qe(ye),"data-testid":`onboarding-fdd-recommendation-${ye.replace(/\s+/g,"-").toLowerCase()}`,children:ye},ye))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-[10px] font-black uppercase tracking-widest text-slate-400",children:"Findings Summary"}),e.jsx(Gs,{placeholder:"Summarize key financial findings or discrepancies...",className:"min-h-[100px] rounded-xl border-slate-200 focus:ring-re-red text-sm",value:ge,onChange:ye=>Be(ye.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(_a,{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(se,{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:()=>bt(!1),disabled:ut,"data-testid":"onboarding-fdd-finalize-cancel",children:"Cancel"}),e.jsx(se,{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:ut||!ge,"data-testid":"onboarding-fdd-finalize-submit",onClick:async()=>{try{ht(!0),await ds.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Approved",remarks:(te==null?void 0:te.role)==="FDD"||(te==null?void 0:te.roleCode)==="FDD"?`Findings: ${ge}`:`[RECOMMENDATION: ${ve}]
|
||
Findings: ${ge}`,nextStatus:"LOI In Progress",nextProgress:65}),ee.success("FDD Audit finalized and submitted."),bt(!1),it()}catch{ee.error("Submission failed")}finally{ht(!1)}},children:ut?e.jsx(es,{className:"w-5 h-5 animate-spin"}):"Confirm & Submit"})]})]})]})}),e.jsx(ls,{open:Tt,onOpenChange:It,children:e.jsxs(as,{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(xk,{className:"w-10 h-10 text-red-500"})})]}),e.jsxs("div",{className:"p-8 space-y-6 bg-white text-center",children:[e.jsxs(fs,{children:[e.jsx(us,{className:"text-2xl font-black text-slate-900 tracking-tight",children:"Flag Non-Responsive"}),e.jsx(bs,{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(an,{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(se,{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:()=>It(!1),disabled:he,"data-testid":"onboarding-fdd-flag-cancel",children:"Go Back"}),e.jsx(se,{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:he,"data-testid":"onboarding-fdd-flag-submit",onClick:async()=>{try{vt(!0),await ds.submitStageDecision({applicationId:s.id,stageCode:"FDD_VERIFICATION",decision:"Rejected",remarks:"Applicant is non-responsive to FDD queries."}),ee.error("Applicant flagged as non-responsive."),It(!1),it()}catch{ee.error("Action failed")}finally{vt(!1)}},children:he?e.jsx(es,{className:"w-5 h-5 animate-spin"}):"Confirm Flag"})]})]})]})}),e.jsx(ls,{open:mt,onOpenChange:_e,children:e.jsxs(as,{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(so,{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(de,{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(At,{value:Vt,onValueChange:Et,children:[e.jsx(Dt,{className:"h-12 rounded-xl border-slate-200 focus:ring-re-red","data-testid":"onboarding-firm-type-select",children:e.jsx(kt,{placeholder:"Select Firm Type"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Proprietorship","data-testid":"onboarding-firm-type-proprietorship",children:"Proprietorship"}),e.jsx(Me,{value:"Partnership","data-testid":"onboarding-firm-type-partnership",children:"Partnership"}),e.jsx(Me,{value:"Limited Liability partnership","data-testid":"onboarding-firm-type-llp",children:"LLP (Limited Liability partnership)"}),e.jsx(Me,{value:"Private Limited Company","data-testid":"onboarding-firm-type-pvt-ltd",children:"Private Limited Company"}),e.jsx(Me,{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(se,{variant:"outline",className:"flex-1 h-12 rounded-xl font-bold text-slate-600 border-slate-200",onClick:()=>_e(!1),disabled:Ds,"data-testid":"onboarding-firm-type-cancel",children:"Cancel"}),e.jsx(se,{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:Ds||!Vt,onClick:ln,"data-testid":"onboarding-firm-type-submit",children:Ds?e.jsx(es,{className:"w-5 h-5 animate-spin"}):"Update Type"})]})]})]})})]})}var ZU={};function QU({application:t,documents:s,setPreviewDoc:n,setShowPreviewModal:r,setIsUploading:a,fetchApplication:l,refreshDocuments:o}){var w,v;const d=(t==null?void 0:t.fddAssignments)||[],m=((w=t==null?void 0:t.participants)==null?void 0:w.filter(N=>{var j,y,C,S;return((j=N.user)==null?void 0:j.role)==="FDD"||((y=N.user)==null?void 0:y.roleCode)==="FDD"||((S=(C=N.user)==null?void 0:C.allRoles)==null?void 0:S.includes("FDD"))}))||[],f=d.length>0||m.length>0,x=(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"}],p=N=>{const j=N.toLowerCase();return(s||[]).find(y=>{const C=(y.documentType||"").toLowerCase(),S=(y.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=N=>{const j=(N.documentType||"").toLowerCase();return(N.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(no,{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(no,{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"}),x&&e.jsxs("p",{className:"text-xs text-slate-500 font-medium","data-testid":"onboarding-fdd-assigned-user",children:["Assigned to: ",x.name]})]})]})}),e.jsxs(Le,{className:"border-slate-200 shadow-sm overflow-hidden rounded-2xl","data-testid":"onboarding-fdd-checklist-card",children:[e.jsx(Qe,{className:"bg-slate-50/50 border-b border-slate-100 py-4",children:e.jsxs(et,{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(ac,{className:"w-4 h-4"})," Financial Artefacts Checklist"]}),e.jsx(Ce,{variant:"outline",className:"text-[10px] bg-white",children:"Verify before sign-off"})]})}),e.jsx(Fe,{className:"p-0",children:e.jsx("div",{className:"divide-y divide-slate-100",children:h.map((N,j)=>{const y=p(N.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:jt("w-8 h-8 rounded-lg flex items-center justify-center",y?"bg-emerald-50 text-emerald-600":"bg-slate-50 text-slate-300"),children:y?e.jsx(fn,{className:"w-5 h-5"}):e.jsx(an,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:N.label}),e.jsx("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-tighter","data-testid":`onboarding-fdd-checklist-status-${j}`,children:y?`Uploaded: ${Gt(y.createdAt)}`:"Missing in Documentation"})]})]}),y?e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-blue-600 font-black text-[10px] uppercase tracking-widest hover:bg-blue-50",onClick:()=>{n(y),r(!0)},"data-testid":`onboarding-fdd-checklist-preview-${j}`,children:[e.jsx(bn,{className:"w-4 h-4 mr-1"})," Preview"]}):e.jsxs(se,{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 R;const D=S.target.files[0];if(D)try{a(!0);const A=new FormData;A.append("file",D),A.append("documentType",N.type),A.append("stage","FDD"),A.append("applicationId",t.id);const L=await ds.uploadDocument(t.id,A);N.type==="FDD Final Audit Report"&&(await ds.submitFddReport({applicationId:t.id,reportDocumentId:((R=L.data)==null?void 0:R.id)||L.id,findings:"Final Audit Report uploaded via checklist.",recommendation:"REVIEW_PENDING"}),l()),ee.success(`${N.label} uploaded successfully`),o()}catch{ee.error("Upload failed")}finally{a(!1)}},C.click()},children:[e.jsx(or,{className:"w-4 h-4 mr-1 text-slate-300"})," Upload"]})]},N.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(Ce,{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((N,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(Ns,{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:N.fileName,"data-testid":`onboarding-fdd-support-doc-name-${j}`,children:N.fileName}),e.jsx("p",{className:"text-slate-500 text-[10px] font-medium uppercase",children:N.documentType})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{const y=ZU.NEXT_PUBLIC_API_URL||"http://localhost:5000";window.open(`${y}/${N.filePath}`,"_blank")},"data-testid":`onboarding-fdd-support-doc-download-${j}`,children:e.jsx(Ni,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-re-red hover:bg-red-50",onClick:()=>{n(N),r(!0)},"data-testid":`onboarding-fdd-support-doc-preview-${j}`,children:e.jsx(bn,{className:"w-4 h-4"})})]})]},N.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 XU(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 jf(t,s){return t==null||s==null?!1:String(t).trim()===String(s).trim()}function f_(t){return String(t??"").trim().toLowerCase().replace(/\s+/g," ")}function Am(t){const s=f_(t);return s?s==="scheduled"||s==="rescheduled"||s==="pending"||s==="in progress"||s==="inprogress":!1}function JU(t){return f_(t)==="completed"}function Hg(t,s){var n;return!s||!((n=t==null?void 0:t.participants)!=null&&n.length)?!1:t.participants.some(r=>{var a;return jf(r.userId,s)||jf((a=r.user)==null?void 0:a.id,s)})}function eV(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 _S(t){return String(t??"").trim().toLowerCase().replace(/[_\s-]+/g,"")}function tV(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 l=a.map(_S),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(_S);for(const f of o)if(f){for(const x of l)if(x&&(f===x||f.includes(x)||x.includes(f)))return!0}return!1}function sV({application:t,interviews:s,currentUser:n,getDeposit:r,eorProgress:a}){var C,S,D;const l=Array.isArray(s)?s:[],o=eV(t==null?void 0:t.status),d=(o!=null?l.find(R=>Am(R.status)&&Hg(R,n==null?void 0:n.id)&&Number(R.level)===o):void 0)??l.find(R=>Am(R.status)&&Hg(R,n==null?void 0:n.id)),m=o!=null&&n&&tV(n,o)?l.find(R=>Number(R.level)===o&&Am(R.status)):void 0,f=d??m,x=l.find(R=>Hg(R,n==null?void 0:n.id)),h=((C=f==null?void 0:f.evaluations)==null?void 0:C.find(R=>jf(R.evaluatorId,n==null?void 0:n.id)))??((S=x==null?void 0:x.evaluations)==null?void 0:S.find(R=>jf(R.evaluatorId,n==null?void 0:n.id))),p=R=>l.some(A=>Number(A.level)===R&&JU(A.status)),u=R=>l.some(A=>Number(A.level)===R&&Am(A.status)),w=!!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"},N=v[t==null?void 0:t.status],j=(D=t==null?void 0:t.stageApprovals)==null?void 0:D.find(R=>R.stageCode===N&&String(R.actorUserId)===String(n==null?void 0:n.id));return{activeInterviewForUser:f,lastInterviewForUser:x,currentUserEvaluation:h,hasSubmittedFeedback:w,currentUserStageAction:j,isInterviewCompleted:p,isInterviewActive:u,permissions:(()=>{var Q,_,z,T,F;if(!t||!n)return{canApprove:!1,canReject:!1,canSchedule:!1,canAssign:!1,isLoaLocked:!1,isSecurityDetailsLocked:!1,showDecisionMessage:!1};const R=["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),L=t.status==="LOA Pending"&&((Q=r("FIRST_FILL"))==null?void 0:Q.status)!=="Verified",$=["Security Deposit","Security Details","Payment Pending"].includes(t.status)&&((_=r("SECURITY_DEPOSIT"))==null?void 0:_.status)!=="Verified",P=t.status==="Onboarded"||t.status==="Rejected",E=(z=t.stageApprovals)==null?void 0:z.some(B=>B.stageCode==="LOI_APPROVAL"&&B.actorRole==="DD Head"&&B.decision==="Approved"),O=(T=t.stageApprovals)==null?void 0:T.some(B=>B.stageCode==="LOA_APPROVAL"&&B.actorRole==="DD Head"&&B.decision==="Approved");let I=!0;["Super Admin","DD Admin","DD Lead","DD Head"].includes(n.role)||((t.status==="FDD Verification"||t.status==="Level 3 Approved")&&(I=!1),t.status==="LOI In Progress"&&(I=n.role==="NBH"?!!E:n.role==="DD Head"),t.status==="LOA Pending"&&(I=n.role==="NBH"?!!O:n.role==="DD Head"));const q=!!((F=t.stageApprovals)!=null&&F.find(B=>v[t.status]===B.stageCode&&String(B.actorUserId)===String(n.id))),G=["Approved","Rejected","Selected"].includes((h==null?void 0:h.decision)||(h==null?void 0:h.recommendation)||""),Y=(f?G:!1)||q,V=!P&&!Y&&R&&A&&I&&(!["EOR In Progress","Inauguration","Approved"].includes(t.status)||a===100);return{canApprove:V&&!L&&!$,canReject:V&&!L,isLoaLocked:L,isSecurityDetailsLocked:$,showDecisionMessage:Y&&(!A||q),canSchedule:["DD Admin","Super Admin","DD AM","ASM"].includes(n.role)&&!P&&![1,2,3].every(B=>l.some(K=>K.level===B)),canAssign:["DD Admin","Super Admin","DD AM"].includes(n.role)}})()}}function nV({initialTab:t="questionnaire"}){const[s,n]=g.useState(!1),[r,a]=g.useState(!1),[l,o]=g.useState(""),[d,m]=g.useState(t),[f,x]=g.useState(!1),[h,p]=g.useState(!1),[u,w]=g.useState(!1),[v,N]=g.useState(!1),[j,y]=g.useState(""),[C,S]=g.useState([]),[D,R]=g.useState(!1),[A,L]=g.useState(!1),[$,P]=g.useState(""),[E,O]=g.useState(null),[I,q]=g.useState(!1),[G,Y]=g.useState(!1),[V,Q]=g.useState(!1),[_,z]=g.useState(!1),[T,F]=g.useState(!1),[B,K]=g.useState(null),[W,H]=g.useState("virtual"),[X,J]=g.useState(""),[ie,ae]=g.useState({}),[xe,ce]=g.useState([]),[we,ke]=g.useState(""),[Xe,Ot]=g.useState("contributor"),[bt,te]=g.useState(""),[ve,qe]=g.useState("level1"),[ge,Be]=g.useState(""),[ut,ht]=g.useState(""),[it,Tt]=g.useState(!1),[It,he]=g.useState(null),[vt,mt]=g.useState(""),[_e,Vt]=g.useState(null),[Et,Ds]=g.useState(!1),[ln,Bs]=g.useState(null),[Ys,Xs]=g.useState(!1),[Js,Ws]=g.useState(""),[Z,oe]=g.useState(!1),[Ne,Oe]=g.useState({}),[De,ye]=g.useState(!1),[Ve,Ge]=g.useState([]),[st,Kt]=g.useState(!1),[Xt,ot]=g.useState(!1),[ft,Es]=g.useState(!1),[ts,vs]=g.useState(""),[Te,je]=g.useState(!1),[nt,Ye]=g.useState(!1),[pt,yt]=g.useState(""),[Jt,ss]=g.useState(""),[Ss,Zs]=g.useState(!1),[on,en]=g.useState(!1),[tn,cn]=g.useState([]),[Ae,Ht]=g.useState([]),[Pe,ct]=g.useState(""),[tt,Nt]=g.useState(!1),[Mt,Pt]=g.useState(!1),[ys,Yt]=g.useState(!1),[ps,ks]=g.useState(!1),[hs,gn]=g.useState({}),[$s,dn]=g.useState({}),[sn,We]=g.useState(""),[Ft,gt]=g.useState("Approve"),[rt,Is]=g.useState(!1),[xs,Nn]=g.useState(null),[kn,Cn]=g.useState(!1),[Us,Za]=g.useState(!1),[Pa,Ms]=g.useState("Recommended"),[un,ta]=g.useState(""),[sa,na]=g.useState(!1),[Mr,Xn]=g.useState(!1),[zn,Zt]=g.useState({}),[Jn,Er]=g.useState("Approve"),[Gn,_r]=g.useState(!1),[On,ur]=g.useState({}),[ns,nn]=g.useState("Approve"),[va,Si]=g.useState(!1),[Ci,Fr]=g.useState(null),[Hr,sr]=g.useState(!1);return{showFirmTypeModal:s,setShowFirmTypeModal:n,updatingFirmType:r,setUpdatingFirmType:a,tempFirmType:l,setTempFirmType:o,activeTab:d,setActiveTab:m,showApproveModal:f,setShowApproveModal:x,showOnboardModal:h,setShowOnboardModal:p,isOnboarding:u,setIsOnboarding:w,showRejectModal:v,setShowRejectModal:N,rejectionReason:j,setRejectionReason:y,scheduledInterviewParticipants:C,setScheduledInterviewParticipants:S,showScheduleModal:D,setShowScheduleModal:R,showCancelInterviewModal:A,setShowCancelInterviewModal:L,interviewIdToCancel:$,setInterviewIdToCancel:P,interviewToReschedule:E,setInterviewToReschedule:O,showKTMatrixModal:I,setShowKTMatrixModal:q,showLevel2FeedbackModal:G,setShowLevel2FeedbackModal:Y,showLevel3FeedbackModal:V,setShowLevel3FeedbackModal:Q,showDocumentsModal:_,setShowDocumentsModal:z,showAssignModal:T,setShowAssignModal:F,selectedStage:B,setSelectedStage:K,interviewMode:W,setInterviewMode:H,approvalRemark:X,setApprovalRemark:J,expandedBranches:ie,setExpandedBranches:ae,users:xe,setUsers:ce,selectedUser:we,setSelectedUser:ke,participantType:Xe,setParticipantType:Ot,interviewDate:bt,setInterviewDate:te,interviewType:ve,setInterviewType:qe,meetingLink:ge,setMeetingLink:Be,location:ut,setLocation:ht,showUploadForm:it,setShowUploadForm:Tt,uploadFile:It,setUploadFile:he,uploadDocType:vt,setUploadDocType:mt,approvalFile:_e,setApprovalFile:Vt,isUploading:Et,setIsUploading:Ds,previewDoc:ln,setPreviewDoc:Bs,showPreviewModal:Ys,setShowPreviewModal:Xs,selectedInterviewerId:Js,setSelectedInterviewerId:Ws,isEditingStatutory:Z,setIsEditingStatutory:oe,statutoryForm:Ne,setStatutoryForm:Oe,isSavingStatutory:De,setIsSavingStatutory:ye,interviews:Ve,setInterviews:Ge,isScheduling:st,setIsScheduling:Kt,isCancellingInterview:Xt,setIsCancellingInterview:ot,showAssignArchitectureModal:ft,setShowAssignArchitectureModal:Es,architectureLeadId:ts,setArchitectureLeadId:vs,isAssigningArchitecture:Te,setIsAssigningArchitecture:je,showArchitectureStatusModal:nt,setShowArchitectureStatusModal:Ye,architectureStatus:pt,setArchitectureStatus:yt,architectureRemarks:Jt,setArchitectureRemarks:ss,isUpdatingArchitecture:Ss,setIsUpdatingArchitecture:Zs,isAssigningParticipant:on,setIsAssigningParticipant:en,documentConfigs:tn,setDocumentConfigs:cn,fddAgencies:Ae,setFddAgencies:Ht,selectedAgencyId:Pe,setSelectedAgencyId:ct,isAssigningAgency:tt,setIsAssigningAgency:Nt,showAssignFddModal:Mt,setShowAssignFddModal:Pt,isApproving:ys,setIsApproving:Yt,isRejecting:ps,setIsRejecting:ks,ktMatrixScores:hs,setKtMatrixScores:gn,ktMatrixSelectedValues:$s,setKtMatrixSelectedValues:dn,ktMatrixRemarks:sn,setKtMatrixRemarks:We,ktMatrixRecommendation:Ft,setKtMatrixRecommendation:gt,isSubmittingKT:rt,setIsSubmittingKT:Is,selectedInterviewForFeedback:xs,setSelectedInterviewForFeedback:Nn,showFddFinalizeModal:kn,setShowFddFinalizeModal:Cn,showFddFlagModal:Us,setShowFddFlagModal:Za,fddAuditRecommendation:Pa,setFddAuditRecommendation:Ms,fddAuditFindings:un,setFddAuditFindings:ta,isFinalizingFdd:sa,setIsFinalizingFdd:na,isFddFlagging:Mr,setIsFddFlagging:Xn,level2Feedback:zn,setLevel2Feedback:Zt,level2Recommendation:Jn,setLevel2Recommendation:Er,isSubmittingLevel2:Gn,setIsSubmittingLevel2:_r,level3Feedback:On,setLevel3Feedback:ur,level3Recommendation:ns,setLevel3Recommendation:nn,isSubmittingLevel3:va,setIsSubmittingLevel3:Si,selectedEvaluationForView:Ci,setSelectedEvaluationForView:Fr,showFeedbackDetailsModal:Hr,setShowFeedbackDetailsModal:sr}}const p_=()=>new Date().toISOString().split("T")[0],rV=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:p_()}),aV=t=>({strategicVision:"",managementCapabilities:"",operationalUnderstanding:"",brandAlignment:"",executiveSummary:"",keyStrengths:"",areasOfConcern:"",additionalComments:"",overallScore:"",interviewerName:(t==null?void 0:t.name)||"",interviewDate:p_()});function iV({ktMatrixScores:t,setKtMatrixScores:s,setKtMatrixSelectedValues:n,ktMatrixRemarks:r,setKtMatrixRemarks:a,ktMatrixRecommendation:l,setKtMatrixRecommendation:o,selectedInterviewForFeedback:d,interviews:m,setIsSubmittingKT:f,setShowKTMatrixModal:x,level2Feedback:h,setLevel2Feedback:p,level2Recommendation:u,setLevel2Recommendation:w,setIsSubmittingLevel2:v,setShowLevel2FeedbackModal:N,level3Feedback:j,setLevel3Feedback:y,level3Recommendation:C,setLevel3Recommendation:S,setIsSubmittingLevel3:D,setShowLevel3FeedbackModal:R,currentUser:A,fetchInterviews:L,fetchApplication:$,ktMatrixConfig:P,level2Config:E,level3Config:O}){const I=J=>J==="Approve"?"Recommended":J==="Reject"?"Not Recommended":"Hold",q=J=>J==="Approve"?"Approved":J==="Reject"?"Rejected":null,G=()=>P!=null&&P.items&&P.items.length>0?P.items.map(J=>({name:J.label,weight:Number(J.weight)||0,maxScore:Number(J.maxScore)||10,options:(J.options||[]).map(ie=>({label:ie.optionLabel,value:ie.optionValue,score:Number(ie.score)||0}))})):[],Y=()=>E!=null&&E.items&&E.items.length>0?E.items:[],V=()=>O!=null&&O.items&&O.items.length>0?O.items:[],Q=G(),_=Y(),z=V();return{handleKTMatrixChange:(J,ie,ae)=>{s(xe=>({...xe,[J]:ae})),n(xe=>({...xe,[J]:ie}))},calculateKTScore:()=>{let J=0;return Q.forEach(ie=>{const ae=t[ie.name||ie.label]||0,xe=ie.maxScore||10,ce=ie.weight||0;J+=ae/xe*ce}),J.toFixed(2)},handleSubmitKTMatrix:async()=>{var ie,ae;if(Q.length===0){ee.error("KT Matrix configuration is missing. Please configure it in Master > Interview Configurations.");return}if(Object.keys(t).length<Q.length){ee.warning("Please fill all fields in the KT Matrix");return}const J=(d==null?void 0:d.id)||((ie=m.find(xe=>xe.status!=="Completed"))==null?void 0:ie.id)||((ae=m[0])==null?void 0:ae.id);if(!J){ee.error("No active interview found to link this KT Matrix to.");return}try{f(!0);const xe=Q.map(we=>({criterionName:we.name||we.label,score:t[we.name||we.label]||0,maxScore:we.maxScore||10,weightage:we.weight||0}));await ds.submitKTMatrix({interviewId:J,criteriaScores:xe,feedback:r,recommendation:I(l)});const ce=q(l);ce&&await ds.updateInterviewDecision({interviewId:J,decision:ce,remarks:r||`Level 1 ${ce.toLowerCase()} via KT Matrix`}),ee.success(ce?`KT Matrix submitted and interview ${ce.toLowerCase()}`:"KT Matrix submitted and interview kept on hold"),x(!1),s({}),n({}),a(""),o("Approve"),await L(),await $()}catch{ee.error("Failed to submit KT Matrix")}finally{f(!1)}},handleLevel2Change:(J,ie)=>{p(ae=>({...ae,[J]:ie}))},handleSubmitLevel2Feedback:async()=>{var ie;if(_.length===0){ee.error("Level 2 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!h.overallScore){ee.warning("Please provide an overall score.");return}const J=(d==null?void 0:d.id)||((ie=m.find(ae=>ae.status!=="Completed"&&ae.level===2))==null?void 0:ie.id);if(!J){ee.error("No active Level 2 interview found to link this feedback to.");return}try{v(!0);const ae=_.map(we=>({type:we.label,comments:h[we.itemKey]||""})).filter(we=>we.comments.trim()!=="");await ds.submitLevel2Feedback({interviewId:J,overallScore:Number(h.overallScore),feedbackItems:ae,recommendation:I(u)});const xe=q(u),ce=h.additionalComments||"Level 2 decision submitted via feedback modal";xe&&await ds.updateInterviewDecision({interviewId:J,decision:xe,remarks:ce}),ee.success(xe?`Level 2 feedback submitted and interview ${xe.toLowerCase()}`:"Level 2 feedback submitted and interview kept on hold"),N(!1),p(rV(A)),w("Approve"),await L(),await $()}catch{ee.error("Failed to submit Level 2 Feedback")}finally{v(!1)}},handleLevel3Change:(J,ie)=>{y(ae=>({...ae,[J]:ie}))},handleSubmitLevel3Feedback:async()=>{var ie;if(z.length===0){ee.error("Level 3 feedback configuration is missing. Please configure it in Master > Interview Configurations.");return}if(!j.overallScore){ee.warning("Please provide an overall score.");return}const J=(d==null?void 0:d.id)||((ie=m.find(ae=>ae.status!=="Completed"&&ae.level===3))==null?void 0:ie.id);if(!J){ee.error("No active Level 3 interview found to link this feedback to.");return}try{D(!0);const ae=z.map(we=>({type:we.label,comments:j[we.itemKey]||""})).filter(we=>we.comments.trim()!=="");await ds.submitLevel2Feedback({interviewId:J,overallScore:Number(j.overallScore),feedbackItems:ae,recommendation:I(C)});const xe=q(C),ce=j.executiveSummary||j.additionalComments||"Level 3 decision submitted via feedback modal";xe&&await ds.updateInterviewDecision({interviewId:J,decision:xe,remarks:ce}),ee.success(xe?`Level 3 feedback submitted and interview ${xe.toLowerCase()}`:"Level 3 feedback submitted and interview kept on hold"),R(!1),y(aV(A)),S("Approve"),await L(),await $()}catch{ee.error("Failed to submit Level 3 Feedback")}finally{D(!1)}},ktCriteria:Q,l2Fields:_,l3Fields:z}}function lV(){const[t,s]=g.useState(null),[n,r]=g.useState(null),[a,l]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(null),x=g.useCallback(async p=>{var u,w;try{const v=await Ee.getInterviewConfigByType(p);if((u=v.data)!=null&&u.success)return v.data.data}catch(v){((w=v==null?void 0:v.response)==null?void 0:w.status)!==404&&console.warn(`Failed to fetch ${p} config:`,v)}return null},[]),h=g.useCallback(async()=>{d(!0),f(null);try{const[p,u,w]=await Promise.all([x("KT_MATRIX"),x("LEVEL2_FEEDBACK"),x("LEVEL3_FEEDBACK")]);s(p),r(u),l(w)}catch{f("Failed to load interview configurations"),ee.error("Failed to load interview configurations")}finally{d(!1)}},[x]);return g.useEffect(()=>{h()},[h]),{ktMatrixConfig:t,level2Config:n,level3Config:a,loading:o,error:m,refresh:h}}function oV(t){const{application:s,applicationId:n,currentUser:r,interviews:a,approvalFile:l,approvalRemark:o,rejectionReason:d,architectureLeadId:m,architectureStatus:f,architectureRemarks:x,selectedUser:h,participantType:p,users:u,interviewDate:w,setInterviewDate:v,interviewType:N,setInterviewType:j,interviewMode:y,setInterviewMode:C,meetingLink:S,setMeetingLink:D,location:R,setLocation:A,scheduledInterviewParticipants:L,uploadFile:$,uploadDocType:P,selectedStage:E,setIsApproving:O,setShowApproveModal:I,setApprovalRemark:q,setApprovalFile:G,setIsRejecting:Y,setShowRejectModal:V,setRejectionReason:Q,setIsAssigningArchitecture:_,setShowAssignArchitectureModal:z,setIsUpdatingArchitecture:T,setShowArchitectureStatusModal:F,setIsAssigningParticipant:B,setSelectedUser:K,setShowAssignModal:W,setLoading:H,setIsScheduling:X,setShowScheduleModal:J,setShowCancelInterviewModal:ie,interviewIdToCancel:ae,setInterviewIdToCancel:xe,interviewToReschedule:ce,setInterviewToReschedule:we,setIsCancellingInterview:ke,setIsUploading:Xe,setShowUploadForm:Ot,setUploadFile:bt,setUploadDocType:te,setDocuments:ve,selectedInterviewerId:qe,setSelectedInterviewerId:ge,setScheduledInterviewParticipants:Be,setUsers:ut,showScheduleModal:ht,showAssignArchitectureModal:it,showAssignModal:Tt,fetchApplication:It,fetchInterviews:he,fetchEorData:vt}=t,mt=()=>{if(!qe)return;const Ge=(Array.isArray(u)?u:[]).find(st=>st.id===qe);Ge&&!L.find(st=>st.id===Ge.id)&&(Be([...L,Ge]),ge(""))},_e=Ve=>{Be(L.filter(Ge=>Ge.id!==Ve))},Vt=g.useCallback(async Ve=>{if(!(!r||!["DD Admin","Super Admin","DD Lead","DD Head","NBH"].includes(r.role)))try{const Ge={};if(Ve){const ot={level1:["DD-ZM","RBM"],level2:["DD Lead","ZBH"],level3:["NBH","DD Head"]};ot[Ve]&&(Ge.preferredRoleCode=ot[Ve]),s&&(Ge.locationId=s.districtId||s.areaId||s.regionId||s.zoneId)}Ge.isExternal=!1;const st=await ds.getUsers(Ge),Xt=(Array.isArray(st)?st:st&&Array.isArray(st.data)?st.data:st&&Array.isArray(st.users)?st.users:[]).filter(ot=>(ot.status||"").toLowerCase()!=="inactive");ut(Xt.sort((ot,ft)=>String(ot.fullName||ot.name||"").localeCompare(String(ft.fullName||ft.name||""))))}catch{ut([])}},[r,s,ut]),Et=g.useCallback(()=>{if(!ht||!s||ce)return;const Ve=parseInt(N.replace("level",""))||1,Ge={1:["DD-ZM","RBM"],2:["DD Lead","ZBH"],3:["NBH","DD Head"]},st=ts=>String(ts||"").trim().toLowerCase().replace(/[_\s-]+/g," "),Kt=(Ge[Ve]||[]).map(st),Xt=(ts,vs)=>{var nt,Ye,pt;const Te=[(nt=ts==null?void 0:ts.metadata)==null?void 0:nt.role,(Ye=vs==null?void 0:vs.role)==null?void 0:Ye.roleName,(pt=vs==null?void 0:vs.role)==null?void 0:pt.roleCode,vs==null?void 0:vs.roleCode,vs==null?void 0:vs.role].filter(Boolean),je=Te.find(yt=>Kt.includes(st(yt)));return String(je||Te[0]||"Panelist")},ot=((s==null?void 0:s.participants)||[]).filter(ts=>{var vs,Te,je,nt,Ye,pt,yt,Jt,ss;return((vs=ts.metadata)==null?void 0:vs.interviewLevel)===Ve||((Te=ts.metadata)==null?void 0:Te.interviewLevel)===String(Ve)||((nt=(je=ts.metadata)==null?void 0:je.allAssignments)==null?void 0:nt.includes(Ve))||((pt=(Ye=ts.metadata)==null?void 0:Ye.allAssignments)==null?void 0:pt.includes(String(Ve)))||Kt.includes(st((yt=ts.user)==null?void 0:yt.role))||Kt.includes(st((Jt=ts.user)==null?void 0:Jt.roleCode))||Kt.includes(st((ss=ts.metadata)==null?void 0:ss.role))}).map(ts=>{const vs=ts.user||{};return{...vs,__stageRole:Xt(ts,vs)}}).filter(ts=>!!(ts!=null&&ts.id));if(ot.length===0){Be([]);return}const ft=[],Es=new Set;ot.forEach(ts=>{ts.id&&!Es.has(ts.id)&&(Es.add(ts.id),ft.push(ts))}),Be(ft)},[ht,s,N,ce,Be]),Ds=async()=>{if(!w){ee.warning("Please select date and time");return}try{X(!0);const Ve={applicationId:s==null?void 0:s.id,level:N,scheduledAt:w,type:y==="virtual"?"Virtual Interview":"Physical Interview",location:y==="virtual"?S:R,participants:L.map(Ge=>Ge.id)};ce?(await ds.updateInterview(ce.id,{...Ve,status:"Scheduled"}),ee.success("Interview rescheduled successfully")):(await ds.scheduleInterview(Ve),ee.success("Interview scheduled successfully")),J(!1),we(null),await he(),await It()}catch{ee.error(ce?"Failed to reschedule interview":"Failed to schedule interview")}finally{X(!1)}},ln=async Ve=>{xe(Ve),ie(!0)},Bs=async Ve=>{var st,Kt;we(Ve),j(`level${Ve.level}`),C((st=Ve.interviewType)!=null&&st.toLowerCase().includes("virtual")?"virtual":"physical"),v(Ve.scheduleDate?(()=>{const Xt=new Date(Ve.scheduleDate);return new Date(Xt.getTime()-Xt.getTimezoneOffset()*6e4).toISOString().slice(0,16)})():""),(Kt=Ve.interviewType)!=null&&Kt.toLowerCase().includes("virtual")?D(Ve.linkOrLocation||""):A(Ve.linkOrLocation||"");const Ge=(Ve.participants||[]).map(Xt=>Xt.user||Xt).filter(Boolean);Be(Ge),J(!0)},Ys=async()=>{if(ae)try{ke(!0),await ds.updateInterview(ae,{status:"Cancelled"}),ee.success("Interview cancelled successfully"),ie(!1),xe(""),await he()}catch{ee.error("Failed to cancel interview")}finally{ke(!1)}},Xs=async()=>{var Ve;if(!$||!P){ee.warning("Please enter a document name and select a file");return}try{Xe(!0);const Ge=new FormData,st=((Ve=$.name.match(/\.[^/.]+$/))==null?void 0:Ve[0])||"",Kt=P.trim(),Xt=Kt.toLowerCase().endsWith(st.toLowerCase())?Kt:`${Kt}${st}`;Ge.append("file",$,Xt);const ot=E!=null&&E.startsWith("EOR: ")?E.replace(/^EOR:\s*/,""):null;Ge.append("documentType",ot||"Other"),E&&Ge.append("stage",E),await ds.uploadDocument(n,Ge),ee.success("Document uploaded successfully"),Ot(!1),bt(null),te("");const ft=await ds.getDocuments(n);ve(ft||[]),await vt()}catch{ee.error("Failed to upload document")}finally{Xe(!1)}},Js=async()=>{var Ve;try{O(!0);const Ge=a.find(ot=>{var ft;return ot.status!=="Completed"&&ot.status!=="Cancelled"&&((ft=ot.participants)==null?void 0:ft.some(Es=>Es.userId===(r==null?void 0:r.id)))});if(l&&n)try{const ot=new FormData;ot.append("file",l),ot.append("documentType","Approval Attachment");let ft=null;Ge&&(Ge.level===1||Ge.level==="1"?ft="1st Level Interview":Ge.level===2||Ge.level==="2"?ft="2nd Level Interview":(Ge.level===3||Ge.level==="3")&&(ft="3rd Level Interview")),ft||(s.status==="Shortlisted"||s.status==="Level 1 Interview Pending"?ft="1st Level Interview":s.status==="Level 1 Approved"||s.status==="Level 2 Interview Pending"?ft="2nd Level Interview":(s.status==="Level 2 Approved"||s.status==="Level 3 Interview Pending")&&(ft="3rd Level Interview")),ft&&ot.append("stage",ft),await ds.uploadDocument(n,ot)}catch{ee.error("Failed to upload document")}if(Ge)try{await ds.updateInterviewDecision({interviewId:Ge.id,decision:"Approved",remarks:o}),ee.success("Interview approved successfully"),I(!1),q(""),G(null),await he(),await It();return}catch{ee.error("Failed to approve interview");return}if(!o.trim()){ee.warning("Please enter a remark");return}let st=s.status;switch(s.status){case"Shortlisted":case"Level 1 Interview Pending":st="Level 1 Approved";break;case"Level 1 Approved":case"Level 2 Interview Pending":st="Level 2 Approved";break;case"Level 2 Approved":case"Level 3 Interview Pending":st="Level 3 Approved";break;case"Level 3 Approved":st="FDD Verification";break;case"FDD Verification":st="LOI In Progress";break;case"LOI In Progress":st="Security Deposit";break;case"Security Deposit":case"Security Details":case"Payment Pending":st="LOI Issued";break;case"LOI Issued":st="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":st="LOA Pending";break;case"LOA Pending":st="EOR In Progress";break;case"EOR In Progress":st="EOR Complete";break;case"EOR Complete":st="Inauguration";break;case"Inauguration":case"Approved":st="Onboarded";break;default:st="Onboarded"}const Xt={"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(Xt){const ot=await ds.submitStageDecision({applicationId:s.id,stageCode:Xt,decision:"Approved",remarks:o,nextStatus:st});(Ve=ot.data)!=null&&Ve.statusUpdated?ee.success(ot.message||"Stage completed and moved to next step"):ee.info(ot.message||"Approval recorded. Waiting for other mandatory approvers.")}else await ds.updateApplicationStatus(n,{status:st,remarks:o});st==="Onboarded"?(await ds.createDealer({applicationId:n}),ee.success("Application finalized and Dealer profile created!")):ee.success(`Application moved to ${st}`),I(!1),q(""),G(null),await It()}catch(Ge){ee.error(Ge.message||"Failed to process approval")}finally{O(!1)}},Ws=async()=>{try{Y(!0);const Ve=a.find(Kt=>{var Xt;return Kt.status!=="Completed"&&Kt.status!=="Cancelled"&&((Xt=Kt.participants)==null?void 0:Xt.some(ot=>ot.userId===(r==null?void 0:r.id)))});if(Ve)try{await ds.updateInterviewDecision({interviewId:Ve.id,decision:"Rejected",remarks:d}),ee.success("Interview rejected"),V(!1),Q(""),await he(),await It();return}catch{ee.error("Failed to reject interview");return}if(!d.trim()){ee.warning("Please enter a reason for rejection");return}const st={"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];st?await ds.submitStageDecision({applicationId:s.id,stageCode:st,decision:"Rejected",remarks:d,interviewId:Ve==null?void 0:Ve.id}):await ds.updateApplicationStatus(n,{status:"Rejected",remarks:d}),ee.success("Application rejected"),V(!1),Q(""),await It()}catch(Ve){ee.error(Ve.message||"Failed to process rejection")}finally{Y(!1)}},Z=async()=>{try{await ds.generateDealerCodes(n),ee.success("Dealer codes generated successfully"),await It()}catch(Ve){ee.error(Ve.message||"Failed to generate dealer codes")}},oe=async()=>{if(!m){ee.warning("Please select an architecture lead");return}try{_(!0),await ds.assignArchitectureTeam(n,m),ee.success("Architecture team assigned successfully"),z(!1),await It()}catch(Ve){ee.error(Ve.message||"Failed to assign architecture team")}finally{_(!1)}},Ne=async()=>{try{T(!0),await ds.updateArchitectureStatus(n,f,x),ee.success("Architecture status updated successfully"),F(!1),await It()}catch{ee.error("Failed to update architecture status")}finally{T(!1)}},Oe=async()=>{if(!h){ee.warning("Please select a user");return}try{B(!0);const Ve=Array.isArray(u)?u.find(Ge=>Ge.id===h):null;Ve&&(Ve.role==="FDD"||Ve.roleCode==="FDD")&&(await ds.assignFddAgency({applicationId:n,assignedToAgency:h}),ee.info(`${Ve.fullName||Ve.name} assigned as FDD Agency based on role.`)),await ds.addParticipant({requestId:n,requestType:"application",userId:h,participantType:p||"contributor"}),ee.success("User assigned successfully!"),await It(),K(""),W(!1)}catch{ee.error("Failed to assign user")}finally{B(!1)}},De=async()=>{try{H(!0),await ds.retriggerEvaluators(n),ee.success("Evaluators re-assigned successfully"),await It()}catch{ee.error("Failed to re-assign evaluators")}finally{H(!1)}},ye=g.useCallback(async()=>{if(ht&&s){await Vt(N),Et();return}(it||Tt)&&s&&await Vt()},[ht,it,Tt,s,N,Vt,Et]);return{handleAddInterviewer:mt,handleRemoveInterviewer:_e,fetchUsers:Vt,maybeFetchUsersForModal:ye,handleScheduleInterview:Ds,handleRescheduleInterview:Bs,handleCancelInterview:ln,handleConfirmCancelInterview:Ys,handleUpload:Xs,handleApprove:Js,handleReject:Ws,handleGenerateDealerCodes:Z,handleAssignArchitecture:oe,handleUpdateArchitectureStatus:Ne,handleAddParticipant:Oe,handleRetriggerEvaluators:De}}const x_={getChecklist:async(t,s)=>{const n=s?`/eor/relocation/${s}`:`/eor/application/${t}`;return(await $e.get(n)).data},createChecklist:async t=>(await $e.post("/eor",t)).data,updateItem:async(t,s)=>(await $e.post(`/eor/item/${t}`,s)).data,submitAudit:async(t,s)=>(await $e.post(`/eor/audit/${t}`,s)).data},Wg=Object.freeze(Object.defineProperty({__proto__:null,eorService:x_},Symbol.toStringTag,{value:"Module"})),cV={getAuditLogs:async(t,s,n=1,r=50)=>{var a;try{const l=await Ee.getAuditLogs(t,s,n,r);return((a=l.data)==null?void 0:a.data)||l.data||[]}catch(l){throw console.error("Get audit logs error:",l),l}},getAuditSummary:async(t,s)=>{var n;try{const r=await Ee.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}}},dV={getWorknotes:async(t,s)=>{var r,a;const n=await Ee.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 Ee.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 Ee.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 Ee.removeParticipant(t);if(!s.ok)throw new Error(((n=s.data)==null?void 0:n.message)||"Failed to remove participant");return s.data}};function uV({applicationId:t}){const[s,n]=g.useState(null),[r,a]=g.useState(!0),[l,o]=g.useState([]),[d,m]=g.useState(null),[f,x]=g.useState([]),[h,p]=g.useState(!1),[u,w]=g.useState([]),[v,N]=g.useState([]),[j,y]=g.useState({}),C=g.useCallback(async()=>{try{const A=await ds.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 L=await ds.getApplicationById(t),$=(E,O)=>{var q;const I=(q=L.progressTracking)==null?void 0:q.find(G=>G.stageName===E);if(I!=null&&I.stageCompletedAt)return new Date(I.stageCompletedAt).toISOString();if(I!=null&&I.stageStartedAt)return new Date(I.stageStartedAt).toISOString();if(O){const G=(L.statusHistory||[]).find(Y=>Y.newStatus===O);if(G)return new Date(G.createdAt).toISOString()}},P={id:L.id,registrationNumber:L.applicationId||"N/A",name:L.applicantName,email:L.email,phone:L.phone,age:L.age,education:L.education,residentialAddress:L.address||L.city||"",businessAddress:L.address||"",preferredLocation:L.preferredLocation,state:L.state,ownsBike:L.ownRoyalEnfield==="yes",pastExperience:L.experienceYears?`${L.experienceYears} years`:L.description||"",status:L.overallStatus,questionnaireMarks:L.score||L.questionnaireMarks||0,questionnaireResponses:L.questionnaireResponses||[],rank:0,totalApplicantsAtLocation:0,assignedUsers:[],progress:L.progressPercentage||0,isShortlisted:L.isShortlisted||!0,companyName:L.companyName,source:L.source,existingDealer:L.existingDealer,royalEnfieldModel:L.royalEnfieldModel,description:L.description,pincode:L.pincode,locationType:L.locationType,ownRoyalEnfield:L.ownRoyalEnfield,address:L.address,submissionDate:L.createdAt?new Date(L.createdAt).toISOString():"",questionnaireDate:$("Questionnaire","Questionnaire Completed")||$("Questionnaire","Questionnaire Pending"),shortlistDate:$("Shortlist","Shortlisted"),level1InterviewDate:$("1st Level Interview","Level 1 Approved"),level2InterviewDate:$("2nd Level Interview","Level 2 Approved"),level3InterviewDate:$("3rd Level Interview","Level 3 Approved"),fddDate:$("FDD","FDD Verification"),loiApprovalDate:$("LOI Approval","LOI In Progress"),securityDetailsDate:$("Security Deposit","Security Deposit")||$("Security Details","Security Details"),loiIssueDate:$("LOI Issue","LOI Issued"),dealerCodeDate:$("Dealer Code Generation","Dealer Code Generation"),architectureAssignedDate:$("Architecture Team Assigned","Architecture Team Assigned"),architectureDocumentDate:$("Architecture Document Upload","Architecture Document Upload"),architectureCompletionDate:$("Architecture Team Completion","Architecture Team Completion"),loaDate:$("LOA","LOA Pending"),eorCompleteDate:$("EOR Complete","EOR Complete"),inaugurationDate:$("Inauguration","Inauguration"),onboardedDate:L.overallStatus==="Onboarded"?L.updatedAt?new Date(L.updatedAt).toISOString():new Date().toISOString():void 0,progressTracking:L.progressTracking||[],participants:L.participants||[],dealerCode:L.dealerCode,zoneId:L.zoneId,regionId:L.regionId,areaId:L.areaId,districtId:L.districtId,stageApprovals:L.stageApprovals||[],fddAssignments:L.fddAssignments||[],constitutionType:L.constitutionType,architectureStatus:L.architectureStatus,statutoryStatus:L.statutoryStatus,panNumber:L.panNumber,gstNumber:L.gstNumber,bankName:L.bankName,accountNumber:L.accountNumber,ifscCode:L.ifscCode,branchName:L.branchName,accountHolderName:L.accountHolderName,registeredAddress:L.registeredAddress};n(P),L.uploadedDocuments&&o(L.uploadedDocuments||[])}catch(L){console.error("Failed to fetch application details",L)}finally{a(!1)}},[t]),D=g.useCallback(async()=>{if(t)try{const A=await x_.getChecklist(t);A.success&&A.data&&m(A.data)}catch{m(null)}},[t]),R=A=>v.find(L=>L.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()=>{p(!0);try{const L=await cV.getAuditLogs("application",s.id,1,100);x(Array.isArray(L)?L:[])}catch{x([])}finally{p(!1)}try{const L=await dV.getWorknotes("application",s.id);w(L.data||[])}catch{w([])}})()},[s==null?void 0:s.id]),g.useEffect(()=>{if(!t)return;(async()=>{try{const[L,$]=await Promise.all([ds.getSecurityDeposit(t),ds.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);N(Array.isArray(L)?L:[L].filter(Boolean)),y($||{})}catch(L){console.error("Failed to fetch payment data",L)}})()},[t]),{application:s,loading:r,setLoading:a,documents:l,setDocuments:o,eorData:d,auditLogs:f,auditLoading:h,worknotes:u,deposits:v,paymentConfigs:j,refreshDocuments:C,fetchApplication:S,fetchEorData:D,getDeposit:R}}function hV({application:t,applicationId:s,tempFirmType:n,setUpdatingFirmType:r,setShowFirmTypeModal:a,setStatutoryForm:l,setIsEditingStatutory:o,setIsSavingStatutory:d,statutoryForm:m,setFddAgencies:f,selectedAgencyId:x,setIsAssigningAgency:h,fetchApplication:p}){const u=async()=>{try{r(!0),await ds.updateApplication(s,{constitutionType:n}),ee.success("Firm type updated successfully"),a(!1),await p()}catch{ee.error("Failed to update firm type")}finally{r(!1)}},w=()=>{t&&(l({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 ds.updateApplication(s,m),ee.success("Statutory & Bank details updated successfully"),o(!1),await p(!0)}catch{ee.error("Failed to update details")}finally{d(!1)}},N=g.useCallback(async()=>{try{const y=await ds.getUsers({roleCode:"FDD"});f(Array.isArray(y)?y:[])}catch{f([])}},[f]);return{handleUpdateFirmType:u,handleEditStatutory:w,handleSaveStatutory:v,fetchFddAgencies:N,handleAssignAgency:async()=>{if(!x){ee.warning("Please select an agency");return}try{h(!0),await ds.assignFddAgency({applicationId:(t==null?void 0:t.id)||s,assignedToAgency:x}),await ds.addParticipant({requestId:(t==null?void 0:t.id)||s,requestType:"application",userId:x,participantType:"contributor"}),ee.success("FDD Agency assigned and added as participant"),await p()}catch{ee.error("Failed to assign agency")}finally{h(!1)}}}}function mV({application:t,documents:s,interviews:n,eorData:r,getDeposit:a,documentConfigs:l=[]}){var N;const o=j=>String(j||"").trim().toLowerCase().replace(/[_\s-]+/g," "),d=(j,y)=>{var D,R,A;const C=[(D=j==null?void 0:j.user)==null?void 0:D.role,(R=j==null?void 0:j.user)==null?void 0:R.roleCode,(A=j==null?void 0:j.metadata)==null?void 0:A.role].map(o),S=y.map(o);return C.some(L=>S.includes(L))},m=j=>{var y,C,S,D,R;return`${((y=j==null?void 0:j.user)==null?void 0:y.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)||((R=j==null?void 0:j.metadata)==null?void 0:R.role)||(j==null?void 0:j.participantType)||"participant"})`},f=j=>(s||[]).some(y=>y.documentType===j),x=()=>{const j=t.progressTracking||[],y=j.find(C=>C.stageName==="Security Deposit")||j.find(C=>C.stageName==="Security Details");return y!=null&&y.status?y.status:"pending"},h=(j,y="pending")=>{const C=(t.progressTracking||[]).find(S=>S.stageName===j);return C!=null&&C.status?C.status:y},p=[{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 y,C,S;return`${((y=j.user)==null?void 0:y.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 y,C,S,D,R,A;return((y=j.metadata)==null?void 0:y.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=(R=j.metadata)==null?void 0:R.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 y,C,S,D,R,A;return((y=j.metadata)==null?void 0:y.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=(R=j.metadata)==null?void 0:R.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 y,C,S,D,R,A;return((y=j.metadata)==null?void 0:y.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=(R=j.metadata)==null?void 0:R.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 y,C,S;return((y=j.metadata)==null?void 0:y.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:x(),date:t.securityDetailsDate,description:"Security Deposit verification",documentsUploaded:3},(()=>{const j=l.filter(R=>R.stageCode==="LOI Issue"||R.stageCode==="LOI Documents"),C=(j.length?j.map(R=>R.documentType):["Letter of Intent","Signed LOI"]).every(R=>f(R)||R==="Letter of Intent"&&f("LOI")||R==="Signed LOI"&&f("LOI Signed Copy")),S=h("LOI Approval")==="completed";return{id:10,name:"LOI Documents",status:C?"completed":S?"active":"pending",description:"Upload Letter of Intent documents before issuance",isParallel:!0,branches:[{name:"Documents Required",color:"green",stages:j.length?j.map((R,A)=>({id:`10a-${A}`,name:R.documentType,status:f(R.documentType)?"completed":"active",description:R.isMandatory?`Upload ${R.documentType} (Mandatory)`:`Upload ${R.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:"LOI Issue",status:h("LOI Issue"),date:t.loiIssueDate,description:"Letter of Intent issued"},{id:12,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:"12a-1",name:"Architecture Assignment",status:t.architectureAssignedTo?"completed":t.status==="Architecture Team Assigned"?"active":"pending",description:"Assigned to architecture team"},{id:"12a-2",name:"Site Plan Blueprint",status:f("Architecture Blueprint")?"completed":t.architectureAssignedTo?"active":"pending",description:"Blueprints and site plans"},{id:"12a-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:"12b-1",name:"GST",status:f("GST Certificate")||f("GST")?"completed":"active",description:"GST certificate"},{id:"12b-2",name:"PAN",status:f("PAN Card")||f("PAN")?"completed":"active",description:"PAN card"},{id:"12b-3",name:"Nodal Agreement",status:f("Nodal Agreement")?"completed":"active",description:"Nodal agreement document"},{id:"12b-4",name:"Cancelled Check",status:f("Cancelled Check")?"completed":"active",description:"Cancelled check copy"},{id:"12b-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:"12b-6",name:"Firm Registration Certificate",status:f("Firm Registration Certificate")||f("Firm Registration")?"completed":"active",description:"Firm registration certificate"},{id:"12b-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:"12b-8",name:"Virtual Code",status:f("Virtual Code")||f("Virtual Code Confirmation")?"completed":"active",description:"Virtual code availability"},{id:"12b-9",name:"Domain ID",status:f("Domain ID")||f("Domain ID Setup")?"completed":"active",description:"Domain ID setup"},{id:"12b-10",name:"MSD Configuration",status:f("MSD Configuration")?"completed":"active",description:"Microsoft Dynamics configuration"},{id:"12b-11",name:"LOI Acknowledgement Copy",status:f("LOI Acknowledgement Copy")||f("LOI Acknowledgement")?"completed":"active",description:"LOI acknowledgement copy"}]}]},{id:13,name:"LOA",status:h("LOA"),isLocked:t.status==="LOA Pending"&&((N=a("FIRST_FILL"))==null?void 0:N.status)!=="Verified",lockMessage:"First Fill (₹15L) must be verified by Finance before LOA Approval.",evaluators:Array.from(new Set((t.participants||[]).filter(j=>{var y,C,S;return((y=j.metadata)==null?void 0:y.stageCode)==="LOA_APPROVAL"||((S=(C=j.metadata)==null?void 0:C.allAssignments)==null?void 0:S.includes("LOA_APPROVAL"))}).map(m))),description:"Letter of Agreement"},{id:14,name:"EOR Complete",status:h("EOR Complete"),description:"Essential Operating Requirements"},{id:15,name:"Inauguration",status:h("Inauguration"),description:"Dealership inauguration"},{id:16,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}],w=p.reduce((j,y)=>(j.push({name:y.name}),y.branches&&y.branches.forEach(C=>C.stages.forEach(S=>j.push({name:S.name,parentBranch:C.name}))),(y.name==="EOR In Progress"||y.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:p,eorChecklist:u,flattenedStages:w,getDocumentsForStage:j=>s.filter(y=>{var C;return y.stage===j||!y.stage&&((C=y.documentType)==null?void 0:C.toLowerCase().includes(j.toLowerCase().split(" ")[0]))})}}const TS=()=>{var _d;const{id:t}=gd(),s=tr(),{user:n}=Fn(yr=>yr.auth),r=t||"",a=()=>s(-1),[l,o]=g.useState(null);g.useEffect(()=>{r&&Zl.getBatchStatus([{entityType:"application",entityId:r}]).then(yr=>{yr!=null&&yr.success&&o(yr.data[`application:${r}`]??null)}).catch(()=>o(null))},[r]);const{application:d,loading:m,setLoading:f,documents:x,setDocuments:h,eorData:p,auditLogs:u,auditLoading:w,worknotes:v,deposits:N,paymentConfigs:j,refreshDocuments:y,fetchApplication:C,fetchEorData:S,getDeposit:D}=uV({applicationId:r}),R=p!=null&&p.items?p.items.filter(yr=>yr.isCompliant).length/p.items.length*100:0,A=Ui(),{showFirmTypeModal:L,setShowFirmTypeModal:$,updatingFirmType:P,setUpdatingFirmType:E,tempFirmType:O,setTempFirmType:I,activeTab:q,setActiveTab:G,showApproveModal:Y,setShowApproveModal:V,showOnboardModal:Q,setShowOnboardModal:_,isOnboarding:z,setIsOnboarding:T,showRejectModal:F,setShowRejectModal:B,rejectionReason:K,setRejectionReason:W,scheduledInterviewParticipants:H,setScheduledInterviewParticipants:X,showScheduleModal:J,setShowScheduleModal:ie,showCancelInterviewModal:ae,setShowCancelInterviewModal:xe,interviewIdToCancel:ce,setInterviewIdToCancel:we,interviewToReschedule:ke,setInterviewToReschedule:Xe,showKTMatrixModal:Ot,setShowKTMatrixModal:bt,showLevel2FeedbackModal:te,setShowLevel2FeedbackModal:ve,showLevel3FeedbackModal:qe,setShowLevel3FeedbackModal:ge,showDocumentsModal:Be,setShowDocumentsModal:ut,showAssignModal:ht,setShowAssignModal:it,selectedStage:Tt,setSelectedStage:It,interviewMode:he,setInterviewMode:vt,approvalRemark:mt,setApprovalRemark:_e,expandedBranches:Vt,setExpandedBranches:Et,users:Ds,setUsers:ln,selectedUser:Bs,setSelectedUser:Ys,participantType:Xs,setParticipantType:Js,interviewDate:Ws,setInterviewDate:Z,interviewType:oe,setInterviewType:Ne,meetingLink:Oe,setMeetingLink:De,location:ye,setLocation:Ve,showUploadForm:Ge,setShowUploadForm:st,uploadFile:Kt,setUploadFile:Xt,uploadDocType:ot,setUploadDocType:ft,approvalFile:Es,setApprovalFile:ts,isUploading:vs,setIsUploading:Te,previewDoc:je,setPreviewDoc:nt,showPreviewModal:Ye,setShowPreviewModal:pt,selectedInterviewerId:yt,setSelectedInterviewerId:Jt,isEditingStatutory:ss,setIsEditingStatutory:Ss,statutoryForm:Zs,setStatutoryForm:on,isSavingStatutory:en,setIsSavingStatutory:tn,interviews:cn,setInterviews:Ae,isScheduling:Ht,setIsScheduling:Pe,isCancellingInterview:ct,setIsCancellingInterview:tt,showAssignArchitectureModal:Nt,setShowAssignArchitectureModal:Mt,architectureLeadId:Pt,setArchitectureLeadId:ys,isAssigningArchitecture:Yt,setIsAssigningArchitecture:ps,showArchitectureStatusModal:ks,setShowArchitectureStatusModal:hs,architectureStatus:gn,setArchitectureStatus:$s,architectureRemarks:dn,setArchitectureRemarks:sn,isUpdatingArchitecture:We,setIsUpdatingArchitecture:Ft,isAssigningParticipant:gt,setIsAssigningParticipant:rt,documentConfigs:Is,setDocumentConfigs:xs,fddAgencies:Nn,setFddAgencies:kn,selectedAgencyId:Cn,setSelectedAgencyId:Us,isAssigningAgency:Za,setIsAssigningAgency:Pa,showAssignFddModal:Ms,setShowAssignFddModal:un,isApproving:ta,setIsApproving:sa,isRejecting:na,setIsRejecting:Mr,ktMatrixScores:Xn,setKtMatrixScores:zn,ktMatrixSelectedValues:Zt,setKtMatrixSelectedValues:Jn,ktMatrixRemarks:Er,setKtMatrixRemarks:Gn,ktMatrixRecommendation:_r,setKtMatrixRecommendation:On,isSubmittingKT:ur,setIsSubmittingKT:ns,selectedInterviewForFeedback:nn,setSelectedInterviewForFeedback:va,showFddFinalizeModal:Si,setShowFddFinalizeModal:Ci,showFddFlagModal:Fr,setShowFddFlagModal:Hr,fddAuditRecommendation:sr,setFddAuditRecommendation:ya,fddAuditFindings:Gi,setFddAuditFindings:bo,isFinalizingFdd:Oa,setIsFinalizingFdd:An,isFddFlagging:ba,setIsFddFlagging:Ki,level2Feedback:Wr,setLevel2Feedback:jo,level2Recommendation:Yi,setLevel2Recommendation:No,isSubmittingLevel2:Ai,setIsSubmittingLevel2:wl,level3Feedback:Sl,setLevel3Feedback:hn,level3Recommendation:ne,setLevel3Recommendation:re,isSubmittingLevel3:me,setIsSubmittingLevel3:pe,showFeedbackDetailsModal:Se,setShowFeedbackDetailsModal:ze,selectedEvaluationForView:Ue,setSelectedEvaluationForView:dt}=nV({initialTab:((_d=A.state)==null?void 0:_d.activeTab)||"questionnaire"}),is=(v||[]).some(yr=>(yr.noteText||"").includes("FLAGGED:"))||(d==null?void 0:d.statutoryStatus)==="Flagged",{handleUpdateFirmType:Ut,handleEditStatutory:Lt,handleSaveStatutory:Cs,fetchFddAgencies:vn,handleAssignAgency:nr}=hV({application:d,applicationId:r,tempFirmType:O,setUpdatingFirmType:E,setShowFirmTypeModal:$,setStatutoryForm:on,setIsEditingStatutory:Ss,setIsSavingStatutory:tn,statutoryForm:Zs,setFddAgencies:kn,selectedAgencyId:Cn,setIsAssigningAgency:Pa,fetchApplication:C}),Bt=(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",As=(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",os=(n==null?void 0:n.roleCode)==="Super Admin"||(n==null?void 0:n.roleCode)==="DD Admin"||(n==null?void 0:n.roleCode)==="Finance"||(n==null?void 0:n.roleCode)==="Finance Admin"||(n==null?void 0:n.role)==="Super Admin"||(n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="Finance"||(n==null?void 0:n.role)==="Finance Admin";g.useEffect(()=>{(async()=>{try{const El=await ds.getDocumentConfigs({limit:1e3}),Pp=El.data||(Array.isArray(El)?El:[]);xs(Pp)}catch(El){console.error("Failed to fetch document configs:",El)}})()},[xs]),g.useEffect(()=>{J&&d&&(d.status==="Shortlisted"||d.status==="Questionnaire Completed"?Ne("level1"):d.status==="Level 1 Approved"?Ne("level2"):(d.status==="Level 2 Approved"||d.status==="Level 2 Recommended")&&Ne("level3"))},[J,d==null?void 0:d.status,Ne]);const En=async()=>{if(r)try{const yr=await ds.getInterviews(r);Ae(yr||[])}catch(yr){console.error("Failed to fetch interviews",yr)}};g.useEffect(()=>{En()},[r]);const{ktMatrixConfig:Tr,level2Config:Kn,level3Config:xr}=lV(),{handleKTMatrixChange:Gr,calculateKTScore:Qa,handleSubmitKTMatrix:gr,handleLevel2Change:wo,handleSubmitLevel2Feedback:Cl,handleLevel3Change:gc,handleSubmitLevel3Feedback:So,ktCriteria:Al,l2Fields:Zi,l3Fields:Xa}=iV({ktMatrixScores:Xn,setKtMatrixScores:zn,setKtMatrixSelectedValues:Jn,ktMatrixRemarks:Er,setKtMatrixRemarks:Gn,ktMatrixRecommendation:_r,setKtMatrixRecommendation:On,selectedInterviewForFeedback:nn,interviews:cn,setIsSubmittingKT:ns,setShowKTMatrixModal:bt,level2Feedback:Wr,setLevel2Feedback:jo,level2Recommendation:Yi,setLevel2Recommendation:No,setIsSubmittingLevel2:wl,setShowLevel2FeedbackModal:ve,level3Feedback:Sl,setLevel3Feedback:hn,level3Recommendation:ne,setLevel3Recommendation:re,setIsSubmittingLevel3:pe,setShowLevel3FeedbackModal:ge,currentUser:n,fetchInterviews:En,fetchApplication:C,ktMatrixConfig:Tr,level2Config:Kn,level3Config:xr});g.useEffect(()=>{["documents","progress","fdd","eor"].includes(q)&&r&&y(),q==="fdd"&&((n==null?void 0:n.role)==="DD Admin"||(n==null?void 0:n.role)==="Super Admin")&&vn()},[q,r,y,vn,n==null?void 0:n.role]);const{handleAddInterviewer:vc,handleRemoveInterviewer:vr,maybeFetchUsersForModal:Co,handleScheduleInterview:La,handleRescheduleInterview:kl,handleConfirmCancelInterview:Qi,handleUpload:Ia,handleApprove:Ja,handleReject:Dl,handleGenerateDealerCodes:Xi,handleAssignArchitecture:Ao,handleUpdateArchitectureStatus:ch,handleAddParticipant:Rl,handleRetriggerEvaluators:Dp}=oV({application:d,applicationId:r,currentUser:n,interviews:cn,approvalFile:Es,approvalRemark:mt,rejectionReason:K,architectureLeadId:Pt,architectureStatus:gn,architectureRemarks:dn,selectedUser:Bs,participantType:Xs,users:Ds,interviewDate:Ws,setInterviewDate:Z,interviewType:oe,setInterviewType:Ne,interviewMode:he,setInterviewMode:vt,meetingLink:Oe,setMeetingLink:De,location:ye,setLocation:Ve,scheduledInterviewParticipants:H,uploadFile:Kt,uploadDocType:ot,selectedStage:Tt,setIsApproving:sa,setShowApproveModal:V,setApprovalRemark:_e,setApprovalFile:ts,setIsRejecting:Mr,setShowRejectModal:B,setRejectionReason:W,setIsAssigningArchitecture:ps,setShowAssignArchitectureModal:Mt,setIsUpdatingArchitecture:Ft,setShowArchitectureStatusModal:hs,setIsAssigningParticipant:rt,setSelectedUser:Ys,setShowAssignModal:it,setLoading:f,setIsScheduling:Pe,setShowScheduleModal:ie,setShowCancelInterviewModal:xe,interviewIdToCancel:ce,setInterviewIdToCancel:we,interviewToReschedule:ke,setInterviewToReschedule:Xe,setIsCancellingInterview:tt,setIsUploading:Te,setShowUploadForm:st,setUploadFile:Xt,setUploadDocType:ft,setDocuments:h,selectedInterviewerId:yt,setSelectedInterviewerId:Jt,setScheduledInterviewParticipants:X,setUsers:ln,showScheduleModal:J,showAssignArchitectureModal:Nt,showAssignModal:ht,fetchApplication:C,fetchInterviews:En,fetchEorData:S});if(g.useEffect(()=>{Co()},[J,Nt,ht,oe,d==null?void 0:d.id,Co]),m&&!d)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(es,{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:Rp,eorChecklist:Ep,flattenedStages:dh,getDocumentsForStage:uh}=mV({application:d,documents:x,interviews:cn,eorData:p,getDeposit:D,documentConfigs:Is}),{activeInterviewForUser:ko,currentUserEvaluation:Do,hasSubmittedFeedback:_p,currentUserStageAction:yc,isInterviewCompleted:Tp,isInterviewActive:hh,permissions:Rd}=sV({application:d,interviews:cn,currentUser:n,getDeposit:D,eorProgress:R}),Ed=()=>e.jsx(QU,{application:d,documents:x,setPreviewDoc:nt,setShowPreviewModal:pt,setIsUploading:Te,fetchApplication:C,refreshDocuments:y});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(_U,{application:d,slaStatus:l,isNonResponsive:is,isAdmin:As,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(FU,{application:d,canEditStatutory:Bt,isEditingStatutory:ss,isSavingStatutory:en,statutoryForm:Zs,onEditFirmType:()=>{I(d.constitutionType||""),$(!0)},onEditStatutory:Lt,onCancelEditStatutory:()=>Ss(!1),onSaveStatutory:Cs,onStatutoryFormChange:on}),d.isShortlisted!==!1&&e.jsx(zU,{application:d,activeTab:q,setActiveTab:G,processStages:Rp,documents:x,interviews:cn,expandedBranches:Vt,setExpandedBranches:Et,setSelectedStage:It,setShowDocumentsModal:ut,setShowUploadForm:st,handleRetriggerEvaluators:Dp,handleRescheduleInterview:kl,setSelectedEvaluationForView:dt,setShowFeedbackDetailsModal:ze,renderFddAuditContent:Ed,eorProgress:R,eorData:p,eorChecklist:Ep,setUploadDocType:ft,isAdmin:As,canViewFinanceTabs:os,fetchApplication:C,fetchEorData:S,deposits:N,getDeposit:D,paymentConfigs:j,setPreviewDoc:nt,setShowPreviewModal:pt,auditLoading:w,auditLogs:u,auditLogActionBadgeClass:XU})]}),e.jsx(GU,{application:d,permissions:Rd,getDeposit:D,isNonResponsive:is,isAdmin:As,currentUserStageAction:yc,currentUserEvaluation:Do,onOpenApproveModal:()=>V(!0),onOpenRejectModal:()=>B(!0),onOpenWorknote:()=>s(`/worknotes/application/${d.id}`,{state:{applicationName:d.name,registrationNumber:d.registrationNumber,participants:d.participants}}),onOpenScheduleModal:()=>ie(!0),currentUser:n,handleGenerateDealerCodes:Xi,onOpenAssignArchitectureModal:()=>Mt(!0),onOpenAssignFdd:()=>{Us(""),vn(),un(!0)},showAssignFddModal:Ms,setShowAssignFddModal:un,fddAgencies:Nn,selectedAgencyId:Cn,setSelectedAgencyId:Us,isAssigningAgency:Za,handleAssignAgency:async()=>{await nr(),un(!1)},activeInterviewForUser:ko,hasSubmittedFeedback:_p,setSelectedInterviewForFeedback:va,setShowKTMatrixModal:bt,setShowLevel2FeedbackModal:ve,setShowLevel3FeedbackModal:ge,onGoToDashboard:()=>s("/dashboard"),showAssignModal:ht,setShowAssignModal:it,selectedUser:Bs,setSelectedUser:Ys,users:Ds,participantType:Xs,setParticipantType:Js,handleAddParticipant:Rl,isAssigningParticipant:gt,documents:x,documentConfigs:Is}),e.jsx(KU,{application:d,fetchApplication:C,showApproveModal:Y,setShowApproveModal:V,approvalRemark:mt,setApprovalRemark:_e,setApprovalFile:ts,isApproving:ta,handleApprove:Ja,showOnboardModal:Q,setShowOnboardModal:_,isOnboarding:z,setIsOnboarding:T,showRejectModal:F,setShowRejectModal:B,rejectionReason:K,setRejectionReason:W,isRejecting:na,handleReject:Dl,showScheduleModal:J,setShowScheduleModal:ie,showCancelInterviewModal:ae,setShowCancelInterviewModal:xe,setInterviewIdToCancel:we,isCancellingInterview:ct,handleConfirmCancelInterview:Qi,interviewToReschedule:ke,setInterviewToReschedule:Xe,interviewType:oe,setInterviewType:Ne,interviewMode:he,setInterviewMode:vt,interviewDate:Ws,setInterviewDate:Z,meetingLink:Oe,setMeetingLink:De,location:ye,setLocation:Ve,isInterviewCompleted:Tp,isInterviewActive:hh,users:Ds,selectedInterviewerId:yt,setSelectedInterviewerId:Jt,handleAddInterviewer:vc,scheduledInterviewParticipants:H,handleRemoveInterviewer:vr,isScheduling:Ht,handleScheduleInterview:La,showAssignArchitectureModal:Nt,setShowAssignArchitectureModal:Mt,architectureLeadId:Pt,setArchitectureLeadId:ys,isAssigningArchitecture:Yt,handleAssignArchitecture:Ao,showArchitectureStatusModal:ks,setShowArchitectureStatusModal:hs,architectureStatus:gn,setArchitectureStatus:$s,architectureRemarks:dn,setArchitectureRemarks:sn,isUpdatingArchitecture:We,handleUpdateArchitectureStatus:ch}),e.jsx(YU,{application:d,ktCriteria:Al,l2Fields:Zi,l3Fields:Xa,showKTMatrixModal:Ot,setShowKTMatrixModal:bt,ktMatrixSelectedValues:Zt,handleKTMatrixChange:Gr,ktMatrixRemarks:Er,setKtMatrixRemarks:Gn,ktMatrixRecommendation:_r,setKtMatrixRecommendation:On,calculateKTScore:Qa,handleSubmitKTMatrix:gr,isSubmittingKT:ur,showLevel2FeedbackModal:te,setShowLevel2FeedbackModal:ve,level2Feedback:Wr,handleLevel2Change:wo,level2Recommendation:Yi,setLevel2Recommendation:No,handleSubmitLevel2Feedback:Cl,isSubmittingLevel2:Ai,showFeedbackDetailsModal:Se,setShowFeedbackDetailsModal:ze,selectedEvaluationForView:Ue,selectedInterviewForFeedback:nn,showLevel3FeedbackModal:qe,setShowLevel3FeedbackModal:ge,level3Feedback:Sl,handleLevel3Change:gc,level3Recommendation:ne,setLevel3Recommendation:re,handleSubmitLevel3Feedback:So,isSubmittingLevel3:me,showDocumentsModal:Be,setShowDocumentsModal:ut,showUploadForm:Ge,setShowUploadForm:st,selectedStage:Tt,getDocumentsForStage:uh,setPreviewDoc:nt,setShowPreviewModal:pt,flattenedStages:dh,setSelectedStage:It,uploadDocType:ot,setUploadDocType:ft,setUploadFile:Xt,isUploading:vs,handleUpload:Ia,uploadFile:Kt,documentConfigs:Is,showPreviewModal:Ye,previewDoc:je,showFddFinalizeModal:Si,setShowFddFinalizeModal:Ci,currentUser:n,fddAuditRecommendation:sr,setFddAuditRecommendation:ya,fddAuditFindings:Gi,setFddAuditFindings:bo,isFinalizingFdd:Oa,setIsFinalizingFdd:An,fetchApplication:C,showFddFlagModal:Fr,setShowFddFlagModal:Hr,isFddFlagging:ba,setIsFddFlagging:Ki,showFirmTypeModal:L,setShowFirmTypeModal:$,tempFirmType:O,setTempFirmType:I,updatingFirmType:P,handleUpdateFirmType:Ut})]})]})};function xc(t,s=!0){const[n,r]=g.useState({});return g.useEffect(()=>{if(!s||t.length===0){r({});return}Zl.getBatchStatus(t).then(l=>{l!=null&&l.success&&r(l.data)}).catch(()=>r({}))},[s,JSON.stringify(t.map(l=>`${l.entityType}:${l.entityId}`).sort())]),{byKey:n,get:(l,o)=>n[`${l}:${o}`]??null}}const Gg=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 fV({onViewDetails:t}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[l,o]=g.useState(1),[d,m]=g.useState("all"),[f,x]=g.useState(null),h=10,p=async()=>{var y;a(!0);try{const S=(await Ee.getResignations({page:l,limit:h,status:d==="all"?void 0:d==="open"?"open":"Completed,Closed"})).data;S!=null&&S.success&&(n(S.requests||((y=S.resignations)==null?void 0:y.rows)||S.resignations||[]),x(S.meta))}catch(C){console.error("Error fetching resignations:",C),ee.error("Failed to fetch resignation requests")}finally{a(!1)}};g.useEffect(()=>{p()},[l,d]);const u=y=>{m(y),o(1)},w=d==="open"?s:[],v=d==="completed"?s:[],N=s.map(y=>({entityType:"resignation",entityId:y.id})),{get:j}=xc(N,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(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"All Requests"}),e.jsx(et,{className:"text-3xl",children:(f==null?void 0:f.total)||0})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Requests"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Open"}),e.jsx(et,{className:"text-3xl text-yellow-600",children:d==="open"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Completed"}),e.jsx(et,{className:"text-3xl text-green-600",children:d==="completed"?(f==null?void 0:f.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(et,{children:"Resignation Requests"}),e.jsxs(Qt,{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(Fe,{children:e.jsxs($n,{value:d,onValueChange:u,className:"w-full",children:[e.jsxs(qn,{children:[e.jsx(zt,{value:"all",children:"All Requests"}),e.jsx(zt,{value:"open",children:"Open"}),e.jsx(zt,{value:"completed",children:"Completed"})]}),e.jsx(qt,{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(y=>{var C,S,D,R,A,L,$,P,E,O,I;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(Ns,{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:y.resignationId}),e.jsx(Ce,{className:Gg(y.status),children:y.status}),e.jsx(kr,{status:j("resignation",y.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=y.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=y.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:((L=(A=(R=y.dealer)==null?void 0:R.dealerProfile)==null?void 0:A.dealerCode)==null?void 0:L.dealerCode)||(($=y.outlet)==null?void 0:$.code)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((E=(P=y.dealer)==null?void 0:P.dealerProfile)==null?void 0:E.registeredAddress)||((O=y.outlet)!=null&&O.city&&((I=y.outlet)!=null&&I.state)?`${y.outlet.city}, ${y.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Type"}),e.jsx("p",{children:y.resignationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate max-w-[200px]",children:y.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:y.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(dr,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:Gt(y.submittedOn)})]})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(y.id),className:"ml-4",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},y.id)}),f&&f.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>o(y=>Math.max(1,y-1)),className:l===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(f.totalPages)].map((y,C)=>{const S=C+1;return S===1||S===f.totalPages||S>=l-1&&S<=l+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:l===S,onClick:()=>o(S),className:"cursor-pointer",children:S})},S):S===2&&l>3||S===f.totalPages-1&&l<f.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},S):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>o(y=>Math.min(f.totalPages,y+1)),className:l===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(qt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w.length>0?w.map(y=>{var C,S,D,R,A,L,$;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(Ns,{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:y.resignationId}),e.jsx(Ce,{className:Gg(y.status),children:y.status}),e.jsx(kr,{status:j("resignation",y.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=y.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=y.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=(R=y.dealer)==null?void 0:R.dealerProfile)==null?void 0:A.registeredAddress)||((L=y.outlet)!=null&&L.city&&(($=y.outlet)!=null&&$.state)?`${y.outlet.city}, ${y.outlet.state}`:"N/A")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:y.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Gt(y.submittedOn)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(y.id),className:"ml-4",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},y.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ns,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(qt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:v.length>0?v.map(y=>{var C,S,D,R,A,L;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(Ns,{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:y.resignationId}),e.jsx(Ce,{className:Gg(y.status),children:y.status}),e.jsx(kr,{status:j("resignation",y.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=y.dealer)==null?void 0:C.dealerProfile)==null?void 0:S.businessName)||((D=y.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=(R=y.dealer)==null?void 0:R.dealerProfile)==null?void 0:A.registeredAddress)||((L=y.outlet)==null?void 0:L.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Final Stage"}),e.jsx("p",{children:y.currentStage})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Gt(y.submittedOn)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(y.id),className:"ml-4",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},y.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(Ns,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed resignations to display"})]})})})]})})]})]})}const Oi="Last Working Day",PS="Proposed Last Working Day",Vc={AWAITING_FNF:"Awaiting F&F",AWAITING_FNF_LWD_PENDING:"Awaiting F&F (LWD Pending)"},Li=fr.inProgress;function oj(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,Oi),s}const pV=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"}},Kg=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",lu=oj;function xV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState(!1),[a,l]=g.useState([]),[o,d]=g.useState(""),[m,f]=g.useState(!1),[x,h]=g.useState(""),[p,u]=g.useState(null),[w,v]=g.useState([]),[N,j]=g.useState({}),[y,C]=g.useState(!0),[S,D]=g.useState(1),[R,A]=g.useState(null),[L,$]=g.useState("all"),P=10,[E,O]=g.useState({terminationCategory:"",reason:"",proposedLwd:"",comments:"",documents:[]}),I=async()=>{C(!0);try{const ie=(await Ee.getTerminations({page:S,limit:P,status:L==="all"?void 0:L})).data;if(ie!=null&&ie.success){v(ie.terminations),A(ie.meta);const ae=ie.terminations||[];ae.length?Zl.getBatchStatus(ae.map(xe=>({entityType:"termination",entityId:xe.id}))).then(xe=>{if(xe!=null&&xe.success){const ce={};ae.forEach(we=>{ce[we.id]=xe.data[`termination:${we.id}`]??null}),j(ce)}}).catch(()=>j({})):j({})}}catch(J){console.error("Error fetching terminations:",J),ee.error("Failed to fetch termination requests")}finally{C(!1)}};g.useEffect(()=>{I()},[S,L]);const q=J=>{$(J),D(1)};g.useEffect(()=>{if(!n||!W)return;let J=!1;return(async()=>{try{f(!0);const ae=(await Ee.getDealers({onboarded:"true",activeOnly:"true"})).data;if(!J&&(ae!=null&&ae.success)){const xe=(Array.isArray(ae.data)?ae.data:[]).filter(ce=>{var Xe,Ot;const we=String((ce==null?void 0:ce.status)||"").toLowerCase(),ke=String(((Xe=ce==null?void 0:ce.user)==null?void 0:Xe.status)||"").toLowerCase();return we==="active"&&((Ot=ce==null?void 0:ce.user)==null?void 0:Ot.isActive)&&ke==="active"});l(xe)}}catch(ie){J||(console.error("Error fetching dealers:",ie),ee.error("Failed to load dealer list"))}finally{J||f(!1)}})(),()=>{J=!0}},[n]);const G=J=>{var ie,ae,xe,ce,we,ke;return{id:J.id,dealerId:J.id,dealerCode:((ie=J.dealerCode)==null?void 0:ie.dealerCode)||"",legalName:J.legalName||"N/A",businessName:J.businessName||"N/A",gstNumber:J.gstNumber||"N/A",address:J.registeredAddress||((ae=J.application)==null?void 0:ae.preferredLocation)||"N/A",city:((xe=J.application)==null?void 0:xe.city)||"N/A",state:((ce=J.application)==null?void 0:ce.state)||"N/A",email:((we=J.user)==null?void 0:we.email)||"N/A",phoneNumber:((ke=J.user)==null?void 0:ke.mobileNumber)||"N/A"}},Y=J=>{d(J);const ie=a.find(xe=>String(xe.id)===String(J));if(!ie){h(""),u(null);return}const ae=G(ie);h(ae.dealerCode),u(ae)},V=J=>{h(J);const ie=J.trim().toLowerCase();if(!ie){d(""),u(null);return}const ae=a.find(xe=>{var ce;return String(((ce=xe.dealerCode)==null?void 0:ce.dealerCode)||"").toLowerCase()===ie});if(!ae){d(""),u(null);return}d(String(ae.id)),u(G(ae))},_=!((t==null?void 0:t.role)==="Super Admin"),z=J=>{const ie=J.name.toLowerCase();return ie.endsWith(".ppt")||ie.endsWith(".pptx")},T=(J,ie)=>{!J||J.length===0||(O(ae=>{const xe=ae.documents,ce=new Set(xe.map(ke=>`${ke.name}::${ke.size}`)),we=[];return Array.from(J).forEach(ke=>{const Xe=`${ke.name}::${ke.size}`;ce.has(Xe)||(ce.add(Xe),we.push(ke))}),{...ae,documents:[...xe,...we]}}),ie&&(ie.value=""))},F=J=>{O({...E,documents:E.documents.filter((ie,ae)=>ae!==J)})},B=async J=>{var ie,ae;if(J.preventDefault(),!p){ee.error("Please select a dealer");return}if(_){if(E.documents.length===0){ee.error("Please upload at least one Presentation (.ppt or .pptx)");return}if(!E.documents.some(z)){ee.error("At least one PowerPoint file (.ppt or .pptx) is required");return}}try{const xe=p.dealerId||p.id;if(!xe){ee.error("Dealer record not found for the selected dealer");return}let ce;if(E.documents.length>0){const Xe=new FormData;Xe.append("dealerId",String(xe)),Xe.append("category",E.terminationCategory),Xe.append("reason",E.reason),Xe.append("proposedLwd",E.proposedLwd),Xe.append("comments",E.comments),E.documents.forEach(Ot=>Xe.append("files",Ot)),ce=Xe}else ce={dealerId:xe,category:E.terminationCategory,reason:E.reason,proposedLwd:E.proposedLwd,comments:E.comments};const ke=(await Ee.createTermination(ce)).data;ke!=null&&ke.success&&(ee.success(E.documents.length>0?"Termination request and documents submitted":"Termination request submitted successfully"),r(!1),I(),d(""),h(""),l([]),u(null),O({terminationCategory:"",reason:"",proposedLwd:"",comments:"",documents:[]}))}catch(xe){console.error("Error submitting termination:",xe),ee.error(((ae=(ie=xe.response)==null?void 0:ie.data)==null?void 0:ae.message)||"Failed to submit termination request")}},K=["DD Lead","ASM","DD Admin","DD AM","Super Admin"],W=(t==null?void 0:t.role)&&K.includes(t.role),H=L==="open"||L==="all"?w:[],X=L==="completed"||L==="all"?w:[];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(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"All Cases"}),e.jsx(et,{className:"text-3xl",children:(R==null?void 0:R.total)||0})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Total Cases"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Open"}),e.jsx(et,{className:"text-3xl text-orange-600",children:L==="open"?(R==null?void 0:R.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Requires Your Action"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Completed"}),e.jsx(et,{className:"text-3xl text-green-600",children:L==="completed"?(R==null?void 0:R.total)||0:"..."})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Termination Requests"}),e.jsx(Qt,{children:"Manage dealer termination proceedings and legal compliance"})]}),W&&e.jsxs(ls,{open:n,onOpenChange:r,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-red-600 hover:bg-red-700",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Create Termination Request"]})}),e.jsxs(as,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Create Termination Request"}),e.jsx(bs,{children:"Fill in the details to create a new termination request"})]}),e.jsxs("form",{onSubmit:B,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Select Dealer *"}),e.jsxs(At,{value:o,onValueChange:Y,disabled:m,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:m?"Loading dealers...":"Select dealer"})}),e.jsx(Rt,{children:a.map(J=>{var ie;return e.jsxs(Me,{value:String(J.id),children:[J.legalName||J.businessName||"Unnamed Dealer"," - ",((ie=J.dealerCode)==null?void 0:ie.dealerCode)||"No Code"]},J.id)})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"dealerCode",children:"Dealer Code *"}),e.jsx(at,{id:"dealerCode",value:x,onChange:J=>V(J.target.value),placeholder:"Type dealer code to auto-select",required:!0})]}),p&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-slate-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name (Legal)"}),e.jsx("p",{children:p.legalName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Business Name"}),e.jsx("p",{children:p.businessName||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:p.gstNumber||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:p.address})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"City/State"}),e.jsxs("p",{children:[p.city,", ",p.state]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:p.dealerCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Contact"}),e.jsxs("p",{children:[p.email," / ",p.phoneNumber]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Termination Category *"}),e.jsxs(At,{value:E.terminationCategory,onValueChange:J=>O({...E,terminationCategory:J}),children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select termination category"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Working Capital",children:"Working Capital"}),e.jsx(Me,{value:"Performance Issues",children:"Performance Issues"}),e.jsx(Me,{value:"Unethical Practice",children:"Unethical Practice"}),e.jsx(Me,{value:"Unforeseen Circumstances",children:"Unforeseen Circumstances"}),e.jsx(Me,{value:"Others",children:"Others"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{children:[PS," *"]}),e.jsx(at,{type:"date",value:E.proposedLwd,onChange:J=>O({...E,proposedLwd:J.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Termination Reason *"}),e.jsx(at,{id:"reason",value:E.reason,onChange:J=>O({...E,reason:J.target.value}),placeholder:"Primary reason for termination",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"comments",children:"Additional Comments *"}),e.jsx(Gs,{id:"comments",value:E.comments,onChange:J=>O({...E,comments:J.target.value}),placeholder:"Detailed observations and justification",rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"documents",children:_?"Upload Documents *":"Upload Supporting Documents"}),e.jsx(at,{id:"documents",type:"file",multiple:!0,accept:".ppt,.pptx,.pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png",onChange:J=>T(J.target.files,J.currentTarget),required:_&&E.documents.length===0}),_&&e.jsx("p",{className:"text-xs text-slate-500",children:"At least one PowerPoint (.ppt / .pptx) is mandatory. You can also attach MOM, dealer commitments, and other supporting files (PDF / DOC / XLS / image)."}),E.documents.length>0&&e.jsx("div",{className:"border rounded-md divide-y bg-slate-50",children:E.documents.map((J,ie)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate",children:J.name}),z(J)&&e.jsx(Ce,{className:"bg-blue-100 text-blue-700 border-blue-300",children:"Presentation"})]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>F(ie),className:"text-red-600 hover:text-red-700",children:"Remove"})]},`${J.name}-${ie}`))})]}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-red-600 hover:bg-red-700",children:"Submit Request"})]})]})]})]})]})}),e.jsxs(Fe,{children:[e.jsxs($n,{value:L,onValueChange:q,className:"w-full",children:[e.jsxs(qn,{children:[e.jsx(zt,{value:"all",children:"All Cases"}),e.jsx(zt,{value:"open",children:"Open"}),e.jsx(zt,{value:"completed",children:"Completed"})]}),e.jsx(qt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:y?e.jsx("div",{className:"text-center py-12",children:"Loading requests..."}):w.length>0?w.map(J=>{var ie,ae,xe,ce;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(mi,{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:J.requestId||((ae=(ie=J.dealer)==null?void 0:ie.dealerCode)==null?void 0:ae.code)||"N/A"}),e.jsx(Ce,{className:pV(J.severity||"Medium"),children:J.severity||"Normal"}),e.jsx(Ce,{className:Kg(J.status),children:lu(J.status)}),e.jsx(kr,{status:N[J.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:((xe=J.dealer)==null?void 0:xe.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:((ce=J.dealer)==null?void 0:ce.registeredAddress)||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Category"}),e.jsx("p",{children:J.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:lu(J.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:PS}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-500"}),e.jsx("p",{children:J.proposedLwd})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Gt(J.createdAt)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(J.id),className:"ml-4",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},J.id)}):e.jsx("div",{className:"text-center py-12 text-slate-500",children:e.jsx("p",{children:"No termination requests found"})})})}),e.jsx(qt,{value:"open",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:H.length>0?H.map(J=>{var ie,ae,xe;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(Ha,{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:J.requestId||((ae=(ie=J.dealer)==null?void 0:ie.dealerCode)==null?void 0:ae.code)||"N/A"}),e.jsx(Ce,{className:Kg(J.status),children:lu(J.status)}),e.jsx(kr,{status:N[J.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:(xe=J.dealer)==null?void 0:xe.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Reason"}),e.jsx("p",{className:"truncate",children:J.reason})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:lu(J.currentStage)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Gt(J.createdAt)})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(J.id),className:"ml-4",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},J.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(mi,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No requests requiring your action"})]})})}),e.jsx(qt,{value:"completed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:X.length>0?X.map(J=>{var ie,ae,xe;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(mi,{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:J.requestId||((ae=(ie=J.dealer)==null?void 0:ie.dealerCode)==null?void 0:ae.code)||"N/A"}),e.jsx(Ce,{className:Kg(J.status),children:lu(J.status)}),e.jsx(kr,{status:N[J.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:(xe=J.dealer)==null?void 0:xe.businessName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Closed On"}),e.jsx("p",{children:Gt(J.updatedAt)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{children:J.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600",children:Oi}),e.jsx("p",{children:J.proposedLwd})]})]})]})]}),e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(J.id),className:"ml-4",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})]})})},J.id)}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(mi,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed terminations to display"})]})})})]}),R&&R.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>D(J=>Math.max(1,J-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(R.totalPages)].map((J,ie)=>{const ae=ie+1;return ae===1||ae===R.totalPages||ae>=S-1&&ae<=S+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:S===ae,onClick:()=>D(ae),className:"cursor-pointer",children:ae})},ae):ae===2&&S>3||ae===R.totalPages-1&&S<R.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},ae):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>D(J=>Math.min(R.totalPages,J+1)),className:S===R.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const ou=t=>{switch(t){case"Initiated":return"bg-red-100 text-re-red-hover border-red-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"}},cu=t=>t==="Resignation"?"bg-red-50 text-re-red-hover border-red-300":"bg-red-100 text-red-700 border-red-300";function gV({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,l]=g.useState(!0);g.useEffect(()=>{o()},[]);const o=async()=>{try{l(!0);const w=(await Ee.getFnFSettlements()).data;w.success&&r(w.settlements||[])}catch(u){console.error("Fetch settlements error:",u),ee.error("Failed to fetch settlement cases")}finally{l(!1)}};if(a)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(es,{className:"w-8 h-8 animate-spin text-re-red"})});const d=u=>{var w,v,N,j,y,C,S,D,R,A,L,$,P,E,O,I;return{id:u.id,caseNumber:u.settlementId||((w=u.resignation)==null?void 0:w.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=(N=u.outlet)==null?void 0:N.dealer)==null?void 0:j.fullName)||((y=u.dealer)==null?void 0:y.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=(R=u.dealer)==null?void 0:R.dealerCode)==null?void 0:A.dealerCode)||"N/A",dealershipName:((L=u.outlet)==null?void 0:L.name)||"N/A",location:(($=u.outlet)==null?void 0:$.city)||((P=u.outlet)==null?void 0:P.location)||"N/A",originalRequestId:((E=u.resignation)==null?void 0:E.resignationId)||((O=u.terminationRequest)==null?void 0:O.requestId)||((I=u.terminationRequest)==null?void 0:I.id)||"N/A",submittedOn:Gt(u.createdAt),financeReportStatus:u.status==="Calculated"||u.status==="Settled"?"Completed":"Pending",totalRecoveryAmount:parseFloat(u.totalReceivables)||0,totalPayableAmount:parseFloat(u.totalPayables)||0,completedOn:u.settlementDate?Gt(u.settlementDate):null,departmentResponses:u.lineItems||[]}},m=n.map(d),f=m.filter(u=>u.status==="Initiated"),x=m.filter(u=>u.status==="DD Clearance"||u.status==="Legal Clearance"),h=m.filter(u=>u.status==="Finance Approval"||u.status==="Calculated"),p=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(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Initiated"}),e.jsx(et,{className:"text-3xl text-re-red",children:f.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Newly created"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Clearance"}),e.jsx(et,{className:"text-3xl text-yellow-600",children:x.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Department / legal stage"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Finance Approval"}),e.jsx(et,{className:"text-3xl text-orange-600",children:h.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Ready for finance review"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"Completed"}),e.jsx(et,{className:"text-3xl text-green-600",children:m.filter(u=>u.status==="Completed"||u.status==="Settled").length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Finalized"})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-3",children:[e.jsx(Qt,{children:"All Cases"}),e.jsx(et,{className:"text-3xl",children:m.length})]}),e.jsx(Fe,{children:e.jsx("p",{className:"text-slate-600",children:"Total"})})]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Full & Final Settlement Cases"}),e.jsxs(Qt,{children:["Manage dealer exit dues clearance and settlement",t&&` • Current Role: ${t.role}`]})]}),e.jsx(Fe,{children:e.jsxs($n,{defaultValue:"all",className:"w-full",children:[e.jsxs(qn,{children:[e.jsx(zt,{value:"all",children:"All Cases"}),e.jsx(zt,{value:"initiated",children:"Initiated"}),e.jsx(zt,{value:"clearance",children:"Clearance"}),e.jsx(zt,{value:"finance",children:"Finance Approval"}),e.jsx(zt,{value:"completed",children:"Completed"})]}),e.jsx(qt,{value:"initiated",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[f.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(mu,{className:"w-6 h-6 text-re-red"})}),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(Ce,{className:ou(u.status),children:u.status}),e.jsx(Ce,{className:cu(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(dr,{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(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(bn,{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(mu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No initiated cases to display"})]})]})}),e.jsx(qt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:m.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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-red-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(ka,{className:`w-6 h-6 ${u.status==="Initiated"?"text-re-red":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(Ce,{className:ou(u.status),children:u.status}),e.jsx(Ce,{className:cu(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(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),"View Details"]})})]})})},u.id))})}),e.jsx(qt,{value:"clearance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[x.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(ka,{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(Ce,{className:ou(u.status),children:u.status}),e.jsx(Ce,{className:cu(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(w=>w.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(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(bn,{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(ka,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No clearance-stage cases"})]})]})}),e.jsx(qt,{value:"finance",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[h.map(u=>{var w,v;return e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(ka,{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(Ce,{className:ou(u.status),children:u.status}),e.jsx(Ce,{className:cu(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:["₹",(w=u.totalRecoveryAmount)==null?void 0:w.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(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(bn,{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(ka,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No finance-approval cases"})]})]})}),e.jsx(qt,{value:"completed",className:"mt-6",children:e.jsxs("div",{className:"space-y-4",children:[p.map(u=>e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(mu,{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(Ce,{className:ou(u.status),children:u.status}),e.jsx(Ce,{className:cu(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(se,{size:"sm",variant:"outline",onClick:()=>s(u.id),className:"ml-4",children:[e.jsx(bn,{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(mu,{className:"w-12 h-12 mx-auto mb-4 text-slate-400"}),e.jsx("p",{children:"No completed cases"})]})]})})]})})]})]})}const sc={getResignations:async()=>{try{return(await Ee.getResignations()).data}catch(t){throw console.error("Get resignations error:",t),t}},createResignation:async t=>{try{return(await Ee.createResignation(t)).data}catch(s){throw console.error("Create resignation error:",s),s}},getResignationById:async t=>{var s,n;try{const r=await Ee.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 Ee.updateClearance(t,s)).data}catch(n){throw console.error("Update clearance error:",n),n}},uploadDocument:async(t,s)=>{try{return(await Ee.uploadResignationDocument(t,s)).data}catch(n){throw console.error("Upload resignation document error:",n),n}},withdraw:async(t,s)=>{try{return(await Ee.withdrawResignation(t,s)).data}catch(n){throw console.error("Withdraw resignation error:",n),n}}},Yg=["Resignation Letter","Dealer Undertaking","Approval Note","Resignation Acceptance Letter","Handover Document","Settlement Supporting Document","PPT Presentation","Other"],vV=["Request Submitted","ASM","RBM","ZBH","DD Lead","DD Head","NBH","DD Admin","Legal","F&F Initiated"],Zg=["Termination Recommendation","Show Cause Notice","SCN Response","Hearing Record","Approval Note","Termination Letter","Settlement Supporting Document","Other"],yV=["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"],bV={ASM:"ASM",RBM:"RBM",ZBH:"ZBH","DD Lead":"DD Lead","DD Head":"DD Head",NBH:"NBH","DD Admin":"DD Admin",Legal:"Legal Admin"},OS=["REJECTED","Rejected","REVOKED","Revoked","WITHDRAWN","Withdrawn"],km={"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"],"DD Head":["DD Head","DD Head Review","DDH 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 jV({resignationId:t,onBack:s,currentUser:n}){var ut,ht,it,Tt,It,he,vt,mt,_e,Vt,Et,Ds,ln,Bs,Ys,Xs,Js,Ws,Z,oe,Ne,Oe,De,ye,Ve,Ge,st,Kt,Xt,ot,ft,Es,ts,vs,Te;const r=(je,nt)=>{const Ye=[...(A==null?void 0:A.documents)||[],...(A==null?void 0:A.uploadedDocuments)||[]],pt=[je,nt,...nt?km[nt]||[]:[],...km[je]||[]].filter(yt=>!!yt).map(yt=>yt.trim().toLowerCase());return Ye.filter(yt=>{if(!(yt!=null&&yt.stage))return!1;const Jt=String(yt.stage).trim().toLowerCase();return pt.includes(Jt)})},a=tr(),[l,o]=g.useState({open:!1,type:null}),[d,m]=g.useState(""),[f,x]=g.useState(""),[h,p]=g.useState(""),[u,w]=g.useState(""),[v,N]=g.useState([]),[j,y]=g.useState(!1),[C,S]=g.useState(!1),[D,R]=g.useState({open:!1,stageName:"",documents:[]}),[A,L]=g.useState(null),$=(A==null?void 0:A.id)||"",{get:P}=xc($?[{entityType:"resignation",entityId:$}]:[],!!$),[E,O]=g.useState(!1),[I,q]=g.useState([]),[G,Y]=g.useState(!1),[V,Q]=g.useState(null),[_,z]=g.useState(!1),[T,F]=g.useState(null),[B,K]=g.useState(Yg[0]),[W,H]=g.useState(""),X=g.useMemo(()=>[...(A==null?void 0:A.documents)||[],...(A==null?void 0:A.uploadedDocuments)||[]].some(nt=>(nt.documentType||nt.type)==="PPT Presentation"),[A]),J=async()=>{try{O(!0);const je=await sc.getResignationById(t);L(je),ie()}catch(je){console.error("Error fetching resignation:",je)}finally{O(!1)}},ie=async()=>{try{const je=await Ee.getAuditLogs("resignation",t);je.data&&je.data.success&&q(je.data.data||[])}catch(je){console.error("Error fetching audit logs:",je)}};g.useEffect(()=>{J()},[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 consolidated review"},{id:6,name:"DD Head Review",key:"DD Head",description:"DD Head final dealer development approval"},{id:7,name:"NBH Approval",key:"NBH",description:"National Business Head approval"},{id:8,name:"Legal - Resignation Letter",key:"Legal",description:"Legal team issues resignation approval letter"},{id:9,name:"DD Admin Review",key:"DD Admin",description:"DD Admin verification and final closure"},{id:10,name:"Awaiting F&F",key:"Awaiting F&F",description:"Internal review complete — start Full & Final using Push to F&F when ready"},{id:11,name:"F&F Settlement",key:"F&F Initiated",description:"Full & Final settlement process"},{id:12,name:"Completed",key:"Completed",description:"Resignation process finalized"}],xe=["Request Submitted","ASM","RBM","ZBH","DD Lead","DD Head","NBH","Legal","DD Admin","Awaiting F&F","F&F Initiated","Completed"],ce=A?["F&F Initiated","Completed","Settled","FNF_INITIATED"].includes(String(A.status||A.currentStage||""))?!0:(Array.isArray(A.timeline)?A.timeline:[]).some(Ye=>{const pt=String((Ye==null?void 0:Ye.stage)||"").trim().toLowerCase(),yt=String((Ye==null?void 0:Ye.targetStage)||"").trim().toLowerCase(),Jt=String((Ye==null?void 0:Ye.action)||"").trim().toLowerCase(),ss=pt==="legal"||pt==="legal - resignation letter",Ss=yt==="legal"||yt==="dd admin"||yt==="awaiting f&f"||yt==="f&f initiated"||yt==="fnf_initiated"||Jt.includes("approved");return ss&&Ss}):!1,ke=(()=>{if(!A||!n)return{canApprove:!1,canDispatch:!1,dispatchMissed:!1,canWithdraw:!1,canSendBack:!1,canPushToFnF:!1,canAssign:!1};const je=A.currentStage,nt=A.status,Ye=n.role,pt=je==="RBM"||je==="RBM Review"||je==="RBM + DD-ZM Review",yt=String(n.roleCode||n.role||"").trim().toUpperCase(),Jt=pt&&I.some(xs=>{var Nn,kn,Cn,Us;return xs.action==="PARTIAL_APPROVE"&&(((Nn=xs.actor)==null?void 0:Nn.id)===n.id||xs.actorId===n.id||((kn=xs.actor)==null?void 0:kn.email)===n.email||xs.userEmail===n.email)&&(((Cn=xs.details)==null?void 0:Cn.roleCode)===yt||((Us=xs.details)==null?void 0:Us.roleCode)==="DD-ZM"&&yt==="DD ZM")}),ss=["Completed","Rejected","Withdrawn","Revoked"].includes(nt),Ss=nt==="F&F Initiated"||je==="F&F Initiated"||nt==="Settled"||nt==="FNF_INITIATED",Zs=xe.indexOf(je),on=xe.indexOf("NBH"),en=Zs!==-1&&on!==-1&&Zs>=on,tn=yt==="SUPER_ADMIN"||pt&&(yt==="RBM"||yt==="DD-ZM"||yt==="DD ZM")||Ye===bV[je],cn=je==="DD Lead"||je==="DD Lead Review",Ae=yt==="DD_LEAD"||yt==="DD LEAD",Ht=(()=>{const xs=new Date;xs.setHours(0,0,0,0);const Nn=A.lastOperationalDateServices||A.lastOperationalDateSales;if(!Nn)return!0;const kn=new Date(Nn);return kn.setHours(0,0,0,0),xs>=kn})(),Pe=je==="Awaiting F&F",ct=(()=>{const xs=String(je||"").trim();return xe.find(kn=>kn===xs||(km[kn]||[]).includes(xs))||xs})(),tt=ct==="NBH",Nt=ct==="Awaiting F&F",Mt=ct==="Legal",Pt=["DD Lead","DD Head","DD Admin","Super Admin"],ys=["DD Lead","DD Head","DD Admin","Super Admin"],Yt=je==="DD Admin"||je==="DD Admin Review",ps=yt==="DD_ADMIN"||Ye==="DD Admin",ks=yt==="SUPER_ADMIN"||Ye==="Super Admin",gn=[...A.documents||[],...A.uploadedDocuments||[]].some(xs=>{const Nn=String((xs==null?void 0:xs.documentType)||(xs==null?void 0:xs.type)||"").toLowerCase(),kn=String((xs==null?void 0:xs.stage)||"").toLowerCase();return Nn.includes("acceptance letter")||kn==="legal"}),$s=I.some(xs=>{var Cn;const Nn=String((xs==null?void 0:xs.action)||"").toUpperCase(),kn=String((xs==null?void 0:xs.description)||((Cn=xs==null?void 0:xs.details)==null?void 0:Cn.action)||"").toLowerCase();return Nn==="RESIGNATION_LETTER_DISPATCHED"||kn.includes("resignation letter dispatched")})||(A.timeline||[]).some(xs=>String((xs==null?void 0:xs.action)||"").toLowerCase().includes("resignation letter dispatched")),dn=xe.indexOf("DD Admin"),sn=xe.indexOf("Completed"),We=xe.indexOf(xe.find(xs=>xs===je||(km[xs]||[]).includes(je))||je),gt=dn!==-1&&We!==-1&&We>=dn&&(sn===-1||We<sn)&&(ps||ks)&&gn&&!$s&&!ss;return{canApprove:tn&&!ss&&!Ss&&!Jt&&!(je==="Legal"&&ce)&&!(Ae&&cn&&!X)&&!(je==="DD Admin"&&!Ht)&&!Yt&&!Pe,canDispatch:gt,dispatchMissed:gt&&!Yt,canSendBack:tn&&!ss&&!Ss&&Zs>0&&Ye!=="Legal Admin"&&yt!=="LEGAL_ADMIN",canWithdraw:Ye==="Dealer"&&!en&&!ss,canRevoke:(yt==="SUPER_ADMIN"||Ye==="DD Admin")&&!ss&&!Ss,canPushToFnF:Pt.includes(Ye)&&!Ss&&!ss&&!tt&&Ht&&(Nt||Mt&&ys.includes(Ye)),canAssign:Ye!=="Dealer"&&!ss}})(),Xe=["Super Admin","DD Lead","DD Head","NBH","DD Admin","Legal Admin","DD-ZM"].includes((n==null?void 0:n.role)||""),Ot={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"],"DD Head":["DD Head","DD Head Review","Head 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"]},bt=je=>{if(!je)return"";const nt=String(je).trim();return xe.find(pt=>pt===nt||(Ot[pt]||[]).includes(nt))||nt},te=je=>{if(!A)return"pending";const nt=["Rejected","Revoked","Withdrawn"].includes(A.status);let Ye=A.currentStage;if(nt&&(!Ye||OS.includes(String(Ye)))){const ss=[...A.timeline||[]].reverse().find(Ss=>(Ss==null?void 0:Ss.stage)&&!OS.includes(String(Ss.stage)));ss!=null&&ss.stage&&(Ye=ss.stage)}const pt=xe.indexOf(bt(Ye)),yt=xe.indexOf(je);if((A.status==="Completed"||A.status==="Settled")&&yt<=pt)return"completed";const Jt=["Rejected","Revoked","Withdrawn"].includes(A.status);return je==="Legal"&&ce&&!Jt?"completed":pt===-1?je==="ASM"?"completed":"pending":yt<pt?"completed":yt===pt?nt?"completed":"active":"pending"},ve=je=>{o({open:!0,type:je})},qe=(je,nt)=>{const Ye=r(je,nt).map((pt,yt)=>{var Jt;return{id:pt.id||`${je}-${yt}`,name:pt.name||pt.fileName||"Document",type:pt.type||pt.documentType||"Document",uploadDate:pt.uploadDate||(pt.createdAt?Gt(pt.createdAt):"N/A"),uploader:typeof pt.uploader=="string"?pt.uploader:((Jt=pt.uploader)==null?void 0:Jt.fullName)||pt.uploadedBy||"System",filePath:pt.filePath||pt.path}});R({open:!0,stageName:je,documents:Ye})},ge=async()=>{var je,nt,Ye,pt,yt,Jt,ss,Ss;if(!d&&!["assign","pushfnf","dispatch"].includes(l.type||"")){ee.error("Please provide remarks (min 5 characters)");return}if(["sendBack","revoke"].includes(l.type||"")&&d.trim().length<5){ee.error("Remarks are required for this action (min 5 characters).");return}if(l.type==="assign"&&!f){ee.error("Please select a designation");return}try{Y(!0);const on={action:l.type==="sendBack"?"sendBack":l.type,remarks:d,assignTo:u||f,force:C},en=await Ee.updateResignationStatus(t,on);if((je=en.data)!=null&&je.success)ee.success(((nt=en.data)==null?void 0:nt.message)||"Action completed successfully"),o({open:!1,type:null}),m(""),x(""),w(""),N([]),S(!1),J();else{const tn=((Ye=en.data)==null?void 0:Ye.message)||"Failed to submit action";ee.error(tn),(pt=en.data)!=null&&pt.canForce&&ee.info(`${Oi} restriction: use "Push to F&F" and enable "Force Initiate F&F Settlement Immediately" if urgent.`)}}catch(Zs){console.error("Error submitting action:",Zs),ee.error(((Jt=(yt=Zs.response)==null?void 0:yt.data)==null?void 0:Jt.message)||"Failed to submit action"),(Ss=(ss=Zs==null?void 0:Zs.response)==null?void 0:ss.data)!=null&&Ss.canForce&&ee.info(`${Oi} restriction: use "Push to F&F" with the force option if business-approved.`)}finally{Y(!1)}},Be=async()=>{var je,nt;if(!T){ee.error("Please select a file to upload");return}try{Y(!0);const Ye=new FormData;Ye.append("file",T),Ye.append("documentType",B),W&&Ye.append("stage",W),await sc.uploadDocument(t,Ye),ee.success("Document uploaded successfully"),z(!1),F(null),K(Yg[0]),H(""),J()}catch(Ye){ee.error(((nt=(je=Ye==null?void 0:Ye.response)==null?void 0:je.data)==null?void 0:nt.message)||"Failed to upload document")}finally{Y(!1)}};return g.useEffect(()=>{(async()=>{if(l.type==="assign"&&(f||h)){const nt=setTimeout(async()=>{var Ye;try{y(!0);const pt={asm:"ASM",rbm:"RBM",zbh:"ZBH",nbh:"NBH",legal:"Legal Admin"},yt={limit:20,search:h};f&&(yt.roleCode=pt[f]||f);const Jt=await Ee.getUsers(yt);(Ye=Jt.data)!=null&&Ye.success&&N(Jt.data.data)}catch(pt){console.error("Error fetching users:",pt)}finally{y(!1)}},300);return()=>clearTimeout(nt)}})()},[f,h,l.type]),E&&!A?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(es,{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(se,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:(A==null?void 0:A.resignationId)||t}),e.jsx("p",{className:"text-slate-600",children:(ut=A==null?void 0:A.outlet)==null?void 0:ut.name})]}),e.jsx(Ce,{className:(A==null?void 0:A.status)==="Completed"||(A==null?void 0:A.status)==="Settled"?"bg-green-100 text-green-700 border-green-300":(A==null?void 0:A.status)==="Rejected"||(A==null?void 0:A.status)==="Withdrawn"||(A==null?void 0:A.status)==="Revoked"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:(A==null?void 0:A.status)==="Settled"?"Completed":oj((A==null?void 0:A.status)||"Pending")}),e.jsx(kr,{status:P("resignation",$)})]})}),e.jsxs($n,{defaultValue:"details",className:"w-full",children:[e.jsxs(qn,{className:"bg-slate-100 p-1",children:[e.jsx(zt,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(zt,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(zt,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(zt,{value:"audit",className:"data-[state=active]:bg-white",children:"Audit Trail"}),Xe&&e.jsx(zt,{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(qt,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Resignation Details"})}),e.jsx(Fe,{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(de,{className:"text-slate-600",children:"Resignation Type"}),e.jsx("p",{children:A==null?void 0:A.resignationType})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Reason"}),e.jsx("p",{children:A==null?void 0:A.reason})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:A!=null&&A.lastOperationalDateSales?Gt(A.lastOperationalDateSales,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:A!=null&&A.lastOperationalDateServices?Gt(A.lastOperationalDateServices,"date"):"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Additional Info / Dealer Voice"}),e.jsx("p",{children:(A==null?void 0:A.additionalInfo)||"No additional info provided"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:A!=null&&A.submittedOn?Gt(A.submittedOn):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Current Stage"}),e.jsx("p",{children:A==null?void 0:A.currentStage})]})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Request Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((ht=A==null?void 0:A.dealer)==null?void 0:ht.fullName)||((it=A==null?void 0:A.outlet)==null?void 0:it.name)})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((It=(Tt=A==null?void 0:A.dealer)==null?void 0:Tt.dealerProfile)==null?void 0:It.gstNumber)||((he=A==null?void 0:A.outlet)==null?void 0:he.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((vt=A==null?void 0:A.dealer)==null?void 0:vt.email)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((Vt=(_e=(mt=A==null?void 0:A.dealer)==null?void 0:mt.dealerProfile)==null?void 0:_e.dealerCode)==null?void 0:Vt.salesCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((ln=(Ds=(Et=A==null?void 0:A.dealer)==null?void 0:Et.dealerProfile)==null?void 0:Ds.dealerCode)==null?void 0:ln.serviceCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((Xs=(Ys=(Bs=A==null?void 0:A.dealer)==null?void 0:Bs.dealerProfile)==null?void 0:Ys.dealerCode)==null?void 0:Xs.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((Z=(Ws=(Js=A==null?void 0:A.dealer)==null?void 0:Js.dealerProfile)==null?void 0:Ws.dealerCode)==null?void 0:Z.gearCode)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((Ne=(oe=A==null?void 0:A.dealer)==null?void 0:oe.dealerProfile)==null?void 0:Ne.registeredAddress)||((Oe=A==null?void 0:A.outlet)==null?void 0:Oe.address)})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Operational Details"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(ye=(De=A==null?void 0:A.dealer)==null?void 0:De.dealerProfile)!=null&&ye.onboardedAt?Gt(A.dealer.dealerProfile.onboardedAt,"date"):(Ve=A==null?void 0:A.outlet)!=null&&Ve.inaugurationDate?Gt(A.outlet.inaugurationDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(st=(Ge=A==null?void 0:A.dealer)==null?void 0:Ge.dealerProfile)!=null&&st.loaDate?Gt(A.dealer.dealerProfile.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(Xt=(Kt=A==null?void 0:A.dealer)==null?void 0:Kt.dealerProfile)!=null&&Xt.loiDate?Gt(A.dealer.dealerProfile.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((Es=(ft=(ot=A==null?void 0:A.dealer)==null?void 0:ot.dealerProfile)==null?void 0:ft.application)==null?void 0:Es.businessType)||((ts=A==null?void 0:A.outlet)==null?void 0:ts.type)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"City Category"}),e.jsx("p",{children:((vs=A==null?void 0:A.outlet)==null?void 0:vs.cityCategory)||"N/A"})]})]})})]})]}),e.jsx(qt,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Progress Timeline"}),e.jsx(Qt,{children:"Track the resignation request approval process"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:ae.map((je,nt)=>{const Ye=te(je.key),pt=r(je.name,je.key).length,yt=((A==null?void 0:A.timeline)||[]).filter(ss=>ss.stage===je.key||ss.stage===je.name),Jt=yt.length>0?yt[yt.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 ${Ye==="completed"?"bg-green-100 text-green-600":Ye==="active"?"bg-blue-100 text-re-red":"bg-slate-100 text-slate-400"}`,children:Ye==="completed"?e.jsx(Wn,{className:"w-5 h-5"}):e.jsx("span",{children:je.id})}),nt<ae.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${Ye==="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:Ye==="completed"?"text-green-600":Ye==="active"?"text-re-red":"text-slate-400",children:je.name}),pt>0&&e.jsxs("button",{onClick:()=>qe(je.name,je.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(Ns,{className:"w-3 h-3"}),e.jsxs("span",{children:[pt," ",pt===1?"doc":"docs"]})]})]}),Jt&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-slate-600",children:[e.jsx(dr,{className:"w-4 h-4"}),e.jsx("span",{children:Gt(Jt.timestamp||Jt.createdAt)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm mb-1",children:je.description}),yt.length>0&&e.jsx("div",{className:"space-y-4 mt-3",children:yt.map((ss,Ss)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:ss.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:ss.action}),e.jsx("span",{className:"text-[10px] text-slate-400 ml-auto",children:Gt(ss.timestamp||ss.createdAt)})]}),e.jsx("div",{className:"bg-slate-50 p-3 rounded-lg border border-slate-100 text-sm text-slate-700 shadow-sm",children:ss.comments||ss.remarks||"No remarks provided."})]},Ss))})]})]},je.id)})})})]})}),e.jsx(qt,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Documents"}),e.jsx(Qt,{children:"View and manage resignation documents"})]}),e.jsxs(se,{size:"sm",onClick:()=>z(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:(()=>{var nt;const je=[...(A==null?void 0:A.documents)||[],...(A==null?void 0:A.uploadedDocuments)||[]];return A!=null&&A.departmentalClearances&&Object.entries(A.departmentalClearances).forEach(([Ye,pt])=>{pt.supportingDocument&&je.push({name:`${Ye} Clearance Proof`,type:"Clearance NOC",path:pt.supportingDocument,createdAt:pt.updatedAt,uploadedBy:pt.updatedBy||"Department Admin"})}),(nt=A==null?void 0:A.settlement)!=null&&nt.clearances&&A.settlement.clearances.forEach(Ye=>{Ye.supportingDocument&&je.push({name:`${Ye.department} Clearance NOC`,type:"Live NOC",path:Ye.supportingDocument,createdAt:Ye.clearedAt||Ye.updatedAt,uploadedBy:"Department Admin"})}),je.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):je.map((Ye,pt)=>{var yt;return e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Ye.name||Ye.fileName})]})}),e.jsx(ue,{children:Ye.documentType||Ye.type||"Document"}),e.jsx(ue,{children:Ye.createdAt?Gt(Ye.createdAt):"N/A"}),e.jsx(ue,{children:((yt=Ye.uploader)==null?void 0:yt.fullName)||Ye.uploadedBy||"Dealer"}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const Jt=Ye.filePath||Ye.path,ss=Jt!=null&&Jt.startsWith("/uploads/")&&!Jt.startsWith("/uploads/documents/")?Jt.replace("/uploads/","/uploads/documents/"):Jt;Q({fileName:Ye.fileName||Ye.name,filePath:ss,documentType:Ye.documentType||Ye.type})},children:"View"})})]},pt)})})()})]})})]})}),e.jsx(qt,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Audit Trail"}),e.jsx(Qt,{children:"Complete history of actions on this resignation request"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:I.length>0?I.map((je,nt)=>{var Ye,pt,yt,Jt,ss,Ss,Zs,on,en,tn,cn;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(Ce,{className:`
|
||
${(je.description||je.action||((Ye=je.details)==null?void 0:Ye.action)||"").toLowerCase().includes("reject")||(je.description||je.action||((pt=je.details)==null?void 0:pt.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(je.description||je.action||((yt=je.details)==null?void 0:yt.action)||"").toLowerCase().includes("sent back")||(je.description||je.action||((Jt=je.details)==null?void 0:Jt.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(je.description||je.action||((ss=je.details)==null?void 0:ss.action)||"").toLowerCase().includes("approv")||(je.description||je.action||((Ss=je.details)==null?void 0:Ss.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
|
||
`,children:je.description||je.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Zs=je.actor)==null?void 0:Zs.name)||je.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Gt(je.timestamp||je.createdAt)})]}),(je.remarks||((on=je.newData)==null?void 0:on.remarks)||((en=je.details)==null?void 0:en.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:je.remarks||((tn=je.newData)==null?void 0:tn.remarks)||((cn=je.details)==null?void 0:cn.remarks)})]})]},nt)}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:e.jsx("p",{children:"No activity logs found for this case."})})})})]})}),Xe&&e.jsx(qt,{value:"approvals",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Approval Summary"}),e.jsx(Qt,{children:"Comprehensive view of all approvals and remarks"})]}),ke.canApprove&&e.jsxs(se,{onClick:()=>ve("approve"),className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Wn,{className:"w-4 h-4 mr-2"}),"Approve Request"]})]}),e.jsx(Fe,{children:e.jsxs(Ps,{className:"w-full border-collapse",children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50/50",children:[e.jsx(fe,{className:"min-w-[120px]",children:"Stage"}),e.jsx(fe,{className:"min-w-[120px]",children:"Approver"}),e.jsx(fe,{className:"min-w-[200px]",children:"Action"}),e.jsx(fe,{className:"w-full min-w-[300px]",children:"Remarks"}),e.jsx(fe,{className:"min-w-[180px] text-right",children:"Date"})]})}),e.jsx(Ls,{children:((A==null?void 0:A.timeline)||[]).length>0?A.timeline.map((je,nt)=>e.jsxs(lt,{children:[e.jsx(ue,{className:"font-medium",children:je.stage}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:je.user||"System"})}),e.jsx(ue,{className:"whitespace-normal break-words",children:je.action}),e.jsx(ue,{className:"whitespace-normal break-words",children:je.remarks||je.comments||"-"}),e.jsx(ue,{className:"text-slate-500 whitespace-nowrap text-right",children:Gt(je.timestamp||je.createdAt)})]},nt)):e.jsx(lt,{children:e.jsx(ue,{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(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[(()=>{const je=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").trim().toUpperCase(),nt=je==="DD LEAD"||je==="DD_LEAD",Ye=["DD Lead","DD Lead Review","DDL Review"].includes(A==null?void 0:A.currentStage);return nt&&Ye?e.jsxs(se,{variant:"outline",className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>{K("PPT Presentation"),H("DD Lead"),z(!0)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload PPT"]}):null})(),ke.canApprove&&e.jsxs(se,{disabled:G,className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>ve("approve"),children:[G&&l.type==="approve"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Wn,{className:"w-4 h-4 mr-2"}),"Approve"]}),ke.canDispatch&&e.jsxs(e.Fragment,{children:[ke.dispatchMissed&&e.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 text-amber-800 px-3 py-2 text-xs flex items-start gap-2",children:[e.jsx(an,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Resignation acceptance letter was not dispatched at the DD Admin step. Please send it to the dealer now."})]}),e.jsxs(se,{disabled:G,className:`w-full font-bold ${ke.dispatchMissed?"bg-amber-600 hover:bg-amber-700":"bg-re-red hover:bg-re-red-hover"}`,onClick:()=>ve("dispatch"),children:[G&&l.type==="dispatch"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Dr,{className:"w-4 h-4 mr-2"}),ke.dispatchMissed?"Dispatch Resignation Letter (Pending)":"Dispatch Resignation Letter"]})]}),ke.canSendBack&&e.jsxs(se,{variant:"outline",disabled:G,className:"w-full font-bold",onClick:()=>ve("sendBack"),children:[G&&l.type==="sendBack"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(rb,{className:"w-4 h-4 mr-2"}),"Send Back"]}),ke.canWithdraw&&e.jsxs(se,{variant:"outline",disabled:G,className:"w-full text-red-600 border-red-300 hover:bg-red-50 font-bold",onClick:()=>ve("withdrawal"),children:[G&&l.type==="withdrawal"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(id,{className:"w-4 h-4 mr-2"}),"Withdrawal"]}),ke.canRevoke&&e.jsxs(se,{variant:"outline",disabled:G,className:"w-full text-orange-600 border-orange-300 hover:bg-orange-50 font-bold",onClick:()=>ve("revoke"),children:[G&&l.type==="revoke"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(tb,{className:"w-4 h-4 mr-2"}),"Revoke"]}),ke.canPushToFnF&&e.jsxs(se,{variant:"outline",disabled:G,className:"w-full text-re-red-hover border-red-300 hover:bg-red-50",onClick:()=>ve("pushfnf"),children:[G&&l.type==="pushfnf"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ku,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),ke.canAssign&&e.jsxs(se,{variant:"outline",disabled:G,className:"w-full",onClick:()=>ve("assign"),children:[G&&l.type==="assign"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ab,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(tc,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>{var je;return a(`/worknotes/resignation/${t}`,{state:{applicationName:((je=A==null?void 0:A.outlet)==null?void 0:je.name)||"Resignation",registrationNumber:(A==null?void 0:A.resignationId)||"",participants:(A==null?void 0:A.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes",((Te=A==null?void 0:A.worknotes)==null?void 0:Te.length)>0&&e.jsx(Ce,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:A.worknotes.length})]})]})]})})]})]}),e.jsx(ls,{open:l.open,onOpenChange:je=>o({open:je,type:null}),children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[l.type==="approve"&&"Approve Resignation Request",l.type==="withdrawal"&&"Withdraw Resignation Request",l.type==="sendBack"&&"Send Back for Clarification",l.type==="revoke"&&"Revoke Resignation Request",l.type==="assign"&&"Assign to User",l.type==="pushfnf"&&"Push to Full & Final Settlement",l.type==="dispatch"&&"Dispatch Resignation Letter"]}),e.jsx(bs,{children:l.type==="assign"?"Select a user to assign this request to":l.type==="pushfnf"?"This will move the resignation request to F&F for dues clearance":l.type==="dispatch"?"The Legal-issued acceptance letter will be emailed to the dealer and the request will advance to Awaiting F&F. Remarks are optional.":"Please provide remarks for this action"})]}),e.jsx("div",{className:"space-y-4",children:l.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(de,{children:"Designation Filter"}),e.jsxs(At,{value:f,onValueChange:je=>{x(je),w("")},children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"All Roles"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Roles"}),e.jsx(Me,{value:"asm",children:"ASM"}),e.jsx(Me,{value:"rbm",children:"RBM"}),e.jsx(Me,{value:"zbh",children:"ZBH"}),e.jsx(Me,{value:"nbh",children:"NBH"}),e.jsx(Me,{value:"legal",children:"Legal"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Search Name/Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(at,{placeholder:"Search...",value:h,onChange:je=>p(je.target.value),className:"pr-8"}),j&&e.jsx(es,{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(de,{children:"Select Specific Person *"}),e.jsxs(At,{value:u,onValueChange:w,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:v.length>0?"Choose a user":"No users found"})}),e.jsx(Rt,{className:"max-h-60",children:v.map(je=>e.jsx(Me,{value:je.id,children:e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("span",{className:"font-medium",children:je.fullName}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:[je.roleCode," • ",je.email]})]})},je.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Assignment Remarks *"}),e.jsx(Gs,{value:d,onChange:je=>m(je.target.value),placeholder:"Why are you assigning this user?",rows:2})]})]}):l.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(an,{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 ",Oi.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:C,onChange:je=>S(je.target.checked),className:"w-4 h-4 rounded border-slate-300"}),e.jsx(de,{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(de,{children:"Remarks (Optional)"}),e.jsx(Gs,{value:d,onChange:je=>m(je.target.value),placeholder:"Add any additional notes...",rows:3})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks *"}),e.jsx(Gs,{value:d,onChange:je=>m(je.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>o({open:!1,type:null}),disabled:G,children:"Cancel"}),e.jsx(se,{onClick:ge,disabled:G,className:l.type==="approve"?"bg-green-600 hover:bg-green-700":l.type==="withdrawal"?"bg-red-600 hover:bg-red-700":"bg-re-red hover:bg-re-red-hover",children:G?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}),l.type==="dispatch"?"Dispatching...":"Processing..."]}):e.jsxs(e.Fragment,{children:[l.type==="approve"&&"Approve",l.type==="withdrawal"&&"Withdraw",l.type==="sendBack"&&"Send Back",l.type==="revoke"&&"Revoke",l.type==="assign"&&"Assign",l.type==="pushfnf"&&"Push to F&F",l.type==="dispatch"&&"Send to Dealer"]})})]})]})}),e.jsx(ls,{open:D.open,onOpenChange:je=>R({open:je,stageName:"",documents:[]}),children:e.jsxs(as,{className:Kb,children:[e.jsxs(fs,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Documents - ",D.stageName]}),e.jsxs(bs,{children:["Documents uploaded for this stage (",D.documents.length," ",D.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:D.documents.length>0?e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Action"})]})}),e.jsx(Ls,{children:D.documents.map(je=>e.jsxs(lt,{children:[e.jsx(ue,{children:je.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:je.type})}),e.jsx(ue,{children:je.uploadDate}),e.jsx(ue,{children:je.uploader}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",className:"text-re-red hover:text-blue-700",onClick:()=>{if(!je.filePath)return;const nt=je.filePath.startsWith("/uploads/")&&!je.filePath.startsWith("/uploads/documents/")?je.filePath.replace("/uploads/","/uploads/documents/"):je.filePath;Q({fileName:je.name,filePath:nt,documentType:je.type})},children:[e.jsx(Ns,{className:"w-4 h-4 mr-1"}),"View"]})})]},je.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(xn,{children:e.jsx(se,{variant:"outline",onClick:()=>R({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ls,{open:_,onOpenChange:z,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Upload Resignation Document"}),e.jsx(bs,{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(de,{children:"Document Type"}),e.jsxs(At,{value:B,onValueChange:K,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select document type"})}),e.jsx(Rt,{children:Yg.map(je=>e.jsx(Me,{value:je,children:je},je))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Stage (Optional)"}),e.jsxs(At,{value:W||"none",onValueChange:je=>H(je==="none"?"":je),children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select stage"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"none",children:"No Stage Mapping"}),vV.map(je=>e.jsx(Me,{value:je,children:je},je))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"File"}),e.jsx(at,{type:"file",onChange:je=>{var nt;return F(((nt=je.target.files)==null?void 0:nt[0])||null)}})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>z(!1),disabled:G,children:"Cancel"}),e.jsx(se,{onClick:Be,disabled:G,children:G?"Uploading...":"Upload"})]})]})}),e.jsx(mo,{isOpen:!!V,onClose:()=>Q(null),document:V})]})}const zo={getTerminationById:async t=>{const n=(await Ee.getTerminationById(t)).data;return(n==null?void 0:n.termination)||(n==null?void 0:n.data)||n},updateTerminationStatus:async(t,s,n,r)=>(await Ee.updateTerminationStatus(t,{action:s,remarks:n,...r!=null&&r.force?{force:!0}:{}})).data,issueSCN:async(t,s)=>(await Ee.issueSCN(t,s)).data,uploadSCNResponse:async(t,s,n)=>{const r=new FormData;return r.append("file",s),n&&r.append("remarks",n),(await Ee.uploadSCNResponse(t,r)).data},uploadDocument:async(t,s)=>(await Ee.uploadTerminationDocument(t,s)).data,finalizeTermination:async(t,s,n)=>(await Ee.finalizeTermination(t,{decision:s,remarks:n})).data},Nf=t=>String(t||"").toLowerCase().replace(/\s+/g," ").trim(),NV="Evaluation of Dealer SCN Response",wV=t=>{const s=Nf(t);return s?!!(s===Nf(NV)||s.includes("evaluation")&&s.includes("scn")&&s.includes("response")||s.includes("personal hearing")):!1},SV=t=>{const s=Nf(t);return s.includes("rbm")&&(s.includes("dd-zm")||s.includes("dd zm"))};function CV(t){const s=Nf(t);return s.includes("sent back")||s.includes("send back")||s.includes("reconsider")||s.includes("reconsideration")}function LS(t,s){if(!Array.isArray(t)||t.length===0)return null;const n=s==="scn_response_eval"?wV:SV,r=t;for(let a=r.length-1;a>=0;a--){const l=r[a];if(!CV(l==null?void 0:l.action)||!n(l==null?void 0:l.targetStage))continue;const o=(l==null?void 0:l.timestamp)!=null?new Date(l.timestamp).getTime():NaN;if(!Number.isNaN(o))return o}return null}function AV(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 kV(t,s){return s==null?!0:AV(t)>=s}function DV({terminationId:t,onBack:s,currentUser:n}){var Ys,Xs,Js,Ws,Z,oe,Ne,Oe,De,ye,Ve,Ge,st,Kt,Xt,ot,ft,Es,ts,vs,Te,je,nt,Ye,pt,yt,Jt,ss,Ss,Zs,on,en,tn,cn;const r=tr(),[a,l]=g.useState({open:!1,type:null}),[o,d]=g.useState(""),[m,f]=g.useState(""),[x,h]=g.useState(!1),[p,u]=g.useState({open:!1,stageName:"",documents:[]}),[w,v]=g.useState(!0),[N,j]=g.useState(null),y=(N==null?void 0:N.id)||"",{get:C}=xc(y?[{entityType:"termination",entityId:y}]:[],!!y),[S,D]=g.useState([]),[R,A]=g.useState(!1),[L,$]=g.useState(null),[P,E]=g.useState(""),[O,I]=g.useState(!1),[q,G]=g.useState(!1),[Y,V]=g.useState("Approve"),[Q,_]=g.useState(""),[z,T]=g.useState(!1),[F,B]=g.useState(null),[K,W]=g.useState(Zg[0]),[H,X]=g.useState(""),[J,ie]=g.useState(null),ae=async()=>{try{v(!0);const Ae=await zo.getTerminationById(t);j(Ae),xe()}catch(Ae){console.error("Error fetching termination:",Ae)}finally{v(!1)}},xe=async()=>{try{const Ae=await Ee.getAuditLogs("termination",t);Ae.data&&Ae.data.success&&D(Ae.data.data||[])}catch(Ae){console.error("Error fetching audit logs:",Ae)}};if(g.useEffect(()=>{ae()},[t]),w)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(es,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading termination details..."})]});const ce=async()=>{try{I(!0),await zo.issueSCN(t,{remarks:P}),ee.success("SCN issued successfully"),A(!1),ae()}catch{ee.error("Failed to issue SCN")}finally{I(!1)}},we=async()=>{if(L)try{I(!0),await zo.uploadSCNResponse(t,L,P),ee.success("SCN response uploaded"),A(!1),ae()}catch{ee.error("Failed to upload response")}finally{I(!1)}},ke=async()=>{try{I(!0),await zo.finalizeTermination(t,Y,Q),ee.success(`Termination ${Y.toLowerCase()}ed`),G(!1),ae()}catch{ee.error("Failed to finalize termination")}finally{I(!1)}},Xe=async()=>{if(!F){ee.error("Please select a file to upload");return}try{I(!0);const Ae=new FormData;Ae.append("file",F),Ae.append("documentType",K),H&&Ae.append("stage",H),await zo.uploadDocument(t,Ae),ee.success("Document uploaded successfully"),T(!1),B(null),W(Zg[0]),X(""),ae()}catch{ee.error("Failed to upload document")}finally{I(!1)}},Ot=n&&["DD Lead","DD Head","DD_HEAD","NBH","DD Admin","Super Admin"].includes(n.role||n.roleCode),bt={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"]},te=["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"],qe=(()=>{if(!N||!n)return{canApprove:!1,canWithdraw:!1,canIssueSCN:!1,canUploadSCNResponse:!1,canFinalize:!1,canPushToFnF:!1};const Ae=N.currentStage,Ht=N.status,Pe=n.role||n.roleCode,ct=["Show Cause Notice (SCN)","SCN"].includes(Ae),tt=["Completed","Rejected","Withdrawn","Terminated"].includes(Ht)||Ae==="Terminated",Nt=Ht==="F&F Initiated"||Ae==="F&F Initiated"||Ht==="Settled"||Ht==="FNF_INITIATED",Mt=(()=>{const $s=new Date;$s.setHours(0,0,0,0);const dn=N.proposedLwd;if(!dn)return!0;const sn=new Date(dn);return sn.setHours(0,0,0,0),$s>=sn})(),Pt=LS(N.timeline,"scn_response_eval"),ys=LS(N.timeline,"rbm_review"),Yt=Ae==="Evaluation of Dealer SCN Response"||Ae==="Personal Hearing",ps=Ae==="RBM + DD-ZM Review"?ys:Yt?Pt:null,ks=S.some($s=>{var Nn,kn,Cn;if(!kV($s,ps))return!1;const dn=$s.userId||((Nn=$s.user)==null?void 0:Nn.id)||((kn=$s.actor)==null?void 0:kn.id)||$s.actorId,sn=String(dn)===String(n.id),We=($s.action||$s.description||"").toUpperCase(),Ft=We.includes("PARTIAL_APPROVE")||We.includes("PARTIAL APPROVED"),gt=((Cn=$s.details)==null?void 0:Cn.stage)||$s.stage||"",rt=gt==="RBM + DD-ZM Review"||($s.remarks||"").includes("Partial approval by"),Is=gt==="Evaluation of Dealer SCN Response"||gt==="Personal Hearing"||($s.remarks||"").includes("SCN Response Review by");return sn&&Ft&&(Ae==="RBM + DD-ZM Review"&&rt||Yt&&Is)}),hs=$s=>(bt[$s]||[$s]).includes(Ae);return{canApprove:(Pe==="Super Admin"||hs("RBM + DD-ZM Review")&&(Pe==="RBM"||Pe==="DD-ZM")&&!ks||hs("ZBH Review")&&Pe==="ZBH"||hs("DD Lead Review")&&Pe==="DD Lead"||hs("Legal Verification")&&Pe==="Legal Admin"||hs("DD Head Review")&&(Pe==="DD Head"||Pe==="DD_HEAD")||hs("NBH Evaluation")&&Pe==="NBH"||hs("Evaluation of Dealer SCN Response")&&["DD Lead","ZBH","RBM","DD Head","DD_HEAD"].includes(Pe)&&!ks||hs("NBH Final Approval")&&Pe==="NBH"||hs("CCO Approval")&&Pe==="CCO"||hs("CEO Final Approval")&&Pe==="CEO"||hs("Legal - Termination Letter")&&Pe==="Legal Admin")&&!tt&&!Nt&&!["NBH Final Approval","CCO Approval","CEO Final Approval","NBH Evaluation","Show Cause Notice (SCN)","SCN"].includes(Ae),canIssueSCN:Ae==="NBH Evaluation"&&(Pe==="NBH"||Pe==="Super Admin")&&!tt,canUploadSCNResponse:ct&&["Legal Admin","DD Admin","DD Lead","Super Admin"].includes(Pe)&&!tt,canHold:(hs("NBH Evaluation")||hs("NBH Final Approval"))&&(Pe==="NBH"||Pe==="Super Admin")&&Ht!=="On Hold"&&!tt,canFinalize:(Ae==="NBH Final Approval"&&Pe==="NBH"||Ae==="CCO Approval"&&Pe==="CCO"||Ae==="CEO Final Approval"&&Pe==="CEO"||Pe==="Super Admin")&&["NBH Final Approval","CCO Approval","CEO Final Approval"].includes(Ae)&&!tt,canPushToFnF:Ot&&!Nt&&!N.fnfSettlement&&(Ae==="Terminated"||Ht===Vc.AWAITING_FNF||Ht===Vc.AWAITING_FNF_LWD_PENDING)&&Mt,isLwdReached:Mt,canWithdraw:Pe==="ASM"&&Ae==="Request Initiated"&&!tt,isFinalState:tt,isSettlementPhase:Nt}})(),ge=N||{},Be=["Show Cause Notice","Show Cause Notice (SCN)","SCN"].includes(ge.currentStage),ut=Ae=>{if(!Ae)return"";const Ht=String(Ae).trim();return te.find(ct=>(bt[ct]||[ct]).includes(Ht))||Ht},ht=Ae=>{const Ht=bt[Ae]||[Ae];return(ge.timeline||[]).some(Pe=>Pe!=null&&Pe.stage?!!(Ht.includes(Pe.stage)||Ae==="Submitted"&&(Pe.stage==="Submitted"||Pe.stage==="Request Initiated")):!1)},it=Ae=>{const Ht=["Rejected","Revoked","Withdrawn"].includes(ge.status),Pe=["Completed","Terminated","Settled","F&F Initiated","FNF_INITIATED",Vc.AWAITING_FNF,Vc.AWAITING_FNF_LWD_PENDING].includes(ge.status)||ge.currentStage==="Terminated";let ct=ge.currentStage||ge.status;if(Ht&&(ge.currentStage==="Rejected"||ge.currentStage==="Revoked"||!ge.currentStage)){const Pt=[...ge.timeline||[]].reverse().find(ys=>ys.stage&&ys.stage!=="Rejected"&&ys.stage!=="Revoked");Pt&&(ct=Pt.stage)}const tt=ut(ct),Nt=te.indexOf(tt),Mt=te.indexOf(Ae);return Pe&&Mt<=Nt?Mt<Nt&&Ae!=="Submitted"&&!ht(Ae)?"skipped":"completed":Mt===-1?"pending":Nt===-1?Ae==="Submitted"?"completed":"pending":Mt<Nt?Ae!=="Submitted"&&!ht(Ae)?"skipped":"completed":Mt===Nt?Ht?"completed":"active":"pending"},Tt=[...ge.documents||[],...ge.uploadedDocuments||[]],It=Object.keys(bt).reduce((Ae,Ht)=>{const Pe=bt[Ht]||[Ht],ct=Tt.filter(tt=>!tt.stage||Pe.includes(tt.stage)).map(tt=>{var Nt;return{id:tt.id||`${Ht}-${tt.fileName||tt.name}`,name:tt.fileName||tt.name||"Document",type:tt.documentType||tt.type||"Document",uploadDate:tt.uploadDate||tt.createdAt?Gt(tt.uploadDate||tt.createdAt):"N/A",uploader:((Nt=tt.uploader)==null?void 0:Nt.fullName)||tt.uploader||"-",path:tt.filePath||tt.path||tt.url}});return Ae[Ht]=ct,Ae},{}),he=Ae=>{const Ht=bt[Ae]||[Ae];return(ge.timeline||[]).filter(ct=>Ht.includes(ct.stage)||Ae==="Submitted"&&(ct.stage==="Submitted"||ct.stage==="Request Initiated")).sort((ct,tt)=>new Date(ct.timestamp).getTime()-new Date(tt.timestamp).getTime())},mt=String(ge.category||"").trim().toLowerCase().includes("unethical")?"Unethical Practice category — request was escalated directly to DD Lead Review.":null,_e=[{id:1,name:"Submitted",status:it("Submitted"),description:"Termination request initiated",date:"",actionType:"",actionBy:"",remarks:"",feedback:""},{id:2,name:"RBM + DD-ZM Review",status:it("RBM + DD-ZM Review"),description:"Joint review and approval by RBM and DD-ZM"},{id:3,name:"ZBH Review",status:it("ZBH Review"),description:"Zonal Business Head evaluation"},{id:4,name:"DD Lead Review",status:it("DD Lead Review"),description:"DD Lead validation"},{id:5,name:"Legal Verification",status:it("Legal Verification"),description:"Legal team validates termination grounds"},{id:6,name:"DD Head Review",status:it("DD Head Review"),description:"DD Head strategic review"},{id:7,name:"NBH Evaluation",status:it("NBH Evaluation"),description:"National Business Head decision"},{id:8,name:"Show Cause Notice (SCN)",status:it("Show Cause Notice (SCN)"),description:"SCN sent to dealer, awaiting response"},{id:9,name:"Evaluation of Dealer SCN Response",status:it("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:it("NBH Final Approval"),description:"NBH final termination decision"},{id:11,name:"CCO Approval",status:it("CCO Approval"),description:"Chief Commercial Officer approval"},{id:12,name:"CEO Final Approval",status:it("CEO Final Approval"),description:"CEO final authorization"},{id:13,name:"Legal - Termination Letter",status:it("Legal - Termination Letter"),description:"Legal team issues final termination letter"},{id:14,name:"Dealer Terminated",status:it("Dealer Terminated"),description:"Dealership termination effective",date:"",actionType:"",actionBy:"",remarks:"",feedback:""}],Vt=Ae=>{const Ht=It[Ae]||[];u({open:!0,stageName:Ae,documents:Ht})},Et=Ae=>{l({open:!0,type:Ae})},Ds=async()=>{var ct,tt,Nt,Mt,Pt,ys;const Ae=a.type,Ht=Ae==="sendBack"?"sendBack":Ae||"approve",Pe=o.trim();if(["sendBack","revoke"].includes(Ae||"")&&Pe.length<5){ee.error("Please provide detailed remarks (minimum 5 characters required for Send Back / Revoke)");return}if(!Pe&&!["assign","pushfnf"].includes(Ae||"")){ee.error("Please provide remarks/comments for this action");return}if(Ae==="assign"&&!m){ee.error("Please select a user");return}I(!0);try{let Yt;if(Ae==="approve"||Ae==="sendBack"||Ae==="withdrawal"||Ae==="revoke"||Ae==="hold")Yt=await zo.updateTerminationStatus(t,Ht,o);else if(Ae==="pushfnf")Yt=await zo.updateTerminationStatus(t,"pushfnf",o,{force:x});else{ee.error("Action logic not fully implemented for this type"),I(!1);return}if(Yt&&(Yt.success===!1||Yt.ok===!1)){console.error("[TerminationDetails] Action failed:",Yt);const ks=Yt.message||((ct=Yt.data)==null?void 0:ct.message)||"Failed to perform action";ee.error(ks),(Yt.canForce||(tt=Yt.data)!=null&&tt.canForce)&&ee.info('Enable "Force initiate F&F" in the dialog if an exception is approved.'),I(!1);return}const ps={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"};ee.success(ps[Ae]||(Yt==null?void 0:Yt.message)||"Action completed"),l({open:!1,type:null}),d(""),f(""),h(!1),ae()}catch(Yt){const ps=((Mt=(Nt=Yt.response)==null?void 0:Nt.data)==null?void 0:Mt.message)||"Failed to perform action";ee.error(ps),(ys=(Pt=Yt==null?void 0:Yt.response)==null?void 0:Pt.data)!=null&&ys.canForce&&ee.info('Enable "Force initiate F&F" in the dialog if an exception is approved.')}finally{I(!1)}},ln=Ae=>{switch(Ae){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"}},Bs=(ge.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(se,{variant:"outline",size:"icon",onClick:s,className:"hover:bg-slate-100 transition-colors",children:e.jsx(Jr,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl",children:ge.requestId||t}),e.jsx("p",{className:"text-slate-600",children:((Ys=ge.dealer)==null?void 0:Ys.businessName)||((Xs=ge.dealer)==null?void 0:Xs.legalName)||"Termination"})]}),e.jsx(Ce,{className:ln(ge.severity),children:ge.severity}),e.jsx(Ce,{className:ge.status==="Completed"||ge.status==="Terminated"||ge.status==="Settled"?"bg-green-100 text-green-700 border-green-300":ge.status==="Rejected"||ge.status==="Withdrawn"?"bg-red-100 text-red-700 border-red-300":"bg-yellow-100 text-yellow-700 border-yellow-300",children:ge.status==="Settled"?"Completed":oj(ge.status||"Pending")}),e.jsx(kr,{status:C("termination",y)})]})}),e.jsxs($n,{defaultValue:"details",className:"w-full",children:[e.jsxs(qn,{className:"bg-slate-100 p-1",children:[e.jsx(zt,{value:"details",className:"data-[state=active]:bg-white",children:"Details"}),e.jsx(zt,{value:"progress",className:"data-[state=active]:bg-white",children:"Progress"}),e.jsx(zt,{value:"documents",className:"data-[state=active]:bg-white",children:"Documents"}),e.jsx(zt,{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(qt,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Dealer Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:((Ws=(Js=ge.dealer)==null?void 0:Js.dealerCode)==null?void 0:Ws.dealerCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:((Z=ge.dealer)==null?void 0:Z.businessName)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:((oe=ge.dealer)==null?void 0:oe.gstNumber)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Email"}),e.jsx("p",{children:((Oe=(Ne=ge.dealer)==null?void 0:Ne.user)==null?void 0:Oe.email)||"N/A"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(de,{className:"text-slate-600",children:"Address"}),e.jsx("p",{children:((De=ge.dealer)==null?void 0:De.registeredAddress)||((Ve=(ye=ge.dealer)==null?void 0:ye.application)==null?void 0:Ve.address)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"City"}),e.jsx("p",{children:((st=(Ge=ge.dealer)==null?void 0:Ge.application)==null?void 0:st.city)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"District"}),e.jsx("p",{children:((ot=(Xt=(Kt=ge.dealer)==null?void 0:Kt.application)==null?void 0:Xt.district)==null?void 0:ot.name)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:((ft=ge.dealer)==null?void 0:ft.businessName)||ge.dealershipName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:((ts=(Es=ge.dealer)==null?void 0:Es.dealerCode)==null?void 0:ts.salesCode)||ge.salesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:((Te=(vs=ge.dealer)==null?void 0:vs.dealerCode)==null?void 0:Te.serviceCode)||ge.serviceCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((nt=(je=ge.dealer)==null?void 0:je.dealerCode)==null?void 0:nt.gmaCode)||ge.accessoriesCode||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:((pt=(Ye=ge.dealer)==null?void 0:Ye.dealerCode)==null?void 0:pt.gmaCode)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:((Jt=(yt=ge.dealer)==null?void 0:yt.dealerCode)==null?void 0:Jt.gearCode)||"N/A"})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Operational Details"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Inauguration"}),e.jsx("p",{children:(ss=ge.dealer)!=null&&ss.onboardedAt?Gt(ge.dealer.onboardedAt,"date"):ge.inauguration||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOA Date"}),e.jsx("p",{children:(Ss=ge.dealer)!=null&&Ss.loaDate?Gt(ge.dealer.loaDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"LOI Date"}),e.jsx("p",{children:(Zs=ge.dealer)!=null&&Zs.loiDate?Gt(ge.dealer.loiDate,"date"):"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last 6 Months Sales"}),e.jsx("p",{children:ge.lastSixMonthsSales})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Number of Dealerships"}),e.jsx("p",{children:ge.numberOfDealerships})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Number of Studios"}),e.jsx("p",{children:ge.numberOfStudios})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Constitution"}),e.jsx("p",{children:((on=ge.dealer)==null?void 0:on.constitutionType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Type"}),e.jsx("p",{children:((tn=(en=ge.dealer)==null?void 0:en.application)==null?void 0:tn.businessType)||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:ge.typeOfClosure||"Complete"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Format Category"}),e.jsx("p",{children:ge.formatCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Score Card Band"}),e.jsx("p",{children:ge.dealerScoreCardBand||"N/A"})]})]})})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50/30",children:[e.jsx(Qe,{children:e.jsxs(et,{className:"text-red-900 flex items-center gap-2",children:[e.jsx(Ha,{className:"w-5 h-5"}),"Termination Details"]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Termination Category"}),e.jsx("p",{className:"text-red-900",children:ge.category})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sub Category"}),e.jsx("p",{children:ge.subCategory||"N/A"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Description"}),e.jsx("p",{children:ge.reason})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Severity"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ce,{className:ln(ge.severity),children:ge.severity})})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted By"}),e.jsx("p",{children:((cn=ge.initiator)==null?void 0:cn.fullName)||"System"})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:Gt(ge.createdAt)})]})]})]})})]})]}),e.jsx(qt,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Termination Progress Timeline"}),e.jsx(Qt,{children:"Track the termination request approval process"})]}),e.jsxs(Fe,{children:[mt&&_e.some(Ae=>Ae.status==="skipped")&&e.jsxs(di,{className:"mb-4 border-amber-300 bg-amber-50 text-amber-900",children:[e.jsx(_a,{className:"h-4 w-4 text-amber-600"}),e.jsx(Ti,{children:"Fast-tracked workflow"}),e.jsxs(ui,{children:[mt," Stages marked “Skipped” below were intentionally bypassed and never reviewed."]})]}),e.jsx("div",{className:"space-y-4",children:_e.map((Ae,Ht)=>{var tt,Nt,Mt;const Pe=((tt=It[Ae.name])==null?void 0:tt.length)||0,ct=he(Ae.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 ${Ae.status==="completed"?"bg-green-100 text-green-600":Ae.status==="active"?"bg-red-50 text-re-red":Ae.status==="skipped"?"bg-amber-50 text-amber-600 border border-dashed border-amber-300":"bg-slate-100 text-slate-400"}`,children:Ae.status==="completed"?e.jsx(Wn,{className:"w-5 h-5"}):Ae.status==="active"?e.jsx(Ha,{className:"w-5 h-5"}):Ae.status==="skipped"?e.jsx(k1,{className:"w-5 h-5"}):e.jsx("span",{children:Ae.id})}),Ht<_e.length-1&&e.jsx("div",{className:`w-0.5 ${Ae.remarks?"h-32":"h-16"} ${Ae.status==="completed"?"bg-green-300":Ae.status==="skipped"?"bg-amber-200":"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:Ae.status==="completed"?"text-green-600":Ae.status==="active"?"text-re-red":Ae.status==="skipped"?"text-amber-700":"text-slate-400",children:Ae.name}),Ae.status==="skipped"&&e.jsx(Ce,{className:"bg-amber-100 text-amber-800 border-amber-300 hover:bg-amber-100",title:mt||"This stage was bypassed by the workflow.",children:"Skipped"}),Pe>0&&e.jsxs("button",{onClick:()=>Vt(Ae.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(Ns,{className:"w-3 h-3"}),e.jsxs("span",{children:[Pe," ",Pe===1?"doc":"docs"]})]})]}),(((Nt=ct[0])==null?void 0:Nt.timestamp)||Ae.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(dr,{className:"w-3 h-3"}),e.jsx("span",{children:Gt(((Mt=ct[0])==null?void 0:Mt.timestamp)||Ae.date)})]})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:Ae.description}),Ae.status==="skipped"&&e.jsxs("p",{className:"text-xs text-amber-700 mt-1 flex items-center gap-1",children:[e.jsx(k1,{className:"w-3 h-3"}),mt?`Bypassed — ${mt}`:"This stage was bypassed by the workflow and not reviewed."]}),ct.length>0&&e.jsx("div",{className:"mt-3 space-y-3",children:ct.map((Pt,ys)=>{var hs,gn,$s;const Yt=Pt.remarks||Pt.comments||"",ps=Yt==null?void 0:Yt.startsWith("Attachment:"),ks=ps?Yt.replace("Attachment:","").trim():Yt;return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ce,{className:`
|
||
text-[10px] h-4 px-1.5
|
||
${(hs=Pt.action)!=null&&hs.toLowerCase().includes("rejected")||(gn=Pt.action)!=null&&gn.toLowerCase().includes("revoked")?"bg-red-100 text-red-700":($s=Pt.action)!=null&&$s.toLowerCase().includes("approved")?"bg-emerald-100 text-emerald-700":"bg-blue-100 text-blue-700"}
|
||
`,children:Pt.action||"Action"}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-medium",children:["by ",Pt.user||"System",Pt.role?` (${Pt.role})`:""," • ",Gt(Pt.timestamp)]})]}),e.jsx("div",{className:`
|
||
p-2.5 rounded-lg border text-sm
|
||
${ps?"bg-red-50/50 border-red-100 text-red-900":"bg-slate-50 border-slate-100 text-slate-700"}
|
||
`,children:ps?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-3.5 h-3.5 text-re-red"}),e.jsx("span",{className:"font-medium truncate",children:ks})]}):e.jsx("p",{className:"leading-relaxed",children:ks||"No remarks provided."})})]},ys)})})]})]},Ae.id)})})]})]})}),e.jsx(qt,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Documents"}),e.jsx(Qt,{children:"View and manage termination case documents"})]}),e.jsxs(se,{size:"sm",onClick:()=>T(!0),className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:(()=>{const Ae=[...ge.documents||[],...ge.uploadedDocuments||[]];return Ae.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No documents found"})}):Ae.map((Ht,Pe)=>{var ct;return e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Ht.name||Ht.fileName})]})}),e.jsx(ue,{children:Ht.documentType||Ht.type||"Document"}),e.jsx(ue,{children:Gt(Ht.uploadDate||Ht.createdAt)}),e.jsx(ue,{children:((ct=Ht.uploader)==null?void 0:ct.fullName)||Ht.uploader||"-"}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const tt=Ht.filePath||Ht.path||Ht.url;if(!tt)return;const Nt=tt.startsWith("/uploads/")&&!tt.startsWith("/uploads/documents/")?tt.replace("/uploads/","/uploads/documents/"):tt;ie({fileName:Ht.name||Ht.fileName||"Document",filePath:Nt,documentType:Ht.documentType||Ht.type||"Document"})},children:"View"})})]},Ht.id||Pe)})})()})]})})]})}),e.jsx(qt,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Audit Trail"}),e.jsx(Qt,{children:"Complete history of actions on this termination case"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:S.length>0?S.map((Ae,Ht)=>{var Pe,ct,tt,Nt,Mt,Pt,ys,Yt,ps,ks,hs;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(Ce,{className:`
|
||
${(Ae.description||Ae.action||((Pe=Ae.details)==null?void 0:Pe.action)||"").toLowerCase().includes("reject")||(Ae.description||Ae.action||((ct=Ae.details)==null?void 0:ct.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Ae.description||Ae.action||((tt=Ae.details)==null?void 0:tt.action)||"").toLowerCase().includes("sent back")||(Ae.description||Ae.action||((Nt=Ae.details)==null?void 0:Nt.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(Ae.description||Ae.action||((Mt=Ae.details)==null?void 0:Mt.action)||"").toLowerCase().includes("approv")||(Ae.description||Ae.action||((Pt=Ae.details)==null?void 0:Pt.action)||"").toLowerCase().includes("initi")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
|
||
`,children:Ae.description||Ae.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((ys=Ae.actor)==null?void 0:ys.name)||Ae.userName||"System"]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Gt(Ae.timestamp||Ae.createdAt)})]}),(Ae.remarks||((Yt=Ae.newData)==null?void 0:Yt.remarks)||((ps=Ae.details)==null?void 0:ps.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:Ae.remarks||((ks=Ae.newData)==null?void 0:ks.remarks)||((hs=Ae.details)==null?void 0:hs.remarks)})]})]},Ht)}):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(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[(ge.currentStage==="Evaluation of Dealer SCN Response"||ge.currentStage==="Personal Hearing")&&e.jsxs(di,{className:"mb-2 bg-blue-50 border-blue-200",children:[e.jsx(Ti,{className:"text-blue-800 text-sm font-semibold",children:"Joint Review Stage"}),e.jsxs(ui,{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:[!qe.canFinalize&&e.jsxs(e.Fragment,{children:[qe.canApprove&&e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700 font-bold",onClick:()=>Et("approve"),children:[e.jsx(Wn,{className:"w-4 h-4 mr-2"}),"Approve"]}),qe.canIssueSCN&&e.jsxs(se,{className:"w-full bg-purple-600 hover:bg-purple-700",onClick:()=>A(!0),children:[e.jsx(Ha,{className:"w-4 h-4 mr-2"}),"Issue SCN"]}),qe.canUploadSCNResponse&&e.jsxs(se,{className:"w-full bg-re-red hover:bg-re-red-hover",onClick:()=>{$(null),A(!0)},children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"Upload SCN Response"]}),qe.canApprove&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>Et("sendBack"),children:[e.jsx(rb,{className:"w-4 h-4 mr-2"}),"Send Back"]})]}),qe.canHold&&e.jsxs(se,{variant:"outline",className:"w-full border-orange-200 text-orange-700 hover:bg-orange-50",onClick:()=>Et("hold"),children:[e.jsx(ZI,{className:"w-4 h-4 mr-2"}),"Hold Decision"]}),qe.canFinalize&&e.jsxs(se,{className:"w-full bg-indigo-600 hover:bg-indigo-700",onClick:()=>G(!0),children:[e.jsx(no,{className:"w-4 h-4 mr-2"}),"Final Authorization"]})]}),qe.canPushToFnF&&e.jsxs(se,{variant:"outline",className:"w-full text-blue-600 border-blue-300 hover:bg-blue-50",onClick:()=>Et("pushfnf"),children:[e.jsx(Ku,{className:"w-4 h-4 mr-2"}),"Push to F&F"]}),Ot&&!qe.isSettlementPhase&&!qe.canPushToFnF&&!ge.fnfSettlement&&(ge.currentStage==="Terminated"||ge.status===Vc.AWAITING_FNF||ge.status===Vc.AWAITING_FNF_LWD_PENDING)&&!qe.isLwdReached&&e.jsxs(di,{className:"border-red-200 bg-red-50",children:[e.jsx(Ha,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(Ti,{className:"text-red-900",children:["Push to F&F locked until ",Oi]}),e.jsxs(ui,{className:"text-red-800 text-sm",children:[Oi," is"," ",ge.proposedLwd?new Date(ge.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"}):"not set",". Admins are notified by email when the ",Oi.toLowerCase()," is reached."]})]}),!qe.isFinalState&&e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>Et("assign"),children:[e.jsx(ab,{className:"w-4 h-4 mr-2"}),"Assign User"]}),e.jsx(tc,{}),e.jsxs(se,{variant:"outline",className:"w-full",onClick:()=>{var Ae;return r(`/worknotes/termination/${t}`,{state:{applicationName:((Ae=ge==null?void 0:ge.dealer)==null?void 0:Ae.businessName)||"Termination",registrationNumber:t||"",participants:(ge==null?void 0:ge.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes",Bs>0&&e.jsx(Ce,{className:"ml-auto bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:Bs})]})]})]})})]})]}),e.jsx(ls,{open:a.open,onOpenChange:Ae=>l({open:Ae,type:null}),children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[a.type==="approve"&&"Approve Termination Request",a.type==="withdrawal"&&"Withdraw Termination Request",a.type==="sendBack"&&"Send Back for Clarification",a.type==="revoke"&&"Revoke Termination Request",a.type==="assign"&&"Assign to User",a.type==="pushfnf"&&"Push to Full & Final Settlement",a.type==="hold"&&"Hold Termination Case"]}),e.jsx(bs,{children:a.type==="assign"?"Select a user to assign this request to":a.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:a.type==="assign"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Select User"}),e.jsxs(At,{value:m,onValueChange:f,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Choose a user"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"rbm",children:"RBM - Regional Business Manager"}),e.jsx(Me,{value:"zbh",children:"ZBH - Zonal Business Head"}),e.jsx(Me,{value:"dd-lead",children:"DD Lead"}),e.jsx(Me,{value:"legal",children:"Legal Team"}),e.jsx(Me,{value:"nbh",children:"NBH - National Business Head"}),e.jsx(Me,{value:"cco",children:"CCO - Chief Commercial Officer"}),e.jsx(Me,{value:"ceo",children:"CEO"})]})]})]}):a.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 ",Oi,ge.proposedLwd?` (${new Date(ge.proposedLwd).toLocaleDateString("en-IN",{dateStyle:"medium"})})`:"","."]}),e.jsx(de,{children:"Remarks (Optional)"}),e.jsx(Gs,{value:o,onChange:Ae=>d(Ae.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:x,onChange:Ae=>h(Ae.target.checked)}),e.jsxs("span",{children:["Force initiate F&F before ",Oi," (requires business approval; exception use only)"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks *"}),e.jsx(Gs,{value:o,onChange:Ae=>d(Ae.target.value),placeholder:"Enter your remarks here...",rows:4})]})}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>l({open:!1,type:null}),children:"Cancel"}),e.jsx(se,{onClick:Ds,className:a.type==="approve"?"bg-green-600 hover:bg-green-700":a.type==="withdrawal"?"bg-red-600 hover:bg-red-700":a.type==="hold"?"bg-orange-600 hover:bg-orange-700":"bg-blue-600 hover:bg-blue-700",children:"Confirm"})]})]})}),e.jsx(ls,{open:p.open,onOpenChange:Ae=>u({open:Ae,stageName:"",documents:[]}),children:e.jsxs(as,{className:Kb,children:[e.jsxs(fs,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Documents - ",p.stageName]}),e.jsxs(bs,{children:["Documents uploaded for this stage (",p.documents.length," ",p.documents.length===1?"document":"documents",")"]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:p.documents.length>0?e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Uploader"}),e.jsx(fe,{children:"Action"})]})}),e.jsx(Ls,{children:p.documents.map(Ae=>e.jsxs(lt,{children:[e.jsx(ue,{children:Ae.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:Ae.type})}),e.jsx(ue,{children:Ae.uploadDate}),e.jsx(ue,{children:Ae.uploader}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",className:"text-re-red hover:text-re-red-hover",onClick:()=>{const Ht=Ae.path;if(!Ht)return;const Pe=Ht.startsWith("/uploads/")&&!Ht.startsWith("/uploads/documents/")?Ht.replace("/uploads/","/uploads/documents/"):Ht;ie({fileName:Ae.name||"Document",filePath:Pe,documentType:Ae.type||"Document"})},children:[e.jsx(Ns,{className:"w-4 h-4 mr-1"}),"View"]})})]},Ae.id))})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded for this stage yet"})}),e.jsx(xn,{children:e.jsx(se,{variant:"outline",onClick:()=>u({open:!1,stageName:"",documents:[]}),children:"Close"})})]})}),e.jsx(ls,{open:R,onOpenChange:A,children:e.jsxs(as,{className:"bg-white",children:[e.jsxs(fs,{children:[e.jsx(us,{children:Be?"Upload SCN Response":"Issue Show Cause Notice (SCN)"}),e.jsx(bs,{children:Be?"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:[Be&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{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:Ae=>{var Ht;return $(((Ht=Ae.target.files)==null?void 0:Ht[0])||null)}}),e.jsx(se,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ae;return(Ae=document.getElementById("scn-file-upload"))==null?void 0:Ae.click()},children:L?L.name:"Select PDF or Image"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Remarks/Details"}),e.jsx(Gs,{placeholder:"Add any internal remarks or justification...",value:P,onChange:Ae=>E(Ae.target.value),rows:4})]}),e.jsxs(xn,{className:"gap-2 sm:gap-0",children:[e.jsx(se,{variant:"outline",onClick:()=>A(!1),disabled:O,children:"Cancel"}),e.jsx(se,{className:Be?"bg-re-red hover:bg-re-red-hover":"bg-purple-600 hover:bg-purple-700",onClick:Be?we:ce,disabled:O||Be&&!L,children:O?"Processing...":Be?"Upload Response":"Issue SCN"})]})]})]})}),e.jsx(ls,{open:q,onOpenChange:G,children:e.jsxs(as,{className:"bg-white",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Final Termination Authorization"}),e.jsx(bs,{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(de,{children:"Final Decision"}),e.jsxs(At,{value:Y,onValueChange:Ae=>V(Ae),children:[e.jsx(Dt,{className:"mt-2 text-slate-900 border-slate-300",children:e.jsx(kt,{placeholder:"Select decision"})}),e.jsxs(Rt,{className:"bg-white border-slate-200 shadow-xl overflow-visible z-[9999]",children:[e.jsx(Me,{value:"Approve",className:"text-re-red-hover focus:bg-red-50",children:"Confirm Termination"}),e.jsx(Me,{value:"Reject",className:"text-slate-600 focus:bg-slate-50",children:"Reject Termination"}),e.jsx(Me,{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(de,{children:"Authorization Remarks"}),e.jsx(Gs,{placeholder:"Provide your rationale for this decision...",value:Q,onChange:Ae=>_(Ae.target.value),rows:4})]}),e.jsxs(xn,{className:"gap-2 sm:gap-0",children:[e.jsx(se,{variant:"outline",onClick:()=>G(!1),disabled:O,children:"Cancel"}),e.jsx(se,{className:"bg-indigo-600 hover:bg-indigo-700",onClick:ke,disabled:O||!Q,children:O?"Authorizing...":"Submit Decision"})]})]})]})}),e.jsx(ls,{open:z,onOpenChange:T,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Upload Termination Document"}),e.jsx(bs,{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(de,{children:"Document Type"}),e.jsxs(At,{value:K,onValueChange:W,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select document type"})}),e.jsx(Rt,{children:Zg.map(Ae=>e.jsx(Me,{value:Ae,children:Ae},Ae))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"Stage (Optional)"}),e.jsxs(At,{value:H||"none",onValueChange:Ae=>X(Ae==="none"?"":Ae),children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select stage"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"none",children:"No Stage Mapping"}),yV.map(Ae=>e.jsx(Me,{value:Ae,children:Ae},Ae))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:"File"}),e.jsx("input",{type:"file",onChange:Ae=>{var Ht;return B(((Ht=Ae.target.files)==null?void 0:Ht[0])||null)}})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>T(!1),disabled:O,children:"Cancel"}),e.jsx(se,{onClick:Xe,disabled:O,children:O?"Uploading...":"Upload"})]})]})}),e.jsx(mo,{isOpen:!!J,onClose:()=>ie(null),document:J})]})}const ua=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"-"}},IS=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"-"}},g_=({isOpen:t,onClose:s,onSubmit:n,editingBank:r,isSubmitting:a})=>e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"sm:max-w-[500px]",children:[e.jsxs(fs,{children:[e.jsx(us,{children:r?"Edit Bank Details":"Add Bank Account"}),e.jsx(bs,{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(de,{htmlFor:"bankName",className:"text-right text-xs",children:"Bank Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{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(de,{htmlFor:"accountHolderName",className:"text-right text-xs",children:"Holder Name"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{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(de,{htmlFor:"accountNumber",className:"text-right text-xs",children:"A/C Number"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{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(de,{htmlFor:"ifscCode",className:"text-right text-xs",children:"IFSC Code"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{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(de,{htmlFor:"branchName",className:"text-right text-xs",children:"Branch"}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{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(de,{htmlFor:"isPrimaryModal",className:"text-xs font-medium cursor-pointer",children:"Set as primary account"})]})})]}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:s,"data-testid":"onboarding-bank-details-cancel",children:"Cancel"}),e.jsxs(se,{type:"submit",disabled:a,size:"sm",className:"bg-re-red","data-testid":"onboarding-bank-details-submit",children:[a?e.jsx(es,{className:"w-4 h-4 animate-spin mr-2"}):null,r?"Update Account":"Save Bank Details"]})]})]})]})}),MS=["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"],RV="[DEPARTMENT_CLAIM]",EV="[FINANCE_VALIDATED]";function _V({fnfId:t,onBack:s,currentUser:n}){var Bs,Ys,Xs,Js,Ws;const r=tr(),[a,l]=g.useState(null),[o,d]=g.useState(!0),[m,f]=g.useState("details"),[x,h]=g.useState(!1),[p,u]=g.useState(null),[w,v]=g.useState([]),[N,j]=g.useState([]),[y,C]=g.useState(!1),[S,D]=g.useState(null),[R,A]=g.useState(!1),[L,$]=g.useState(!1),[P,E]=g.useState(null),[O,I]=g.useState(!1),[q,G]=g.useState({remarks:"",amount:0,type:"Receivable"}),[Y,V]=g.useState(null),[Q,_]=g.useState(!1),z=g.useRef(null),[T,F]=g.useState(!1),[B,K]=g.useState(""),[W,H]=g.useState(""),[X,J]=g.useState(null);g.useEffect(()=>{ke(),Xe()},[t]);const ie=Z=>{if(!Z)return Z;let oe=Z.trim();const Ne=MS.find(ye=>ye.toLowerCase()===oe.toLowerCase());if(Ne)return Ne;const De={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"}[oe.toLowerCase().replace(" department","")];return De||Z},ae=(Z,oe)=>oe==="DepartmentClaim"||typeof Z=="string"&&(Z.startsWith(RV)||Z.includes("Clearance:")),xe=Z=>(Z==null?void 0:Z.sourceType)==="FinanceValidated"&&typeof(Z==null?void 0:Z.description)=="string"&&Z.description.includes("Auto-seeded from department claim"),ce=(Z,oe)=>oe==="FinanceValidated"||typeof Z=="string"&&Z.startsWith(EV),we=Z=>Z?{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"}[Z]||Z.split("_").map(Ne=>Ne.charAt(0).toUpperCase()+Ne.slice(1).toLowerCase()).join(" "):"Action",ke=async(Z=!0)=>{var oe,Ne,Oe,De,ye,Ve,Ge,st,Kt,Xt,ot,ft,Es,ts,vs,Te,je,nt,Ye,pt,yt,Jt,ss,Ss,Zs,on,en,tn,cn,Ae,Ht,Pe,ct,tt,Nt,Mt,Pt,ys,Yt,ps,ks,hs,gn,$s,dn,sn,We,Ft,gt,rt,Is,xs,Nn,kn,Cn,Us,Za,Pa,Ms,un,ta,sa,na,Mr;try{Z&&d(!0);const zn=(await Ee.getFnFSettlementById(t)).data;if(zn.success){const Zt=zn.fnf,Jn=(Zt.lineItems||[]).filter(ns=>ns.isActive!==!1),Gn=Jn.some(ns=>ce(ns.description,ns.sourceType))?Jn.filter(ns=>ce(ns.description,ns.sourceType)):Jn.filter(ns=>!ae(ns.description,ns.sourceType)),_r={id:Zt.id,caseNumber:Zt.settlementId||((oe=Zt.resignation)==null?void 0:oe.resignationId)||((Ne=Zt.terminationRequest)==null?void 0:Ne.requestId)||Zt.id.substring(0,8),status:Zt.status,requestType:Zt.resignationId?"Resignation":"Termination",dealerName:((De=(Oe=Zt.outlet)==null?void 0:Oe.dealer)==null?void 0:De.fullName)||((ye=Zt.dealer)==null?void 0:ye.fullName)||"N/A",dealerCode:((Ve=Zt.outlet)==null?void 0:Ve.code)||((st=(Ge=Zt.dealer)==null?void 0:Ge.dealerCode)==null?void 0:st.dealerCode)||"N/A",dealershipName:((Kt=Zt.outlet)==null?void 0:Kt.name)||((Xt=Zt.dealer)==null?void 0:Xt.businessName)||"N/A",location:((ot=Zt.outlet)==null?void 0:ot.city)||((ft=Zt.outlet)==null?void 0:ft.location)||"N/A",originalRequestId:((Es=Zt.resignation)==null?void 0:Es.resignationId)||((ts=Zt.terminationRequest)==null?void 0:ts.requestId)||((vs=Zt.terminationRequest)==null?void 0:vs.id)||"N/A",submittedOn:ua(Zt.createdAt),lastOperationalDateSales:(Te=Zt.resignation)!=null&&Te.lastOperationalDateSales||(je=Zt.terminationRequest)!=null&&je.proposedLwd?IS(((nt=Zt.resignation)==null?void 0:nt.lastOperationalDateSales)||((Ye=Zt.terminationRequest)==null?void 0:Ye.proposedLwd)):"N/A",lastOperationalDateServices:(pt=Zt.resignation)!=null&&pt.lastOperationalDateServices||(yt=Zt.terminationRequest)!=null&&yt.proposedLwd?IS(((Jt=Zt.resignation)==null?void 0:Jt.lastOperationalDateServices)||((ss=Zt.terminationRequest)==null?void 0:ss.proposedLwd)):"N/A",typeOfClosure:Zt.resignationId?"Voluntary":"Involuntary",gst:((on=(Zs=(Ss=Zt.outlet)==null?void 0:Ss.dealer)==null?void 0:Zs.dealerProfile)==null?void 0:on.gstNumber)||((en=Zt.dealer)==null?void 0:en.gstNumber)||"N/A",pan:((Ae=(cn=(tn=Zt.outlet)==null?void 0:tn.dealer)==null?void 0:cn.dealerProfile)==null?void 0:Ae.panNumber)||((Ht=Zt.dealer)==null?void 0:Ht.panNumber)||"N/A",salesCode:((ct=(Pe=Zt.dealer)==null?void 0:Pe.dealerCode)==null?void 0:ct.salesCode)||((Pt=(Mt=(Nt=(tt=Zt.outlet)==null?void 0:tt.dealer)==null?void 0:Nt.dealerProfile)==null?void 0:Mt.dealerCode)==null?void 0:Pt.salesCode)||"N/A",serviceCode:((Yt=(ys=Zt.dealer)==null?void 0:ys.dealerCode)==null?void 0:Yt.serviceCode)||((gn=(hs=(ks=(ps=Zt.outlet)==null?void 0:ps.dealer)==null?void 0:ks.dealerProfile)==null?void 0:hs.dealerCode)==null?void 0:gn.serviceCode)||"N/A",gearCode:((dn=($s=Zt.dealer)==null?void 0:$s.dealerCode)==null?void 0:dn.gearCode)||((gt=(Ft=(We=(sn=Zt.outlet)==null?void 0:sn.dealer)==null?void 0:We.dealerProfile)==null?void 0:Ft.dealerCode)==null?void 0:gt.gearCode)||"N/A",gmaCode:((Is=(rt=Zt.dealer)==null?void 0:rt.dealerCode)==null?void 0:Is.gmaCode)||((Cn=(kn=(Nn=(xs=Zt.outlet)==null?void 0:xs.dealer)==null?void 0:Nn.dealerProfile)==null?void 0:kn.dealerCode)==null?void 0:Cn.gmaCode)||"N/A",financeReportStatus:Zt.status==="Finance Approval"?"In Progress":Zt.status==="Completed"?"Completed":"Pending",totalPayableAmount:Gn.filter(ns=>ns.itemType==="Payable").reduce((ns,nn)=>ns+(parseFloat(nn.amount)||0),0),totalRecoveryAmount:Gn.filter(ns=>ns.itemType==="Receivable"||ns.itemType==="Recovery").reduce((ns,nn)=>ns+(parseFloat(nn.amount)||0),0),totalDeductions:Gn.filter(ns=>ns.itemType==="Deduction").reduce((ns,nn)=>ns+(parseFloat(nn.amount)||0),0),allLineItems:Jn,netAmount:0,departmentResponses:[]};_r.netAmount=_r.totalPayableAmount-_r.totalRecoveryAmount-_r.totalDeductions,_r.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(ns=>{const nn=(Zt.clearances||[]).find(An=>ie(An.department)===ns),va=Jn.filter(An=>ie(An.department)===ns&&ae(An.description,An.sourceType)),Si=Jn.filter(An=>ie(An.department)===ns&&xe(An)),Ci=va.length>0?va:Si;let Fr=0,Hr=0;Ci.forEach(An=>{const ba=Math.abs(parseFloat(An.amount)||0);An.itemType==="Payable"?Fr+=ba:Hr+=ba});const sr=Fr-Hr,ya=Math.abs(sr)>0,Gi=(nn==null?void 0:nn.status)||"Pending",bo=ya?"Dues Pending":Gi==="Cleared"?"NOC Submitted":Gi,Oa=sr>0?"payable":sr<0?"recovery":null;return{id:(nn==null?void 0:nn.id)||`dept-${ns}`,clearanceId:(nn==null?void 0:nn.id)||null,departmentName:ns,status:bo,duesFlow:Oa,amountType:sr>0?"Payable to dealer":sr<0?"Receivable from dealer":null,amount:Math.abs(sr),submittedDate:nn!=null&&nn.clearedAt?ua(nn.clearedAt):"-",remarks:(nn==null?void 0:nn.remarks)||"-",supportingDocument:(nn==null?void 0:nn.supportingDocument)||null}});const On={..._r,documents:[...(((Us=Zt.resignation)==null?void 0:Us.uploadedDocuments)||[]).map(ns=>({id:`res-${ns.id}`,name:ns.fileName,type:"Resignation",uploadDate:ua(ns.createdAt),status:"Verified",url:ns.filePath})),...(Zt.clearances||[]).filter(ns=>ns.supportingDocument).map(ns=>({id:`clr-${ns.id}`,name:ns.supportingDocument.split("/").pop(),type:`${ns.department} Proof`,uploadDate:ua(ns.clearedAt),status:"Attached",url:ns.supportingDocument})),...(Zt.settlementDocs||[]).map(ns=>({id:`set-${ns.id}`,name:ns.fileName,type:"Settlement Proof",uploadDate:ua(ns.createdAt),status:"Finance",url:ns.filePath})),...(Zt.clearanceDocuments||[]).filter(ns=>ns==null?void 0:ns.supportingDocument).map((ns,nn)=>({id:ns.id||`fnf-doc-${nn}`,name:ns.name||(ns.supportingDocument||"").split("/").pop(),type:ns.documentType||ns.department||"F&F Document",uploadDate:ns.clearedAt?ua(ns.clearedAt):"-",status:"Attached",url:ns.supportingDocument}))],participants:Zt.participants||[]};l(On);const ur=Zt.bankDetails||((Za=Zt.dealer)==null?void 0:Za.bankDetails)||((un=(Ms=(Pa=Zt.outlet)==null?void 0:Pa.dealer)==null?void 0:Ms.dealerProfile)==null?void 0:un.bankDetails);ur&&ur.length>0?j(ur):((sa=(ta=Zt.outlet)==null?void 0:ta.dealer)!=null&&sa.id||Zt.dealerId)&&Ot(((Mr=(na=Zt.outlet)==null?void 0:na.dealer)==null?void 0:Mr.id)||Zt.dealerId)}}catch(Xn){console.error("Fetch F&F details error:",Xn),ee.error("Failed to fetch settlement details")}finally{Z&&d(!1)}},Xe=async()=>{try{const oe=(await Ee.getAuditLogs("fnf",t)).data;oe.success&&v(oe.data||[])}catch(Z){console.error("Fetch audit logs error:",Z)}},Ot=async Z=>{try{const Ne=(await Ee.getDealerBankDetails(Z)).data;Ne.success&&j(Ne.bankDetails||[])}catch(oe){console.error("Fetch bank details error:",oe)}},bt=async Z=>{var Oe,De;Z.preventDefault();const oe=new FormData(Z.currentTarget),Ne=Object.fromEntries(oe.entries());try{A(!0);const ye=((De=(Oe=a==null?void 0:a.outlet)==null?void 0:Oe.dealer)==null?void 0:De.id)||(a==null?void 0:a.dealerId);if(!ye){ee.error("Dealer information missing");return}(await Ee.saveBankDetail(ye,{...Ne,id:S==null?void 0:S.id,isPrimary:oe.get("isPrimary")==="on"})).data.success&&(ee.success("Bank details saved successfully"),Ot(ye),C(!1),D(null))}catch{ee.error("Failed to save bank details")}finally{A(!1)}},te=async Z=>{var oe,Ne;if(confirm("Are you sure you want to delete this bank account?"))try{if((await Ee.deleteBankDetail(Z)).data.success){ee.success("Bank detail deleted");const De=((Ne=(oe=a==null?void 0:a.outlet)==null?void 0:oe.dealer)==null?void 0:Ne.id)||(a==null?void 0:a.dealerId);De&&Ot(De)}}catch{ee.error("Failed to delete bank detail")}};if(o)return e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(es,{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(se,{onClick:s,className:"mt-4",children:"Go Back"})]});const qe=(Z=>{const oe=new Date(Z),Oe=Math.abs(new Date().getTime()-oe.getTime());return Math.ceil(Oe/(1e3*60*60*24))})(a.submittedOn),ge=String((n==null?void 0:n.role)||"").toLowerCase(),Be=ge.includes("super admin")||ge.includes("dd admin"),ut=Z=>{if(!a||!Z)return!1;const oe=ge;if(!oe||Z.status!=="Pending")return!1;const Oe=["Finance Approval","Completed"].includes(a.status),De=oe.includes("super admin")||oe.includes("finance")||oe.includes("dd admin");if(Oe&&!De)return!1;if(De)return!0;const ye=Z.departmentName.replace(" Department","").toLowerCase();return oe.includes(ye)},ht=((a==null?void 0:a.departmentResponses)||[]).some(Z=>ut(Z)),it=async()=>{var Z;if(!(P!=null&&P.clearanceId)||!t){ee.error("Clearance record not available for this department");return}try{I(!0);const oe=new FormData,Ne=Number(q.amount)>0?"Dues Pending":"NOC Submitted";oe.append("status",Ne),oe.append("remarks",q.remarks),oe.append("amount",String(q.amount)),oe.append("type",q.type),Y&&oe.append("file",Y);const Oe=await Ee.updateFnFClearance(t,P.clearanceId,oe);if(!Oe.ok){ee.error(((Z=Oe.data)==null?void 0:Z.message)||"Failed to update department clearance"),I(!1);return}ee.success(`Clearance updated for ${P.departmentName}`),$(!1),V(null),f("departments"),ke(!1)}catch(oe){console.error("Update clearance error:",oe),ee.error("Failed to update department clearance")}finally{I(!1)}},Tt=Z=>{var Ne;const oe=((Ne=Z.target.files)==null?void 0:Ne[0])||null;J(oe)},It=()=>{F(!1),K(""),H(""),J(null),z.current&&(z.current.value="")},he=async()=>{var oe,Ne,Oe,De;const Z=B.trim();if(!Z){ee.error("Please enter a document name.");return}if(!X){ee.error("Please choose a file to upload.");return}if(!t){ee.error("Cannot upload — settlement id is missing.");return}_(!0);try{const ye=new FormData;ye.append("file",X),ye.append("documentName",Z),W.trim()&&ye.append("documentType",W.trim());const Ve=await Ee.uploadFnFDocument(t,ye);(oe=Ve.data)!=null&&oe.success?(ee.success("Document uploaded successfully"),It(),ke(!1)):ee.error(((Ne=Ve.data)==null?void 0:Ne.message)||"Failed to upload document")}catch(ye){console.error("Upload F&F document error:",ye),ee.error(((De=(Oe=ye==null?void 0:ye.response)==null?void 0:Oe.data)==null?void 0:De.message)||"Failed to upload document")}finally{_(!1)}},vt=()=>{ee.success("Notifications sent to all 16 departments"),h(!1)},mt=Z=>{switch(Z){case"New":return"bg-red-50 text-re-red-hover border-red-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"}},_e=Z=>{switch(Z){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"}},Vt=a.departmentResponses.filter(Z=>Z.status!=="Pending").length,Et=a.departmentResponses.length,Ds=Vt/Et*100,ln=MS.map(Z=>{const oe=(a.departmentResponses||[]).find(ot=>ot.departmentName===Z),Ne=Number(oe==null?void 0:oe.amount)||0,Oe=(oe==null?void 0:oe.amountType)||"-",De=(a.allLineItems||[]).filter(ot=>ie(ot.department)===Z),ye=De.filter(ot=>ot.sourceType==="FinanceValidated"&&ot.itemType==="Payable").reduce((ot,ft)=>ot+Math.abs(parseFloat(ft.amount)||0),0),Ve=De.filter(ot=>ot.sourceType==="FinanceValidated"&&(ot.itemType==="Receivable"||ot.itemType==="Recovery")).reduce((ot,ft)=>ot+Math.abs(parseFloat(ft.amount)||0),0),Ge=De.filter(ot=>ot.sourceType==="FinanceValidated"&&ot.itemType==="Deduction").reduce((ot,ft)=>ot+Math.abs(parseFloat(ft.amount)||0),0),st=ye-Ve-Ge,Kt=Math.abs(st),Xt=st>0?"Payable":st<0?"Receivable":"-";return{department:Z,claimAmount:Ne,claimType:Oe,validatedAmount:Kt,validatedType:Xt,variance:Kt-Ne}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Le,{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(Fe,{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(hk,{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(Ce,{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(se,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Jr,{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(Ce,{className:mt(a.status),children:a.status}),e.jsx(Ce,{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(se,{variant:"outline",onClick:()=>r(`/worknotes/fnf/${t}`,{state:{applicationName:a.dealerName||"F&F Settlement",registrationNumber:a.caseNumber||"",participants:a.participants||[]}}),children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Overall Progress"}),e.jsxs(Qt,{children:["Department responses: ",Vt," / ",Et]})]}),e.jsxs(Fe,{children:[e.jsx(uc,{value:Ds,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(Z=>Z.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(Z=>Z.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(Z=>Z.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($n,{value:m,onValueChange:f,className:"w-full",children:[e.jsxs(qn,{children:[e.jsx(zt,{value:"progress",children:"Progress"}),e.jsx(zt,{value:"details",children:"Case Details"}),e.jsx(zt,{value:"departments",children:"Department Responses"}),Be&&e.jsx(zt,{value:"documents",children:"Documents"}),e.jsx(zt,{value:"audit",children:"Audit Trail"})]}),e.jsx(qt,{value:"progress",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"F&F Settlement Progress"}),e.jsx(Qt,{children:"Track the complete journey from initiation to completion"})]}),e.jsx(Fe,{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(Wn,{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(Ce,{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(Le,{className:"bg-green-50 border-green-200",children:e.jsx(Fe,{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 ${Vt===Et||["Finance Approval","Completed"].includes(a.status)?"bg-green-100 border-green-600":Vt>0?"bg-red-50 border-re-red":"bg-slate-100 border-slate-300"}`,children:Vt===Et||["Finance Approval","Completed"].includes(a.status)?e.jsx(Wn,{className:"w-6 h-6 text-green-600"}):Vt>0?e.jsx(Ra,{className:"w-6 h-6 text-re-red"}):e.jsx(yn,{className:"w-6 h-6 text-slate-400"})}),e.jsx("div",{className:`w-0.5 h-full mt-2 ${Vt===Et||["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(Ce,{className:Vt===Et||["Finance Approval","Completed"].includes(a.status)?"bg-green-600":Vt>0?"bg-re-red":"bg-slate-400",children:Vt===Et||["Finance Approval","Completed"].includes(a.status)?"Completed":Vt>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.",Vt>0&&` (${Vt}/${Et} responses received)`]}),Vt>0&&e.jsx(Le,{className:Vt===Et||["Finance Approval","Completed"].includes(a.status)?"bg-green-50 border-green-200":"bg-red-50 border-red-200",children:e.jsx(Fe,{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:[Vt," / ",Et," ","departments"]})]}),e.jsx(uc,{value:Ds,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(Z=>Z.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(Z=>Z.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(Z=>Z.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(Wn,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(mu,{className:"w-6 h-6 text-re-red"}):e.jsx(yn,{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(Ce,{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(Le,{className:a.status==="Completed"?"bg-green-50 border-green-200":"bg-red-50 border-red-200",children:e.jsx(Fe,{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:["₹",((Bs=a.totalPayableAmount)==null?void 0:Bs.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:["₹",((Ys=a.totalRecoveryAmount)==null?void 0:Ys.toLocaleString())||"0"]})]}),e.jsxs("div",{className:"text-center p-3 bg-red-50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-re-red-hover 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(Wn,{className:"w-6 h-6 text-green-600"}):a.status==="Finance Approval"?e.jsx(Ga,{className:"w-6 h-6 text-re-red"}):e.jsx(yn,{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(Ce,{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(Le,{className:"bg-orange-50 border-orange-200",children:e.jsx(Fe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(an,{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(Wn,{className:"w-6 h-6 text-green-600"}):e.jsx(yn,{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(Ce,{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(yn,{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(Ce,{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(Le,{className:"bg-gradient-to-r from-green-50 to-red-50 border-green-300",children:e.jsx(Fe,{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(qt,{value:"details",className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Basic Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Case Number"}),e.jsx("p",{children:a.caseNumber})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Code"}),e.jsx("p",{children:a.dealerCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealer Name"}),e.jsx("p",{children:a.dealerName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Dealership Name"}),e.jsx("p",{children:a.dealershipName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Location"}),e.jsx("p",{children:a.location})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Request Type"}),e.jsx("p",{children:a.requestType})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Original Request ID"}),e.jsx("p",{children:a.originalRequestId})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted On"}),e.jsx("p",{children:a.submittedOn})]})]})})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50/30",children:[e.jsx(Qe,{children:e.jsx(et,{className:"text-re-red-hover",children:"F&F Settlement Information"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Sales)"}),e.jsx("p",{children:a.lastOperationalDateSales})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Last Operational Date (Services)"}),e.jsx("p",{children:a.lastOperationalDateServices})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Submitted Date (F&F Start)"}),e.jsx("p",{children:a.submittedOn})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Days Elapsed since Submission"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{children:[qe," days"]}),e.jsx(Ce,{variant:"outline",className:qe<30?"bg-green-100 text-green-700 border-green-300":qe<60?"bg-yellow-100 text-yellow-700 border-yellow-300":"bg-red-100 text-red-700 border-red-300",children:qe<30?"Recent":qe<60?"In Progress":"Overdue"})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Type of Closure"}),e.jsx("p",{children:a.typeOfClosure})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GST"}),e.jsx("p",{children:a.gst})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Sales Code"}),e.jsx("p",{children:a.salesCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Service Code"}),e.jsx("p",{children:a.serviceCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"Gear Code"}),e.jsx("p",{children:a.gearCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-600",children:"GMA Code"}),e.jsx("p",{children:a.gmaCode})]})]})})]}),a.status==="Under Review"&&e.jsxs(Le,{className:"border-orange-200 bg-orange-50",children:[e.jsxs(Qe,{children:[e.jsx(et,{className:"text-orange-900",children:"Under Review"}),e.jsx(Qt,{className:"text-orange-700",children:"This case is under negotiation/discussion with the dealer, finance team, legal team, and relevant departments"})]}),e.jsx(Fe,{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(qt,{value:"departments",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{children:["Department Responses (",Vt," / ",Et,")"]}),e.jsx(Qt,{children:"Status of NOC and dues from all departments"})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Amount Type"}),e.jsx(fe,{children:"Amount"}),e.jsx(fe,{children:"Submitted Date"}),e.jsx(fe,{children:"Remarks"}),ht&&e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:a.departmentResponses.map(Z=>e.jsxs(lt,{children:[e.jsx(ue,{children:Z.departmentName}),e.jsx(ue,{children:e.jsx(Ce,{className:_e(Z.status),children:Z.status})}),e.jsx(ue,{children:Z.amountType?e.jsx(Ce,{variant:"outline",className:Z.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:Z.amountType}):"-"}),e.jsx(ue,{children:Z.amount?e.jsxs("span",{className:`font-semibold tabular-nums ${Z.duesFlow==="recovery"?"text-red-700":"text-emerald-700"}`,children:["₹",Z.amount.toLocaleString()]}):"-"}),e.jsx(ue,{children:Z.submittedDate||"-"}),e.jsx(ue,{className:"max-w-xs truncate",children:Z.remarks||"-"}),ht&&e.jsx(ue,{children:ut(Z)?e.jsx(se,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover",onClick:()=>{E(Z),G({remarks:Z.remarks==="-"?"":Z.remarks,amount:Z.amount||0,type:Z.duesFlow==="payable"?"Payable":"Receivable"}),V(null),$(!0)},children:"Action"}):e.jsx("span",{className:"text-slate-400 text-sm",children:"-"})})]},Z.id))})]})})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50 mt-6",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Department Claim vs Finance Validation"}),e.jsx(Qt,{children:"Final settlement totals are based on finance validated values."})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Department Claim"}),e.jsx(fe,{children:"Finance Validated"}),e.jsx(fe,{children:"Variance"})]})}),e.jsx(Ls,{children:ln.map(Z=>e.jsxs(lt,{children:[e.jsx(ue,{children:Z.department}),e.jsx(ue,{children:Z.claimAmount>0?`${Z.claimType} ₹${Z.claimAmount.toLocaleString()}`:"-"}),e.jsx(ue,{children:Z.validatedAmount>0?`${Z.validatedType} ₹${Z.validatedAmount.toLocaleString()}`:"-"}),e.jsx(ue,{className:Z.variance===0?"text-slate-600":Z.variance>0?"text-red-600":"text-green-600",children:Z.claimAmount===0&&Z.validatedAmount===0?"-":`₹${Z.variance.toLocaleString()}`})]},Z.department))})]})})]}),e.jsxs(Le,{className:"mt-6",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Financial Summary"}),e.jsx(Qt,{children:"Consolidated view of all payable and receivable amounts"})]}),e.jsx(Fe,{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:["₹",((Xs=a.totalPayableAmount)==null?void 0:Xs.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:["₹",((Js=a.totalRecoveryAmount)==null?void 0:Js.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:["₹",((Ws=a.totalDeductions)==null?void 0:Ws.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-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-re-red-hover 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-re-red mt-1",children:(a.netAmount||0)<0?"Receivable from dealer":"Payment to dealer"})]})]})})]}),e.jsxs(Le,{className:"mt-6",children:[e.jsx(Qe,{children:e.jsx(et,{children:"Finance Report Status"})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ce,{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(de,{className:"text-slate-600",children:"Finance Remarks"}),e.jsx("p",{className:"mt-1",children:a.financeRemarks})]})]})]})]}),Be&&e.jsx(qt,{value:"documents",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Documents"}),e.jsx(Qt,{children:"All NOC documents and due statements from departments"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(se,{onClick:()=>F(!0),disabled:Q,className:"bg-re-red hover:bg-re-red-hover text-white","data-testid":"fnf-upload-docs-btn",children:[Q?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(or,{className:"w-4 h-4 mr-2"}),Q?"Uploading...":"Upload Document"]})})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Upload Date"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Ls,{children:[(a.documents||[]).length===0&&e.jsx(lt,{children:e.jsxs(ue,{colSpan:5,className:"text-center text-slate-500 py-8",children:["No documents uploaded yet. Click ",e.jsx("span",{className:"font-medium",children:"Upload Documents"})," to add files."]})}),(a.documents||[]).map(Z=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4 text-slate-500"}),e.jsx("span",{children:Z.name})]})}),e.jsx(ue,{children:Z.type}),e.jsx(ue,{children:Z.uploadDate}),e.jsx(ue,{children:e.jsx(Ce,{variant:Z.status==="Verified"?"default":"secondary",children:Z.status})}),e.jsx(ue,{children:e.jsx(se,{size:"sm",variant:"outline",onClick:()=>{const oe=Z.url,Ne=oe.startsWith("/uploads/")&&!oe.startsWith("/uploads/documents/")?oe.replace("/uploads/","/uploads/documents/"):oe;u({fileName:Z.name,filePath:Ne,documentType:Z.type})},children:"View"})})]},Z.id))]})]})})]})}),e.jsx(qt,{value:"bank",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Bank Details"}),e.jsx(Qt,{children:"Dealer bank accounts for settlement disbursement"})]}),e.jsxs(se,{onClick:()=>{D(null),C(!0)},className:"bg-re-red",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Account"]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:N.length>0?N.map(Z=>e.jsxs(Le,{className:`relative overflow-hidden ${Z.isPrimary?"border-re-red bg-red-50/30":""}`,children:[Z.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(Fe,{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(so,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-slate-900",children:Z.bankName}),e.jsx("p",{className:"text-xs text-slate-500",children:Z.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:Z.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:Z.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:Z.ifscCode})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-re-red",onClick:()=>{D(Z),C(!0)},children:[e.jsx(iy,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-8 text-red-600",onClick:()=>te(Z.id),children:[e.jsx(ar,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})]},Z.id)):e.jsxs("div",{className:"col-span-full py-12 text-center border-2 border-dashed rounded-lg bg-slate-50",children:[e.jsx(so,{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(se,{variant:"link",onClick:()=>C(!0),children:"Add first bank account"})]})})})]})}),e.jsx(qt,{value:"audit",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Audit Trail"}),e.jsx(Qt,{children:"Complete history of actions on this F&F case"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-4",children:w.length>0?w.map(Z=>{var oe,Ne,Oe,De,ye,Ve;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:[Z.action==="FNF_CREATED"&&e.jsx(Ce,{className:"bg-re-red h-2 w-2 p-0 rounded-full"}),Z.description&&!((oe=Z.newData)!=null&&oe.action)?Z.description:e.jsxs(e.Fragment,{children:[we(((Ne=Z.newData)==null?void 0:Ne.action)||Z.action),((Oe=Z.newData)==null?void 0:Oe.department)&&e.jsxs("span",{className:"text-re-red ml-1 font-bold",children:["- ",Z.newData.department]})]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:ua(Z.createdAt||Z.timestamp)})]}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-slate-600 mb-2",children:e.jsx(Ce,{variant:"outline",className:"text-[10px] uppercase",children:((De=Z.actor)==null?void 0:De.name)||Z.userName||"System"})}),(((ye=Z.newData)==null?void 0:ye.remarks)||Z.remarks)&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 border border-slate-200 rounded text-sm text-slate-700",children:((Ve=Z.newData)==null?void 0:Ve.remarks)||Z.remarks}),Z.newData&&Object.keys(Z.newData).filter(Ge=>Ge!=="remarks"&&Ge!=="status"&&Ge!=="action"&&Ge!=="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(Z.newData).filter(([Ge])=>Ge!=="remarks"&&Ge!=="action"&&Ge!=="department").map(([Ge,st])=>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:[Ge,":"]}),e.jsx("span",{className:"text-slate-900 font-medium",children:String(st)})]},Ge))})]})]})]},Z.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(ls,{open:x,onOpenChange:h,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Send to All Stakeholders"}),e.jsx(bs,{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-red-50 rounded-lg border border-red-200",children:[e.jsx("p",{className:"text-sm text-re-red-hover mb-2",children:"Notifications will be sent to:"}),e.jsxs("ul",{className:"text-sm text-re-red-hover 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(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(se,{onClick:vt,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Ku,{className:"w-4 h-4 mr-2"}),"Send Notifications"]})]})]})}),e.jsx(ls,{open:L,onOpenChange:$,children:e.jsxs(as,{className:"sm:max-w-[460px]",children:[e.jsxs(fs,{children:[e.jsxs(us,{children:["Update ",P==null?void 0:P.departmentName," Response"]}),e.jsx(bs,{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(de,{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:q.type,onChange:Z=>G({...q,type:Z.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(de,{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:q.amount,onChange:Z=>G({...q,amount:Number(Z.target.value)})})]})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{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:q.remarks,onChange:Z=>G({...q,remarks:Z.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{htmlFor:"proof",className:"text-right",children:"Proof"}),e.jsx("input",{id:"proof",type:"file",className:"col-span-3 text-sm",onChange:Z=>{var oe;return V(((oe=Z.target.files)==null?void 0:oe[0])||null)}})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:it,disabled:O,children:O?"Saving...":"Submit Response"})]})]})}),e.jsx(ls,{open:T,onOpenChange:Z=>{Z?F(!0):It()},children:e.jsxs(as,{className:"sm:max-w-md",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Upload Document"}),e.jsx(bs,{children:"Provide a name for this document and attach a file. The name is required."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(de,{htmlFor:"fnf-upload-doc-name",children:["Document Name ",e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx("input",{id:"fnf-upload-doc-name",type:"text",placeholder:"e.g. Final NOC — Sales",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:B,onChange:Z=>K(Z.target.value),"data-testid":"fnf-upload-doc-name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{htmlFor:"fnf-upload-doc-type",children:"Document Type (optional)"}),e.jsx("input",{id:"fnf-upload-doc-type",type:"text",placeholder:"e.g. NOC, Statement, Receipt",className:"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm",value:W,onChange:Z=>H(Z.target.value),"data-testid":"fnf-upload-doc-type"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(de,{htmlFor:"fnf-upload-doc-file",children:["File ",e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx("input",{id:"fnf-upload-doc-file",ref:z,type:"file",className:"flex w-full text-sm",onChange:Tt,"data-testid":"fnf-upload-docs-input"}),X&&e.jsxs("p",{className:"text-xs text-slate-500 truncate",children:["Selected: ",e.jsx("span",{className:"font-medium",children:X.name})]})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:It,disabled:Q,children:"Cancel"}),e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover text-white",onClick:he,disabled:Q||!B.trim()||!X,"data-testid":"fnf-upload-doc-submit",children:[Q?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(or,{className:"w-4 h-4 mr-2"}),Q?"Uploading...":"Upload"]})]})]})}),e.jsx(g_,{isOpen:y,onClose:()=>{C(!1),D(null)},onSubmit:bt,editingBank:S,isSubmitting:R}),e.jsx(mo,{isOpen:!!p,onClose:()=>u(null),document:p})]})}function TV({onViewPaymentDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[l,o]=g.useState("pending");g.useEffect(()=>{d()},[]);const d=async()=>{try{a(!0);const u=await ds.getApplications();n(u.data||[])}catch(u){console.error("Fetch error:",u),ee.error("Failed to fetch applications")}finally{a(!1)}},m=u=>String(u||"").trim().toLowerCase(),f=u=>{const w=m(u);return w==="verified"||w==="paid"},x=s.flatMap(u=>{const w=u.overallStatus||u.status,v=["Payment Pending","Security Deposit","Security Details","LOI In Progress","LOI Issued","LOA Pending","Dealer Code Generation","LOA_APPROVAL"].includes(w),N=u.securityDeposits||[];return N.length>0?N.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(w)?[{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=x.filter(u=>l==="all"?!0:l==="pending"?!f(u.paymentStatus):l==="verified"?f(u.paymentStatus):!0),p=u=>{t&&t(u)};return r?e.jsxs("div",{className:"flex items-center justify-center p-20 text-re-red",children:[e.jsx(yn,{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(se,{onClick:d,variant:"outline",size:"sm",className:"bg-white hover:bg-slate-50","data-testid":"onboarding-finance-queue-sync-btn",children:[e.jsx(yn,{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(ka,{className:"w-4 h-4 mr-2 text-re-red"}),"Pending Payments (",x.filter(u=>!f(u.paymentStatus)).length,")"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(se,{variant:l==="pending"?"secondary":"ghost",size:"sm",onClick:()=>o("pending"),className:l==="pending"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-pending",children:"Pending"}),e.jsx(se,{variant:l==="verified"?"secondary":"ghost",size:"sm",onClick:()=>o("verified"),className:l==="verified"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-verified",children:"Verified"}),e.jsx(se,{variant:l==="all"?"secondary":"ghost",size:"sm",onClick:()=>o("all"),className:l==="all"?"bg-slate-200 text-slate-900":"text-slate-500","data-testid":"onboarding-finance-queue-filter-all",children:"All"})]})]}),e.jsx(Le,{className:"border-none shadow-xl overflow-hidden rounded-2xl bg-white","data-testid":"onboarding-finance-queue-table-card",children:e.jsx(Fe,{className:"p-0",children:e.jsxs(Ps,{children:[e.jsx(Os,{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(fe,{className:"py-4 pl-6","data-testid":"onboarding-finance-queue-th-details",children:"Application Details"}),e.jsx(fe,{"data-testid":"onboarding-finance-queue-th-location",children:"Location"}),e.jsx(fe,{"data-testid":"onboarding-finance-queue-th-stage",children:"Payment Stage"}),e.jsx(fe,{"data-testid":"onboarding-finance-queue-th-status",children:"Current Status"}),e.jsx(fe,{className:"text-right pr-6","data-testid":"onboarding-finance-queue-th-action",children:"Workflow Action"})]})}),e.jsx(Ls,{children:h.length>0?h.map((u,w)=>{const v=u.paymentStatus||"Awaiting Payment",N=u.application||{};return e.jsxs(lt,{className:"hover:bg-red-50/20 group transition-all","data-testid":`onboarding-finance-queue-row-${w}`,children:[e.jsx(ue,{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-re-red mb-1","data-testid":`onboarding-finance-queue-app-id-${w}`,children:N.applicationId||N.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-${w}`,children:N.applicantName})})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-col text-sm","data-testid":`onboarding-finance-queue-location-${w}`,children:[e.jsx("span",{className:"text-slate-600 leading-none",children:N.city}),e.jsx("span",{className:"text-slate-400 text-xs mt-1",children:N.state})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2","data-testid":`onboarding-finance-queue-type-${w}`,children:[e.jsx(Gu,{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(ue,{children:e.jsx(Ce,{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-${w}`,children:v})}),e.jsx(ue,{className:"text-right pr-6",children:e.jsx(se,{size:"sm",variant:f(v)?"outline":"default",className:f(v)?"bg-white text-slate-600 border-slate-200":"bg-re-red hover:bg-re-red-hover shadow-md",onClick:()=>p(u.applicationId||N.id),"data-testid":`onboarding-finance-queue-action-btn-${w}`,children:e.jsxs(e.Fragment,{children:[e.jsx(ka,{className:"w-4 h-4 mr-2"}),f(v)?"View Receipt":"Record Payment"]})})})]},u.id)}):e.jsx(lt,{children:e.jsx(ue,{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(fn,{className:"w-6 h-6 text-slate-200"})}),e.jsx("p",{className:"text-sm",children:l==="verified"?"No verified payments found":l==="pending"?"No pending payments in the queue":"No onboarding payments found"})]})})})})]})})})]})}function PV({onViewFnFDetails:t}={}){const[s,n]=g.useState([]),[r,a]=g.useState(!0),[l,o]=g.useState(null),[d,m]=g.useState(!1),[f,x]=g.useState(!1),[h,p]=g.useState(""),[u,w]=g.useState(""),[v,N]=g.useState("all");g.useEffect(()=>{j()},[]);const j=async()=>{try{a(!0);const O=(await Ee.getFnFSettlements()).data;O.success&&n(O.settlements||[])}catch(E){console.error("Fetch settlements error:",E),ee.error("Failed to fetch settlement cases")}finally{a(!1)}},y=E=>{var O,I,q,G,Y,V,Q,_,z,T,F,B;return{id:E.id,caseId:E.settlementId||((O=E.resignation)==null?void 0:O.resignationId)||((I=E.terminationRequest)==null?void 0:I.requestId)||E.id.substring(0,8),dealerCode:((q=E.outlet)==null?void 0:q.code)||((Y=(G=E.dealer)==null?void 0:G.dealerCode)==null?void 0:Y.dealerCode)||"N/A",dealerName:((Q=(V=E.outlet)==null?void 0:V.dealer)==null?void 0:Q.fullName)||((_=E.dealer)==null?void 0:_.legalName)||((z=E.dealer)==null?void 0:z.businessName)||((T=E.dealer)==null?void 0:T.fullName)||"N/A",location:((F=E.outlet)==null?void 0:F.city)||((B=E.outlet)==null?void 0:B.location)||"N/A",terminationType:E.resignationId?"Resignation":"Termination",submittedDate:Gt(E.createdAt),status:E.status==="Calculated"?"Pending Finance Review":E.status==="Settled"?"Settled":E.status,financialData:{totalPayables:parseFloat(E.totalPayables)||0,totalReceivables:parseFloat(E.totalReceivables)||0,netAmount:parseFloat(E.netAmount)||0},settlementAmount:Math.abs(parseFloat(E.netAmount)||0),settlementType:parseFloat(E.netAmount)>0?"Payable to Dealer":"Receivable from Dealer",approvedDate:E.settlementDate?Gt(E.settlementDate):null}},C=s.map(y),S=C.filter(E=>v==="all"?!0:v==="pending"?E.status==="Pending Finance Review"||E.status==="Calculated"||E.status==="Initiated"||E.status==="Under Review":v==="approved"?E.status==="Settled"||E.status==="Completed":!0),D=E=>({receivables:E.totalReceivables||0,payables:E.totalPayables||0,deductions:0,netSettlement:E.netAmount||0,settlementType:(E.netAmount||0)>0?"Payable to Dealer":"Receivable from Dealer",settlementAmount:Math.abs(E.netAmount||0)}),R=E=>{t?t(E.id):(o(E),m(!0))},A=E=>{t?t(E.id):(o(E),x(!0))},L=()=>{const E=D(l.financialData);ee.success(`Settlement approved: ${E.settlementType} - ₹${E.settlementAmount.toLocaleString()}`),m(!1),p(""),w(""),o(null)},$=C.filter(E=>E.status==="Pending Finance Review"||E.status==="Calculated"||E.status==="Initiated"||E.status==="Under Review").length,P=C.filter(E=>E.status==="Settled"||E.status==="Completed").length;return r?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(es,{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(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(et,{className:"text-sm text-slate-600",children:"Pending Review"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:$}),e.jsx(lk,{className:"w-8 h-8 text-re-red"})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(et,{className:"text-sm text-slate-600",children:"Approved Settlements"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-slate-900 text-2xl",children:P}),e.jsx(fn,{className:"w-8 h-8 text-green-600"})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(et,{className:"text-sm text-slate-600",children:"Total Cases"})}),e.jsx(Fe,{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(Ns,{className:"w-8 h-8 text-re-red"})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{className:"pb-3",children:e.jsx(et,{className:"text-sm text-slate-600",children:"Net Financial Position"})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`text-2xl ${C.reduce((E,O)=>E+(O.financialData.netAmount||0),0)<0?"text-green-600":"text-red-600"}`,children:["₹",Math.abs(C.reduce((E,O)=>E+(O.financialData.netAmount||0),0)).toLocaleString("en-IN")]}),e.jsx(hl,{className:"w-8 h-8 text-purple-600"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:C.reduce((E,O)=>E+(O.financialData.netAmount||0),0)<0?"Net Receivable":"Net Payable"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{variant:v==="all"?"default":"outline",onClick:()=>N("all"),className:v==="all"?"bg-re-red hover:bg-re-red-hover":"",children:["All Cases (",C.length,")"]}),e.jsxs(se,{variant:v==="pending"?"default":"outline",onClick:()=>N("pending"),className:v==="pending"?"bg-re-red hover:bg-re-red-hover":"",children:["Pending Review (",$,")"]}),e.jsxs(se,{variant:v==="approved"?"default":"outline",onClick:()=>N("approved"),className:v==="approved"?"bg-re-red hover:bg-re-red-hover":"",children:["Approved (",P,")"]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"F&F Settlement Queue"}),e.jsx(Qt,{children:"Review financial status and calculate settlements"})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Case ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Location"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Submitted Date"}),e.jsx(fe,{children:"Net Settlement"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:S.map(E=>{const O=D(E.financialData);return e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{children:[e.jsx("div",{className:"text-slate-900",children:E.caseId}),e.jsx("div",{className:"text-sm text-slate-500",children:E.dealerCode})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ir,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:E.dealerName})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:E.location})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:E.terminationType==="Resignation"?"default":"secondary",children:E.terminationType})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:E.submittedDate})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[O.settlementType==="Payable to Dealer"?e.jsx(Zo,{className:"w-4 h-4 text-red-600"}):e.jsx(hl,{className:"w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-slate-900",children:["₹",O.settlementAmount.toLocaleString()]}),e.jsx("div",{className:"text-xs text-slate-500",children:O.settlementType})]})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:E.status==="Settlement Approved"?"default":"secondary",className:E.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:E.status})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:E.status==="Pending Finance Review"?"default":"outline",className:E.status==="Pending Finance Review"?"bg-re-red hover:bg-re-red-hover":"",onClick:()=>A(E),children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"View Details"]})})]},E.id)})})]})})]}),e.jsx(ls,{open:d,onOpenChange:m,children:e.jsxs(as,{className:"max-w-5xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Financial Settlement Review"}),e.jsxs(bs,{children:["Review financial details and calculate final settlement for ",l==null?void 0:l.dealerName]})]}),l&&e.jsxs($n,{defaultValue:"breakdown",className:"w-full",children:[e.jsxs(qn,{className:"grid w-full grid-cols-3",children:[e.jsx(zt,{value:"breakdown",children:"Financial Breakdown"}),e.jsx(zt,{value:"calculation",children:"Settlement Calculation"}),e.jsx(zt,{value:"summary",children:"Final Summary"})]}),e.jsxs(qt,{value:"breakdown",className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(lf,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]}),e.jsx(Qt,{children:"Amounts company owes to dealer"})]}),e.jsxs(Fe,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",(l.financialData.securityDeposit+l.financialData.inventoryValue+l.financialData.equipmentValue).toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(ly,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]}),e.jsx(Qt,{children:"Amounts dealer owes to company"})]}),e.jsxs(Fe,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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(l.financialData).receivables.toLocaleString()]})]})})]})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(an,{className:"w-5 h-5 text-re-red"}),"Deductions"]}),e.jsx(Qt,{children:"Pending claims and deductions"})]}),e.jsx(Fe,{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:["₹",l.financialData.warrantyPending.toLocaleString()]})]})})]})]}),e.jsx(qt,{value:"calculation",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Settlement Calculation"}),e.jsx(Qt,{children:"Step-by-step calculation of final settlement amount"})]}),e.jsx(Fe,{className:"space-y-4",children:(()=>{const E=D(l.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:["+ ₹",E.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:["- ₹",E.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:["- ₹",E.deductions.toLocaleString()]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsxs("div",{className:`p-4 rounded-lg ${E.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:["₹",E.settlementAmount.toLocaleString()]})]}),e.jsx("div",{className:"flex items-center gap-2",children:E.settlementType==="Payable to Dealer"?e.jsxs(e.Fragment,{children:[e.jsx(Zo,{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(hl,{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-red-50 border border-red-200 rounded-lg",children:[e.jsx(an,{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.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:["= ₹",E.payables.toLocaleString()," - ₹",E.receivables.toLocaleString()," - ₹",E.deductions.toLocaleString()]})]})]})]})})()})]})}),e.jsxs(qt,{value:"summary",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Case Summary"})}),e.jsx(Fe,{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:l.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:l.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:l.dealerCode})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:l.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:l.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:l.submittedDate})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Final Settlement"})}),e.jsxs(Fe,{className:"space-y-4",children:[(()=>{const E=D(l.financialData);return e.jsxs("div",{className:`p-6 rounded-lg text-center ${E.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:[E.settlementType==="Payable to Dealer"?e.jsx(Zo,{className:"w-8 h-8 text-red-600"}):e.jsx(hl,{className:"w-8 h-8 text-green-600"}),e.jsx("span",{className:`text-lg ${E.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:E.settlementType})]}),e.jsxs("div",{className:"text-4xl text-slate-900 mb-2",children:["₹",E.settlementAmount.toLocaleString()]}),e.jsx("p",{className:"text-slate-600",children:E.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(de,{htmlFor:"adjustments",children:"Adjustments (if any)"}),e.jsx(at,{id:"adjustments",value:h,onChange:E=>p(E.target.value),placeholder:"Enter any adjustments to the settlement amount"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"finalNotes",children:"Final Notes"}),e.jsx(Gs,{id:"finalNotes",value:u,onChange:E=>w(E.target.value),placeholder:"Enter any final notes or remarks for this settlement...",rows:4})]})]})]})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:L,children:[e.jsx(fn,{className:"w-4 h-4 mr-2"}),"Approve Settlement"]})]})]})}),e.jsx(ls,{open:f,onOpenChange:x,children:e.jsxs(as,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Settlement Details"}),e.jsxs(bs,{children:["Complete settlement information for ",l==null?void 0:l.dealerName]})]}),l&&e.jsxs($n,{defaultValue:"info",className:"w-full",children:[e.jsxs(qn,{className:"grid w-full grid-cols-2",children:[e.jsx(zt,{value:"info",children:"Case Information"}),e.jsx(zt,{value:"financial",children:"Financial Breakdown"})]}),e.jsx(qt,{value:"info",className:"space-y-4 mt-4",children:e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{className:"text-base",children:"Case Details"})}),e.jsx(Fe,{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:l.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:l.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:l.dealerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:l.location})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Termination Type"}),e.jsx(Ce,{variant:l.terminationType==="Resignation"?"default":"secondary",children:l.terminationType})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Status"}),e.jsx(Ce,{variant:l.status==="Settlement Approved"?"default":"secondary",className:l.status==="Settlement Approved"?"bg-green-600 text-white":"bg-re-red text-white",children:l.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:l.submittedDate})]}),l.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:l.approvedDate})]})]})})]})}),e.jsx(qt,{value:"financial",className:"space-y-4 mt-4",children:(()=>{const E=D(l.financialData);return e.jsxs(e.Fragment,{children:[e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsx(Qe,{children:e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(lf,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer"]})}),e.jsxs(Fe,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",E.payables.toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(ly,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer"]})}),e.jsxs(Fe,{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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",l.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:["₹",E.receivables.toLocaleString()]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(an,{className:"w-5 h-5 text-re-red"}),"Deductions"]})}),e.jsx(Fe,{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:["₹",l.financialData.warrantyPending.toLocaleString()]})]})})]}),e.jsxs(Le,{className:`${E.settlementType==="Payable to Dealer"?"border-red-300 bg-red-100":"border-green-300 bg-green-100"}`,children:[e.jsx(Qe,{children:e.jsx(et,{className:"text-base",children:"Net Settlement"})}),e.jsx(Fe,{children:e.jsxs("div",{className:"text-center py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-2",children:[E.settlementType==="Payable to Dealer"?e.jsx(Zo,{className:"w-6 h-6 text-red-600"}):e.jsx(hl,{className:"w-6 h-6 text-green-600"}),e.jsx("span",{className:`text-lg ${E.settlementType==="Payable to Dealer"?"text-red-700":"text-green-700"}`,children:E.settlementType})]}),e.jsxs("div",{className:"text-3xl text-slate-900",children:["₹",E.settlementAmount.toLocaleString()]})]})})]})]})})()})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>x(!1),children:"Close"}),(l==null?void 0:l.status)==="Pending Finance Review"&&e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{x(!1),R(l)},children:"Review & Settle"})]})]})})]})}const Uo=(...t)=>t.filter(Boolean).join(" ");function OV({applicationId:t,onBack:s}){var L,$,P,E;const[n,r]=g.useState(null),[a,l]=g.useState([]),[o,d]=g.useState("SECURITY_DEPOSIT"),[m,f]=g.useState(!0),[x,h]=g.useState(!1),[p,u]=g.useState({}),[w,v]=g.useState({verificationTransactionId:"",receivedAmount:"",receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""}),[N,j]=g.useState(!1),[y,C]=g.useState(null),S=a.find(O=>O.depositType===o);g.useEffect(()=>{D()},[t]),g.useEffect(()=>{var O,I,q;if(S)v({verificationTransactionId:S.paymentReference||"",receivedAmount:((O=S.amount)==null?void 0:O.toString())||"",receivedDate:S.verifiedAt?new Date(S.verifiedAt).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],verificationRemarks:S.remarks||""});else{const G=((I=p.SECURITY_DEPOSIT)==null?void 0:I.amount)||5e5,Y=((q=p.FIRST_FILL)==null?void 0:q.amount)||15e5;v({verificationTransactionId:"",receivedAmount:o==="SECURITY_DEPOSIT"?G.toString():Y.toString(),receivedDate:new Date().toISOString().split("T")[0],verificationRemarks:""})}},[o,S,p]);const D=async()=>{try{f(!0);const[O,I,q]=await Promise.all([ds.getApplicationById(t),ds.getSecurityDeposit(t),ds.getSystemConfigs({category:"SECURITY_DEPOSIT",format:"map"})]);r(O),l(Array.isArray(I)?I:[I].filter(Boolean)),u(q||{})}catch(O){console.error("Fetch error:",O),ee.error("Failed to load payment data")}finally{f(!1)}},R=async()=>{if(!w.verificationTransactionId||!w.receivedDate){ee.error("Please fill in all required payment details");return}try{h(!0),await ds.updateSecurityDeposit({applicationId:t,depositType:o,amount:Number(w.receivedAmount),paymentReference:w.verificationTransactionId,status:"Verified"}),ee.success(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} verified and approved`),await D()}catch{ee.error("Failed to verify payment")}finally{h(!1)}},A=async()=>{if(!w.verificationRemarks){ee.error("Please provide remarks for rejection");return}try{h(!0),await ds.updateSecurityDeposit({applicationId:t,depositType:o,status:"Rejected",remarks:w.verificationRemarks}),ee.error(`${o==="SECURITY_DEPOSIT"?"Security Deposit":"First Fill"} rejected`),await D()}catch{ee.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(se,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Jr,{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(se,{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(se,{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(Le,{className:Uo("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(Fe,{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:Uo("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(ka,{className:Uo("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 ${Gt(S.verifiedAt)}`:(S==null?void 0:S.status)==="Rejected"?"Payment Rejected":"Awaiting Verification"})]})]}),e.jsx(Ce,{className:Uo((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(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Ir,{className:"w-5 h-5 text-re-red"}),"Applicant Information"]})}),e.jsxs(Fe,{className:"grid grid-cols-2 gap-y-4 gap-x-8",children:[e.jsxs("div",{children:[e.jsx(de,{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(de,{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(de,{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(de,{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(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Gu,{className:"w-5 h-5 text-re-red"}),"Deposit Tracking"]})}),e.jsxs(Fe,{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(de,{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"?((L=p.SECURITY_DEPOSIT)==null?void 0:L.amount)||5e5:(($=p.FIRST_FILL)==null?void 0:$.amount)||15e5).toLocaleString()]})]}),e.jsxs("div",{className:Uo("p-4 rounded-lg border",(S==null?void 0:S.status)==="Verified"?"bg-green-50 border-green-200":"bg-red-50 border-red-200"),children:[e.jsx(de,{className:"text-slate-500 block mb-1",children:"Receipt Status"}),e.jsx("p",{className:Uo("text-2xl font-bold",(S==null?void 0:S.status)==="Verified"?"text-green-700":"text-re-red-hover"),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(de,{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(de,{className:"text-slate-500",children:"Verified By"}),e.jsx("p",{className:"text-slate-900",children:((P=S.verifier)==null?void 0:P.fullName)||"N/A"})]})]})]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"flex items-center gap-2 text-xl",children:[e.jsx(Ns,{className:"w-5 h-5 text-re-red"}),"Verification Evidence"]}),e.jsx(Qt,{children:"Documents uploaded by the applicant for payment proof"})]}),e.jsx(Fe,{children:((E=n.uploadedDocuments)==null?void 0:E.filter(O=>{var I,q,G,Y;return o==="SECURITY_DEPOSIT"?((I=O.documentType)==null?void 0:I.toLowerCase().includes("security"))&&((q=O.documentType)==null?void 0:q.toLowerCase().includes("deposit")):((G=O.documentType)==null?void 0:G.toLowerCase().includes("first"))&&((Y=O.documentType)==null?void 0:Y.toLowerCase().includes("fill"))}).length)>0?e.jsx("div",{className:"space-y-3",children:n.uploadedDocuments.filter(O=>{var I,q,G,Y;return o==="SECURITY_DEPOSIT"?((I=O.documentType)==null?void 0:I.toLowerCase().includes("security"))&&((q=O.documentType)==null?void 0:q.toLowerCase().includes("deposit")):((G=O.documentType)==null?void 0:G.toLowerCase().includes("first"))&&((Y=O.documentType)==null?void 0:Y.toLowerCase().includes("fill"))}).map((O,I)=>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(Ns,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900 font-medium",children:O.fileName||O.name}),e.jsxs("p",{className:"text-xs text-slate-500 uppercase",children:[O.documentType," • ",Gt(O.createdAt)]})]})]}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover hover:bg-red-50",onClick:()=>{C(O),j(!0)},children:"View Receipt"})]},I))}):e.jsxs("div",{className:"text-center py-10 bg-slate-50 rounded-lg border-2 border-dashed border-slate-200",children:[e.jsx(an,{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(Le,{className:"border-red-100 shadow-sm",children:[e.jsx(Qe,{className:"bg-red-50/50",children:e.jsxs(et,{className:"flex items-center gap-2 text-lg",children:[e.jsx(lf,{className:"w-5 h-5 text-re-red"}),"Finance Action"]})}),e.jsxs(Fe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs(de,{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(at,{id:"verificationTxnId",placeholder:"Enter Bank UTR Number",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:w.verificationTransactionId,onChange:O=>v({...w,verificationTransactionId:O.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{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(at,{id:"receivedAmount",type:"number",placeholder:(o==="SECURITY_DEPOSIT"?5e5:15e5).toString(),disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:w.receivedAmount,onChange:O=>v({...w,receivedAmount:O.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{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(at,{id:"receivedDate",type:"date",disabled:(S==null?void 0:S.status)==="Verified",className:"mt-1",value:w.receivedDate,onChange:O=>v({...w,receivedDate:O.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"remarks",className:"text-xs uppercase text-slate-500 font-bold tracking-wider",children:"Verification Remarks"}),e.jsx(Gs,{id:"remarks",placeholder:"Any internal notes for reconciliation...",rows:3,className:"mt-1",value:w.verificationRemarks,onChange:O=>v({...w,verificationRemarks:O.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3",children:[e.jsx(se,{className:Uo("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:R,disabled:x||(S==null?void 0:S.status)==="Verified",children:(S==null?void 0:S.status)==="Verified"?e.jsxs(e.Fragment,{children:[e.jsx(fn,{className:"w-4 h-4 mr-2"})," Verified Successfully"]}):e.jsxs(e.Fragment,{children:[e.jsx(fn,{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(se,{variant:"ghost",className:"w-full text-red-600 hover:text-red-700 hover:bg-red-50",onClick:A,disabled:x,children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),"Reject / Flag Discrepancy"]})]})]})]}),e.jsxs(Le,{className:"bg-slate-900 text-white border-none shadow-xl",children:[e.jsx(Qe,{children:e.jsxs(et,{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(yn,{className:"w-4 h-4 text-re-red"}),"Next Steps"]})}),e.jsxs(Fe,{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(mo,{isOpen:N,onClose:()=>j(!1),document:y})]}):e.jsx("div",{className:"p-20 text-center",children:"Application not found"})}const cl=["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"],FS="[DEPARTMENT_CLAIM]",BS="[FINANCE_VALIDATED]",Qg=[{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 LV({fnfId:t,onBack:s}){const n=tr(),[r,a]=g.useState(null),[l,o]=g.useState(!0),[d,m]=g.useState("overview"),[f,x]=g.useState([]),[h,p]=g.useState([]),[u,w]=g.useState([]),[v,N]=g.useState(null),[j,y]=g.useState([]),[C,S]=g.useState(!1),[D,R]=g.useState(null),[A,L]=g.useState([]);g.useEffect(()=>{$(),G()},[t]);const $=async()=>{var Z;try{const Ne=(await Ee.getSettlementDepartments()).data;Ne&&Ne.success&&((Z=Ne.departments)==null?void 0:Z.length)>0}catch(oe){console.error("Fetch departments error:",oe)}},P=Z=>{if(!Z)return Z;let oe=Z.trim();const Ne=cl.find(ye=>ye.toLowerCase()===oe.toLowerCase());if(Ne)return Ne;const De={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"}[oe.toLowerCase().replace(" department","")];return De||Z},E=(Z,oe)=>oe==="DepartmentClaim"||typeof Z=="string"&&(Z.startsWith(FS)||Z.includes("Clearance:")),O=Z=>(Z==null?void 0:Z.sourceType)==="FinanceValidated"&&typeof(Z==null?void 0:Z.description)=="string"&&Z.description.includes("Auto-seeded from department claim"),I=(Z,oe)=>oe==="FinanceValidated"||typeof Z=="string"&&Z.startsWith(BS),q=Z=>(Z||"").replace(FS,"").replace(BS,"").trim(),G=async(Z=!0)=>{var oe,Ne,Oe,De,ye,Ve,Ge,st,Kt,Xt,ot,ft,Es,ts,vs,Te,je,nt,Ye,pt,yt,Jt,ss,Ss,Zs,on,en,tn,cn,Ae,Ht,Pe,ct,tt,Nt,Mt,Pt,ys,Yt,ps,ks,hs,gn,$s,dn,sn,We;try{Z&&o(!0);const gt=(await Ee.getFnFSettlementById(t)).data;if(gt.success){const rt=gt.fnf,Is={id:rt.id,caseNumber:rt.settlementId||((oe=rt.resignation)==null?void 0:oe.resignationId)||((Ne=rt.terminationRequest)==null?void 0:Ne.requestId)||rt.id.substring(0,8),dealerName:((De=(Oe=rt.outlet)==null?void 0:Oe.dealer)==null?void 0:De.fullName)||((ye=rt.dealer)==null?void 0:ye.fullName)||"N/A",dealerCode:((Ve=rt.outlet)==null?void 0:Ve.code)||((st=(Ge=rt.dealer)==null?void 0:Ge.dealerCode)==null?void 0:st.dealerCode)||"N/A",location:((Kt=rt.outlet)==null?void 0:Kt.city)||((Xt=rt.outlet)==null?void 0:Xt.location)||"N/A",terminationType:rt.resignationId?"Resignation":"Termination",submittedDate:ua(rt.createdAt),createdAt:rt.createdAt,dueDate:rt.settlementDate?ua(rt.settlementDate):"TBD",status:rt.status,dealerId:((ft=(ot=rt.outlet)==null?void 0:ot.dealer)==null?void 0:ft.id)||rt.dealerId,originalRequestId:((Es=rt.resignation)==null?void 0:Es.resignationId)||((ts=rt.terminationRequest)==null?void 0:ts.requestId)||((vs=rt.terminationRequest)==null?void 0:vs.id)||"N/A",salesCode:((je=(Te=rt.dealer)==null?void 0:Te.dealerCode)==null?void 0:je.salesCode)||((yt=(pt=(Ye=(nt=rt.outlet)==null?void 0:nt.dealer)==null?void 0:Ye.dealerProfile)==null?void 0:pt.dealerCode)==null?void 0:yt.salesCode)||"N/A",serviceCode:((ss=(Jt=rt.dealer)==null?void 0:Jt.dealerCode)==null?void 0:ss.serviceCode)||((en=(on=(Zs=(Ss=rt.outlet)==null?void 0:Ss.dealer)==null?void 0:Zs.dealerProfile)==null?void 0:on.dealerCode)==null?void 0:en.serviceCode)||"N/A",gearCode:((cn=(tn=rt.dealer)==null?void 0:tn.dealerCode)==null?void 0:cn.gearCode)||((ct=(Pe=(Ht=(Ae=rt.outlet)==null?void 0:Ae.dealer)==null?void 0:Ht.dealerProfile)==null?void 0:Pe.dealerCode)==null?void 0:ct.gearCode)||"N/A",gmaCode:((Nt=(tt=rt.dealer)==null?void 0:tt.dealerCode)==null?void 0:Nt.gmaCode)||((Yt=(ys=(Pt=(Mt=rt.outlet)==null?void 0:Mt.dealer)==null?void 0:Pt.dealerProfile)==null?void 0:ys.dealerCode)==null?void 0:Yt.gmaCode)||"N/A",allLineItems:(rt.lineItems||[]).filter(Ms=>Ms.isActive!==!1),departmentResponses:cl.map(Ms=>{const un=(rt.clearances||[]).find(On=>P(On.department)===Ms),ta=(rt.lineItems||[]).filter(On=>On.isActive!==!1),sa=ta.filter(On=>P(On.department)===Ms&&E(On.description,On.sourceType)),na=ta.filter(On=>P(On.department)===Ms&&O(On)),Mr=sa.length>0?sa:na;let Xn=0,zn=0;Mr.forEach(On=>{const ur=Math.abs(parseFloat(On.amount)||0);On.itemType==="Payable"?Xn+=ur:zn+=ur});const Zt=Xn-zn,Jn=Math.abs(Zt)>0,Er=(un==null?void 0:un.status)||"Pending",Gn=Jn?"Dues Pending":Er==="Cleared"?"NOC Submitted":Er,_r=Zt>0?"payable":Zt<0?"recovery":null;return{id:(un==null?void 0:un.id)||`dept-${Ms}`,departmentName:Ms,status:Gn,remarks:(un==null?void 0:un.remarks)||"-",submittedDate:un!=null&&un.clearedAt?ua(un.clearedAt):"-",amount:Math.abs(Zt),duesFlow:_r,amountType:Zt>0?"Payable to dealer":Zt<0?"Receivable from dealer":null,supportingDocument:(un==null?void 0:un.supportingDocument)||null}}),documents:[{name:"Resignation Letter.pdf",size:"N/A",uploadedOn:ua(rt.createdAt),type:"Resignation",url:"#"},...(rt.clearances||[]).filter(Ms=>Ms.supportingDocument).map(Ms=>({name:Ms.supportingDocument.split("/").pop(),size:"N/A",uploadedOn:ua(Ms.clearedAt),type:`${Ms.department} Proof`,url:Ms.supportingDocument})),...(rt.clearanceDocuments||[]).map(Ms=>{var un;return{name:Ms.name||((un=Ms.supportingDocument)==null?void 0:un.split("/").pop())||"Document",size:"N/A",uploadedOn:ua(Ms.clearedAt||rt.createdAt),type:"Finance Upload",url:Ms.supportingDocument}})]};a(Is);const xs=rt.bankDetails||((ps=rt.dealer)==null?void 0:ps.bankDetails)||((gn=(hs=(ks=rt.outlet)==null?void 0:ks.dealer)==null?void 0:hs.dealerProfile)==null?void 0:gn.bankDetails);xs&&xs.length>0?y(xs):((dn=($s=rt.outlet)==null?void 0:$s.dealer)!=null&&dn.id||rt.dealerId)&&Y(((We=(sn=rt.outlet)==null?void 0:sn.dealer)==null?void 0:We.id)||rt.dealerId);const Nn=[],kn=[],Cn=[],Us=(rt.lineItems||[]).filter(Ms=>Ms.isActive!==!1);(Us.some(Ms=>I(Ms.description,Ms.sourceType))?Us.filter(Ms=>I(Ms.description,Ms.sourceType)):Us.filter(Ms=>!E(Ms.description,Ms.sourceType))).forEach(Ms=>{const un={id:Ms.id,department:P(Ms.department),description:q(Ms.description||Ms.remarks||""),amount:Math.abs(Ms.amount)};Ms.itemType==="Payable"?Nn.push(un):Ms.itemType==="Deduction"?Cn.push(un):kn.push(un)}),x(Nn),p(kn),w(Cn),Be({verificationTransactionId:rt.transactionReference||"",settlementAmount:(rt.settlementAmount||te().settlementAmount).toString(),settlementDate:rt.settlementDate?new Date(rt.settlementDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],paymentMode:rt.paymentMode||"",bankReference:"",verificationRemarks:rt.remarks||"",adjustments:"0"})}}catch(Ft){console.error("Fetch F&F error:",Ft),ee.error("Failed to fetch settlement details")}finally{Z&&o(!1)}},Y=async Z=>{try{const Ne=(await Ee.getDealerBankDetails(Z)).data;Ne.success&&y(Ne.bankDetails||[])}catch(oe){console.error("Fetch bank details error:",oe)}},V=async Z=>{Z.preventDefault();const oe=new FormData(Z.currentTarget),Ne=Object.fromEntries(oe.entries());try{const Oe=r==null?void 0:r.dealerId;(await Ee.saveBankDetail(Oe,{...Ne,id:D==null?void 0:D.id,isPrimary:oe.get("isPrimary")==="on"})).data.success&&(ee.success("Bank details saved"),Y(Oe),S(!1),R(null))}catch{ee.error("Failed to save bank details")}},Q=async Z=>{if(confirm("Are you sure you want to delete this bank account?"))try{(await Ee.deleteBankDetail(Z)).data.success&&(ee.success("Bank detail deleted"),Y(r==null?void 0:r.dealerId))}catch{ee.error("Failed to delete bank details")}},_=Z=>{L(oe=>oe.includes(Z)?oe.filter(Ne=>Ne!==Z):[...oe,Z])},[z,T]=g.useState({department:"",description:"",amount:""}),[F,B]=g.useState({department:"",description:"",amount:""}),[K,W]=g.useState({department:"",description:"",amount:""}),[H,X]=g.useState(null),[J,ie]=g.useState(null),[ae,xe]=g.useState(null),[ce,we]=g.useState({}),[ke,Xe]=g.useState({}),[Ot,bt]=g.useState({}),te=()=>{const Z=f.reduce((De,ye)=>De+(Number(ye.amount)||0),0),oe=h.reduce((De,ye)=>De+(Number(ye.amount)||0),0),Ne=u.reduce((De,ye)=>De+(Number(ye.amount)||0),0),Oe=Z-oe-Ne;return{payables:Z,receivables:oe,deductions:Ne,netSettlement:Oe,settlementAmount:Math.abs(Oe),settlementType:Oe>0?"Payable to Dealer":Oe<0?"Receivable from Dealer":"No Settlement Required"}},ve=te(),qe=cl.map(Z=>{const oe=((r==null?void 0:r.departmentResponses)||[]).find(ot=>ot.departmentName===Z),Ne=Number(oe==null?void 0:oe.amount)||0,Oe=(oe==null?void 0:oe.amountType)||"-",De=f.filter(ot=>P(ot.department)===Z).reduce((ot,ft)=>ot+(Number(ft.amount)||0),0),ye=h.filter(ot=>P(ot.department)===Z).reduce((ot,ft)=>ot+(Number(ft.amount)||0),0),Ve=u.filter(ot=>P(ot.department)===Z).reduce((ot,ft)=>ot+(Number(ft.amount)||0),0),Ge=De-ye-Ve,st=Math.abs(Ge),Kt=Ge>0?"Payable":Ge<0?"Receivable":"-",Xt=st-Ne;return{department:Z,claimAmount:Ne,claimType:Oe,validatedAmount:st,validatedType:Kt,variance:Xt}}),[ge,Be]=g.useState({verificationTransactionId:"",settlementAmount:ve.settlementAmount.toString(),settlementDate:new Date().toISOString().split("T")[0],paymentMode:"",bankReference:"",verificationRemarks:"",adjustments:"0"}),ut=async()=>{var Z,oe;if(!z.department||!z.description||!z.amount){ee.error("Please fill in all fields");return}try{const Oe=(await Ee.addLineItem(t,{department:z.department,description:z.description,amount:Math.abs(parseFloat(z.amount)),itemType:"Payable"})).data;Oe.success&&(x([...f,{id:Oe.lineItem.id,department:Oe.lineItem.department,description:Oe.lineItem.description,amount:Math.abs(Oe.lineItem.amount)}]),T({department:"",description:"",amount:""}),ee.success("Payable item added"),G())}catch(Ne){ee.error(((oe=(Z=Ne.response)==null?void 0:Z.data)==null?void 0:oe.message)||"Failed to add payable item")}},ht=async(Z,oe,Ne)=>{we(Oe=>{const De=Oe[Z]||f.find(ye=>ye.id===Z);return De?{...Oe,[Z]:{...De,[oe]:oe==="amount"?Number(Ne)||0:Ne}}:Oe})},it=async Z=>{var Ne,Oe;const oe=ce[Z];if(!oe){X(null);return}x(De=>De.map(ye=>ye.id===Z?oe:ye));try{await Ee.updateLineItem(Z,{department:oe.department,description:oe.description,amount:-Math.abs(Number(oe.amount)||0)}),X(null),we(De=>{const ye={...De};return delete ye[Z],ye}),ee.success("Changes saved"),G(!1)}catch(De){ee.error(((Oe=(Ne=De.response)==null?void 0:Ne.data)==null?void 0:Oe.message)||"Failed to update item"),G(!1)}},Tt=async Z=>{var oe,Ne;try{(await Ee.deleteLineItem(Z)).data.success&&(x(f.filter(ye=>ye.id!==Z)),ee.info("Payable item removed"),G())}catch(Oe){ee.error(((Ne=(oe=Oe.response)==null?void 0:oe.data)==null?void 0:Ne.message)||"Failed to delete item")}},It=async()=>{var Z,oe;if(!F.department||!F.description||!F.amount){ee.error("Please fill in all fields");return}try{const Oe=(await Ee.addLineItem(t,{department:F.department,description:F.description,amount:Math.abs(parseFloat(F.amount)),itemType:"Receivable"})).data;Oe.success&&(p([...h,{id:Oe.lineItem.id,department:Oe.lineItem.department,description:Oe.lineItem.description,amount:Oe.lineItem.amount}]),B({department:"",description:"",amount:""}),ee.success("Receivable item added"),G())}catch(Ne){ee.error(((oe=(Z=Ne.response)==null?void 0:Z.data)==null?void 0:oe.message)||"Failed to add receivable item")}},he=async(Z,oe,Ne)=>{Xe(Oe=>{const De=Oe[Z]||h.find(ye=>ye.id===Z);return De?{...Oe,[Z]:{...De,[oe]:oe==="amount"?Number(Ne)||0:Ne}}:Oe})},vt=async Z=>{var Ne,Oe;const oe=ke[Z];if(!oe){ie(null);return}p(De=>De.map(ye=>ye.id===Z?oe:ye));try{await Ee.updateLineItem(Z,{department:oe.department,description:oe.description,amount:Math.abs(Number(oe.amount)||0)}),ie(null),Xe(De=>{const ye={...De};return delete ye[Z],ye}),ee.success("Changes saved"),G(!1)}catch(De){ee.error(((Oe=(Ne=De.response)==null?void 0:Ne.data)==null?void 0:Oe.message)||"Failed to update item"),G(!1)}},mt=async Z=>{var oe,Ne;try{await Ee.deleteLineItem(Z),p(h.filter(Oe=>Oe.id!==Z)),ee.info("Receivable item removed"),G()}catch(Oe){ee.error(((Ne=(oe=Oe.response)==null?void 0:oe.data)==null?void 0:Ne.message)||"Failed to delete item")}},_e=async()=>{var Z,oe;if(!K.department||!K.description||!K.amount){ee.error("Please fill in all fields");return}try{const Oe=(await Ee.addLineItem(t,{department:K.department,description:K.description,amount:Math.abs(parseFloat(K.amount)),itemType:"Deduction"})).data;Oe.success&&(w([...u,{id:Oe.lineItem.id,department:Oe.lineItem.department,description:Oe.lineItem.description,amount:Oe.lineItem.amount}]),W({department:"",description:"",amount:""}),ee.success("Deduction item added"),G())}catch(Ne){ee.error(((oe=(Z=Ne.response)==null?void 0:Z.data)==null?void 0:oe.message)||"Failed to add deduction item")}},Vt=async(Z,oe,Ne)=>{bt(Oe=>{const De=Oe[Z]||u.find(ye=>ye.id===Z);return De?{...Oe,[Z]:{...De,[oe]:oe==="amount"?Number(Ne)||0:Ne}}:Oe})},Et=async Z=>{var Ne,Oe;const oe=Ot[Z];if(!oe){xe(null);return}w(De=>De.map(ye=>ye.id===Z?oe:ye));try{await Ee.updateLineItem(Z,{department:oe.department,description:oe.description,amount:Math.abs(Number(oe.amount)||0)}),xe(null),bt(De=>{const ye={...De};return delete ye[Z],ye}),ee.success("Changes saved"),G(!1)}catch(De){ee.error(((Oe=(Ne=De.response)==null?void 0:Ne.data)==null?void 0:Oe.message)||"Failed to update item"),G(!1)}},Ds=async Z=>{try{await Ee.deleteLineItem(Z),w(u.filter(oe=>oe.id!==Z)),ee.info("Deduction item removed"),G()}catch{ee.error("Failed to delete item")}},ln=async Z=>{var Ne;const oe=Z.target.files;if(oe&&oe.length>0){o(!0);try{let Oe=0;for(let De=0;De<oe.length;De++){const ye=new FormData;ye.append("file",oe[De]),(Ne=(await Ee.uploadFnFDocument(t,ye)).data)!=null&&Ne.success&&Oe++}ee.success(`${Oe} document(s) uploaded successfully`),G(!1)}catch{ee.error("Failed to upload document(s)")}finally{o(!1)}}},[Bs,Ys]=g.useState(!1),Xs=async()=>{if(!ge.verificationTransactionId||!ge.settlementDate||!ge.paymentMode){ee.error("Please fill in all required settlement details");return}try{Ys(!0);const Z=(ve.settlementAmount||0)+parseFloat(ge.adjustments||"0");await TE.updateFnF(t,{status:"Completed",finalSettlementAmount:Z,settlementDate:ge.settlementDate,paymentMode:ge.paymentMode,transactionReference:ge.verificationTransactionId,remarks:ge.verificationRemarks||"Approved by Finance"}),ee.success(`F&F Settlement approved and completed for ${r.dealerName}`),setTimeout(()=>s(),1500)}catch(Z){console.error("Approve settlement error:",Z),ee.error(Z.message||"Failed to approve settlement")}finally{Ys(!1)}},Js=()=>{if(!ge.verificationRemarks){ee.error("Please provide remarks for rejection");return}ee.error(`F&F Settlement rejected for ${r.dealerName}`),setTimeout(()=>s(),1500)},Ws=()=>{if(!ge.verificationRemarks){ee.error("Please provide details for clarification request");return}ee.info(`Clarification request sent for ${r.dealerName}`),setTimeout(()=>s(),1500)};return l?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(es,{className:"w-8 h-8 animate-spin text-re-red"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(se,{variant:"outline",size:"icon",onClick:s,children:e.jsx(Jr,{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 ",r.dealerName]})]})]}),e.jsxs(se,{variant:"outline",onClick:()=>n(`/worknotes/fnf/${t}`,{state:{applicationName:r.dealerName||"F&F Settlement",registrationNumber:r.caseNumber||r.settlementId||"",participants:r.participants||[]}}),children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes"]})]}),e.jsx(Le,{className:"border-red-200 bg-red-50",children:e.jsx(Fe,{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(ka,{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: ",r.caseNumber," • Due: ",r.dueDate]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ce,{className:"bg-re-red",children:r.status}),e.jsx(Ce,{variant:r.terminationType==="Resignation"?"default":"secondary",children:r.terminationType})]})]})})}),e.jsx(Le,{className:`${ve.settlementType==="Payable to Dealer"?"border-red-300 bg-red-50":ve.settlementType==="Receivable from Dealer"?"border-green-300 bg-green-50":"border-slate-300 bg-slate-50"}`,children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[ve.settlementType==="Payable to Dealer"?e.jsx(Zo,{className:"w-12 h-12 text-red-600"}):ve.settlementType==="Receivable from Dealer"?e.jsx(hl,{className:"w-12 h-12 text-green-600"}):e.jsx(fn,{className:"w-12 h-12 text-slate-600"}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm ${ve.settlementType==="Payable to Dealer"?"text-red-700":ve.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:ve.settlementType}),e.jsx("p",{className:"text-3xl text-slate-900",children:ve.settlementType==="No Settlement Required"?"₹0":`₹${ve.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:ve.settlementType==="Payable to Dealer"?"Company will pay to dealer":ve.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($n,{value:d,onValueChange:m,className:"w-full",children:[e.jsxs(qn,{className:"grid w-full grid-cols-5",children:[e.jsx(zt,{value:"overview",children:"Overview"}),e.jsx(zt,{value:"financial",children:"Financial"}),e.jsx(zt,{value:"departments",children:"Departments"}),e.jsx(zt,{value:"documents",children:"Documents"}),e.jsx(zt,{value:"bank",children:"Bank Details"})]}),e.jsxs(qt,{value:"overview",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Ir,{className:"w-5 h-5"}),"Case Information"]})}),e.jsx(Fe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Case Number"}),e.jsx("p",{className:"text-slate-900",children:r.caseNumber})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Dealer Code"}),e.jsx("p",{className:"text-slate-900",children:r.dealerCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Dealer Name"}),e.jsx("p",{className:"text-slate-900",children:r.dealerName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Location"}),e.jsx("p",{className:"text-slate-900",children:r.location})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Termination Type"}),e.jsx(Ce,{variant:r.terminationType==="Resignation"?"default":"secondary",children:r.terminationType})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Status"}),e.jsx(Ce,{className:"bg-re-red",children:r.status})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Submitted Date"}),e.jsx("p",{className:"text-slate-900",children:r.submittedDate})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Due Date"}),e.jsx("p",{className:"text-slate-900",children:r.dueDate})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Request Age"}),e.jsx("p",{className:"text-slate-900",children:(()=>{const Z=new Date(r.createdAt),Ne=Math.abs(new Date().getTime()-Z.getTime()),Oe=Math.ceil(Ne/(1e3*60*60*24));return`${Oe} day${Oe!==1?"s":""}`})()})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Sales Code"}),e.jsx("p",{className:"text-slate-900",children:r.salesCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Service Code"}),e.jsx("p",{className:"text-slate-900",children:r.serviceCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"Gear Code"}),e.jsx("p",{className:"text-slate-900",children:r.gearCode})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-slate-500",children:"GMA Code"}),e.jsx("p",{className:"text-slate-900",children:r.gmaCode})]})]})})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"w-5 h-5"}),"Settlement Calculation Summary"]})}),e.jsxs(Fe,{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:["+ ₹",ve.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:["- ₹",ve.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:["- ₹",ve.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-slate-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${ve.settlementType==="Payable to Dealer"?"bg-red-100 border-red-300":ve.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 ${ve.settlementType==="Payable to Dealer"?"text-red-700":ve.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:ve.settlementType})]}),e.jsx("span",{className:"text-2xl text-slate-900",children:ve.settlementType==="No Settlement Required"?"₹0":`₹${ve.settlementAmount.toLocaleString("en-IN")}`})]})}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(an,{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(qt,{value:"financial",className:"space-y-4",children:[e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsxs(Qe,{children:[e.jsx(et,{className:"text-base",children:"Department Claim vs Finance Validation"}),e.jsx(Qt,{children:"Finance validated values are used for final settlement totals."})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Department Claim"}),e.jsx(fe,{children:"Finance Validated"}),e.jsx(fe,{children:"Variance"})]})}),e.jsx(Ls,{children:qe.map(Z=>e.jsxs(lt,{children:[e.jsx(ue,{children:Z.department}),e.jsx(ue,{children:Z.claimAmount>0?`${Z.claimType} ₹${Z.claimAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(ue,{children:Z.validatedAmount>0?`${Z.validatedType} ₹${Z.validatedAmount.toLocaleString("en-IN")}`:"-"}),e.jsx(ue,{className:Z.variance===0?"text-slate-600":Z.variance>0?"text-red-600":"text-green-600",children:Z.claimAmount===0&&Z.validatedAmount===0?"-":`₹${Z.variance.toLocaleString("en-IN")}`})]},Z.department))})]})})]}),e.jsxs(Le,{className:"border-green-200 bg-green-50",children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(lf,{className:"w-5 h-5 text-green-600"}),"Payables to Dealer (Editable)"]}),e.jsx(Qt,{children:"Add or modify amounts company owes to dealer"})]})})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-right",children:"Amount (₹)"}),e.jsx(fe,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Ls,{children:f.map(Z=>{var oe,Ne,Oe;return e.jsxs(lt,{children:[e.jsx(ue,{children:H===Z.id?e.jsxs(At,{value:((oe=ce[Z.id])==null?void 0:oe.department)||Z.department,onValueChange:De=>ht(Z.id,"department",De),children:[e.jsx(Dt,{className:"h-8",children:e.jsx(kt,{placeholder:"Department"})}),e.jsx(Rt,{children:cl.map(De=>e.jsx(Me,{value:De,children:De},De))})]}):e.jsx("span",{className:"text-slate-900",children:P(Z.department)})}),e.jsx(ue,{children:H===Z.id?e.jsx(at,{value:((Ne=ce[Z.id])==null?void 0:Ne.description)||Z.description,onChange:De=>ht(Z.id,"description",De.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:Z.description})}),e.jsx(ue,{className:"text-right",children:H===Z.id?e.jsx(at,{type:"number",value:((Oe=ce[Z.id])==null?void 0:Oe.amount)??Z.amount,onChange:De=>ht(Z.id,"amount",De.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",Z.amount.toLocaleString("en-IN")]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-1",children:[H===Z.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>it(Z.id),children:e.jsx(pl,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{X(Z.id),we(De=>({...De,[Z.id]:{...Z}}))},children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>Tt(Z.id),children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},Z.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(At,{value:z.department,onValueChange:Z=>T({...z,department:Z}),children:[e.jsx(Dt,{className:"col-span-3",children:e.jsx(kt,{placeholder:"Department"})}),e.jsx(Rt,{children:cl.map(Z=>e.jsx(Me,{value:Z,children:Z},Z))})]}),e.jsx(at,{placeholder:"Description",value:z.description,onChange:Z=>T({...z,description:Z.target.value}),className:"col-span-5"}),e.jsx(at,{type:"number",placeholder:"Amount",value:z.amount,onChange:Z=>T({...z,amount:Z.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:ut,className:"col-span-1 bg-green-600 hover:bg-green-700",children:e.jsx(Dn,{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:["₹",ve.payables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(ly,{className:"w-5 h-5 text-red-600"}),"Receivables from Dealer (Editable)"]}),e.jsx(Qt,{children:"Add or modify amounts dealer owes to company"})]})})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-right",children:"Amount (₹)"}),e.jsx(fe,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Ls,{children:h.map(Z=>{var oe,Ne,Oe;return e.jsxs(lt,{children:[e.jsx(ue,{children:J===Z.id?e.jsxs(At,{value:((oe=ke[Z.id])==null?void 0:oe.department)||Z.department,onValueChange:De=>he(Z.id,"department",De),children:[e.jsx(Dt,{className:"h-8",children:e.jsx(kt,{placeholder:"Department"})}),e.jsx(Rt,{children:cl.map(De=>e.jsx(Me,{value:De,children:De},De))})]}):e.jsx("span",{className:"text-slate-900",children:P(Z.department)})}),e.jsx(ue,{children:J===Z.id?e.jsx(at,{value:((Ne=ke[Z.id])==null?void 0:Ne.description)||Z.description,onChange:De=>he(Z.id,"description",De.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:Z.description})}),e.jsx(ue,{className:"text-right",children:J===Z.id?e.jsx(at,{type:"number",value:((Oe=ke[Z.id])==null?void 0:Oe.amount)??Z.amount,onChange:De=>he(Z.id,"amount",De.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",Z.amount.toLocaleString("en-IN")]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-1",children:[J===Z.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>vt(Z.id),children:e.jsx(pl,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{ie(Z.id),Xe(De=>({...De,[Z.id]:{...Z}}))},children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>mt(Z.id),children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},Z.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(At,{value:F.department,onValueChange:Z=>B({...F,department:Z}),children:[e.jsx(Dt,{className:"col-span-3",children:e.jsx(kt,{placeholder:"Department"})}),e.jsx(Rt,{children:cl.map(Z=>e.jsx(Me,{value:Z,children:Z},Z))})]}),e.jsx(at,{placeholder:"Description",value:F.description,onChange:Z=>B({...F,description:Z.target.value}),className:"col-span-5"}),e.jsx(at,{type:"number",placeholder:"Amount",value:F.amount,onChange:Z=>B({...F,amount:Z.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:It,className:"col-span-1 bg-red-600 hover:bg-red-700",children:e.jsx(Dn,{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:["₹",ve.receivables.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-red-200 bg-red-50",children:[e.jsx(Qe,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(et,{className:"text-base flex items-center gap-2",children:[e.jsx(an,{className:"w-5 h-5 text-re-red"}),"Deductions (Editable)"]}),e.jsx(Qt,{children:"Add or modify pending claims and deductions"})]})})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Description"}),e.jsx(fe,{className:"text-right",children:"Amount (₹)"}),e.jsx(fe,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Ls,{children:u.map(Z=>{var oe,Ne,Oe;return e.jsxs(lt,{children:[e.jsx(ue,{children:ae===Z.id?e.jsxs(At,{value:((oe=Ot[Z.id])==null?void 0:oe.department)||Z.department,onValueChange:De=>Vt(Z.id,"department",De),children:[e.jsx(Dt,{className:"h-8",children:e.jsx(kt,{placeholder:"Department"})}),e.jsx(Rt,{children:cl.map(De=>e.jsx(Me,{value:De,children:De},De))})]}):e.jsx("span",{className:"text-slate-900",children:P(Z.department)})}),e.jsx(ue,{children:ae===Z.id?e.jsx(at,{value:((Ne=Ot[Z.id])==null?void 0:Ne.description)||Z.description,onChange:De=>Vt(Z.id,"description",De.target.value),className:"h-8"}):e.jsx("span",{className:"text-slate-600",children:Z.description})}),e.jsx(ue,{className:"text-right",children:ae===Z.id?e.jsx(at,{type:"number",value:((Oe=Ot[Z.id])==null?void 0:Oe.amount)??Z.amount,onChange:De=>Vt(Z.id,"amount",De.target.value),className:"h-8 text-right"}):e.jsxs("span",{className:"text-slate-900",children:["₹",Z.amount.toLocaleString("en-IN")]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-1",children:[ae===Z.id?e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Et(Z.id),children:e.jsx(pl,{className:"w-4 h-4"})}):e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>{xe(Z.id),bt(De=>({...De,[Z.id]:{...Z}}))},children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8 text-red-600 hover:text-red-700",onClick:()=>Ds(Z.id),children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},Z.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(At,{value:K.department,onValueChange:Z=>W({...K,department:Z}),children:[e.jsx(Dt,{className:"col-span-3",children:e.jsx(kt,{placeholder:"Department"})}),e.jsx(Rt,{children:cl.map(Z=>e.jsx(Me,{value:Z,children:Z},Z))})]}),e.jsx(at,{placeholder:"Description",value:K.description,onChange:Z=>W({...K,description:Z.target.value}),className:"col-span-5"}),e.jsx(at,{type:"number",placeholder:"Amount",value:K.amount,onChange:Z=>W({...K,amount:Z.target.value}),className:"col-span-3"}),e.jsx(se,{onClick:_e,className:"col-span-1 bg-re-red hover:bg-re-red-hover",children:e.jsx(Dn,{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:["₹",ve.deductions.toLocaleString("en-IN")]})]})})]})]}),e.jsxs(Le,{className:"border-2 border-red-300 bg-red-50",children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"w-5 h-5 text-re-red"}),"Final Settlement Summary"]})}),e.jsxs(Fe,{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:["+ ₹",ve.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:["- ₹",ve.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:["- ₹",ve.deductions.toLocaleString("en-IN")]})]})]}),e.jsx("div",{className:"h-px bg-red-300"}),e.jsx("div",{className:`p-4 rounded-lg border-2 ${ve.settlementType==="Payable to Dealer"?"bg-red-100 border-red-400":ve.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 ${ve.settlementType==="Payable to Dealer"?"text-red-700":ve.settlementType==="Receivable from Dealer"?"text-green-700":"text-slate-700"}`,children:ve.settlementType})]}),e.jsx("span",{className:"text-3xl text-slate-900",children:ve.settlementType==="No Settlement Required"?"₹0":`₹${ve.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(an,{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",{}),ve.netSettlement>0&&"Positive value means company pays to dealer",ve.netSettlement<0&&"Negative value means dealer pays to company",ve.netSettlement===0&&"Zero means no payment required from either party"]})]})]})]})]})]}),e.jsxs(qt,{value:"departments",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-5 h-5"}),"Department Response Progress"]}),e.jsxs(Qt,{children:[r.departmentResponses.filter(Z=>Z.status!=="Pending").length," of ",r.departmentResponses.length," departments have responded"]})]}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsx(uc,{value:r.departmentResponses.filter(Z=>Z.status!=="Pending").length/r.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:r.departmentResponses.filter(Z=>Z.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:r.departmentResponses.filter(Z=>Z.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:r.departmentResponses.filter(Z=>Z.status==="Pending").length})]})]})]})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"All Department Responses"}),e.jsx(Qt,{children:"Status of NOC and dues clearance from all 16 departments (read-only for Finance; updates are done by department stakeholders)."})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Department"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Amount Type"}),e.jsx(fe,{children:"Amount"}),e.jsx(fe,{children:"Submitted Date"}),e.jsx(fe,{children:"Remarks"})]})}),e.jsx(Ls,{children:r.departmentResponses.map(Z=>e.jsxs(lt,{className:Z.duesFlow==="recovery"?"bg-red-50/40":Z.duesFlow==="payable"?"bg-emerald-50/40":"",children:[e.jsx(ue,{children:Z.departmentName}),e.jsx(ue,{children:e.jsx(Ce,{className:`border ${Z.status==="NOC Submitted"?"bg-green-100 text-green-700 border-green-300":Z.status==="Dues Pending"?"bg-red-100 text-red-700 border-red-300":"bg-slate-100 text-slate-700 border-slate-300"}`,children:Z.status})}),e.jsx(ue,{children:Z.amountType?e.jsx(Ce,{variant:"outline",className:Z.duesFlow==="recovery"?"bg-red-100 text-red-900 border-red-400 font-semibold":Z.duesFlow==="payable"?"bg-emerald-100 text-emerald-900 border-emerald-400 font-semibold":"bg-slate-50 text-slate-700 border-slate-200",children:Z.amountType}):"-"}),e.jsx(ue,{children:Z.amount?e.jsxs("span",{className:`rounded-md px-2 py-0.5 font-semibold tabular-nums ${Z.duesFlow==="recovery"?"bg-red-100 text-red-800 ring-1 ring-red-300/70":Z.duesFlow==="payable"?"bg-emerald-100 text-emerald-800 ring-1 ring-emerald-300/70":"text-slate-700"}`,children:["₹",Z.amount.toLocaleString("en-IN")]}):"-"}),e.jsx(ue,{children:Z.submittedDate||"-"}),e.jsx(ue,{className:"max-w-xs truncate",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:Z.remarks||"-"}),Z.supportingDocument&&e.jsxs("button",{onClick:()=>N({fileName:`${Z.departmentName}_Proof`,filePath:Z.supportingDocument,documentType:"Departmental Clearance Proof"}),className:"flex items-center gap-1 text-[10px] text-re-red hover:underline",children:[e.jsx(ju,{className:"w-3 h-3"}),"View Proof"]})]})})]},Z.id))})]})})]}),e.jsx(Le,{className:"bg-red-50 border-red-200",children:e.jsx(Fe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(an,{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(qt,{value:"documents",className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-5 h-5"}),"Submitted Documents"]})}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-2",children:r.documents.map((Z,oe)=>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(Ns,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-900",children:Z.name}),e.jsxs("p",{className:"text-sm text-slate-500",children:[Z.size," • ",Z.type," • Uploaded on ",Z.uploadedOn]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Z.url&&Z.url!=="#"&&e.jsxs("button",{onClick:()=>N({fileName:Z.name,filePath:Z.url,documentType:Z.type}),className:"text-re-red hover:text-re-red-hover text-[10px] font-semibold flex items-center gap-1",children:[e.jsx(ju,{className:"w-3 h-3"})," PREVIEW"]}),e.jsx(se,{variant:"outline",size:"sm",onClick:async()=>{if(Z.url&&Z.url!=="#")try{const Oe=await(await fetch(Z.url)).blob(),De=window.URL.createObjectURL(Oe),ye=document.createElement("a");ye.href=De,ye.download=Z.name||"download",document.body.appendChild(ye),ye.click(),document.body.removeChild(ye),window.URL.revokeObjectURL(De)}catch{const Oe=document.createElement("a");Oe.href=Z.url,Oe.download=Z.name||"download",document.body.appendChild(Oe),Oe.click(),document.body.removeChild(Oe)}else ee.error("Document URL not available")},children:"Download"})]})]},oe))})})]}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"w-5 h-5"}),"Upload Settlement Verification Documents"]}),e.jsx(Qt,{children:"Upload bank receipts, settlement proofs, or any additional documents"})]}),e.jsx(Fe,{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(or,{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:ln,accept:".pdf,.doc,.docx,.png,.jpg,.jpeg,.xlsx,.xls"}),e.jsx("label",{htmlFor:"file-upload",children:e.jsx(se,{variant:"outline",className:"mt-4",asChild:!0,children:e.jsx("span",{children:"Choose Files"})})})]})})})]})]}),e.jsx(qt,{value:"bank",className:"space-y-4",children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(ad,{className:"w-5 h-5"}),"Dealer Bank Account Details"]}),e.jsx(Qt,{children:"Manage bank accounts for settlement transfer"})]}),e.jsxs(se,{size:"sm",className:"bg-re-red",onClick:()=>{R(null),S(!0)},children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Bank Account"]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:j.length>0?j.map(Z=>e.jsxs(Le,{className:`relative ${Z.isPrimary?"border-re-red bg-red-50/30":""}`,children:[Z.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(Fe,{className:"p-4 pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Holder"}),e.jsx("p",{className:"text-sm font-semibold",children:Z.accountHolderName})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Bank"}),e.jsx("p",{className:"text-xs truncate",children:Z.bankName})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"IFSC"}),e.jsx("p",{className:"text-xs",children:Z.ifscCode})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-[10px] text-slate-500 uppercase font-bold",children:"Account Number"}),e.jsx("p",{className:"text-xs font-mono",children:Z.accountNumber})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[e.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-re-red",onClick:()=>{R(Z),S(!0)},children:[e.jsx(Cr,{className:"w-3 h-3 mr-1"}),"Edit"]}),e.jsxs(se,{variant:"ghost",size:"sm",className:"h-7 text-[11px] text-red-600",onClick:()=>Q(Z.id),children:[e.jsx(ar,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]})})]},Z.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(Le,{className:"sticky top-6",children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Gu,{className:"w-5 h-5"}),"Settlement Verification"]}),e.jsx(Qt,{children:"Enter settlement transaction details"})]}),e.jsx(Fe,{className:"space-y-4",children:r.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(fn,{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:ua(ge.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:ge.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:ge.verificationTransactionId,children:ge.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(ge.settlementAmount).toLocaleString()]})]})]}),ge.verificationRemarks&&e.jsxs("div",{className:"mt-4",children:[e.jsx(de,{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:ge.verificationRemarks})]}),e.jsxs(se,{variant:"outline",className:"w-full mt-4",onClick:()=>window.print(),children:[e.jsx(BI,{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(fn,{className:"w-4 h-4 text-re-red"}),"Compliance Checklist"]}),e.jsx("div",{className:"space-y-3",children:Qg.map(Z=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:`check-${Z.id}`,checked:A.includes(Z.id),onChange:()=>_(Z.id),className:"w-4 h-4 mt-1 rounded border-slate-300 text-re-red focus:ring-re-red"}),e.jsx("label",{htmlFor:`check-${Z.id}`,className:"text-sm text-slate-700 leading-tight",children:Z.label})]},Z.id))})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"paymentMode",children:["Payment Mode ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"paymentMode",placeholder:"e.g., NEFT, RTGS, Cheque",value:ge.paymentMode,onChange:Z=>Be({...ge,paymentMode:Z.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"verificationTxnId",children:["Transaction ID / Reference ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"verificationTxnId",placeholder:"Enter transaction reference",value:ge.verificationTransactionId,onChange:Z=>Be({...ge,verificationTransactionId:Z.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"bankReference",children:"Bank Reference Number"}),e.jsx(at,{id:"bankReference",placeholder:"Enter bank reference",value:ge.bankReference,onChange:Z=>Be({...ge,bankReference:Z.target.value})})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"settlementAmount",children:["Settlement Amount (₹) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"settlementAmount",type:"number",placeholder:"Enter settlement amount",value:ge.settlementAmount,onChange:Z=>Be({...ge,settlementAmount:Z.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"adjustments",children:"Adjustments (₹)"}),e.jsx(at,{id:"adjustments",type:"number",placeholder:"Enter any adjustments",value:ge.adjustments,onChange:Z=>{const oe=Z.target.value,Ne=ve.settlementAmount+parseFloat(oe||"0");Be({...ge,adjustments:oe,settlementAmount:Ne.toString()})}}),parseFloat(ge.adjustments)!==0&&e.jsxs("p",{className:"text-sm text-re-red mt-1 flex items-center gap-1",children:[e.jsx(an,{className:"w-3 h-3"}),"Adjusted amount: ₹",ge.settlementAmount]})]}),e.jsxs("div",{children:[e.jsxs(de,{htmlFor:"settlementDate",children:["Settlement Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(at,{id:"settlementDate",type:"date",value:ge.settlementDate,onChange:Z=>Be({...ge,settlementDate:Z.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{htmlFor:"verificationRemarks",children:"Verification Remarks"}),e.jsx(Gs,{id:"verificationRemarks",placeholder:"Enter any remarks or notes...",rows:4,value:ge.verificationRemarks,onChange:Z=>Be({...ge,verificationRemarks:Z.target.value})})]}),e.jsxs("div",{className:"pt-4 space-y-3 border-t",children:[e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:Xs,disabled:Bs||A.length<Qg.length,children:[Bs?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(fn,{className:"w-4 h-4 mr-2"}),"Complete Settlement"]}),A.length<Qg.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(se,{variant:"outline",className:"w-full border-red-300 text-re-red hover:bg-red-50",onClick:Ws,disabled:Bs,children:[e.jsx(Ku,{className:"w-4 h-4 mr-2"}),"Request Clarification"]}),e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-600 hover:bg-red-50",onClick:Js,disabled:Bs,children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),"Reject Settlement"]})]})]})})]})})]}),e.jsx(g_,{isOpen:C,onClose:()=>{S(!1),R(null)},onSubmit:V,editingBank:D,isSubmitting:!1}),e.jsx(mo,{isOpen:!!v,onClose:()=>N(null),document:v})]}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx("p",{children:"Settlement case not found"}),e.jsx(se,{onClick:s,className:"mt-4",children:"Go Back"})]})}const IV=()=>{const t=Iu(),s=g.useCallback(async()=>{try{t(o1(!0));const[r,a,l,o,d,m,f,x,h,p,u,w,v]=await Promise.all([Fs.getRoles().catch(()=>({success:!1})),Fs.getZones().catch(()=>({success:!1})),Fs.getPermissions().catch(()=>({success:!1})),Fs.getRegions().catch(()=>({success:!1})),Fs.getUsers().catch(()=>({success:!1})),Fs.getStates().catch(()=>({success:!1})),Fs.getEmailTemplates().catch(()=>({success:!1})),Fs.getDistricts({limit:"all"}).catch(()=>({success:!1})),Fs.getAreas({limit:"all"}).catch(()=>({success:!1})),Fs.getSlaConfigs().catch(()=>({success:!1})),Fs.getASMs().catch(()=>({success:!1})),Fs.getZonalManagers().catch(()=>({success:!1})),Fs.getDDLeads().catch(()=>({success:!1}))]),N=H=>H.success?H:H.data?H.data:H,j=N(r),y=N(a),C=N(l),S=N(o),D=N(d),R=N(m),A=N(f),L=N(x),$=N(h),P=N(p),E=N(u),O=N(w),I=N(v),q=((D==null?void 0:D.users)||(D==null?void 0:D.data)||[]).map(H=>{var ce;const X=Array.isArray(H.territoryProfile)?H.territoryProfile:[],J=X.filter(we=>String(we.locationType||"").toLowerCase()==="zone").map(we=>we.locationName||we.zone).filter(Boolean),ie=X.filter(we=>String(we.locationType||"").toLowerCase()==="region").map(we=>we.locationName||we.region).filter(Boolean),ae=Array.from(new Set([...H.allZones||[],...J])),xe=Array.from(new Set([...H.allRegions||[],...ie]));return{...H,name:H.fullName||H.name,role:((ce=H.role)==null?void 0:ce.roleName)||(Array.isArray(H.allRoles)&&H.allRoles.length>0?H.allRoles[0]:"System User"),zone:ae.length>0?ae.join(", "):"Global",region:xe.length>0?xe.join(", "):"Unassigned",status:H.isActive!==!1?"Active":"Inactive"}}),G=((j==null?void 0:j.roles)||(j==null?void 0:j.data)||[]).map(H=>{var X;return{id:H.id,name:H.roleName,permissions:((X=H.permissions)==null?void 0:X.map(J=>J.permissionCode))||[],userCount:H.userCount||0}}),Y=((y==null?void 0:y.zones)||(y==null?void 0:y.data)||[]).map(H=>{var J,ie,ae,xe,ce;const X=(H.name||H.zoneName||"").toUpperCase();return{id:H.id,name:X,description:H.description||"",code:H.name?H.name.substring(0,3).toUpperCase():"ZON",regionCount:H.regionCount||0,asmCount:H.asmCount||0,regionalOfficerCount:H.regionalOfficerCount||0,zmCount:H.zmCount||0,states:H.states||[],zonalBusinessHead:{name:((J=H.zonalBusinessHead)==null?void 0:J.name)||((ie=H.zonalBusinessHead)==null?void 0:ie.fullName)||"Not Assigned",email:((ae=H.zonalBusinessHead)==null?void 0:ae.email)||"",phone:((xe=H.zonalBusinessHead)==null?void 0:xe.mobileNumber)||((ce=H.zonalBusinessHead)==null?void 0:ce.phone)||""},zonalManagers:(H.zonalManagers||[]).map(we=>({id:we.id,name:we.name||we.fullName||"Unknown",email:we.email||"",phone:we.phone||we.mobileNumber||"",regions:we.regions||[]}))}}),V=((S==null?void 0:S.regions)||(S==null?void 0:S.data)||[]).map(H=>({id:H.id,code:H.code||(H.name?H.name.substring(0,3).toUpperCase():"REG"),name:H.name||H.regionName,zoneId:H.zoneId,zoneName:H.zoneName||"Unknown",states:H.states||[],cities:H.cities||[],districts:(H.districts||[]).map(X=>({id:X.id,name:X.name,stateId:X.stateId})),asmCount:H.asmCount||0,regionalOfficerCount:H.regionalOfficerCount||0,regionalManager:H.regionalManager?{id:H.regionalManager.id,name:H.regionalManager.fullName||H.regionalManager.name,email:H.regionalManager.email,phone:H.regionalManager.mobileNumber||H.regionalManager.phone}:void 0,status:H.isActive!==!1?"Active":"Inactive"})),Q=Array.isArray(E==null?void 0:E.data)?E.data:Array.isArray(E)?E:[],_=Array.isArray(O==null?void 0:O.data)?O.data:Array.isArray(O)?O:[],z=_.length>0?_:q.filter(H=>{var X;return(X=H.allRoles)==null?void 0:X.some(J=>(J==="ZM"||J==="DD-ZM"||J.includes("ZONAL MANAGER"))&&!J.includes("HEAD"))}).map(H=>{const X=(H.territoryProfile||[]).find(ae=>ae.roleCode==="ZM"||ae.roleCode==="DD-ZM")||{},J=(H.territoryProfile||[]).filter(ae=>(ae.roleCode==="ZM"||ae.roleCode==="DD-ZM")&&ae.locationType==="region").map(ae=>ae.locationName),ie=(H.territoryProfile||[]).filter(ae=>(ae.roleCode==="ZM"||ae.roleCode==="DD-ZM")&&ae.locationType==="region").map(ae=>ae.locationId);return{id:H.id,name:H.fullName,zmCode:H.employeeId||"N/A",email:H.email,phone:H.mobileNumber,zoneId:X.zoneId,zoneName:X.zone||H.zone||"Not Assigned",regionNames:J,assignedRegionIds:ie,status:H.status}}),T=((R==null?void 0:R.states)||(R==null?void 0:R.data)||[]).map(H=>({...H,stateName:H.name})),F=((L==null?void 0:L.districts)||(L==null?void 0:L.data)||[]).map(H=>({...H,districtName:H.name,stateId:H.stateId,asmId:H.asmId,ddAmId:H.ddAmId,zmId:H.zmId})),B=($.areas||$.data||[]).map(H=>({...H,areaName:H.name,districtId:H.districtId})),K=(P.data||[]).map(H=>{var X,J;return{id:H.id,stage:H.stageCode||"Unknown",days:H.tatValue||0,enabled:H.isActive!==!1,reminders:((X=H.reminderConfig)==null?void 0:X.reminders)||[],escalations:((J=H.escalationConfig)==null?void 0:J.escalations)||[]}}),W=Array.isArray(I==null?void 0:I.data)?I.data:Array.isArray(I)?I:[];t(RA({zones:Y,regionalOffices:V,asms:Q,zonalManagerMappings:z,zonalManagers:_,roles:G,allStates:T,allDistricts:F,allAreas:B,availablePermissions:(C==null?void 0:C.permissions)||(C==null?void 0:C.data)||[],emailTemplates:(A==null?void 0:A.data)||[],slaConfigs:K,users:q,ddLeads:W,loading:!1}))}catch(r){console.error("[useMasterData] Error fetching data:",r),t(k5("Could not load configuration data")),ee.error("Could not load configuration data")}finally{t(o1(!1))}},[t]),n=g.useCallback(async r=>{try{t(c1(!0));const a=await Fs.getAreas(r);a.success&&t(D5({data:a.data,pagination:a.pagination}))}catch(a){console.error("[useMasterData] Error fetching areas:",a),ee.error("Could not load locations")}finally{t(c1(!1))}},[t]);return{fetchInitialData:s,fetchAreas:n}},MV=({selectedZone:t,onZoneClick:s})=>{const{zones:n}=Fn(r=>r.master);return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:n.map(r=>e.jsxs(Le,{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(Qe,{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(Du,{className:"w-5 h-5 text-re-red"}),e.jsx(et,{className:"text-lg",children:r.name.toUpperCase().endsWith("ZONE")?r.name:`${r.name} Zone`})]}),e.jsx(Ce,{variant:"outline",className:"text-xs",children:r.code})]})}),e.jsxs(Fe,{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(Ce,{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(Ce,{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(Ce,{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(Ce,{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(Ce,{className:"bg-blue-600",children:r.zmCount})]})]})]})]},r.id))})},FV=({selectedZone:t,onAddZone:s,onEditZone:n})=>{const{zones:r}=Fn(l=>l.master),a=r.filter(l=>t==="all"||l.id===t);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Zone Details"}),e.jsx(Qt,{children:"Geographical coverage and state mappings for each zone"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Zone"]})]})}),e.jsx(Fe,{children:e.jsx(ap,{className:"h-[400px]",children:e.jsx("div",{className:"space-y-4",children:a.map(l=>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(Du,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:l.name}),e.jsx("p",{className:"text-slate-500 text-sm",children:l.code})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(se,{variant:"outline",size:"sm",onClick:()=>n(l),className:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",children:e.jsx(Cr,{className:"w-4 h-4"})})})]}),l.description&&e.jsx("div",{className:"bg-slate-50 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-slate-600",children:l.description})}),e.jsxs("div",{children:[e.jsxs(de,{className:"text-xs text-slate-600 mb-2 block",children:["States Covered (",l.states.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:l.states.map((o,d)=>e.jsx(Ce,{variant:"secondary",className:"text-xs border-transparent bg-secondary text-secondary-foreground",children:o},d))})]}),l.zonalBusinessHead&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsx(de,{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(mc,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:l.zonalBusinessHead.name}),e.jsx(Ce,{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(Dr,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:l.zonalBusinessHead.email})]})]})]}),l.zonalManagers&&l.zonalManagers.length>0&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsxs(de,{className:"text-xs text-slate-600 mb-2 block",children:["Zonal Managers (",l.zonalManagers.length,")"]}),e.jsx("div",{className:"space-y-2",children:l.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(Ra,{className:"w-4 h-4 text-slate-600"}),e.jsx("span",{className:"text-sm text-slate-900",children:o.name}),e.jsxs(Ce,{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(Dr,{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(de,{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(Ce,{variant:"outline",className:"text-xs bg-white text-foreground",children:[e.jsx(Du,{className:"w-2.5 h-2.5 mr-1"}),m]},f))})]})]},d))})]})]},l.id))})})})]})},BV=({selectedZone:t,onAddRegion:s,onEditRegion:n,onDeleteRegion:r})=>{const{regionalOffices:a}=Fn(o=>o.master),l=a.filter(o=>t==="all"||o.zoneId===t);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Regional Offices"}),e.jsx(Qt,{children:"Manage regional offices within zones"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Regional Office"]})]})}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Region Code"}),e.jsx(fe,{children:"Region Name"}),e.jsx(fe,{children:"Zone"}),e.jsx(fe,{children:"Regional Manager"}),e.jsx(fe,{children:"Districts"}),e.jsx(fe,{children:"Cities"}),e.jsx(fe,{children:"Regional Officers"}),e.jsx(fe,{children:"ASMs"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:l.map(o=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(so,{className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{className:"font-medium",children:o.code})]})}),e.jsx(ue,{className:"font-medium",children:o.name}),e.jsx(ue,{children:o.zoneName}),e.jsx(ue,{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(ue,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.districts||[]).slice(0,2).map((d,m)=>e.jsx(Ce,{variant:"secondary",className:"text-xs",children:d.name||d},m)),(o.districts||[]).length>2&&e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:["+",(o.districts||[]).length-2]})]})}),e.jsx(ue,{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(ue,{children:e.jsx(Ce,{className:"bg-purple-600",children:o.regionalOfficerCount})}),e.jsx(ue,{children:e.jsx(Ce,{className:"bg-green-600",children:o.asmCount})}),e.jsx(ue,{children:e.jsx(Ce,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{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(ar,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},$V=({selectedZone:t,onAddASM:s,onEditASM:n,onDeleteASM:r})=>{const{asms:a,zonalManagerMappings:l}=Fn(m=>m.master),o=a.filter(m=>t==="all"||m.zoneId===t),d=g.useMemo(()=>{const m={};return[...a,...l].forEach(f=>{(f.areasManaged||f.districts||[]).forEach(h=>{m[h]||(m[h]=[]),m[h].includes(f.name)||m[h].push(f.name)})}),m},[a,l]);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"District Development Area Managers (DD-AM)"}),e.jsx(Qt,{children:"Manage DD-AM users across districts (multi-district)"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add DD-AM"]})]})}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"DD-AM Code"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Zone"}),e.jsx(fe,{children:"Region"}),e.jsx(fe,{children:"Districts Managed"}),e.jsx(fe,{children:"Contact"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:o.map(m=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cM,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"font-medium",children:m.asmCode||"N/A"})]})}),e.jsx(ue,{children:m.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:m.zoneName})}),e.jsx(ue,{className:"text-sm text-slate-600",children:m.regionName}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:m.areasManaged.map((f,x)=>{const h=typeof f=="string"?f:f.id,p=typeof f=="string"?f:f.name,u=(d[h]||[]).filter(v=>v!==m.name),w=u.length>0;return e.jsxs(Ce,{variant:w?"outline":"secondary",className:`text-xs ${w?"border-red-300 bg-red-50 text-re-red-hover font-medium":""}`,title:w?`Also managed by: ${u.join(", ")}`:void 0,children:[p,w&&e.jsx(Ra,{className:"w-2.5 h-2.5 ml-1 inline"})]},x)})})}),e.jsx(ue,{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(ue,{children:e.jsx(Ce,{variant:m.status==="Active"?"default":"secondary",className:m.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:m.status})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(m),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{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(ar,{className:"w-4 h-4"})})]})})]},m.id))})]})})]})},qV=({selectedZone:t,onAddZM:s,onEditZM:n,onDeleteZM:r})=>{const{zonalManagers:a}=Fn(o=>o.master),l=(a||[]).filter(o=>t==="all"||o.zoneId===t||o.zones&&o.zones.includes(t));return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{children:"Zonal Managers (DD-ZM)"}),e.jsx(Qt,{children:"Manage Zonal Managers and their region assignments"})]}),e.jsxs(se,{onClick:s,className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add ZM"]})]})}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"ZM Code"}),e.jsx(fe,{children:"Name"}),e.jsx(fe,{children:"Zone"}),e.jsx(fe,{children:"Regions Managed"}),e.jsx(fe,{children:"Contact"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:l.map(o=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:o.zmCode||o.code})]})}),e.jsx(ue,{children:o.name}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(o.zones||[o.zoneName]).map((d,m)=>e.jsx(Ce,{variant:"outline",children:d},m))})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(o.regionNames||[]).slice(0,3).map((d,m)=>e.jsx(Ce,{variant:"secondary",className:"text-xs",children:d},m)),(o.regionNames||[]).length>3&&e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:["+",(o.regionNames||[]).length-3]})]})}),e.jsx(ue,{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(ue,{children:e.jsx(Ce,{variant:o.status==="Active"?"default":"secondary",className:o.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:o.status})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>n(o),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{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(ar,{className:"w-4 h-4"})})]})})]},o.id))})]})})]})},zV=({userAssignedData:t})=>e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{className:"text-xl",children:"System Users & Territory Assignments"})}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"User Details"}),e.jsx(fe,{children:"Role"}),e.jsx(fe,{children:"Assigned Zone"}),e.jsx(fe,{children:"Assigned Region"}),e.jsx(fe,{children:"Status"})]})}),e.jsx(Ls,{children:t.map(s=>e.jsxs(lt,{children:[e.jsx(ue,{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(Ir,{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(Dr,{className:"w-3 h-3"}),s.email]})]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mc,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-sm font-medium",children:s.role})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:s.zone})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"bg-indigo-50 text-indigo-700 border-indigo-200",children:s.region})}),e.jsx(ue,{children:e.jsx(Ce,{variant:s.status==="Active"?"default":"secondary",className:s.status==="Active"?"bg-emerald-100 text-emerald-700":"",children:s.status})})]},s.id))})]})})]}),UV=({onAddRole:t,onEditRole:s})=>{const{roles:n}=Fn(r=>r.master);return e.jsxs(Le,{className:"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border shadow-sm",children:[e.jsx(Qe,{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(et,{className:"leading-none text-xl font-bold",children:"Role Definitions"}),e.jsx(Qt,{className:"text-muted-foreground mt-1.5",children:"Overview of available roles and their access levels"})]}),e.jsxs(se,{onClick:t,className:"bg-re-red hover:bg-re-red-hover h-9",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Role"]})]})}),e.jsx(Fe,{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(mc,{className:"w-5 h-5 text-re-red"}),e.jsx("h3",{className:"text-slate-900 font-bold",children:r.name})]}),e.jsxs(Ce,{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((l,o)=>e.jsx(Ce,{variant:"outline",className:"border px-2 py-0.5 font-medium text-foreground text-[10px] bg-white/50",children:l.replace(/_/g," ").toLowerCase()},o)),((a=r.permissions)==null?void 0:a.length)>3&&e.jsxs(Ce,{variant:"outline",className:"text-[10px] border-slate-200",children:["+",r.permissions.length-3]})]})]}),e.jsxs(se,{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(Cr,{className:"w-3 h-3 mr-1"}),"Edit Permissions"]})]},r.id)})})})]})},VV=({isOpen:t,onOpenChange:s,role:n,onSave:r})=>{const[a,l]=g.useState([]);g.useEffect(()=>{n&&l(n.permissions||[])},[n,t]);const o=m=>{l(f=>f.includes(m)?f.filter(x=>x!==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(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{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(fs,{className:"p-6 pb-2 space-y-2 text-left bg-white sticky top-0 z-10 border-b",children:[e.jsxs(us,{className:"text-xl font-bold tracking-tight",children:["Edit Role Permissions - ",n.name]}),e.jsxs(bs,{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(mc,{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(Ce,{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(x=>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-${x.id}`,checked:a.includes(x.id),onCheckedChange:()=>o(x.id),className:"border-slate-300 data-[state=checked]:bg-purple-600 data-[state=checked]:border-purple-600"}),e.jsx("label",{htmlFor:`perm-${x.id}`,className:"text-sm font-medium text-slate-700 cursor-pointer group-hover:text-slate-900 transition-colors flex-1",children:x.label})]},x.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(se,{variant:"ghost",onClick:()=>s(!1),className:"flex-1 h-11 font-bold text-slate-600 hover:bg-slate-100",children:"Cancel"}),e.jsxs(se,{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(pl,{className:"w-4 h-4 mr-2"}),"Save Role Permissions"]})]})]})})},HV=({isOpen:t,onOpenChange:s,onSave:n})=>{const[r,a]=g.useState(""),[l,o]=g.useState(""),[d,m]=g.useState(""),[f,x]=g.useState(!1);g.useEffect(()=>{t&&(a(""),o(""),m(""),x(!1))},[t]);const h=async()=>{if(!(!r.trim()||!l.trim())){x(!0);try{await n({roleName:r.trim(),roleCode:l.trim(),description:d.trim()||void 0}),s(!1)}finally{x(!1)}}};return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"sm:max-w-md",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Add Role"}),e.jsx(bs,{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(de,{htmlFor:"role-name",children:"Role Name"}),e.jsx(at,{id:"role-name",value:r,onChange:p=>a(p.target.value),placeholder:"e.g. Finance Admin"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"role-code",children:"Role Code"}),e.jsx(at,{id:"role-code",value:l,onChange:p=>o(p.target.value),placeholder:"e.g. FINANCE_ADMIN"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"role-description",children:"Description"}),e.jsx(Gs,{id:"role-description",value:d,onChange:p=>m(p.target.value),placeholder:"Optional",rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"outline",onClick:()=>s(!1),disabled:f,children:"Cancel"}),e.jsx(se,{onClick:h,disabled:f||!r.trim()||!l.trim(),children:f?"Saving...":"Create Role"})]})]})})},WV=({onEditTemplate:t,onDeleteTemplate:s})=>{const{emailTemplates:n}=Fn(r=>r.master);return e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs("div",{children:[e.jsx(et,{children:"Email & Letter Templates"}),e.jsx(Qt,{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(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Template Name"}),e.jsx(fe,{children:"Subject"}),e.jsx(fe,{children:"Trigger Code"}),e.jsx(fe,{children:"Modified Date"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsxs(Ls,{children:[n.map(r=>e.jsxs(lt,{children:[e.jsx(ue,{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(Dr,{className:"w-4 h-4 text-re-red"})}),e.jsx("span",{className:"font-medium text-slate-900",children:r.name||r.templateCode})]})}),e.jsx(ue,{className:"text-slate-600 max-w-xs truncate",children:r.subject}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"bg-slate-50 text-[10px] font-mono",children:r.templateCode||"-"})}),e.jsx(ue,{className:"text-slate-500 text-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dr,{className:"w-3.5 h-3.5"}),r.updatedAt?Gt(r.updatedAt):"-"]})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>t(r),children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>s(r.id),className:"text-red-500 hover:text-re-red hover:bg-red-50",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},r.id)),n.length===0&&e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"text-center py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Dr,{className:"w-8 h-8 text-slate-200"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No templates configured yet"})]})})})]})]})})]})},GV=({onAddLocation:t,onEditLocation:s,onDeleteLocation:n,onSearch:r,onPageChange:a,searchTerm:l,states:o,stateFilter:d,onStateFilterChange:m,statusFilter:f,onStatusFilterChange:x})=>{const{allAreas:h,areasPagination:p,isAreasLoading:u}=Fn(w=>w.master);return e.jsx("div",{className:"space-y-4",children:e.jsxs(Le,{children:[e.jsx(Qe,{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(et,{children:"Dealership Locations"}),e.jsxs(Qt,{children:["Manage ",p.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(Du,{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:l,onChange:w=>r(w.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(At,{value:d,onValueChange:m,children:[e.jsx(Dt,{className:"w-48",children:e.jsx(kt,{placeholder:"All States"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All States"}),o.map(w=>e.jsx(Me,{value:w.id,children:w.name||w.stateName},w.id))]})]}),e.jsxs(At,{value:f,onValueChange:x,children:[e.jsx(Dt,{className:"w-44",children:e.jsx(kt,{placeholder:"Opportunity Filter"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Opportunities"}),e.jsx(Me,{value:"active",children:"Opportunity: Yes"}),e.jsx(Me,{value:"inactive",children:"Opportunity: No"})]})]}),e.jsxs(se,{onClick:t,className:"bg-re-red hover:bg-re-red-hover whitespace-nowrap",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Location"]})]})]})}),e.jsxs(Fe,{children:[e.jsxs("div",{className:`relative ${u?"opacity-50 pointer-events-none":""}`,children:[e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"State"}),e.jsx(fe,{children:"City"}),e.jsx(fe,{children:"District"}),e.jsx(fe,{children:"Active Period"}),e.jsx(fe,{children:"Opportunity"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:h.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:6,className:"h-32 text-center text-slate-500 italic",children:l?"No locations found matching your search":"No locations available"})}):h.map(w=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vr,{className:"w-4 h-4 text-re-red"}),e.jsx("span",{className:"font-medium",children:w.stateName||"N/A"})]})}),e.jsx(ue,{className:"font-medium text-slate-900",children:w.city||"N/A"}),e.jsx(ue,{className:"text-slate-600 text-sm",children:w.name}),e.jsx(ue,{children:w.openFrom&&w.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(Ce,{variant:"outline",className:"text-xs font-medium",children:Gt(w.openFrom)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-600",children:"To:"}),e.jsx(Ce,{variant:"outline",className:"text-xs font-medium",children:Gt(w.openTo)})]})]}):e.jsx("span",{className:"text-slate-400 italic text-sm",children:"Not Defined"})}),e.jsx(ue,{children:e.jsx(Ce,{variant:w.isOpportunity?"default":"secondary",className:w.isOpportunity?"bg-green-600 hover:bg-green-700 text-white border-transparent":"",children:w.isOpportunity?"Yes":"No"})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>s(w),className:"h-8 w-8 p-0",children:e.jsx(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"outline",size:"sm",onClick:()=>n(w.id),className:"h-8 w-8 p-0 text-re-red hover:bg-red-50 hover:text-re-red-hover",children:e.jsx(ar,{className:"w-4 h-4"})})]})})]},w.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"})})]}),p.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:(p.page-1)*p.limit+1})," to ",e.jsx("span",{className:"font-medium text-slate-900",children:Math.min(p.page*p.limit,p.total)})," of ",e.jsx("span",{className:"font-medium text-slate-900",children:p.total})," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{variant:"outline",size:"sm",onClick:()=>a(p.page-1),disabled:p.page<=1||u,className:"h-8",children:"Previous"}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,p.totalPages)},(w,v)=>{let N=p.page;return p.page<=3?N=v+1:p.page>=p.totalPages-2?N=p.totalPages-4+v:N=p.page-2+v,N<=0||N>p.totalPages?null:e.jsx(se,{variant:p.page===N?"default":"outline",size:"sm",onClick:()=>a(N),disabled:u,className:"h-8 w-8 p-0",children:N},N)})}),e.jsx(se,{variant:"outline",size:"sm",onClick:()=>a(p.page+1),disabled:p.page>=p.totalPages||u,className:"h-8",children:"Next"})]})]})]})]})})};var KV=Symbol("radix.slottable");function YV(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=KV,s}var[xp]=ga("Tooltip",[oo]),gp=oo(),v_="TooltipProvider",ZV=700,Ey="tooltip.open",[QV,cj]=xp(v_),y_=t=>{const{__scopeTooltip:s,delayDuration:n=ZV,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:l}=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(QV,{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:l})};y_.displayName=v_;var Lu="Tooltip",[XV,lh]=xp(Lu),b_=t=>{const{__scopeTooltip:s,children:n,open:r,defaultOpen:a,onOpenChange:l,disableHoverableContent:o,delayDuration:d}=t,m=cj(Lu,t.__scopeTooltip),f=gp(s),[x,h]=g.useState(null),p=Ar(),u=g.useRef(0),w=o??m.disableHoverableContent,v=d??m.delayDuration,N=g.useRef(!1),[j,y]=$i({prop:r,defaultProp:a??!1,onChange:A=>{A?(m.onOpen(),document.dispatchEvent(new CustomEvent(Ey))):m.onClose(),l==null||l(A)},caller:Lu}),C=g.useMemo(()=>j?N.current?"delayed-open":"instant-open":"closed",[j]),S=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,N.current=!1,y(!0)},[y]),D=g.useCallback(()=>{window.clearTimeout(u.current),u.current=0,y(!1)},[y]),R=g.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>{N.current=!0,y(!0),u.current=0},v)},[v,y]);return g.useEffect(()=>()=>{u.current&&(window.clearTimeout(u.current),u.current=0)},[]),e.jsx(Hf,{...f,children:e.jsx(XV,{scope:s,contentId:p,open:j,stateAttribute:C,trigger:x,onTriggerChange:h,onTriggerEnter:g.useCallback(()=>{m.isOpenDelayedRef.current?R():S()},[m.isOpenDelayedRef,R,S]),onTriggerLeave:g.useCallback(()=>{w?D():(window.clearTimeout(u.current),u.current=0)},[D,w]),onOpen:S,onClose:D,disableHoverableContent:w,children:n})})};b_.displayName=Lu;var _y="TooltipTrigger",j_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=lh(_y,n),l=cj(_y,n),o=gp(n),d=g.useRef(null),m=Ks(s,d,a.onTriggerChange),f=g.useRef(!1),x=g.useRef(!1),h=g.useCallback(()=>f.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),e.jsx(Xu,{asChild:!0,...o,children:e.jsx(ws.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:m,onPointerMove:Wt(t.onPointerMove,p=>{p.pointerType!=="touch"&&!x.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),x.current=!0)}),onPointerLeave:Wt(t.onPointerLeave,()=>{a.onTriggerLeave(),x.current=!1}),onPointerDown:Wt(t.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Wt(t.onFocus,()=>{f.current||a.onOpen()}),onBlur:Wt(t.onBlur,a.onClose),onClick:Wt(t.onClick,a.onClose)})})});j_.displayName=_y;var dj="TooltipPortal",[JV,eH]=xp(dj,{forceMount:void 0}),N_=t=>{const{__scopeTooltip:s,forceMount:n,children:r,container:a}=t,l=lh(dj,s);return e.jsx(JV,{scope:s,forceMount:n,children:e.jsx(Rr,{present:n||l.open,children:e.jsx(Nd,{asChild:!0,container:a,children:r})})})};N_.displayName=dj;var md="TooltipContent",w_=g.forwardRef((t,s)=>{const n=eH(md,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...l}=t,o=lh(md,t.__scopeTooltip);return e.jsx(Rr,{present:r||o.open,children:o.disableHoverableContent?e.jsx(S_,{side:a,...l,ref:s}):e.jsx(tH,{side:a,...l,ref:s})})}),tH=g.forwardRef((t,s)=>{const n=lh(md,t.__scopeTooltip),r=cj(md,t.__scopeTooltip),a=g.useRef(null),l=Ks(s,a),[o,d]=g.useState(null),{trigger:m,onClose:f}=n,x=a.current,{onPointerInTransitChange:h}=r,p=g.useCallback(()=>{d(null),h(!1)},[h]),u=g.useCallback((w,v)=>{const N=w.currentTarget,j={x:w.clientX,y:w.clientY},y=aH(j,N.getBoundingClientRect()),C=iH(j,y),S=lH(v.getBoundingClientRect()),D=cH([...C,...S]);d(D),h(!0)},[h]);return g.useEffect(()=>()=>p(),[p]),g.useEffect(()=>{if(m&&x){const w=N=>u(N,x),v=N=>u(N,m);return m.addEventListener("pointerleave",w),x.addEventListener("pointerleave",v),()=>{m.removeEventListener("pointerleave",w),x.removeEventListener("pointerleave",v)}}},[m,x,u,p]),g.useEffect(()=>{if(o){const w=v=>{const N=v.target,j={x:v.clientX,y:v.clientY},y=(m==null?void 0:m.contains(N))||(x==null?void 0:x.contains(N)),C=!oH(j,o);y?p():C&&(p(),f())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[m,x,o,f,p]),e.jsx(S_,{...t,ref:l})}),[sH,nH]=xp(Lu,{isInside:!1}),rH=YV("TooltipContent"),S_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:o,...d}=t,m=lh(md,n),f=gp(n),{onClose:x}=m;return g.useEffect(()=>(document.addEventListener(Ey,x),()=>document.removeEventListener(Ey,x)),[x]),g.useEffect(()=>{if(m.trigger){const h=p=>{const u=p.target;u!=null&&u.contains(m.trigger)&&x()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[m.trigger,x]),e.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:x,children:e.jsxs(Wf,{"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(rH,{children:r}),e.jsx(sH,{scope:n,isInside:!0,children:e.jsx(t7,{id:m.contentId,role:"tooltip",children:a||r})})]})})});w_.displayName=md;var C_="TooltipArrow",A_=g.forwardRef((t,s)=>{const{__scopeTooltip:n,...r}=t,a=gp(n);return nH(C_,n).isInside?null:e.jsx(Gf,{...a,...r,ref:s})});A_.displayName=C_;function aH(t,s){const n=Math.abs(s.top-t.y),r=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),l=Math.abs(s.left-t.x);switch(Math.min(n,r,a,l)){case l:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function iH(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 lH(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 oH(t,s){const{x:n,y:r}=t;let a=!1;for(let l=0,o=s.length-1;l<s.length;o=l++){const d=s[l],m=s[o],f=d.x,x=d.y,h=m.x,p=m.y;x>r!=p>r&&n<(h-f)*(r-x)/(p-x)+f&&(a=!a)}return a}function cH(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),dH(s)}function dH(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 l=s[s.length-1],o=s[s.length-2];if((l.x-o.x)*(a.y-o.y)>=(l.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 l=n[n.length-1],o=n[n.length-2];if((l.x-o.x)*(a.y-o.y)>=(l.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 uH=y_,hH=b_,mH=j_,fH=N_,pH=w_,xH=A_;function vp({delayDuration:t=0,...s}){return e.jsx(uH,{"data-slot":"tooltip-provider",delayDuration:t,...s})}function uj({...t}){return e.jsx(vp,{children:e.jsx(hH,{"data-slot":"tooltip",...t})})}function hj({...t}){return e.jsx(mH,{"data-slot":"tooltip-trigger",...t})}function mj({className:t,sideOffset:s=0,children:n,...r}){return e.jsx(fH,{children:e.jsxs(pH,{"data-slot":"tooltip-content",sideOffset:s,className:jt("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(xH,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const gH=({isOpen:t,onOpenChange:s,editingASMId:n,asmManagerId:r,setAsmManagerId:a,asmStatus:l,setAsmStatus:o,selectedASMZone:d,setSelectedASMZone:m,selectedASMRegion:f,setSelectedASMRegion:x,selectedASMStates:h,setSelectedASMStates:p,selectedASMDistricts:u,setSelectedASMDistricts:w,onSave:v,asmRoleCode:N,userAssignedData:j,districtsAssignedToOthers:y,getDistrictsForSelectedState:C})=>{const{zones:S,regionalOffices:D}=Fn(A=>A.master),R=j.filter(A=>{const L=(A.allRoles||[]).map(P=>String(P||"").toUpperCase()),$=String(A.roleCode||"").toUpperCase();return L.includes("DD-AM")||$==="DD-AM"});return wt.useEffect(()=>{if(r&&t){const A=j.find(L=>L.id===r);if(A&&A.territoryProfile){const L=A.territoryProfile.filter($=>$.roleCode===N&&$.locationType==="district").map($=>$.locationId);L.length>0&&w(L)}}},[r,N,t,j,w]),e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," DD Area Manager"]}),e.jsx(bs,{children:"Configure DD-AM details and district assignment"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Zone"}),e.jsxs(At,{value:d,onValueChange:A=>{m(A),x(""),p([]),w([])},children:[e.jsx(Dt,{className:"mt-2 text-slate-900",children:e.jsx(kt,{placeholder:"Select zone"})}),e.jsx(Rt,{children:S.map(A=>e.jsx(Me,{value:A.id,children:A.name},A.id))})]})]}),d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Regional Office"}),e.jsxs(At,{value:f,onValueChange:A=>{x(A),p([]),w([])},children:[e.jsx(Dt,{className:"mt-2 text-slate-900",children:e.jsx(kt,{placeholder:"Select regional office"})}),e.jsx(Rt,{children:D.filter(A=>A.zoneId===d).map(A=>e.jsx(Me,{value:A.id,children:A.name},A.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Select DD-AM User"}),e.jsxs(At,{value:r,onValueChange:a,children:[e.jsx(Dt,{className:"mt-2 text-slate-900",children:e.jsx(kt,{placeholder:"Select DD-AM"})}),e.jsx(Rt,{className:"max-h-64",children:R.map(A=>e.jsxs(Me,{value:A.id,children:[A.name," (",A.employeeId||"No ID",")"]},A.id))})]})]})]}),f&&e.jsxs("div",{children:[e.jsx(de,{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($=>$.id===f),L=((A==null?void 0:A.states)||[]).map($=>typeof $=="string"?$:$.name);return L.length>0?e.jsx("div",{className:"space-y-2",children:L.map($=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:`asm-state-${$}`,checked:h.some(P=>P.toLowerCase()===$.toLowerCase()),onCheckedChange:P=>{if(P)p([...h,$]);else{p(h.filter(O=>O.toLowerCase()!==$.toLowerCase()));const E=C($);w(u.filter(O=>!E.some(I=>I.id===O)))}}}),e.jsx("label",{htmlFor:`asm-state-${$}`,className:"text-sm cursor-pointer text-slate-900",children:$})]},$))}):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(de,{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(vp,{children:h.map(A=>{const L=C(A);return L.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:L.map($=>e.jsx("div",{children:e.jsxs(uj,{children:[e.jsx(hj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 py-0.5",children:[e.jsx(Tn,{id:`asm-district-${$.id}`,checked:u.includes($.id),disabled:!!y[$.id],onCheckedChange:P=>{w(P?[...u,$.id]:u.filter(E=>E!==$.id))}}),e.jsx("label",{htmlFor:`asm-district-${$.id}`,className:`text-sm flex items-center gap-1.5 ${y[$.id]?"text-slate-400 cursor-not-allowed":"cursor-pointer text-slate-900"}`,children:$.name})]})}),y[$.id]&&e.jsx(mj,{children:e.jsxs("p",{children:["Already managed by: ",y[$.id].join(", ")]})})]})},$.id))})]},A)})})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs(de,{children:["DD Area Manager ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:r,onValueChange:A=>{var $;a(A);const L=j.find(P=>P.id===A);if(L){const P=(L.territoryProfile||[]).find(E=>E.roleCode===N);P!=null&&P.zoneId&&m(P.zoneId),P!=null&&P.regionId&&x(P.regionId),w((($=L.areasManaged)==null?void 0:$.filter(E=>E.roleCode===N).map(E=>E.id))||[]),p(L.stateNames||[])}},disabled:!!n,children:[e.jsx(Dt,{className:"mt-2 w-full text-slate-900",children:e.jsx(kt,{placeholder:"Select DD-AM User"})}),e.jsx(Rt,{className:"max-h-60",children:R.length>0?R.map(A=>e.jsx(Me,{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(de,{children:"Status"}),e.jsxs(At,{value:l,onValueChange:A=>o(A),children:[e.jsx(Dt,{className:"mt-2 text-slate-900",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:v,children:"Save DD-AM"})]})]})]})})};var $S=1,vH=.9,yH=.8,bH=.17,Xg=.1,Jg=.999,jH=.9999,NH=.99,wH=/[\\\/_+.#"@\[\(\{&]/,SH=/[\\\/_+.#"@\[\(\{&]/g,CH=/[\s-]/,k_=/[\s-]/g;function Ty(t,s,n,r,a,l,o){if(l===s.length)return a===t.length?$S:NH;var d=`${a},${l}`;if(o[d]!==void 0)return o[d];for(var m=r.charAt(l),f=n.indexOf(m,a),x=0,h,p,u,w;f>=0;)h=Ty(t,s,n,r,f+1,l+1,o),h>x&&(f===a?h*=$S:wH.test(t.charAt(f-1))?(h*=yH,u=t.slice(a,f-1).match(SH),u&&a>0&&(h*=Math.pow(Jg,u.length))):CH.test(t.charAt(f-1))?(h*=vH,w=t.slice(a,f-1).match(k_),w&&a>0&&(h*=Math.pow(Jg,w.length))):(h*=bH,a>0&&(h*=Math.pow(Jg,f-a))),t.charAt(f)!==s.charAt(l)&&(h*=jH)),(h<Xg&&n.charAt(f-1)===r.charAt(l+1)||r.charAt(l+1)===r.charAt(l)&&n.charAt(f-1)!==r.charAt(l))&&(p=Ty(t,s,n,r,f+1,l+2,o),p*Xg>h&&(h=p*Xg)),h>x&&(x=h),f=n.indexOf(m,f+1);return o[d]=x,x}function qS(t){return t.toLowerCase().replace(k_," ")}function AH(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Ty(t,s,qS(t),qS(s),0,0,{})}var du='[cmdk-group=""]',e0='[cmdk-group-items=""]',kH='[cmdk-group-heading=""]',D_='[cmdk-item=""]',zS=`${D_}:not([aria-disabled="true"])`,Py="cmdk-item-select",Kc="data-value",DH=(t,s,n)=>AH(t,s,n),R_=g.createContext(void 0),oh=()=>g.useContext(R_),E_=g.createContext(void 0),fj=()=>g.useContext(E_),__=g.createContext(void 0),T_=g.forwardRef((t,s)=>{let n=Yc(()=>{var F,B;return{search:"",value:(B=(F=t.value)!=null?F:t.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Yc(()=>new Set),a=Yc(()=>new Map),l=Yc(()=>new Map),o=Yc(()=>new Set),d=P_(t),{label:m,children:f,value:x,onValueChange:h,filter:p,shouldFilter:u,loop:w,disablePointerSelection:v=!1,vimBindings:N=!0,...j}=t,y=Ar(),C=Ar(),S=Ar(),D=g.useRef(null),R=BH();hc(()=>{if(x!==void 0){let F=x.trim();n.current.value=F,A.emit()}},[x]),hc(()=>{R(6,I)},[]);let A=g.useMemo(()=>({subscribe:F=>(o.current.add(F),()=>o.current.delete(F)),snapshot:()=>n.current,setState:(F,B,K)=>{var W,H,X,J;if(!Object.is(n.current[F],B)){if(n.current[F]=B,F==="search")O(),P(),R(1,E);else if(F==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ie=document.getElementById(S);ie?ie.focus():(W=document.getElementById(y))==null||W.focus()}if(R(7,()=>{var ie;n.current.selectedItemId=(ie=q())==null?void 0:ie.id,A.emit()}),K||R(5,I),((H=d.current)==null?void 0:H.value)!==void 0){let ie=B??"";(J=(X=d.current).onValueChange)==null||J.call(X,ie);return}}A.emit()}},emit:()=>{o.current.forEach(F=>F())}}),[]),L=g.useMemo(()=>({value:(F,B,K)=>{var W;B!==((W=l.current.get(F))==null?void 0:W.value)&&(l.current.set(F,{value:B,keywords:K}),n.current.filtered.items.set(F,$(B,K)),R(2,()=>{P(),A.emit()}))},item:(F,B)=>(r.current.add(F),B&&(a.current.has(B)?a.current.get(B).add(F):a.current.set(B,new Set([F]))),R(3,()=>{O(),P(),n.current.value||E(),A.emit()}),()=>{l.current.delete(F),r.current.delete(F),n.current.filtered.items.delete(F);let K=q();R(4,()=>{O(),(K==null?void 0:K.getAttribute("id"))===F&&E(),A.emit()})}),group:F=>(a.current.has(F)||a.current.set(F,new Set),()=>{l.current.delete(F),a.current.delete(F)}),filter:()=>d.current.shouldFilter,label:m||t["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:y,inputId:S,labelId:C,listInnerRef:D}),[]);function $(F,B){var K,W;let H=(W=(K=d.current)==null?void 0:K.filter)!=null?W:DH;return F?H(F,n.current.search,B):0}function P(){if(!n.current.search||d.current.shouldFilter===!1)return;let F=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(W=>{let H=a.current.get(W),X=0;H.forEach(J=>{let ie=F.get(J);X=Math.max(ie,X)}),B.push([W,X])});let K=D.current;G().sort((W,H)=>{var X,J;let ie=W.getAttribute("id"),ae=H.getAttribute("id");return((X=F.get(ae))!=null?X:0)-((J=F.get(ie))!=null?J:0)}).forEach(W=>{let H=W.closest(e0);H?H.appendChild(W.parentElement===H?W:W.closest(`${e0} > *`)):K.appendChild(W.parentElement===K?W:W.closest(`${e0} > *`))}),B.sort((W,H)=>H[1]-W[1]).forEach(W=>{var H;let X=(H=D.current)==null?void 0:H.querySelector(`${du}[${Kc}="${encodeURIComponent(W[0])}"]`);X==null||X.parentElement.appendChild(X)})}function E(){let F=G().find(K=>K.getAttribute("aria-disabled")!=="true"),B=F==null?void 0:F.getAttribute(Kc);A.setState("value",B||void 0)}function O(){var F,B,K,W;if(!n.current.search||d.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let H=0;for(let X of r.current){let J=(B=(F=l.current.get(X))==null?void 0:F.value)!=null?B:"",ie=(W=(K=l.current.get(X))==null?void 0:K.keywords)!=null?W:[],ae=$(J,ie);n.current.filtered.items.set(X,ae),ae>0&&H++}for(let[X,J]of a.current)for(let ie of J)if(n.current.filtered.items.get(ie)>0){n.current.filtered.groups.add(X);break}n.current.filtered.count=H}function I(){var F,B,K;let W=q();W&&(((F=W.parentElement)==null?void 0:F.firstChild)===W&&((K=(B=W.closest(du))==null?void 0:B.querySelector(kH))==null||K.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function q(){var F;return(F=D.current)==null?void 0:F.querySelector(`${D_}[aria-selected="true"]`)}function G(){var F;return Array.from(((F=D.current)==null?void 0:F.querySelectorAll(zS))||[])}function Y(F){let B=G()[F];B&&A.setState("value",B.getAttribute(Kc))}function V(F){var B;let K=q(),W=G(),H=W.findIndex(J=>J===K),X=W[H+F];(B=d.current)!=null&&B.loop&&(X=H+F<0?W[W.length-1]:H+F===W.length?W[0]:W[H+F]),X&&A.setState("value",X.getAttribute(Kc))}function Q(F){let B=q(),K=B==null?void 0:B.closest(du),W;for(;K&&!W;)K=F>0?MH(K,du):FH(K,du),W=K==null?void 0:K.querySelector(zS);W?A.setState("value",W.getAttribute(Kc)):V(F)}let _=()=>Y(G().length-1),z=F=>{F.preventDefault(),F.metaKey?_():F.altKey?Q(1):V(1)},T=F=>{F.preventDefault(),F.metaKey?Y(0):F.altKey?Q(-1):V(-1)};return g.createElement(ws.div,{ref:s,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:F=>{var B;(B=j.onKeyDown)==null||B.call(j,F);let K=F.nativeEvent.isComposing||F.keyCode===229;if(!(F.defaultPrevented||K))switch(F.key){case"n":case"j":{N&&F.ctrlKey&&z(F);break}case"ArrowDown":{z(F);break}case"p":case"k":{N&&F.ctrlKey&&T(F);break}case"ArrowUp":{T(F);break}case"Home":{F.preventDefault(),Y(0);break}case"End":{F.preventDefault(),_();break}case"Enter":{F.preventDefault();let W=q();if(W){let H=new Event(Py);W.dispatchEvent(H)}}}}},g.createElement("label",{"cmdk-label":"",htmlFor:L.inputId,id:L.labelId,style:qH},m),yp(t,F=>g.createElement(E_.Provider,{value:A},g.createElement(R_.Provider,{value:L},F))))}),RH=g.forwardRef((t,s)=>{var n,r;let a=Ar(),l=g.useRef(null),o=g.useContext(__),d=oh(),m=P_(t),f=(r=(n=m.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;hc(()=>{if(!f)return d.item(a,o==null?void 0:o.id)},[f]);let x=O_(a,l,[t.value,t.children,l],t.keywords),h=fj(),p=io(R=>R.value&&R.value===x.current),u=io(R=>f||d.filter()===!1?!0:R.search?R.filtered.items.get(a)>0:!0);g.useEffect(()=>{let R=l.current;if(!(!R||t.disabled))return R.addEventListener(Py,w),()=>R.removeEventListener(Py,w)},[u,t.onSelect,t.disabled]);function w(){var R,A;v(),(A=(R=m.current).onSelect)==null||A.call(R,x.current)}function v(){h.setState("value",x.current,!0)}if(!u)return null;let{disabled:N,value:j,onSelect:y,forceMount:C,keywords:S,...D}=t;return g.createElement(ws.div,{ref:Xr(l,s),...D,id:a,"cmdk-item":"",role:"option","aria-disabled":!!N,"aria-selected":!!p,"data-disabled":!!N,"data-selected":!!p,onPointerMove:N||d.getDisablePointerSelection()?void 0:v,onClick:N?void 0:w},t.children)}),EH=g.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...l}=t,o=Ar(),d=g.useRef(null),m=g.useRef(null),f=Ar(),x=oh(),h=io(u=>a||x.filter()===!1?!0:u.search?u.filtered.groups.has(o):!0);hc(()=>x.group(o),[]),O_(o,d,[t.value,t.heading,m]);let p=g.useMemo(()=>({id:o,forceMount:a}),[a]);return g.createElement(ws.div,{ref:Xr(d,s),...l,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&g.createElement("div",{ref:m,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),yp(t,u=>g.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},g.createElement(__.Provider,{value:p},u))))}),_H=g.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=g.useRef(null),l=io(o=>!o.search);return!n&&!l?null:g.createElement(ws.div,{ref:Xr(a,s),...r,"cmdk-separator":"",role:"separator"})}),TH=g.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,l=fj(),o=io(f=>f.search),d=io(f=>f.selectedItemId),m=oh();return g.useEffect(()=>{t.value!=null&&l.setState("search",t.value)},[t.value]),g.createElement(ws.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||l.setState("search",f.target.value),n==null||n(f.target.value)}})}),PH=g.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,l=g.useRef(null),o=g.useRef(null),d=io(f=>f.selectedItemId),m=oh();return g.useEffect(()=>{if(o.current&&l.current){let f=o.current,x=l.current,h,p=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let u=f.offsetHeight;x.style.setProperty("--cmdk-list-height",u.toFixed(1)+"px")})});return p.observe(f),()=>{cancelAnimationFrame(h),p.unobserve(f)}}},[]),g.createElement(ws.div,{ref:Xr(l,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":r,id:m.listId},yp(t,f=>g.createElement("div",{ref:Xr(o,m.listInnerRef),"cmdk-list-sizer":""},f)))}),OH=g.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:l,container:o,...d}=t;return g.createElement(zb,{open:n,onOpenChange:r},g.createElement(Ub,{container:o},g.createElement(op,{"cmdk-overlay":"",className:a}),g.createElement(cp,{"aria-label":t.label,"cmdk-dialog":"",className:l},g.createElement(T_,{ref:s,...d}))))}),LH=g.forwardRef((t,s)=>io(n=>n.filtered.count===0)?g.createElement(ws.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),IH=g.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...l}=t;return g.createElement(ws.div,{ref:s,...l,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},yp(t,o=>g.createElement("div",{"aria-hidden":!0},o)))}),kd=Object.assign(T_,{List:PH,Item:RH,Input:TH,Group:EH,Separator:_H,Dialog:OH,Empty:LH,Loading:IH});function MH(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function FH(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function P_(t){let s=g.useRef(t);return hc(()=>{s.current=t}),s}var hc=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Yc(t){let s=g.useRef();return s.current===void 0&&(s.current=t()),s}function io(t){let s=fj(),n=()=>t(s.snapshot());return g.useSyncExternalStore(s.subscribe,n,n)}function O_(t,s,n,r=[]){let a=g.useRef(),l=oh();return hc(()=>{var o;let d=(()=>{var f;for(let x of n){if(typeof x=="string")return x.trim();if(typeof x=="object"&&"current"in x)return x.current?(f=x.current.textContent)==null?void 0:f.trim():a.current}})(),m=r.map(f=>f.trim());l.value(t,d,m),(o=s.current)==null||o.setAttribute(Kc,d),a.current=d}),a}var BH=()=>{let[t,s]=g.useState(),n=Yc(()=>new Map);return hc(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function $H(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function yp({asChild:t,children:s},n){return t&&g.isValidElement(s)?g.cloneElement($H(s),{ref:s.ref},n(s.props.children)):n(s)}var qH={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function zH({className:t,...s}){return e.jsx(kd,{"data-slot":"command",className:jt("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...s})}function UH({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(Ta,{className:"size-4 shrink-0 opacity-50"}),e.jsx(kd.Input,{"data-slot":"command-input",className:jt("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 VH({className:t,...s}){return e.jsx(kd.List,{"data-slot":"command-list",className:jt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...s})}function HH({...t}){return e.jsx(kd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function WH({className:t,...s}){return e.jsx(kd.Group,{"data-slot":"command-group",className:jt("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 US({className:t,...s}){return e.jsx(kd.Item,{"data-slot":"command-item",className:jt("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 GH=({value:t,onChange:s,asmUsers:n,className:r})=>{const[a,l]=g.useState(!1),o=n.find(d=>d.id===t);return e.jsxs(Tu,{open:a,onOpenChange:l,children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(se,{variant:"outline",role:"combobox","aria-expanded":a,className:jt("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(MI,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ou,{className:"w-[360px] max-w-[90vw] p-0",children:e.jsxs(zH,{children:[e.jsx(UH,{placeholder:"Search ASM by name/email/id..."}),e.jsxs(VH,{className:"max-h-64 overflow-y-auto custom-scrollbar-slim",children:[e.jsx(HH,{children:"No ASM found."}),e.jsxs(WH,{children:[e.jsxs(US,{value:"Unassign __none__",onSelect:()=>{s("__none__"),l(!1)},children:[e.jsx(Wn,{className:jt("mr-2 h-4 w-4",t==="__none__"?"opacity-100":"opacity-0")}),"Unassign"]}),n.map(d=>e.jsxs(US,{value:`${d.fullName} ${d.email} ${d.employeeId||""}`,onSelect:()=>{s(d.id),l(!1)},children:[e.jsx(Wn,{className:jt("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.fullName," (",d.employeeId||d.email,")"]},d.id))]})]})]})})]})},KH=()=>{const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,l]=g.useState([]),[o,d]=g.useState({}),m=async()=>{var h,p,u,w;try{s(!0);const v=await Fs.getDealerAsmMappings();v!=null&&v.success&&(r(((h=v.data)==null?void 0:h.dealers)||[]),l(((p=v.data)==null?void 0:p.asmUsers)||[]))}catch(v){ee.error(((w=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:w.message)||"Failed to load dealer ASM mappings")}finally{s(!1)}};g.useEffect(()=>{m()},[]);const f=g.useMemo(()=>[...n].sort((h,p)=>{const u=String(h.status||"").toLowerCase()==="active",w=String(p.status||"").toLowerCase()==="active";return u!==w?u?-1:1:String(h.dealerName||"").localeCompare(String(p.dealerName||""))}),[n]),x=async h=>{var u,w;const p=o[h]||"";try{const v=await Fs.saveDealerAsmMapping({dealerId:h,asmUserId:p==="__none__"?null:p||null});v!=null&&v.success?(ee.success(v.message||"Dealer ASM mapping updated"),await m()):ee.error((v==null?void 0:v.message)||"Failed to save mapping")}catch(v){ee.error(((w=(u=v==null?void 0:v.response)==null?void 0:u.data)==null?void 0:w.message)||"Failed to save mapping")}};return e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Dealer-Level ASM Assignment"}),e.jsx(Qt,{children:"Assign Sales ASM to onboarded dealers. DD-AM remains district-level in the section above."})]}),e.jsx(Fe,{children:t?e.jsx("p",{className:"text-sm text-slate-500",children:"Loading mappings..."}):e.jsxs(Ps,{className:"w-full",children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Dealer"}),e.jsx(fe,{children:"Dealer Code"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Current ASM"}),e.jsx(fe,{children:"Assign ASM"})]})}),e.jsxs(Ls,{children:[f.length===0&&e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"text-center text-slate-500 py-8",children:"No dealers available for ASM mapping yet."})}),f.map(h=>{var p;return e.jsxs(lt,{children:[e.jsx(ue,{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(ue,{children:h.dealerCode||"N/A"}),e.jsx(ue,{children:e.jsx(Ce,{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(ue,{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(ue,{children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx(GH,{asmUsers:a,value:o[h.dealerId]??((p=h.assignedAsm)==null?void 0:p.id)??"__none__",onChange:u=>d(w=>({...w,[h.dealerId]:u})),className:"flex-1 min-w-[180px]"}),e.jsx(se,{size:"sm",className:"shrink-0 bg-re-red hover:bg-re-red-hover text-white",onClick:()=>x(h.dealerId),children:"Assign"})]})})]},h.dealerId)})]})]})})]})},YH=({isOpen:t,onOpenChange:s,editingZMId:n,zmManagerId:r,setZmManagerId:a,zmStatus:l,setZmStatus:o,selectedZone:d,setSelectedZone:m,selectedRegions:f,setSelectedRegions:x,onSave:h,userAssignedData:p})=>{const{zones:u,regionalOffices:w}=Fn(j=>j.master),v=p.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")})),N=w.filter(j=>j.zoneId===d);return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"max-w-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," Zonal Manager"]}),e.jsx(bs,{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(de,{children:["Select Zonal Manager User ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:r,onValueChange:j=>{a(j);const y=p.find(C=>C.id===j);y&&(y.zoneId&&m(y.zoneId),y.assignedRegionIds&&x(y.assignedRegionIds))},disabled:!!n,children:[e.jsx(Dt,{className:"mt-2 w-full text-slate-900 border-slate-200",children:e.jsx(kt,{placeholder:"Select ZM User"})}),e.jsx(Rt,{className:"max-h-60",children:v.map(j=>e.jsx(Me,{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(de,{children:["Managed Zone ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(At,{value:d,onValueChange:j=>{m(j),x([])},children:[e.jsx(Dt,{className:"mt-2",children:e.jsx(kt,{placeholder:"Select zone"})}),e.jsx(Rt,{children:u.map(j=>e.jsx(Me,{value:j.id,children:j.name},j.id))})]})]}),d&&e.jsxs("div",{children:[e.jsxs(de,{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:[N.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:y=>{x(y?[...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)),N.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(de,{children:"Status"}),e.jsxs(At,{value:l,onValueChange:j=>o(j),children:[e.jsx(Dt,{className:"mt-2",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-6",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:h,children:"Save Zonal Manager"})]})]})]})})},ZH=({isOpen:t,onOpenChange:s,editingZoneId:n,zoneName:r,setZoneName:a,zoneCode:l,setZoneCode:o,zoneDescription:d,setZoneDescription:m,zonalBusinessHeadId:f,setZonalBusinessHeadId:x,userAssignedData:h,onSave:p})=>{const u=(h||[]).filter(v=>{if(f!=="none"&&v.id===f)return!0;const N=(v.allRoles||[]).map(y=>String(y||"").toUpperCase()),j=String(v.roleCode||v.role||"").toUpperCase();return j==="ZBH"||j.includes("ZONAL BUSINESS HEAD")||N.some(y=>{const C=String(y||"").toUpperCase();return C==="ZBH"||C==="ZONE BUSINESS HEAD"||C==="ZONAL BUSINESS HEAD"})}),w=u.length>0?u:h||[];return wt.useEffect(()=>{},[n,t]),e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"max-w-md",children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," Zone"]}),e.jsx(bs,{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(de,{children:"Zone Name"}),e.jsx(at,{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(de,{children:"Zone Code"}),e.jsx(at,{placeholder:"e.g., NZ",className:"mt-2 text-slate-900",value:l,onChange:v=>o(v.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Zonal Business Head"}),e.jsxs(At,{value:f,onValueChange:x,children:[e.jsx(Dt,{className:"mt-2 w-full text-slate-900",children:e.jsx(kt,{placeholder:"Select Head"})}),e.jsxs(Rt,{className:"max-h-60",children:[e.jsx(Me,{value:"none",children:"None / Unassigned"}),w.map(v=>e.jsxs(Me,{value:v.id,children:[v.name," (",v.email,")"]},v.id))]})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Description"}),e.jsx(Gs,{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(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:p,children:"Save Zone"})]})]})]})})},QH=({isOpen:t,onOpenChange:s,editingRegionId:n,regionName:r,setRegionName:a,regionDescription:l,setRegionDescription:o,selectedRegionZone:d,setSelectedRegionZone:m,regionalManagerId:f,setRegionalManagerId:x,selectedRegionStates:h,setSelectedRegionStates:p,onSave:u,userAssignedData:w})=>{const{zones:v,allStates:N,allDistricts:j,regionalOffices:y}=Fn(E=>E.master),[C,S]=wt.useState([]),D=wt.useMemo(()=>{const E={};return(y||[]).forEach(O=>{O.id!==n&&(O.districts||[]).forEach(I=>{E[I.id]=O.name})}),E},[y,n]),R=wt.useMemo(()=>{if(!d)return N;const E=new Set(j.filter(O=>O.zoneId===d||!O.zoneId||h.includes(O.id)).map(O=>O.stateId).filter(Boolean));return N.filter(O=>O.zoneId===d||E.has(O.id)||!O.zoneId)},[N,j,d,h]),A=wt.useMemo(()=>C.length===0?[]:j.filter(E=>C.includes(E.stateId)&&(!E.zoneId||E.zoneId===d||E.regionId===n)),[j,C,d,n]),L=wt.useMemo(()=>{const E={};return A.forEach(O=>{const I=N.find(G=>G.id===O.stateId),q=(I==null?void 0:I.name)||O.stateId;E[O.stateId]||(E[O.stateId]={stateName:q,districts:[]}),E[O.stateId].districts.push(O)}),Object.values(E)},[A,N]);wt.useEffect(()=>{if(!t){S([]);return}if(h.length>0){const E=Array.from(new Set(j.filter(O=>h.includes(O.id)).map(O=>O.stateId).filter(Boolean)));S(E)}},[t]);const $=E=>{m(E),S([]),p([])},P=(E,O)=>{if(O)S(I=>[...I,E]);else{S(q=>q.filter(G=>G!==E));const I=j.filter(q=>q.stateId===E).map(q=>q.id);p(h.filter(q=>!I.includes(q)))}};return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[n?"Edit":"Add"," Regional Office"]}),e.jsx(bs,{children:"Configure regional office details and coverage area"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{children:"Region Name"}),e.jsx(at,{placeholder:"e.g., Delhi NCR Region",className:"mt-2 text-slate-900",value:r,onChange:E=>a(E.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Zone"}),e.jsxs(At,{value:d,onValueChange:$,children:[e.jsx(Dt,{className:"mt-2 text-slate-900",children:e.jsx(kt,{placeholder:"Select zone"})}),e.jsx(Rt,{children:v.map(E=>e.jsx(Me,{value:E.id,children:E.name},E.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Regional Manager"}),e.jsxs(At,{value:f,onValueChange:x,children:[e.jsx(Dt,{className:"mt-2 w-full text-slate-900",children:e.jsx(kt,{placeholder:"Select from available users"})}),e.jsx(Rt,{className:"max-h-60",children:w.map(E=>e.jsxs(Me,{value:E.id,children:[E.name||E.fullName,E.email?` — ${E.email}`:""]},E.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Description"}),e.jsx(Gs,{placeholder:"Describe the region...",className:"mt-2 text-slate-900",rows:2,value:l,onChange:E=>o(E.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{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:R.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:R.map(E=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Tn,{id:`region-state-${E.id}`,checked:C.includes(E.id),disabled:!d,onCheckedChange:O=>P(E.id,!!O)}),e.jsx("label",{htmlFor:`region-state-${E.id}`,className:`text-sm cursor-pointer ${d?"text-slate-900":"text-slate-400"}`,children:E.name})]},E.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(de,{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"}):L.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(vp,{children:L.map(({stateName:E,districts:O})=>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:E}),e.jsx("div",{className:"space-y-2 ml-1",children:O.map(I=>{const q=D[I.id],G=I.zoneId&&I.zoneId!==d&&I.regionId!==n,Y=!!(q||G),V=q?`Already assigned to region: ${q}`:G?"Belongs to a different zone":"";return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(uj,{children:[e.jsx(hj,{asChild:!0,children:e.jsxs("div",{className:"flex items-center space-x-2 w-full",children:[e.jsx(Tn,{id:`region-district-${I.id}`,disabled:Y,checked:h.includes(I.id),onCheckedChange:Q=>{p(Q?[...h,I.id]:h.filter(_=>_!==I.id))}}),e.jsxs("label",{htmlFor:`region-district-${I.id}`,className:`text-sm flex-1 ${Y?"text-slate-400 cursor-not-allowed line-through":"text-slate-900 cursor-pointer"}`,children:[I.name,q&&e.jsxs("span",{className:"ml-2 text-xs text-red-400 font-normal no-underline",style:{textDecoration:"none"},children:["(in ",q,")"]})]})]})}),Y&&V&&e.jsx(mj,{children:e.jsx("p",{className:"text-xs",children:V})})]})},I.id)})})]},E))})}),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(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",onClick:u,children:"Save Regional Office"})]})]})]})})};var bp="Switch",[XH]=ga(bp),[JH,eW]=XH(bp),L_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:l,required:o,disabled:d,value:m="on",onCheckedChange:f,form:x,...h}=t,[p,u]=g.useState(null),w=Ks(s,C=>u(C)),v=g.useRef(!1),N=p?x||!!p.closest("form"):!0,[j,y]=$i({prop:a,defaultProp:l??!1,onChange:f,caller:bp});return e.jsxs(JH,{scope:n,checked:j,disabled:d,children:[e.jsx(ws.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":B_(j),"data-disabled":d?"":void 0,disabled:d,value:m,...h,ref:w,onClick:Wt(t.onClick,C=>{y(S=>!S),N&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),N&&e.jsx(F_,{control:p,bubbles:!v.current,name:r,value:m,checked:j,required:o,disabled:d,form:x,style:{transform:"translateX(-100%)"}})]})});L_.displayName=bp;var I_="SwitchThumb",M_=g.forwardRef((t,s)=>{const{__scopeSwitch:n,...r}=t,a=eW(I_,n);return e.jsx(ws.span,{"data-state":B_(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:s})});M_.displayName=I_;var tW="SwitchBubbleInput",F_=g.forwardRef(({__scopeSwitch:t,control:s,checked:n,bubbles:r=!0,...a},l)=>{const o=g.useRef(null),d=Ks(o,l),m=Xy(n),f=Jy(s);return g.useEffect(()=>{const x=o.current;if(!x)return;const h=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(h,"checked").set;if(m!==n&&u){const w=new Event("click",{bubbles:r});u.call(x,n),x.dispatchEvent(w)}},[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}})});F_.displayName=tW;function B_(t){return t?"checked":"unchecked"}var sW=L_,nW=M_;function jp({className:t,...s}){return e.jsx(sW,{"data-slot":"switch",className:jt("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(nW,{"data-slot":"switch-thumb",className:jt("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 t0,VS;function rW(){if(VS)return t0;VS=1;function t(){this.__data__=[],this.size=0}return t0=t,t0}var s0,HS;function $_(){if(HS)return s0;HS=1;function t(s,n){return s===n||s!==s&&n!==n}return s0=t,s0}var n0,WS;function Np(){if(WS)return n0;WS=1;var t=$_();function s(n,r){for(var a=n.length;a--;)if(t(n[a][0],r))return a;return-1}return n0=s,n0}var r0,GS;function aW(){if(GS)return r0;GS=1;var t=Np(),s=Array.prototype,n=s.splice;function r(a){var l=this.__data__,o=t(l,a);if(o<0)return!1;var d=l.length-1;return o==d?l.pop():n.call(l,o,1),--this.size,!0}return r0=r,r0}var a0,KS;function iW(){if(KS)return a0;KS=1;var t=Np();function s(n){var r=this.__data__,a=t(r,n);return a<0?void 0:r[a][1]}return a0=s,a0}var i0,YS;function lW(){if(YS)return i0;YS=1;var t=Np();function s(n){return t(this.__data__,n)>-1}return i0=s,i0}var l0,ZS;function oW(){if(ZS)return l0;ZS=1;var t=Np();function s(n,r){var a=this.__data__,l=t(a,n);return l<0?(++this.size,a.push([n,r])):a[l][1]=r,this}return l0=s,l0}var o0,QS;function wp(){if(QS)return o0;QS=1;var t=rW(),s=aW(),n=iW(),r=lW(),a=oW();function l(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 l.prototype.clear=t,l.prototype.delete=s,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,o0=l,o0}var c0,XS;function cW(){if(XS)return c0;XS=1;var t=wp();function s(){this.__data__=new t,this.size=0}return c0=s,c0}var d0,JS;function dW(){if(JS)return d0;JS=1;function t(s){var n=this.__data__,r=n.delete(s);return this.size=n.size,r}return d0=t,d0}var u0,e2;function uW(){if(e2)return u0;e2=1;function t(s){return this.__data__.get(s)}return u0=t,u0}var h0,t2;function hW(){if(t2)return h0;t2=1;function t(s){return this.__data__.has(s)}return h0=t,h0}var m0,s2;function q_(){if(s2)return m0;s2=1;var t=typeof Go=="object"&&Go&&Go.Object===Object&&Go;return m0=t,m0}var f0,n2;function jl(){if(n2)return f0;n2=1;var t=q_(),s=typeof self=="object"&&self&&self.Object===Object&&self,n=t||s||Function("return this")();return f0=n,f0}var p0,r2;function pj(){if(r2)return p0;r2=1;var t=jl(),s=t.Symbol;return p0=s,p0}var x0,a2;function mW(){if(a2)return x0;a2=1;var t=pj(),s=Object.prototype,n=s.hasOwnProperty,r=s.toString,a=t?t.toStringTag:void 0;function l(o){var d=n.call(o,a),m=o[a];try{o[a]=void 0;var f=!0}catch{}var x=r.call(o);return f&&(d?o[a]=m:delete o[a]),x}return x0=l,x0}var g0,i2;function fW(){if(i2)return g0;i2=1;var t=Object.prototype,s=t.toString;function n(r){return s.call(r)}return g0=n,g0}var v0,l2;function Sp(){if(l2)return v0;l2=1;var t=pj(),s=mW(),n=fW(),r="[object Null]",a="[object Undefined]",l=t?t.toStringTag:void 0;function o(d){return d==null?d===void 0?a:r:l&&l in Object(d)?s(d):n(d)}return v0=o,v0}var y0,o2;function z_(){if(o2)return y0;o2=1;function t(s){var n=typeof s;return s!=null&&(n=="object"||n=="function")}return y0=t,y0}var b0,c2;function U_(){if(c2)return b0;c2=1;var t=Sp(),s=z_(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function o(d){if(!s(d))return!1;var m=t(d);return m==r||m==a||m==n||m==l}return b0=o,b0}var j0,d2;function pW(){if(d2)return j0;d2=1;var t=jl(),s=t["__core-js_shared__"];return j0=s,j0}var N0,u2;function xW(){if(u2)return N0;u2=1;var t=pW(),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 N0=n,N0}var w0,h2;function V_(){if(h2)return w0;h2=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 w0=n,w0}var S0,m2;function gW(){if(m2)return S0;m2=1;var t=U_(),s=xW(),n=z_(),r=V_(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,o=Function.prototype,d=Object.prototype,m=o.toString,f=d.hasOwnProperty,x=RegExp("^"+m.call(f).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(p){if(!n(p)||s(p))return!1;var u=t(p)?x:l;return u.test(r(p))}return S0=h,S0}var C0,f2;function vW(){if(f2)return C0;f2=1;function t(s,n){return s==null?void 0:s[n]}return C0=t,C0}var A0,p2;function Dd(){if(p2)return A0;p2=1;var t=gW(),s=vW();function n(r,a){var l=s(r,a);return t(l)?l:void 0}return A0=n,A0}var k0,x2;function xj(){if(x2)return k0;x2=1;var t=Dd(),s=jl(),n=t(s,"Map");return k0=n,k0}var D0,g2;function Cp(){if(g2)return D0;g2=1;var t=Dd(),s=t(Object,"create");return D0=s,D0}var R0,v2;function yW(){if(v2)return R0;v2=1;var t=Cp();function s(){this.__data__=t?t(null):{},this.size=0}return R0=s,R0}var E0,y2;function bW(){if(y2)return E0;y2=1;function t(s){var n=this.has(s)&&delete this.__data__[s];return this.size-=n?1:0,n}return E0=t,E0}var _0,b2;function jW(){if(b2)return _0;b2=1;var t=Cp(),s="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(l){var o=this.__data__;if(t){var d=o[l];return d===s?void 0:d}return r.call(o,l)?o[l]:void 0}return _0=a,_0}var T0,j2;function NW(){if(j2)return T0;j2=1;var t=Cp(),s=Object.prototype,n=s.hasOwnProperty;function r(a){var l=this.__data__;return t?l[a]!==void 0:n.call(l,a)}return T0=r,T0}var P0,N2;function wW(){if(N2)return P0;N2=1;var t=Cp(),s="__lodash_hash_undefined__";function n(r,a){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=t&&a===void 0?s:a,this}return P0=n,P0}var O0,w2;function SW(){if(w2)return O0;w2=1;var t=yW(),s=bW(),n=jW(),r=NW(),a=wW();function l(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 l.prototype.clear=t,l.prototype.delete=s,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,O0=l,O0}var L0,S2;function CW(){if(S2)return L0;S2=1;var t=SW(),s=wp(),n=xj();function r(){this.size=0,this.__data__={hash:new t,map:new(n||s),string:new t}}return L0=r,L0}var I0,C2;function AW(){if(C2)return I0;C2=1;function t(s){var n=typeof s;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?s!=="__proto__":s===null}return I0=t,I0}var M0,A2;function Ap(){if(A2)return M0;A2=1;var t=AW();function s(n,r){var a=n.__data__;return t(r)?a[typeof r=="string"?"string":"hash"]:a.map}return M0=s,M0}var F0,k2;function kW(){if(k2)return F0;k2=1;var t=Ap();function s(n){var r=t(this,n).delete(n);return this.size-=r?1:0,r}return F0=s,F0}var B0,D2;function DW(){if(D2)return B0;D2=1;var t=Ap();function s(n){return t(this,n).get(n)}return B0=s,B0}var $0,R2;function RW(){if(R2)return $0;R2=1;var t=Ap();function s(n){return t(this,n).has(n)}return $0=s,$0}var q0,E2;function EW(){if(E2)return q0;E2=1;var t=Ap();function s(n,r){var a=t(this,n),l=a.size;return a.set(n,r),this.size+=a.size==l?0:1,this}return q0=s,q0}var z0,_2;function H_(){if(_2)return z0;_2=1;var t=CW(),s=kW(),n=DW(),r=RW(),a=EW();function l(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 l.prototype.clear=t,l.prototype.delete=s,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,z0=l,z0}var U0,T2;function _W(){if(T2)return U0;T2=1;var t=wp(),s=xj(),n=H_(),r=200;function a(l,o){var d=this.__data__;if(d instanceof t){var m=d.__data__;if(!s||m.length<r-1)return m.push([l,o]),this.size=++d.size,this;d=this.__data__=new n(m)}return d.set(l,o),this.size=d.size,this}return U0=a,U0}var V0,P2;function TW(){if(P2)return V0;P2=1;var t=wp(),s=cW(),n=dW(),r=uW(),a=hW(),l=_W();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=l,V0=o,V0}var H0,O2;function PW(){if(O2)return H0;O2=1;var t="__lodash_hash_undefined__";function s(n){return this.__data__.set(n,t),this}return H0=s,H0}var W0,L2;function OW(){if(L2)return W0;L2=1;function t(s){return this.__data__.has(s)}return W0=t,W0}var G0,I2;function LW(){if(I2)return G0;I2=1;var t=H_(),s=PW(),n=OW();function r(a){var l=-1,o=a==null?0:a.length;for(this.__data__=new t;++l<o;)this.add(a[l])}return r.prototype.add=r.prototype.push=s,r.prototype.has=n,G0=r,G0}var K0,M2;function IW(){if(M2)return K0;M2=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 K0=t,K0}var Y0,F2;function MW(){if(F2)return Y0;F2=1;function t(s,n){return s.has(n)}return Y0=t,Y0}var Z0,B2;function W_(){if(B2)return Z0;B2=1;var t=LW(),s=IW(),n=MW(),r=1,a=2;function l(o,d,m,f,x,h){var p=m&r,u=o.length,w=d.length;if(u!=w&&!(p&&w>u))return!1;var v=h.get(o),N=h.get(d);if(v&&N)return v==d&&N==o;var j=-1,y=!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 R=p?f(D,S,j,d,o,h):f(S,D,j,o,d,h);if(R!==void 0){if(R)continue;y=!1;break}if(C){if(!s(d,function(A,L){if(!n(C,L)&&(S===A||x(S,A,m,f,h)))return C.push(L)})){y=!1;break}}else if(!(S===D||x(S,D,m,f,h))){y=!1;break}}return h.delete(o),h.delete(d),y}return Z0=l,Z0}var Q0,$2;function FW(){if($2)return Q0;$2=1;var t=jl(),s=t.Uint8Array;return Q0=s,Q0}var X0,q2;function BW(){if(q2)return X0;q2=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a,l){r[++n]=[l,a]}),r}return X0=t,X0}var J0,z2;function $W(){if(z2)return J0;z2=1;function t(s){var n=-1,r=Array(s.size);return s.forEach(function(a){r[++n]=a}),r}return J0=t,J0}var ev,U2;function qW(){if(U2)return ev;U2=1;var t=pj(),s=FW(),n=$_(),r=W_(),a=BW(),l=$W(),o=1,d=2,m="[object Boolean]",f="[object Date]",x="[object Error]",h="[object Map]",p="[object Number]",u="[object RegExp]",w="[object Set]",v="[object String]",N="[object Symbol]",j="[object ArrayBuffer]",y="[object DataView]",C=t?t.prototype:void 0,S=C?C.valueOf:void 0;function D(R,A,L,$,P,E,O){switch(L){case y:if(R.byteLength!=A.byteLength||R.byteOffset!=A.byteOffset)return!1;R=R.buffer,A=A.buffer;case j:return!(R.byteLength!=A.byteLength||!E(new s(R),new s(A)));case m:case f:case p:return n(+R,+A);case x:return R.name==A.name&&R.message==A.message;case u:case v:return R==A+"";case h:var I=a;case w:var q=$&o;if(I||(I=l),R.size!=A.size&&!q)return!1;var G=O.get(R);if(G)return G==A;$|=d,O.set(R,A);var Y=r(I(R),I(A),$,P,E,O);return O.delete(R),Y;case N:if(S)return S.call(R)==S.call(A)}return!1}return ev=D,ev}var tv,V2;function zW(){if(V2)return tv;V2=1;function t(s,n){for(var r=-1,a=n.length,l=s.length;++r<a;)s[l+r]=n[r];return s}return tv=t,tv}var sv,H2;function gj(){if(H2)return sv;H2=1;var t=Array.isArray;return sv=t,sv}var nv,W2;function UW(){if(W2)return nv;W2=1;var t=zW(),s=gj();function n(r,a,l){var o=a(r);return s(r)?o:t(o,l(r))}return nv=n,nv}var rv,G2;function VW(){if(G2)return rv;G2=1;function t(s,n){for(var r=-1,a=s==null?0:s.length,l=0,o=[];++r<a;){var d=s[r];n(d,r,s)&&(o[l++]=d)}return o}return rv=t,rv}var av,K2;function HW(){if(K2)return av;K2=1;function t(){return[]}return av=t,av}var iv,Y2;function WW(){if(Y2)return iv;Y2=1;var t=VW(),s=HW(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(o){return o==null?[]:(o=Object(o),t(a(o),function(d){return r.call(o,d)}))}:s;return iv=l,iv}var lv,Z2;function GW(){if(Z2)return lv;Z2=1;function t(s,n){for(var r=-1,a=Array(s);++r<s;)a[r]=n(r);return a}return lv=t,lv}var ov,Q2;function kp(){if(Q2)return ov;Q2=1;function t(s){return s!=null&&typeof s=="object"}return ov=t,ov}var cv,X2;function KW(){if(X2)return cv;X2=1;var t=Sp(),s=kp(),n="[object Arguments]";function r(a){return s(a)&&t(a)==n}return cv=r,cv}var dv,J2;function YW(){if(J2)return dv;J2=1;var t=KW(),s=kp(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,l=t((function(){return arguments})())?t:function(o){return s(o)&&r.call(o,"callee")&&!a.call(o,"callee")};return dv=l,dv}var gu={exports:{}},uv,eC;function ZW(){if(eC)return uv;eC=1;function t(){return!1}return uv=t,uv}gu.exports;var tC;function G_(){return tC||(tC=1,(function(t,s){var n=jl(),r=ZW(),a=s&&!s.nodeType&&s,l=a&&!0&&t&&!t.nodeType&&t,o=l&&l.exports===a,d=o?n.Buffer:void 0,m=d?d.isBuffer:void 0,f=m||r;t.exports=f})(gu,gu.exports)),gu.exports}var hv,sC;function QW(){if(sC)return hv;sC=1;var t=9007199254740991,s=/^(?:0|[1-9]\d*)$/;function n(r,a){var l=typeof r;return a=a??t,!!a&&(l=="number"||l!="symbol"&&s.test(r))&&r>-1&&r%1==0&&r<a}return hv=n,hv}var mv,nC;function K_(){if(nC)return mv;nC=1;var t=9007199254740991;function s(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return mv=s,mv}var fv,rC;function XW(){if(rC)return fv;rC=1;var t=Sp(),s=K_(),n=kp(),r="[object Arguments]",a="[object Array]",l="[object Boolean]",o="[object Date]",d="[object Error]",m="[object Function]",f="[object Map]",x="[object Number]",h="[object Object]",p="[object RegExp]",u="[object Set]",w="[object String]",v="[object WeakMap]",N="[object ArrayBuffer]",j="[object DataView]",y="[object Float32Array]",C="[object Float64Array]",S="[object Int8Array]",D="[object Int16Array]",R="[object Int32Array]",A="[object Uint8Array]",L="[object Uint8ClampedArray]",$="[object Uint16Array]",P="[object Uint32Array]",E={};E[y]=E[C]=E[S]=E[D]=E[R]=E[A]=E[L]=E[$]=E[P]=!0,E[r]=E[a]=E[N]=E[l]=E[j]=E[o]=E[d]=E[m]=E[f]=E[x]=E[h]=E[p]=E[u]=E[w]=E[v]=!1;function O(I){return n(I)&&s(I.length)&&!!E[t(I)]}return fv=O,fv}var pv,aC;function JW(){if(aC)return pv;aC=1;function t(s){return function(n){return s(n)}}return pv=t,pv}var vu={exports:{}};vu.exports;var iC;function eG(){return iC||(iC=1,(function(t,s){var n=q_(),r=s&&!s.nodeType&&s,a=r&&!0&&t&&!t.nodeType&&t,l=a&&a.exports===r,o=l&&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})(vu,vu.exports)),vu.exports}var xv,lC;function Y_(){if(lC)return xv;lC=1;var t=XW(),s=JW(),n=eG(),r=n&&n.isTypedArray,a=r?s(r):t;return xv=a,xv}var gv,oC;function tG(){if(oC)return gv;oC=1;var t=GW(),s=YW(),n=gj(),r=G_(),a=QW(),l=Y_(),o=Object.prototype,d=o.hasOwnProperty;function m(f,x){var h=n(f),p=!h&&s(f),u=!h&&!p&&r(f),w=!h&&!p&&!u&&l(f),v=h||p||u||w,N=v?t(f.length,String):[],j=N.length;for(var y in f)(x||d.call(f,y))&&!(v&&(y=="length"||u&&(y=="offset"||y=="parent")||w&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||a(y,j)))&&N.push(y);return N}return gv=m,gv}var vv,cC;function sG(){if(cC)return vv;cC=1;var t=Object.prototype;function s(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||t;return n===a}return vv=s,vv}var yv,dC;function nG(){if(dC)return yv;dC=1;function t(s,n){return function(r){return s(n(r))}}return yv=t,yv}var bv,uC;function rG(){if(uC)return bv;uC=1;var t=nG(),s=t(Object.keys,Object);return bv=s,bv}var jv,hC;function aG(){if(hC)return jv;hC=1;var t=sG(),s=rG(),n=Object.prototype,r=n.hasOwnProperty;function a(l){if(!t(l))return s(l);var o=[];for(var d in Object(l))r.call(l,d)&&d!="constructor"&&o.push(d);return o}return jv=a,jv}var Nv,mC;function iG(){if(mC)return Nv;mC=1;var t=U_(),s=K_();function n(r){return r!=null&&s(r.length)&&!t(r)}return Nv=n,Nv}var wv,fC;function lG(){if(fC)return wv;fC=1;var t=tG(),s=aG(),n=iG();function r(a){return n(a)?t(a):s(a)}return wv=r,wv}var Sv,pC;function oG(){if(pC)return Sv;pC=1;var t=UW(),s=WW(),n=lG();function r(a){return t(a,n,s)}return Sv=r,Sv}var Cv,xC;function cG(){if(xC)return Cv;xC=1;var t=oG(),s=1,n=Object.prototype,r=n.hasOwnProperty;function a(l,o,d,m,f,x){var h=d&s,p=t(l),u=p.length,w=t(o),v=w.length;if(u!=v&&!h)return!1;for(var N=u;N--;){var j=p[N];if(!(h?j in o:r.call(o,j)))return!1}var y=x.get(l),C=x.get(o);if(y&&C)return y==o&&C==l;var S=!0;x.set(l,o),x.set(o,l);for(var D=h;++N<u;){j=p[N];var R=l[j],A=o[j];if(m)var L=h?m(A,R,j,o,l,x):m(R,A,j,l,o,x);if(!(L===void 0?R===A||f(R,A,d,m,x):L)){S=!1;break}D||(D=j=="constructor")}if(S&&!D){var $=l.constructor,P=o.constructor;$!=P&&"constructor"in l&&"constructor"in o&&!(typeof $=="function"&&$ instanceof $&&typeof P=="function"&&P instanceof P)&&(S=!1)}return x.delete(l),x.delete(o),S}return Cv=a,Cv}var Av,gC;function dG(){if(gC)return Av;gC=1;var t=Dd(),s=jl(),n=t(s,"DataView");return Av=n,Av}var kv,vC;function uG(){if(vC)return kv;vC=1;var t=Dd(),s=jl(),n=t(s,"Promise");return kv=n,kv}var Dv,yC;function hG(){if(yC)return Dv;yC=1;var t=Dd(),s=jl(),n=t(s,"Set");return Dv=n,Dv}var Rv,bC;function mG(){if(bC)return Rv;bC=1;var t=Dd(),s=jl(),n=t(s,"WeakMap");return Rv=n,Rv}var Ev,jC;function fG(){if(jC)return Ev;jC=1;var t=dG(),s=xj(),n=uG(),r=hG(),a=mG(),l=Sp(),o=V_(),d="[object Map]",m="[object Object]",f="[object Promise]",x="[object Set]",h="[object WeakMap]",p="[object DataView]",u=o(t),w=o(s),v=o(n),N=o(r),j=o(a),y=l;return(t&&y(new t(new ArrayBuffer(1)))!=p||s&&y(new s)!=d||n&&y(n.resolve())!=f||r&&y(new r)!=x||a&&y(new a)!=h)&&(y=function(C){var S=l(C),D=S==m?C.constructor:void 0,R=D?o(D):"";if(R)switch(R){case u:return p;case w:return d;case v:return f;case N:return x;case j:return h}return S}),Ev=y,Ev}var _v,NC;function pG(){if(NC)return _v;NC=1;var t=TW(),s=W_(),n=qW(),r=cG(),a=fG(),l=gj(),o=G_(),d=Y_(),m=1,f="[object Arguments]",x="[object Array]",h="[object Object]",p=Object.prototype,u=p.hasOwnProperty;function w(v,N,j,y,C,S){var D=l(v),R=l(N),A=D?x:a(v),L=R?x:a(N);A=A==f?h:A,L=L==f?h:L;var $=A==h,P=L==h,E=A==L;if(E&&o(v)){if(!o(N))return!1;D=!0,$=!1}if(E&&!$)return S||(S=new t),D||d(v)?s(v,N,j,y,C,S):n(v,N,A,j,y,C,S);if(!(j&m)){var O=$&&u.call(v,"__wrapped__"),I=P&&u.call(N,"__wrapped__");if(O||I){var q=O?v.value():v,G=I?N.value():N;return S||(S=new t),C(q,G,j,y,S)}}return E?(S||(S=new t),r(v,N,j,y,C,S)):!1}return _v=w,_v}var Tv,wC;function xG(){if(wC)return Tv;wC=1;var t=pG(),s=kp();function n(r,a,l,o,d){return r===a?!0:r==null||a==null||!s(r)&&!s(a)?r!==r&&a!==a:t(r,a,l,o,n,d)}return Tv=n,Tv}var Pv,SC;function gG(){if(SC)return Pv;SC=1;var t=xG();function s(n,r){return t(n,r)}return Pv=s,Pv}var Gm={exports:{}};/*!
|
||
* Quill Editor v1.3.7
|
||
* https://quilljs.com/
|
||
* Copyright (c) 2014, Jason Chen
|
||
* Copyright (c) 2013, salesforce.com
|
||
*/var vG=Gm.exports,CC;function yG(){return CC||(CC=1,(function(t,s){(function(r,a){t.exports=a()})(typeof self<"u"?self:vG,function(){return(function(n){var r={};function a(l){if(r[l])return r[l].exports;var o=r[l]={i:l,l:!1,exports:{}};return n[l].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=n,a.c=r,a.d=function(l,o,d){a.o(l,o)||Object.defineProperty(l,o,{configurable:!1,enumerable:!0,get:d})},a.n=function(l){var o=l&&l.__esModule?function(){return l.default}:function(){return l};return a.d(o,"a",o),o},a.o=function(l,o){return Object.prototype.hasOwnProperty.call(l,o)},a.p="",a(a.s=109)})([(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(17),o=a(18),d=a(19),m=a(45),f=a(46),x=a(47),h=a(48),p=a(49),u=a(12),w=a(32),v=a(33),N=a(31),j=a(1),y={Scope:j.Scope,create:j.create,find:j.find,query:j.query,register:j.register,Container:l.default,Format:o.default,Leaf:d.default,Embed:h.default,Scroll:m.default,Block:x.default,Inline:f.default,Text:p.default,Attributor:{Attribute:u.default,Class:w.default,Style:v.default,Store:N.default}};r.default=y}),(function(n,r,a){var l=this&&this.__extends||(function(){var N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,y){j.__proto__=y}||function(j,y){for(var C in y)y.hasOwnProperty(C)&&(j[C]=y[C])};return function(j,y){N(j,y);function C(){this.constructor=j}j.prototype=y===null?Object.create(y):(C.prototype=y.prototype,new C)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=(function(N){l(j,N);function j(y){var C=this;return y="[Parchment] "+y,C=N.call(this,y)||this,C.message=y,C.name=C.constructor.name,C}return j})(Error);r.ParchmentError=o;var d={},m={},f={},x={};r.DATA_KEY="__blot";var h;(function(N){N[N.TYPE=3]="TYPE",N[N.LEVEL=12]="LEVEL",N[N.ATTRIBUTE=13]="ATTRIBUTE",N[N.BLOT=14]="BLOT",N[N.INLINE=7]="INLINE",N[N.BLOCK=11]="BLOCK",N[N.BLOCK_BLOT=10]="BLOCK_BLOT",N[N.INLINE_BLOT=6]="INLINE_BLOT",N[N.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",N[N.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",N[N.ANY=15]="ANY"})(h=r.Scope||(r.Scope={}));function p(N,j){var y=w(N);if(y==null)throw new o("Unable to create "+N+" blot");var C=y,S=N instanceof Node||N.nodeType===Node.TEXT_NODE?N:C.create(j);return new C(S,j)}r.create=p;function u(N,j){return j===void 0&&(j=!1),N==null?null:N[r.DATA_KEY]!=null?N[r.DATA_KEY].blot:j?u(N.parentNode,j):null}r.find=u;function w(N,j){j===void 0&&(j=h.ANY);var y;if(typeof N=="string")y=x[N]||d[N];else if(N instanceof Text||N.nodeType===Node.TEXT_NODE)y=x.text;else if(typeof N=="number")N&h.LEVEL&h.BLOCK?y=x.block:N&h.LEVEL&h.INLINE&&(y=x.inline);else if(N instanceof HTMLElement){var C=(N.getAttribute("class")||"").split(/\s+/);for(var S in C)if(y=m[C[S]],y)break;y=y||f[N.tagName]}return y==null?null:j&h.LEVEL&y.scope&&j&h.TYPE&y.scope?y:null}r.query=w;function v(){for(var N=[],j=0;j<arguments.length;j++)N[j]=arguments[j];if(N.length>1)return N.map(function(S){return v(S)});var y=N[0];if(typeof y.blotName!="string"&&typeof y.attrName!="string")throw new o("Invalid definition");if(y.blotName==="abstract")throw new o("Cannot register abstract class");if(x[y.blotName||y.attrName]=y,typeof y.keyName=="string")d[y.keyName]=y;else if(y.className!=null&&(m[y.className]=y),y.tagName!=null){Array.isArray(y.tagName)?y.tagName=y.tagName.map(function(S){return S.toUpperCase()}):y.tagName=y.tagName.toUpperCase();var C=Array.isArray(y.tagName)?y.tagName:[y.tagName];C.forEach(function(S){(f[S]==null||y.className==null)&&(f[S]=y)})}return y}r.register=v}),(function(n,r,a){var l=a(51),o=a(11),d=a(3),m=a(20),f="\0",x=function(h){Array.isArray(h)?this.ops=h:h!=null&&Array.isArray(h.ops)?this.ops=h.ops:this.ops=[]};x.prototype.insert=function(h,p){var u={};return h.length===0?this:(u.insert=h,p!=null&&typeof p=="object"&&Object.keys(p).length>0&&(u.attributes=p),this.push(u))},x.prototype.delete=function(h){return h<=0?this:this.push({delete:h})},x.prototype.retain=function(h,p){if(h<=0)return this;var u={retain:h};return p!=null&&typeof p=="object"&&Object.keys(p).length>0&&(u.attributes=p),this.push(u)},x.prototype.push=function(h){var p=this.ops.length,u=this.ops[p-1];if(h=d(!0,{},h),typeof u=="object"){if(typeof h.delete=="number"&&typeof u.delete=="number")return this.ops[p-1]={delete:u.delete+h.delete},this;if(typeof u.delete=="number"&&h.insert!=null&&(p-=1,u=this.ops[p-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[p-1]={insert:u.insert+h.insert},typeof h.attributes=="object"&&(this.ops[p-1].attributes=h.attributes),this;if(typeof h.retain=="number"&&typeof u.retain=="number")return this.ops[p-1]={retain:u.retain+h.retain},typeof h.attributes=="object"&&(this.ops[p-1].attributes=h.attributes),this}}return p===this.ops.length?this.ops.push(h):this.ops.splice(p,0,h),this},x.prototype.chop=function(){var h=this.ops[this.ops.length-1];return h&&h.retain&&!h.attributes&&this.ops.pop(),this},x.prototype.filter=function(h){return this.ops.filter(h)},x.prototype.forEach=function(h){this.ops.forEach(h)},x.prototype.map=function(h){return this.ops.map(h)},x.prototype.partition=function(h){var p=[],u=[];return this.forEach(function(w){var v=h(w)?p:u;v.push(w)}),[p,u]},x.prototype.reduce=function(h,p){return this.ops.reduce(h,p)},x.prototype.changeLength=function(){return this.reduce(function(h,p){return p.insert?h+m.length(p):p.delete?h-p.delete:h},0)},x.prototype.length=function(){return this.reduce(function(h,p){return h+m.length(p)},0)},x.prototype.slice=function(h,p){h=h||0,typeof p!="number"&&(p=1/0);for(var u=[],w=m.iterator(this.ops),v=0;v<p&&w.hasNext();){var N;v<h?N=w.next(h-v):(N=w.next(p-v),u.push(N)),v+=m.length(N)}return new x(u)},x.prototype.compose=function(h){var p=m.iterator(this.ops),u=m.iterator(h.ops),w=[],v=u.peek();if(v!=null&&typeof v.retain=="number"&&v.attributes==null){for(var N=v.retain;p.peekType()==="insert"&&p.peekLength()<=N;)N-=p.peekLength(),w.push(p.next());v.retain-N>0&&u.next(v.retain-N)}for(var j=new x(w);p.hasNext()||u.hasNext();)if(u.peekType()==="insert")j.push(u.next());else if(p.peekType()==="delete")j.push(p.next());else{var y=Math.min(p.peekLength(),u.peekLength()),C=p.next(y),S=u.next(y);if(typeof S.retain=="number"){var D={};typeof C.retain=="number"?D.retain=y:D.insert=C.insert;var R=m.attributes.compose(C.attributes,S.attributes,typeof C.retain=="number");if(R&&(D.attributes=R),j.push(D),!u.hasNext()&&o(j.ops[j.ops.length-1],D)){var A=new x(p.rest());return j.concat(A).chop()}}else typeof S.delete=="number"&&typeof C.retain=="number"&&j.push(S)}return j.chop()},x.prototype.concat=function(h){var p=new x(this.ops.slice());return h.ops.length>0&&(p.push(h.ops[0]),p.ops=p.ops.concat(h.ops.slice(1))),p},x.prototype.diff=function(h,p){if(this.ops===h.ops)return new x;var u=[this,h].map(function(y){return y.map(function(C){if(C.insert!=null)return typeof C.insert=="string"?C.insert:f;var S=y===h?"on":"with";throw new Error("diff() called "+S+" non-document")}).join("")}),w=new x,v=l(u[0],u[1],p),N=m.iterator(this.ops),j=m.iterator(h.ops);return v.forEach(function(y){for(var C=y[1].length;C>0;){var S=0;switch(y[0]){case l.INSERT:S=Math.min(j.peekLength(),C),w.push(j.next(S));break;case l.DELETE:S=Math.min(C,N.peekLength()),N.next(S),w.delete(S);break;case l.EQUAL:S=Math.min(N.peekLength(),j.peekLength(),C);var D=N.next(S),R=j.next(S);o(D.insert,R.insert)?w.retain(S,m.attributes.diff(D.attributes,R.attributes)):w.push(R).delete(S);break}C-=S}}),w.chop()},x.prototype.eachLine=function(h,p){p=p||`
|
||
`;for(var u=m.iterator(this.ops),w=new x,v=0;u.hasNext();){if(u.peekType()!=="insert")return;var N=u.peek(),j=m.length(N)-u.peekLength(),y=typeof N.insert=="string"?N.insert.indexOf(p,j)-j:-1;if(y<0)w.push(u.next());else if(y>0)w.push(u.next(y));else{if(h(w,u.next(1).attributes||{},v)===!1)return;v+=1,w=new x}}w.length()>0&&h(w,{},v)},x.prototype.transform=function(h,p){if(p=!!p,typeof h=="number")return this.transformPosition(h,p);for(var u=m.iterator(this.ops),w=m.iterator(h.ops),v=new x;u.hasNext()||w.hasNext();)if(u.peekType()==="insert"&&(p||w.peekType()!=="insert"))v.retain(m.length(u.next()));else if(w.peekType()==="insert")v.push(w.next());else{var N=Math.min(u.peekLength(),w.peekLength()),j=u.next(N),y=w.next(N);if(j.delete)continue;y.delete?v.push(y):v.retain(N,m.attributes.transform(j.attributes,y.attributes,p))}return v.chop()},x.prototype.transformPosition=function(h,p){p=!!p;for(var u=m.iterator(this.ops),w=0;u.hasNext()&&w<=h;){var v=u.peekLength(),N=u.peekType();if(u.next(),N==="delete"){h-=Math.min(v,h-w);continue}else N==="insert"&&(w<h||!p)&&(h+=v);w+=v}return h},n.exports=x}),(function(n,r){var a=Object.prototype.hasOwnProperty,l=Object.prototype.toString,o=Object.defineProperty,d=Object.getOwnPropertyDescriptor,m=function(u){return typeof Array.isArray=="function"?Array.isArray(u):l.call(u)==="[object Array]"},f=function(u){if(!u||l.call(u)!=="[object Object]")return!1;var w=a.call(u,"constructor"),v=u.constructor&&u.constructor.prototype&&a.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!w&&!v)return!1;var N;for(N in u);return typeof N>"u"||a.call(u,N)},x=function(u,w){o&&w.name==="__proto__"?o(u,w.name,{enumerable:!0,configurable:!0,value:w.newValue,writable:!0}):u[w.name]=w.newValue},h=function(u,w){if(w==="__proto__")if(a.call(u,w)){if(d)return d(u,w).value}else return;return u[w]};n.exports=function p(){var u,w,v,N,j,y,C=arguments[0],S=1,D=arguments.length,R=!1;for(typeof C=="boolean"&&(R=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(w in u)v=h(C,w),N=h(u,w),C!==N&&(R&&N&&(f(N)||(j=m(N)))?(j?(j=!1,y=v&&m(v)?v:[]):y=v&&f(v)?v:{},x(C,{name:w,newValue:p(R,y,N)})):typeof N<"u"&&x(C,{name:w,newValue:N}));return C}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BlockEmbed=r.bubbleFormats=void 0;var l=(function(){function E(O,I){for(var q=0;q<I.length;q++){var G=I[q];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(O,G.key,G)}}return function(O,I,q){return I&&E(O.prototype,I),q&&E(O,q),O}})(),o=function E(O,I,q){O===null&&(O=Function.prototype);var G=Object.getOwnPropertyDescriptor(O,I);if(G===void 0){var Y=Object.getPrototypeOf(O);return Y===null?void 0:E(Y,I,q)}else{if("value"in G)return G.value;var V=G.get;return V===void 0?void 0:V.call(q)}},d=a(3),m=C(d),f=a(2),x=C(f),h=a(0),p=C(h),u=a(16),w=C(u),v=a(6),N=C(v),j=a(7),y=C(j);function C(E){return E&&E.__esModule?E:{default:E}}function S(E,O){if(!(E instanceof O))throw new TypeError("Cannot call a class as a function")}function D(E,O){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O&&(typeof O=="object"||typeof O=="function")?O:E}function R(E,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof O);E.prototype=Object.create(O&&O.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),O&&(Object.setPrototypeOf?Object.setPrototypeOf(E,O):E.__proto__=O)}var A=1,L=(function(E){R(O,E);function O(){return S(this,O),D(this,(O.__proto__||Object.getPrototypeOf(O)).apply(this,arguments))}return l(O,[{key:"attach",value:function(){o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"attach",this).call(this),this.attributes=new p.default.Attributor.Store(this.domNode)}},{key:"delta",value:function(){return new x.default().insert(this.value(),(0,m.default)(this.formats(),this.attributes.values()))}},{key:"format",value:function(q,G){var Y=p.default.query(q,p.default.Scope.BLOCK_ATTRIBUTE);Y!=null&&this.attributes.attribute(Y,G)}},{key:"formatAt",value:function(q,G,Y,V){this.format(Y,V)}},{key:"insertAt",value:function(q,G,Y){if(typeof G=="string"&&G.endsWith(`
|
||
`)){var V=p.default.create($.blotName);this.parent.insertBefore(V,q===0?this:this.next),V.insertAt(0,G.slice(0,-1))}else o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"insertAt",this).call(this,q,G,Y)}}]),O})(p.default.Embed);L.scope=p.default.Scope.BLOCK_BLOT;var $=(function(E){R(O,E);function O(I){S(this,O);var q=D(this,(O.__proto__||Object.getPrototypeOf(O)).call(this,I));return q.cache={},q}return l(O,[{key:"delta",value:function(){return this.cache.delta==null&&(this.cache.delta=this.descendants(p.default.Leaf).reduce(function(q,G){return G.length()===0?q:q.insert(G.value(),P(G))},new x.default).insert(`
|
||
`,P(this))),this.cache.delta}},{key:"deleteAt",value:function(q,G){o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"deleteAt",this).call(this,q,G),this.cache={}}},{key:"formatAt",value:function(q,G,Y,V){G<=0||(p.default.query(Y,p.default.Scope.BLOCK)?q+G===this.length()&&this.format(Y,V):o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"formatAt",this).call(this,q,Math.min(G,this.length()-q-1),Y,V),this.cache={})}},{key:"insertAt",value:function(q,G,Y){if(Y!=null)return o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"insertAt",this).call(this,q,G,Y);if(G.length!==0){var V=G.split(`
|
||
`),Q=V.shift();Q.length>0&&(q<this.length()-1||this.children.tail==null?o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"insertAt",this).call(this,Math.min(q,this.length()-1),Q):this.children.tail.insertAt(this.children.tail.length(),Q),this.cache={});var _=this;V.reduce(function(z,T){return _=_.split(z,!0),_.insertAt(0,T),T.length},q+Q.length)}}},{key:"insertBefore",value:function(q,G){var Y=this.children.head;o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"insertBefore",this).call(this,q,G),Y instanceof w.default&&Y.remove(),this.cache={}}},{key:"length",value:function(){return this.cache.length==null&&(this.cache.length=o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"length",this).call(this)+A),this.cache.length}},{key:"moveChildren",value:function(q,G){o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"moveChildren",this).call(this,q,G),this.cache={}}},{key:"optimize",value:function(q){o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"optimize",this).call(this,q),this.cache={}}},{key:"path",value:function(q){return o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"path",this).call(this,q,!0)}},{key:"removeChild",value:function(q){o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"removeChild",this).call(this,q),this.cache={}}},{key:"split",value:function(q){var G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(G&&(q===0||q>=this.length()-A)){var Y=this.clone();return q===0?(this.parent.insertBefore(Y,this),this):(this.parent.insertBefore(Y,this.next),Y)}else{var V=o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"split",this).call(this,q,G);return this.cache={},V}}}]),O})(p.default.Block);$.blotName="block",$.tagName="P",$.defaultChild="break",$.allowedChildren=[N.default,p.default.Embed,y.default];function P(E){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return E==null||(typeof E.formats=="function"&&(O=(0,m.default)(O,E.formats())),E.parent==null||E.parent.blotName=="scroll"||E.parent.statics.scope!==E.statics.scope)?O:P(E.parent,O)}r.bubbleFormats=P,r.BlockEmbed=L,r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.overload=r.expandConfig=void 0;var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},o=(function(){function _(z,T){var F=[],B=!0,K=!1,W=void 0;try{for(var H=z[Symbol.iterator](),X;!(B=(X=H.next()).done)&&(F.push(X.value),!(T&&F.length===T));B=!0);}catch(J){K=!0,W=J}finally{try{!B&&H.return&&H.return()}finally{if(K)throw W}}return F}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return _(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function _(z,T){for(var F=0;F<T.length;F++){var B=T[F];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(z,B.key,B)}}return function(z,T,F){return T&&_(z.prototype,T),F&&_(z,F),z}})();a(50);var m=a(2),f=P(m),x=a(14),h=P(x),p=a(8),u=P(p),w=a(9),v=P(w),N=a(0),j=P(N),y=a(15),C=P(y),S=a(3),D=P(S),R=a(10),A=P(R),L=a(34),$=P(L);function P(_){return _&&_.__esModule?_:{default:_}}function E(_,z,T){return z in _?Object.defineProperty(_,z,{value:T,enumerable:!0,configurable:!0,writable:!0}):_[z]=T,_}function O(_,z){if(!(_ instanceof z))throw new TypeError("Cannot call a class as a function")}var I=(0,A.default)("quill"),q=(function(){d(_,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&&I.error("Cannot import "+T+". Are you sure it was registered?"),this.imports[T]}},{key:"register",value:function(T,F){var B=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(typeof T!="string"){var W=T.attrName||T.blotName;typeof W=="string"?this.register("formats/"+W,T,F):Object.keys(T).forEach(function(H){B.register(H,T[H],F)})}else this.imports[T]!=null&&!K&&I.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 _(z){var T=this,F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(O(this,_),this.options=G(z,F),this.container=this.options.container,this.container==null)return I.error("Invalid Quill container",z);this.options.debug&&_.debug(this.options.debug);var B=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(W){W===u.default.events.TEXT_CHANGE&&T.root.classList.toggle("ql-blank",T.editor.isBlank())}),this.emitter.on(u.default.events.SCROLL_UPDATE,function(W,H){var X=T.selection.lastRange,J=X&&X.length===0?X.index:void 0;Y.call(T,function(){return T.editor.update(null,H,J)},W)});var K=this.clipboard.convert(`<div class='ql-editor' style="white-space: normal;">`+B+"<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(_,[{key:"addContainer",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof T=="string"){var B=T;T=document.createElement("div"),T.classList.add(B)}return this.container.insertBefore(T,F),T}},{key:"blur",value:function(){this.selection.setRange(null)}},{key:"deleteText",value:function(T,F,B){var K=this,W=V(T,F,B),H=o(W,4);return T=H[0],F=H[1],B=H[3],Y.call(this,function(){return K.editor.deleteText(T,F)},B,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 B=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:u.default.sources.API;return Y.call(this,function(){var W=B.getSelection(!0),H=new f.default;if(W==null)return H;if(j.default.query(T,j.default.Scope.BLOCK))H=B.editor.formatLine(W.index,W.length,E({},T,F));else{if(W.length===0)return B.selection.format(T,F),H;H=B.editor.formatText(W.index,W.length,E({},T,F))}return B.setSelection(W,u.default.sources.SILENT),H},K)}},{key:"formatLine",value:function(T,F,B,K,W){var H=this,X=void 0,J=V(T,F,B,K,W),ie=o(J,4);return T=ie[0],F=ie[1],X=ie[2],W=ie[3],Y.call(this,function(){return H.editor.formatLine(T,F,X)},W,T,0)}},{key:"formatText",value:function(T,F,B,K,W){var H=this,X=void 0,J=V(T,F,B,K,W),ie=o(J,4);return T=ie[0],F=ie[1],X=ie[2],W=ie[3],Y.call(this,function(){return H.editor.formatText(T,F,X)},W,T,0)}},{key:"getBounds",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,B=void 0;typeof T=="number"?B=this.selection.getBounds(T,F):B=this.selection.getBounds(T.index,T.length);var K=this.container.getBoundingClientRect();return{bottom:B.bottom-K.top,height:B.height,left:B.left-K.left,right:B.right-K.left,top:B.top-K.top,width:B.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,B=V(T,F),K=o(B,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,B=V(T,F),K=o(B,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,B){var K=this,W=arguments.length>3&&arguments[3]!==void 0?arguments[3]:_.sources.API;return Y.call(this,function(){return K.editor.insertEmbed(T,F,B)},W,T)}},{key:"insertText",value:function(T,F,B,K,W){var H=this,X=void 0,J=V(T,0,B,K,W),ie=o(J,4);return T=ie[0],X=ie[2],W=ie[3],Y.call(this,function(){return H.editor.insertText(T,F,X)},W,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,B){this.clipboard.dangerouslyPasteHTML(T,F,B)}},{key:"removeFormat",value:function(T,F,B){var K=this,W=V(T,F,B),H=o(W,4);return T=H[0],F=H[1],B=H[3],Y.call(this,function(){return K.editor.removeFormat(T,F)},B,T)}},{key:"scrollIntoView",value:function(){this.selection.scrollIntoView(this.scrollingContainer)}},{key:"setContents",value:function(T){var F=this,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Y.call(this,function(){T=new f.default(T);var K=F.getLength(),W=F.editor.deleteText(0,K),H=F.editor.applyDelta(T),X=H.ops[H.ops.length-1];X!=null&&typeof X.insert=="string"&&X.insert[X.insert.length-1]===`
|
||
`&&(F.editor.deleteText(F.getLength()-1,1),H.delete(1));var J=W.compose(H);return J},B)}},{key:"setSelection",value:function(T,F,B){if(T==null)this.selection.setRange(null,F||_.sources.API);else{var K=V(T,F,B),W=o(K,4);T=W[0],F=W[1],B=W[3],this.selection.setRange(new y.Range(T,F),B),B!==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,B=new f.default().insert(T);return this.setContents(B,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,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:u.default.sources.API;return Y.call(this,function(){return T=new f.default(T),F.editor.applyDelta(T,B)},B,!0)}}]),_})();q.DEFAULTS={bounds:null,formats:null,modules:{},placeholder:"",readOnly:!1,scrollingContainer:null,strict:!0,theme:"default"},q.events=u.default.events,q.sources=u.default.sources,q.version="1.3.7",q.imports={delta:f.default,parchment:j.default,"core/module":v.default,"core/theme":$.default};function G(_,z){if(z=(0,D.default)(!0,{container:_,modules:{clipboard:!0,keyboard:!0,history:!0}},z),!z.theme||z.theme===q.DEFAULTS.theme)z.theme=$.default;else if(z.theme=q.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(W){K.modules[W]===!0&&(K.modules[W]={})})});var F=Object.keys(T.modules).concat(Object.keys(z.modules)),B=F.reduce(function(K,W){var H=q.import("modules/"+W);return H==null?I.error("Cannot load "+W+" module. Are you sure you registered it?"):K[W]=H.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,{},q.DEFAULTS,{modules:B},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,W){return z.modules[W]&&(K[W]=z.modules[W]),K},{}),z}function Y(_,z,T,F){if(this.options.strict&&!this.isEnabled()&&z===u.default.sources.USER)return new f.default;var B=T==null?null:this.getSelection(),K=this.editor.delta,W=_();if(B!=null&&(T===!0&&(T=B.index),F==null?B=Q(B,W,z):F!==0&&(B=Q(B,T,F,z)),this.setSelection(B,u.default.sources.SILENT)),W.length()>0){var H,X=[u.default.events.TEXT_CHANGE,W,K,z];if((H=this.emitter).emit.apply(H,[u.default.events.EDITOR_CHANGE].concat(X)),z!==u.default.sources.SILENT){var J;(J=this.emitter).emit.apply(J,X)}}return W}function V(_,z,T,F,B){var K={};return typeof _.index=="number"&&typeof _.length=="number"?typeof z!="number"?(B=F,F=T,T=z,z=_.length,_=_.index):(z=_.length,_=_.index):typeof z!="number"&&(B=F,F=T,T=z,z=0),(typeof T>"u"?"undefined":l(T))==="object"?(K=T,B=F):typeof T=="string"&&(F!=null?K[T]=F:B=T),B=B||u.default.sources.API,[_,z,K,B]}function Q(_,z,T,F){if(_==null)return null;var B=void 0,K=void 0;if(z instanceof f.default){var W=[_.index,_.index+_.length].map(function(ie){return z.transformPosition(ie,F!==u.default.sources.USER)}),H=o(W,2);B=H[0],K=H[1]}else{var X=[_.index,_.index+_.length].map(function(ie){return ie<z||ie===z&&F===u.default.sources.USER?ie:T>=0?ie+T:Math.max(z,ie+T)}),J=o(X,2);B=J[0],K=J[1]}return new y.Range(B,K-B)}r.expandConfig=G,r.overload=V,r.default=q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function N(j,y){for(var C=0;C<y.length;C++){var S=y[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,y,C){return y&&N(j.prototype,y),C&&N(j,C),j}})(),o=function N(j,y,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,y);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:N(D,y,C)}else{if("value"in S)return S.value;var R=S.get;return R===void 0?void 0:R.call(C)}},d=a(7),m=h(d),f=a(0),x=h(f);function h(N){return N&&N.__esModule?N:{default:N}}function p(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")}function u(N,j){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:N}function w(N,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);N.prototype=Object.create(j&&j.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(N,j):N.__proto__=j)}var v=(function(N){w(j,N);function j(){return p(this,j),u(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return l(j,[{key:"formatAt",value:function(C,S,D,R){if(j.compare(this.statics.blotName,D)<0&&x.default.query(D,x.default.Scope.BLOT)){var A=this.isolate(C,S);R&&A.wrap(D,R)}else o(j.prototype.__proto__||Object.getPrototypeOf(j.prototype),"formatAt",this).call(this,C,S,D,R)}},{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),R=j.order.indexOf(S);return D>=0||R>=0?D-R:C===S?0:C<S?-1:1}}]),j})(x.default.Inline);v.allowedChildren=[v,x.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 l=a(0),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function m(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function f(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function x(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var h=(function(p){x(u,p);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 l=(function(){function y(C,S){for(var D=0;D<S.length;D++){var R=S[D];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(C,R.key,R)}}return function(C,S,D){return S&&y(C.prototype,S),D&&y(C,D),C}})(),o=function y(C,S,D){C===null&&(C=Function.prototype);var R=Object.getOwnPropertyDescriptor(C,S);if(R===void 0){var A=Object.getPrototypeOf(C);return A===null?void 0:y(A,S,D)}else{if("value"in R)return R.value;var L=R.get;return L===void 0?void 0:L.call(D)}},d=a(54),m=h(d),f=a(10),x=h(f);function h(y){return y&&y.__esModule?y:{default:y}}function p(y,C){if(!(y instanceof C))throw new TypeError("Cannot call a class as a function")}function u(y,C){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:y}function w(y,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);y.prototype=Object.create(C&&C.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(y,C):y.__proto__=C)}var v=(0,x.default)("quill:events"),N=["selectionchange","mousedown","mouseup","click"];N.forEach(function(y){document.addEventListener(y,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(R){if(R.__quill&&R.__quill.emitter){var A;(A=R.__quill.emitter).handleDOM.apply(A,S)}})})});var j=(function(y){w(C,y);function C(){p(this,C);var S=u(this,(C.__proto__||Object.getPrototypeOf(C)).call(this));return S.listeners={},S.on("error",v.error),S}return l(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 R=arguments.length,A=Array(R>1?R-1:0),L=1;L<R;L++)A[L-1]=arguments[L];(this.listeners[D.type]||[]).forEach(function($){var P=$.node,E=$.handler;(D.target===P||P.contains(D.target))&&E.apply(void 0,[D].concat(A))})}},{key:"listenDOM",value:function(D,R,A){this.listeners[D]||(this.listeners[D]=[]),this.listeners[D].push({node:R,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 l(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]:{};l(this,d),this.quill=m,this.options=f};o.DEFAULTS={},r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=["error","warn","log","info"],o="warn";function d(f){if(l.indexOf(f)<=l.indexOf(o)){for(var x,h=arguments.length,p=Array(h>1?h-1:0),u=1;u<h;u++)p[u-1]=arguments[u];(x=console)[f].apply(x,p)}}function m(f){return l.reduce(function(x,h){return x[h]=d.bind(console,h,f),x},{})}d.level=m.level=function(f){o=f},r.default=m}),(function(n,r,a){var l=Array.prototype.slice,o=a(52),d=a(53),m=n.exports=function(p,u,w){return w||(w={}),p===u?!0:p instanceof Date&&u instanceof Date?p.getTime()===u.getTime():!p||!u||typeof p!="object"&&typeof u!="object"?w.strict?p===u:p==u:h(p,u,w)};function f(p){return p==null}function x(p){return!(!p||typeof p!="object"||typeof p.length!="number"||typeof p.copy!="function"||typeof p.slice!="function"||p.length>0&&typeof p[0]!="number")}function h(p,u,w){var v,N;if(f(p)||f(u)||p.prototype!==u.prototype)return!1;if(d(p))return d(u)?(p=l.call(p),u=l.call(u),m(p,u,w)):!1;if(x(p)){if(!x(u)||p.length!==u.length)return!1;for(v=0;v<p.length;v++)if(p[v]!==u[v])return!1;return!0}try{var j=o(p),y=o(u)}catch{return!1}if(j.length!=y.length)return!1;for(j.sort(),y.sort(),v=j.length-1;v>=0;v--)if(j[v]!=y[v])return!1;for(v=j.length-1;v>=0;v--)if(N=j[v],!m(p[N],u[N],w))return!1;return typeof p==typeof u}}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(1),o=(function(){function d(m,f,x){x===void 0&&(x={}),this.attrName=m,this.keyName=f;var h=l.Scope.TYPE&l.Scope.ATTRIBUTE;x.scope!=null?this.scope=x.scope&l.Scope.LEVEL|h:this.scope=l.Scope.ATTRIBUTE,x.whitelist!=null&&(this.whitelist=x.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 x=l.query(m,l.Scope.BLOT&(this.scope|l.Scope.TYPE));return x==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 l=(function(){function L($,P){var E=[],O=!0,I=!1,q=void 0;try{for(var G=$[Symbol.iterator](),Y;!(O=(Y=G.next()).done)&&(E.push(Y.value),!(P&&E.length===P));O=!0);}catch(V){I=!0,q=V}finally{try{!O&&G.return&&G.return()}finally{if(I)throw q}}return E}return function($,P){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return L($,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function L($,P){for(var E=0;E<P.length;E++){var O=P[E];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty($,O.key,O)}}return function($,P,E){return P&&L($.prototype,P),E&&L($,E),$}})(),d=function L($,P,E){$===null&&($=Function.prototype);var O=Object.getOwnPropertyDescriptor($,P);if(O===void 0){var I=Object.getPrototypeOf($);return I===null?void 0:L(I,P,E)}else{if("value"in O)return O.value;var q=O.get;return q===void 0?void 0:q.call(E)}},m=a(2),f=y(m),x=a(0),h=y(x),p=a(4),u=y(p),w=a(6),v=y(w),N=a(7),j=y(N);function y(L){return L&&L.__esModule?L:{default:L}}function C(L,$){if(!(L instanceof $))throw new TypeError("Cannot call a class as a function")}function S(L,$){if(!L)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return $&&(typeof $=="object"||typeof $=="function")?$:L}function D(L,$){if(typeof $!="function"&&$!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof $);L.prototype=Object.create($&&$.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),$&&(Object.setPrototypeOf?Object.setPrototypeOf(L,$):L.__proto__=$)}var R=(function(L){D($,L);function $(){return C(this,$),S(this,($.__proto__||Object.getPrototypeOf($)).apply(this,arguments))}return $})(v.default);R.blotName="code",R.tagName="CODE";var A=(function(L){D($,L);function $(){return C(this,$),S(this,($.__proto__||Object.getPrototypeOf($)).apply(this,arguments))}return o($,[{key:"delta",value:function(){var E=this,O=this.domNode.textContent;return O.endsWith(`
|
||
`)&&(O=O.slice(0,-1)),O.split(`
|
||
`).reduce(function(I,q){return I.insert(q).insert(`
|
||
`,E.formats())},new f.default)}},{key:"format",value:function(E,O){if(!(E===this.statics.blotName&&O)){var I=this.descendant(j.default,this.length()-1),q=l(I,1),G=q[0];G!=null&&G.deleteAt(G.length()-1,1),d($.prototype.__proto__||Object.getPrototypeOf($.prototype),"format",this).call(this,E,O)}}},{key:"formatAt",value:function(E,O,I,q){if(O!==0&&!(h.default.query(I,h.default.Scope.BLOCK)==null||I===this.statics.blotName&&q===this.statics.formats(this.domNode))){var G=this.newlineIndex(E);if(!(G<0||G>=E+O)){var Y=this.newlineIndex(E,!0)+1,V=G-Y+1,Q=this.isolate(Y,V),_=Q.next;Q.format(I,q),_ instanceof $&&_.formatAt(0,E-Y+O-V,I,q)}}}},{key:"insertAt",value:function(E,O,I){if(I==null){var q=this.descendant(j.default,E),G=l(q,2),Y=G[0],V=G[1];Y.insertAt(V,O)}}},{key:"length",value:function(){var E=this.domNode.textContent.length;return this.domNode.textContent.endsWith(`
|
||
`)?E:E+1}},{key:"newlineIndex",value:function(E){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(O)return this.domNode.textContent.slice(0,E).lastIndexOf(`
|
||
`);var I=this.domNode.textContent.slice(E).indexOf(`
|
||
`);return I>-1?E+I:-1}},{key:"optimize",value:function(E){this.domNode.textContent.endsWith(`
|
||
`)||this.appendChild(h.default.create("text",`
|
||
`)),d($.prototype.__proto__||Object.getPrototypeOf($.prototype),"optimize",this).call(this,E);var O=this.next;O!=null&&O.prev===this&&O.statics.blotName===this.statics.blotName&&this.statics.formats(this.domNode)===O.statics.formats(O.domNode)&&(O.optimize(E),O.moveChildren(this),O.remove())}},{key:"replace",value:function(E){d($.prototype.__proto__||Object.getPrototypeOf($.prototype),"replace",this).call(this,E),[].slice.call(this.domNode.querySelectorAll("*")).forEach(function(O){var I=h.default.find(O);I==null?O.parentNode.removeChild(O):I instanceof h.default.Embed?I.remove():I.unwrap()})}}],[{key:"create",value:function(E){var O=d($.__proto__||Object.getPrototypeOf($),"create",this).call(this,E);return O.setAttribute("spellcheck",!1),O}},{key:"formats",value:function(){return!0}}]),$})(u.default);A.blotName="code-block",A.tagName="PRE",A.TAB=" ",r.Code=R,r.default=A}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},o=(function(){function _(z,T){var F=[],B=!0,K=!1,W=void 0;try{for(var H=z[Symbol.iterator](),X;!(B=(X=H.next()).done)&&(F.push(X.value),!(T&&F.length===T));B=!0);}catch(J){K=!0,W=J}finally{try{!B&&H.return&&H.return()}finally{if(K)throw W}}return F}return function(z,T){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return _(z,T);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function _(z,T){for(var F=0;F<T.length;F++){var B=T[F];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(z,B.key,B)}}return function(z,T,F){return T&&_(z.prototype,T),F&&_(z,F),z}})(),m=a(2),f=O(m),x=a(20),h=O(x),p=a(0),u=O(p),w=a(13),v=O(w),N=a(24),j=O(N),y=a(4),C=O(y),S=a(16),D=O(S),R=a(21),A=O(R),L=a(11),$=O(L),P=a(3),E=O(P);function O(_){return _&&_.__esModule?_:{default:_}}function I(_,z,T){return z in _?Object.defineProperty(_,z,{value:T,enumerable:!0,configurable:!0,writable:!0}):_[z]=T,_}function q(_,z){if(!(_ instanceof z))throw new TypeError("Cannot call a class as a function")}var G=/^[ -~]*$/,Y=(function(){function _(z){q(this,_),this.scroll=z,this.delta=this.getDelta()}return d(_,[{key:"applyDelta",value:function(T){var F=this,B=!1;this.scroll.update();var K=this.scroll.length();return this.scroll.batchStart(),T=Q(T),T.reduce(function(W,H){var X=H.retain||H.delete||H.insert.length||1,J=H.attributes||{};if(H.insert!=null){if(typeof H.insert=="string"){var ie=H.insert;ie.endsWith(`
|
||
`)&&B&&(B=!1,ie=ie.slice(0,-1)),W>=K&&!ie.endsWith(`
|
||
`)&&(B=!0),F.scroll.insertAt(W,ie);var ae=F.scroll.line(W),xe=o(ae,2),ce=xe[0],we=xe[1],ke=(0,E.default)({},(0,y.bubbleFormats)(ce));if(ce instanceof C.default){var Xe=ce.descendant(u.default.Leaf,we),Ot=o(Xe,1),bt=Ot[0];ke=(0,E.default)(ke,(0,y.bubbleFormats)(bt))}J=h.default.attributes.diff(ke,J)||{}}else if(l(H.insert)==="object"){var te=Object.keys(H.insert)[0];if(te==null)return W;F.scroll.insertAt(W,te,H.insert[te])}K+=X}return Object.keys(J).forEach(function(ve){F.scroll.formatAt(W,X,ve,J[ve])}),W+X},0),T.reduce(function(W,H){return typeof H.delete=="number"?(F.scroll.deleteAt(W,H.delete),W):W+(H.retain||H.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 B=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.scroll.update(),Object.keys(K).forEach(function(W){if(!(B.scroll.whitelist!=null&&!B.scroll.whitelist[W])){var H=B.scroll.lines(T,Math.max(F,1)),X=F;H.forEach(function(J){var ie=J.length();if(!(J instanceof v.default))J.format(W,K[W]);else{var ae=T-J.offset(B.scroll),xe=J.newlineIndex(ae+X)-ae+1;J.formatAt(ae,xe,W,K[W])}X-=ie})}}),this.scroll.optimize(),this.update(new f.default().retain(T).retain(F,(0,A.default)(K)))}},{key:"formatText",value:function(T,F){var B=this,K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Object.keys(K).forEach(function(W){B.scroll.formatAt(T,F,W,K[W])}),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,B=[],K=[];F===0?this.scroll.path(T).forEach(function(H){var X=o(H,1),J=X[0];J instanceof C.default?B.push(J):J instanceof u.default.Leaf&&K.push(J)}):(B=this.scroll.lines(T,F),K=this.scroll.descendants(u.default.Leaf,T,F));var W=[B,K].map(function(H){if(H.length===0)return{};for(var X=(0,y.bubbleFormats)(H.shift());Object.keys(X).length>0;){var J=H.shift();if(J==null)return X;X=V((0,y.bubbleFormats)(J),X)}return X});return E.default.apply(E.default,W)}},{key:"getText",value:function(T,F){return this.getContents(T,F).filter(function(B){return typeof B.insert=="string"}).map(function(B){return B.insert}).join("")}},{key:"insertEmbed",value:function(T,F,B){return this.scroll.insertAt(T,F,B),this.update(new f.default().retain(T).insert(I({},F,B)))}},{key:"insertText",value:function(T,F){var B=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(W){B.scroll.formatAt(T,F.length,W,K[W])}),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 B=this.getText(T,F),K=this.scroll.line(T+F),W=o(K,2),H=W[0],X=W[1],J=0,ie=new f.default;H!=null&&(H instanceof v.default?J=H.newlineIndex(X)-X+1:J=H.length()-X,ie=H.delta().slice(X,X+J-1).insert(`
|
||
`));var ae=this.getContents(T,F+J),xe=ae.diff(new f.default().insert(B).concat(ie)),ce=new f.default().retain(T).concat(xe);return this.applyDelta(ce)}},{key:"update",value:function(T){var F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],B=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(G)&&u.default.find(F[0].target)){var W=u.default.find(F[0].target),H=(0,y.bubbleFormats)(W),X=W.offset(this.scroll),J=F[0].oldValue.replace(j.default.CONTENTS,""),ie=new f.default().insert(J),ae=new f.default().insert(W.value()),xe=new f.default().retain(X).concat(ie.diff(ae,B));T=xe.reduce(function(ce,we){return we.insert?ce.insert(we.insert,H):ce.push(we)},new f.default),this.delta=K.compose(T)}else this.delta=this.getDelta(),(!T||!(0,$.default)(K.compose(T),this.delta))&&(T=K.diff(this.delta,B));return T}}]),_})();function V(_,z){return Object.keys(z).reduce(function(T,F){return _[F]==null||(z[F]===_[F]?T[F]=z[F]:Array.isArray(z[F])?z[F].indexOf(_[F])<0&&(T[F]=z[F].concat([_[F]])):T[F]=[z[F],_[F]]),T},{})}function Q(_){return _.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 B=T.insert.replace(/\r\n/g,`
|
||
`).replace(/\r/g,`
|
||
`);return z.insert(B,T.attributes)}return z.push(T)},new f.default)}r.default=Y}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Range=void 0;var l=(function(){function L($,P){var E=[],O=!0,I=!1,q=void 0;try{for(var G=$[Symbol.iterator](),Y;!(O=(Y=G.next()).done)&&(E.push(Y.value),!(P&&E.length===P));O=!0);}catch(V){I=!0,q=V}finally{try{!O&&G.return&&G.return()}finally{if(I)throw q}}return E}return function($,P){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return L($,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function L($,P){for(var E=0;E<P.length;E++){var O=P[E];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty($,O.key,O)}}return function($,P,E){return P&&L($.prototype,P),E&&L($,E),$}})(),d=a(0),m=j(d),f=a(21),x=j(f),h=a(11),p=j(h),u=a(8),w=j(u),v=a(10),N=j(v);function j(L){return L&&L.__esModule?L:{default:L}}function y(L){if(Array.isArray(L)){for(var $=0,P=Array(L.length);$<L.length;$++)P[$]=L[$];return P}else return Array.from(L)}function C(L,$){if(!(L instanceof $))throw new TypeError("Cannot call a class as a function")}var S=(0,N.default)("quill:selection"),D=function L($){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;C(this,L),this.index=$,this.length=P},R=(function(){function L($,P){var E=this;C(this,L),this.emitter=P,this.scroll=$,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(){E.mouseDown||setTimeout(E.update.bind(E,w.default.sources.USER),1)}),this.emitter.on(w.default.events.EDITOR_CHANGE,function(O,I){O===w.default.events.TEXT_CHANGE&&I.length()>0&&E.update(w.default.sources.SILENT)}),this.emitter.on(w.default.events.SCROLL_BEFORE_UPDATE,function(){if(E.hasFocus()){var O=E.getNativeRange();O!=null&&O.start.node!==E.cursor.textNode&&E.emitter.once(w.default.events.SCROLL_UPDATE,function(){try{E.setNativeRange(O.start.node,O.start.offset,O.end.node,O.end.offset)}catch{}})}}),this.emitter.on(w.default.events.SCROLL_OPTIMIZE,function(O,I){if(I.range){var q=I.range,G=q.startNode,Y=q.startOffset,V=q.endNode,Q=q.endOffset;E.setNativeRange(G,Y,V,Q)}}),this.update(w.default.sources.SILENT)}return o(L,[{key:"handleComposition",value:function(){var P=this;this.root.addEventListener("compositionstart",function(){P.composing=!0}),this.root.addEventListener("compositionend",function(){if(P.composing=!1,P.cursor.parent){var E=P.cursor.restore();if(!E)return;setTimeout(function(){P.setNativeRange(E.startNode,E.startOffset,E.endNode,E.endOffset)},1)}})}},{key:"handleDragging",value:function(){var P=this;this.emitter.listenDOM("mousedown",document.body,function(){P.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,function(){P.mouseDown=!1,P.update(w.default.sources.USER)})}},{key:"focus",value:function(){this.hasFocus()||(this.root.focus(),this.setRange(this.savedRange))}},{key:"format",value:function(P,E){if(!(this.scroll.whitelist!=null&&!this.scroll.whitelist[P])){this.scroll.update();var O=this.getNativeRange();if(!(O==null||!O.native.collapsed||m.default.query(P,m.default.Scope.BLOCK))){if(O.start.node!==this.cursor.textNode){var I=m.default.find(O.start.node,!1);if(I==null)return;if(I instanceof m.default.Leaf){var q=I.split(O.start.offset);I.parent.insertBefore(this.cursor,q)}else I.insertBefore(this.cursor,O.start.node);this.cursor.attach()}this.cursor.format(P,E),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}}},{key:"getBounds",value:function(P){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,O=this.scroll.length();P=Math.min(P,O-1),E=Math.min(P+E,O-1)-P;var I=void 0,q=this.scroll.leaf(P),G=l(q,2),Y=G[0],V=G[1];if(Y==null)return null;var Q=Y.position(V,!0),_=l(Q,2);I=_[0],V=_[1];var z=document.createRange();if(E>0){z.setStart(I,V);var T=this.scroll.leaf(P+E),F=l(T,2);if(Y=F[0],V=F[1],Y==null)return null;var B=Y.position(V,!0),K=l(B,2);return I=K[0],V=K[1],z.setEnd(I,V),z.getBoundingClientRect()}else{var W="left",H=void 0;return I instanceof Text?(V<I.data.length?(z.setStart(I,V),z.setEnd(I,V+1)):(z.setStart(I,V-1),z.setEnd(I,V),W="right"),H=z.getBoundingClientRect()):(H=Y.domNode.getBoundingClientRect(),V>0&&(W="right")),{bottom:H.top+H.height,height:H.height,left:H[W],right:H[W],top:H.top,width:0}}}},{key:"getNativeRange",value:function(){var P=document.getSelection();if(P==null||P.rangeCount<=0)return null;var E=P.getRangeAt(0);if(E==null)return null;var O=this.normalizeNative(E);return S.info("getNativeRange",O),O}},{key:"getRange",value:function(){var P=this.getNativeRange();if(P==null)return[null,null];var E=this.normalizedToRange(P);return[E,P]}},{key:"hasFocus",value:function(){return document.activeElement===this.root}},{key:"normalizedToRange",value:function(P){var E=this,O=[[P.start.node,P.start.offset]];P.native.collapsed||O.push([P.end.node,P.end.offset]);var I=O.map(function(Y){var V=l(Y,2),Q=V[0],_=V[1],z=m.default.find(Q,!0),T=z.offset(E.scroll);return _===0?T:z instanceof m.default.Container?T+z.length():T+z.index(Q,_)}),q=Math.min(Math.max.apply(Math,y(I)),this.scroll.length()-1),G=Math.min.apply(Math,[q].concat(y(I)));return new D(G,q-G)}},{key:"normalizeNative",value:function(P){if(!A(this.root,P.startContainer)||!P.collapsed&&!A(this.root,P.endContainer))return null;var E={start:{node:P.startContainer,offset:P.startOffset},end:{node:P.endContainer,offset:P.endOffset},native:P};return[E.start,E.end].forEach(function(O){for(var I=O.node,q=O.offset;!(I instanceof Text)&&I.childNodes.length>0;)if(I.childNodes.length>q)I=I.childNodes[q],q=0;else if(I.childNodes.length===q)I=I.lastChild,q=I instanceof Text?I.data.length:I.childNodes.length+1;else break;O.node=I,O.offset=q}),E}},{key:"rangeToNative",value:function(P){var E=this,O=P.collapsed?[P.index]:[P.index,P.index+P.length],I=[],q=this.scroll.length();return O.forEach(function(G,Y){G=Math.min(q-1,G);var V=void 0,Q=E.scroll.leaf(G),_=l(Q,2),z=_[0],T=_[1],F=z.position(T,Y!==0),B=l(F,2);V=B[0],T=B[1],I.push(V,T)}),I.length<2&&(I=I.concat(I)),I}},{key:"scrollIntoView",value:function(P){var E=this.lastRange;if(E!=null){var O=this.getBounds(E.index,E.length);if(O!=null){var I=this.scroll.length()-1,q=this.scroll.line(Math.min(E.index,I)),G=l(q,1),Y=G[0],V=Y;if(E.length>0){var Q=this.scroll.line(Math.min(E.index+E.length,I)),_=l(Q,1);V=_[0]}if(!(Y==null||V==null)){var z=P.getBoundingClientRect();O.top<z.top?P.scrollTop-=z.top-O.top:O.bottom>z.bottom&&(P.scrollTop+=O.bottom-z.bottom)}}}}},{key:"setNativeRange",value:function(P,E){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:P,I=arguments.length>3&&arguments[3]!==void 0?arguments[3]:E,q=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(S.info("setNativeRange",P,E,O,I),!(P!=null&&(this.root.parentNode==null||P.parentNode==null||O.parentNode==null))){var G=document.getSelection();if(G!=null)if(P!=null){this.hasFocus()||this.root.focus();var Y=(this.getNativeRange()||{}).native;if(Y==null||q||P!==Y.startContainer||E!==Y.startOffset||O!==Y.endContainer||I!==Y.endOffset){P.tagName=="BR"&&(E=[].indexOf.call(P.parentNode.childNodes,P),P=P.parentNode),O.tagName=="BR"&&(I=[].indexOf.call(O.parentNode.childNodes,O),O=O.parentNode);var V=document.createRange();V.setStart(P,E),V.setEnd(O,I),G.removeAllRanges(),G.addRange(V)}}else G.removeAllRanges(),this.root.blur(),document.body.focus()}}},{key:"setRange",value:function(P){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:w.default.sources.API;if(typeof E=="string"&&(O=E,E=!1),S.info("setRange",P),P!=null){var I=this.rangeToNative(P);this.setNativeRange.apply(this,y(I).concat([E]))}else this.setNativeRange(null);this.update(O)}},{key:"update",value:function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w.default.sources.USER,E=this.lastRange,O=this.getRange(),I=l(O,2),q=I[0],G=I[1];if(this.lastRange=q,this.lastRange!=null&&(this.savedRange=this.lastRange),!(0,p.default)(E,this.lastRange)){var Y;!this.composing&&G!=null&&G.native.collapsed&&G.start.node!==this.cursor.textNode&&this.cursor.restore();var V=[w.default.events.SELECTION_CHANGE,(0,x.default)(this.lastRange),(0,x.default)(E),P];if((Y=this.emitter).emit.apply(Y,[w.default.events.EDITOR_CHANGE].concat(V)),P!==w.default.sources.SILENT){var Q;(Q=this.emitter).emit.apply(Q,V)}}}}]),L})();function A(L,$){try{$.parentNode}catch{return!1}return $ instanceof Text&&($=$.parentNode),L.contains($)}r.Range=D,r.default=R}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function w(v,N){for(var j=0;j<N.length;j++){var y=N[j];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}return function(v,N,j){return N&&w(v.prototype,N),j&&w(v,j),v}})(),o=function w(v,N,j){v===null&&(v=Function.prototype);var y=Object.getOwnPropertyDescriptor(v,N);if(y===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:w(C,N,j)}else{if("value"in y)return y.value;var S=y.get;return S===void 0?void 0:S.call(j)}},d=a(0),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function x(w,v){if(!(w instanceof v))throw new TypeError("Cannot call a class as a function")}function h(w,v){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:w}function p(w,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);w.prototype=Object.create(v&&v.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(w,v):w.__proto__=v)}var u=(function(w){p(v,w);function v(){return x(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return l(v,[{key:"insertInto",value:function(j,y){j.children.length===0?o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"insertInto",this).call(this,j,y):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 l=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,u){p.__proto__=u}||function(p,u){for(var w in u)u.hasOwnProperty(w)&&(p[w]=u[w])};return function(p,u){h(p,u);function w(){this.constructor=p}p.prototype=u===null?Object.create(u):(w.prototype=u.prototype,new w)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(44),d=a(30),m=a(1),f=(function(h){l(p,h);function p(u){var w=h.call(this,u)||this;return w.build(),w}return p.prototype.appendChild=function(u){this.insertBefore(u)},p.prototype.attach=function(){h.prototype.attach.call(this),this.children.forEach(function(u){u.attach()})},p.prototype.build=function(){var u=this;this.children=new o.default,[].slice.call(this.domNode.childNodes).reverse().forEach(function(w){try{var v=x(w);u.insertBefore(v,u.children.head||void 0)}catch(N){if(N instanceof m.ParchmentError)return;throw N}})},p.prototype.deleteAt=function(u,w){if(u===0&&w===this.length())return this.remove();this.children.forEachAt(u,w,function(v,N,j){v.deleteAt(N,j)})},p.prototype.descendant=function(u,w){var v=this.children.find(w),N=v[0],j=v[1];return u.blotName==null&&u(N)||u.blotName!=null&&N instanceof u?[N,j]:N instanceof p?N.descendant(u,j):[null,-1]},p.prototype.descendants=function(u,w,v){w===void 0&&(w=0),v===void 0&&(v=Number.MAX_VALUE);var N=[],j=v;return this.children.forEachAt(w,v,function(y,C,S){(u.blotName==null&&u(y)||u.blotName!=null&&y instanceof u)&&N.push(y),y instanceof p&&(N=N.concat(y.descendants(u,C,j))),j-=S}),N},p.prototype.detach=function(){this.children.forEach(function(u){u.detach()}),h.prototype.detach.call(this)},p.prototype.formatAt=function(u,w,v,N){this.children.forEachAt(u,w,function(j,y,C){j.formatAt(y,C,v,N)})},p.prototype.insertAt=function(u,w,v){var N=this.children.find(u),j=N[0],y=N[1];if(j)j.insertAt(y,w,v);else{var C=v==null?m.create("text",w):m.create(w,v);this.appendChild(C)}},p.prototype.insertBefore=function(u,w){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,w)},p.prototype.length=function(){return this.children.reduce(function(u,w){return u+w.length()},0)},p.prototype.moveChildren=function(u,w){this.children.forEach(function(v){u.insertBefore(v,w)})},p.prototype.optimize=function(u){if(h.prototype.optimize.call(this,u),this.children.length===0)if(this.statics.defaultChild!=null){var w=m.create(this.statics.defaultChild);this.appendChild(w),w.optimize(u)}else this.remove()},p.prototype.path=function(u,w){w===void 0&&(w=!1);var v=this.children.find(u,w),N=v[0],j=v[1],y=[[this,u]];return N instanceof p?y.concat(N.path(j,w)):(N!=null&&y.push([N,j]),y)},p.prototype.removeChild=function(u){this.children.remove(u)},p.prototype.replace=function(u){u instanceof p&&u.moveChildren(this),h.prototype.replace.call(this,u)},p.prototype.split=function(u,w){if(w===void 0&&(w=!1),!w){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(N,j,y){N=N.split(j,w),v.appendChild(N)}),v},p.prototype.unwrap=function(){this.moveChildren(this.parent,this.next),this.remove()},p.prototype.update=function(u,w){var v=this,N=[],j=[];u.forEach(function(y){y.target===v.domNode&&y.type==="childList"&&(N.push.apply(N,y.addedNodes),j.push.apply(j,y.removedNodes))}),j.forEach(function(y){if(!(y.parentNode!=null&&y.tagName!=="IFRAME"&&document.body.compareDocumentPosition(y)&Node.DOCUMENT_POSITION_CONTAINED_BY)){var C=m.find(y);C!=null&&(C.domNode.parentNode==null||C.domNode.parentNode===v.domNode)&&C.detach()}}),N.filter(function(y){return y.parentNode==v.domNode}).sort(function(y,C){return y===C?0:y.compareDocumentPosition(C)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1}).forEach(function(y){var C=null;y.nextSibling!=null&&(C=m.find(y.nextSibling));var S=x(y);(S.next!=C||S.next==null)&&(S.parent!=null&&S.parent.removeChild(v),v.insertBefore(S,C||void 0))})},p})(d.default);function x(h){var p=m.find(h);if(p==null)try{p=m.create(h)}catch{p=m.create(m.Scope.INLINE),[].slice.call(h.childNodes).forEach(function(w){p.domNode.appendChild(w)}),h.parentNode&&h.parentNode.replaceChild(p.domNode,h),p.attach()}return p}r.default=f}),(function(n,r,a){var l=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,u){p.__proto__=u}||function(p,u){for(var w in u)u.hasOwnProperty(w)&&(p[w]=u[w])};return function(p,u){h(p,u);function w(){this.constructor=p}p.prototype=u===null?Object.create(u):(w.prototype=u.prototype,new w)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12),d=a(31),m=a(17),f=a(1),x=(function(h){l(p,h);function p(u){var w=h.call(this,u)||this;return w.attributes=new d.default(w.domNode),w}return p.formats=function(u){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return u.tagName.toLowerCase()},p.prototype.format=function(u,w){var v=f.query(u);v instanceof o.default?this.attributes.attribute(v,w):w&&v!=null&&(u!==this.statics.blotName||this.formats()[u]!==w)&&this.replaceWith(u,w)},p.prototype.formats=function(){var u=this.attributes.values(),w=this.statics.formats(this.domNode);return w!=null&&(u[this.statics.blotName]=w),u},p.prototype.replaceWith=function(u,w){var v=h.prototype.replaceWith.call(this,u,w);return this.attributes.copy(v),v},p.prototype.update=function(u,w){var v=this;h.prototype.update.call(this,u,w),u.some(function(N){return N.target===v.domNode&&N.type==="attributes"})&&this.attributes.build()},p.prototype.wrap=function(u,w){var v=h.prototype.wrap.call(this,u,w);return v instanceof p&&v.statics.scope===this.statics.scope&&this.attributes.move(v),v},p})(m.default);r.default=x}),(function(n,r,a){var l=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,h){x.__proto__=h}||function(x,h){for(var p in h)h.hasOwnProperty(p)&&(x[p]=h[p])};return function(x,h){f(x,h);function p(){this.constructor=x}x.prototype=h===null?Object.create(h):(p.prototype=h.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(30),d=a(1),m=(function(f){l(x,f);function x(){return f!==null&&f.apply(this,arguments)||this}return x.value=function(h){return!0},x.prototype.index=function(h,p){return this.domNode===h||this.domNode.compareDocumentPosition(h)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(p,1):-1},x.prototype.position=function(h,p){var u=[].indexOf.call(this.parent.domNode.childNodes,this.domNode);return h>0&&(u+=1),[this.parent.domNode,u]},x.prototype.value=function(){var h;return h={},h[this.statics.blotName]=this.statics.value(this.domNode)||!0,h},x.scope=d.Scope.INLINE_BLOT,x})(o.default);r.default=m}),(function(n,r,a){var l=a(11),o=a(3),d={attributes:{compose:function(f,x,h){typeof f!="object"&&(f={}),typeof x!="object"&&(x={});var p=o(!0,{},x);h||(p=Object.keys(p).reduce(function(w,v){return p[v]!=null&&(w[v]=p[v]),w},{}));for(var u in f)f[u]!==void 0&&x[u]===void 0&&(p[u]=f[u]);return Object.keys(p).length>0?p:void 0},diff:function(f,x){typeof f!="object"&&(f={}),typeof x!="object"&&(x={});var h=Object.keys(f).concat(Object.keys(x)).reduce(function(p,u){return l(f[u],x[u])||(p[u]=x[u]===void 0?null:x[u]),p},{});return Object.keys(h).length>0?h:void 0},transform:function(f,x,h){if(typeof f!="object")return x;if(typeof x=="object"){if(!h)return x;var p=Object.keys(x).reduce(function(u,w){return f[w]===void 0&&(u[w]=x[w]),u},{});return Object.keys(p).length>0?p: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 x=this.ops[this.index];if(x){var h=this.offset,p=d.length(x);if(f>=p-h?(f=p-h,this.index+=1,this.offset=0):this.offset+=f,typeof x.delete=="number")return{delete:f};var u={};return x.attributes&&(u.attributes=x.attributes),typeof x.retain=="number"?u.retain=f:typeof x.insert=="string"?u.insert=x.insert.substr(h,f):u.insert=x.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,x=this.index,h=this.next(),p=this.ops.slice(this.index);return this.offset=f,this.index=x,[h].concat(p)}else return[]},n.exports=d}),(function(n,r){var a=(function(){function l(v,N){return N!=null&&v instanceof N}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,N,j,y,C){typeof N=="object"&&(j=N.depth,y=N.prototype,C=N.includeNonEnumerable,N=N.circular);var S=[],D=[],R=typeof Buffer<"u";typeof N>"u"&&(N=!0),typeof j>"u"&&(j=1/0);function A(L,$){if(L===null)return null;if($===0)return L;var P,E;if(typeof L!="object")return L;if(l(L,o))P=new o;else if(l(L,d))P=new d;else if(l(L,m))P=new m(function(z,T){L.then(function(F){z(A(F,$-1))},function(F){T(A(F,$-1))})});else if(f.__isArray(L))P=[];else if(f.__isRegExp(L))P=new RegExp(L.source,w(L)),L.lastIndex&&(P.lastIndex=L.lastIndex);else if(f.__isDate(L))P=new Date(L.getTime());else{if(R&&Buffer.isBuffer(L))return Buffer.allocUnsafe?P=Buffer.allocUnsafe(L.length):P=new Buffer(L.length),L.copy(P),P;l(L,Error)?P=Object.create(L):typeof y>"u"?(E=Object.getPrototypeOf(L),P=Object.create(E)):(P=Object.create(y),E=y)}if(N){var O=S.indexOf(L);if(O!=-1)return D[O];S.push(L),D.push(P)}l(L,o)&&L.forEach(function(z,T){var F=A(T,$-1),B=A(z,$-1);P.set(F,B)}),l(L,d)&&L.forEach(function(z){var T=A(z,$-1);P.add(T)});for(var I in L){var q;E&&(q=Object.getOwnPropertyDescriptor(E,I)),!(q&&q.set==null)&&(P[I]=A(L[I],$-1))}if(Object.getOwnPropertySymbols)for(var G=Object.getOwnPropertySymbols(L),I=0;I<G.length;I++){var Y=G[I],V=Object.getOwnPropertyDescriptor(L,Y);V&&!V.enumerable&&!C||(P[Y]=A(L[Y],$-1),V.enumerable||Object.defineProperty(P,Y,{enumerable:!1}))}if(C)for(var Q=Object.getOwnPropertyNames(L),I=0;I<Q.length;I++){var _=Q[I],V=Object.getOwnPropertyDescriptor(L,_);V&&V.enumerable||(P[_]=A(L[_],$-1),Object.defineProperty(P,_,{enumerable:!1}))}return P}return A(v,j)}f.clonePrototype=function(N){if(N===null)return null;var j=function(){};return j.prototype=N,new j};function x(v){return Object.prototype.toString.call(v)}f.__objToStr=x;function h(v){return typeof v=="object"&&x(v)==="[object Date]"}f.__isDate=h;function p(v){return typeof v=="object"&&x(v)==="[object Array]"}f.__isArray=p;function u(v){return typeof v=="object"&&x(v)==="[object RegExp]"}f.__isRegExp=u;function w(v){var N="";return v.global&&(N+="g"),v.ignoreCase&&(N+="i"),v.multiline&&(N+="m"),N}return f.__getRegExpFlags=w,f})();typeof n=="object"&&n.exports&&(n.exports=a)}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function P(E,O){var I=[],q=!0,G=!1,Y=void 0;try{for(var V=E[Symbol.iterator](),Q;!(q=(Q=V.next()).done)&&(I.push(Q.value),!(O&&I.length===O));q=!0);}catch(_){G=!0,Y=_}finally{try{!q&&V.return&&V.return()}finally{if(G)throw Y}}return I}return function(E,O){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return P(E,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function P(E,O){for(var I=0;I<O.length;I++){var q=O[I];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(E,q.key,q)}}return function(E,O,I){return O&&P(E.prototype,O),I&&P(E,I),E}})(),d=function P(E,O,I){E===null&&(E=Function.prototype);var q=Object.getOwnPropertyDescriptor(E,O);if(q===void 0){var G=Object.getPrototypeOf(E);return G===null?void 0:P(G,O,I)}else{if("value"in q)return q.value;var Y=q.get;return Y===void 0?void 0:Y.call(I)}},m=a(0),f=S(m),x=a(8),h=S(x),p=a(4),u=S(p),w=a(16),v=S(w),N=a(13),j=S(N),y=a(25),C=S(y);function S(P){return P&&P.__esModule?P:{default:P}}function D(P,E){if(!(P instanceof E))throw new TypeError("Cannot call a class as a function")}function R(P,E){if(!P)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:P}function A(P,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);P.prototype=Object.create(E&&E.prototype,{constructor:{value:P,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(P,E):P.__proto__=E)}function L(P){return P instanceof u.default||P instanceof p.BlockEmbed}var $=(function(P){A(E,P);function E(O,I){D(this,E);var q=R(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,O));return q.emitter=I.emitter,Array.isArray(I.whitelist)&&(q.whitelist=I.whitelist.reduce(function(G,Y){return G[Y]=!0,G},{})),q.domNode.addEventListener("DOMNodeInserted",function(){}),q.optimize(),q.enable(),q}return o(E,[{key:"batchStart",value:function(){this.batch=!0}},{key:"batchEnd",value:function(){this.batch=!1,this.optimize()}},{key:"deleteAt",value:function(I,q){var G=this.line(I),Y=l(G,2),V=Y[0],Q=Y[1],_=this.line(I+q),z=l(_,1),T=z[0];if(d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"deleteAt",this).call(this,I,q),T!=null&&V!==T&&Q>0){if(V instanceof p.BlockEmbed||T instanceof p.BlockEmbed){this.optimize();return}if(V instanceof j.default){var F=V.newlineIndex(V.length(),!0);if(F>-1&&(V=V.split(F+1),V===T)){this.optimize();return}}else if(T instanceof j.default){var B=T.newlineIndex(0);B>-1&&T.split(B+1)}var K=T.children.head instanceof v.default?null:T.children.head;V.moveChildren(T,K),V.remove()}this.optimize()}},{key:"enable",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",I)}},{key:"formatAt",value:function(I,q,G,Y){this.whitelist!=null&&!this.whitelist[G]||(d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"formatAt",this).call(this,I,q,G,Y),this.optimize())}},{key:"insertAt",value:function(I,q,G){if(!(G!=null&&this.whitelist!=null&&!this.whitelist[q])){if(I>=this.length())if(G==null||f.default.query(q,f.default.Scope.BLOCK)==null){var Y=f.default.create(this.statics.defaultChild);this.appendChild(Y),G==null&&q.endsWith(`
|
||
`)&&(q=q.slice(0,-1)),Y.insertAt(0,q,G)}else{var V=f.default.create(q,G);this.appendChild(V)}else d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"insertAt",this).call(this,I,q,G);this.optimize()}}},{key:"insertBefore",value:function(I,q){if(I.statics.scope===f.default.Scope.INLINE_BLOT){var G=f.default.create(this.statics.defaultChild);G.appendChild(I),I=G}d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"insertBefore",this).call(this,I,q)}},{key:"leaf",value:function(I){return this.path(I).pop()||[null,-1]}},{key:"line",value:function(I){return I===this.length()?this.line(I-1):this.descendant(L,I)}},{key:"lines",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,G=function Y(V,Q,_){var z=[],T=_;return V.children.forEachAt(Q,_,function(F,B,K){L(F)?z.push(F):F instanceof f.default.Container&&(z=z.concat(Y(F,B,T))),T-=K}),z};return G(this,I,q)}},{key:"optimize",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch!==!0&&(d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"optimize",this).call(this,I,q),I.length>0&&this.emitter.emit(h.default.events.SCROLL_OPTIMIZE,I,q))}},{key:"path",value:function(I){return d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"path",this).call(this,I).slice(1)}},{key:"update",value:function(I){if(this.batch!==!0){var q=h.default.sources.USER;typeof I=="string"&&(q=I),Array.isArray(I)||(I=this.observer.takeRecords()),I.length>0&&this.emitter.emit(h.default.events.SCROLL_BEFORE_UPDATE,q,I),d(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"update",this).call(this,I.concat([])),I.length>0&&this.emitter.emit(h.default.events.SCROLL_UPDATE,q,I)}}}]),E})(f.default.Scroll);$.blotName="scroll",$.className="ql-editor",$.tagName="DIV",$.defaultChild="block",$.allowedChildren=[u.default,p.BlockEmbed,C.default],r.default=$}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SHORTKEY=r.default=void 0;var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(H){return typeof H}:function(H){return H&&typeof Symbol=="function"&&H.constructor===Symbol&&H!==Symbol.prototype?"symbol":typeof H},o=(function(){function H(X,J){var ie=[],ae=!0,xe=!1,ce=void 0;try{for(var we=X[Symbol.iterator](),ke;!(ae=(ke=we.next()).done)&&(ie.push(ke.value),!(J&&ie.length===J));ae=!0);}catch(Xe){xe=!0,ce=Xe}finally{try{!ae&&we.return&&we.return()}finally{if(xe)throw ce}}return ie}return function(X,J){if(Array.isArray(X))return X;if(Symbol.iterator in Object(X))return H(X,J);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function H(X,J){for(var ie=0;ie<J.length;ie++){var ae=J[ie];ae.enumerable=ae.enumerable||!1,ae.configurable=!0,"value"in ae&&(ae.writable=!0),Object.defineProperty(X,ae.key,ae)}}return function(X,J,ie){return J&&H(X.prototype,J),ie&&H(X,ie),X}})(),m=a(21),f=P(m),x=a(11),h=P(x),p=a(3),u=P(p),w=a(2),v=P(w),N=a(20),j=P(N),y=a(0),C=P(y),S=a(5),D=P(S),R=a(10),A=P(R),L=a(9),$=P(L);function P(H){return H&&H.__esModule?H:{default:H}}function E(H,X,J){return X in H?Object.defineProperty(H,X,{value:J,enumerable:!0,configurable:!0,writable:!0}):H[X]=J,H}function O(H,X){if(!(H instanceof X))throw new TypeError("Cannot call a class as a function")}function I(H,X){if(!H)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return X&&(typeof X=="object"||typeof X=="function")?X:H}function q(H,X){if(typeof X!="function"&&X!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof X);H.prototype=Object.create(X&&X.prototype,{constructor:{value:H,enumerable:!1,writable:!0,configurable:!0}}),X&&(Object.setPrototypeOf?Object.setPrototypeOf(H,X):H.__proto__=X)}var G=(0,A.default)("quill:keyboard"),Y=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",V=(function(H){q(X,H),d(X,null,[{key:"match",value:function(ie,ae){return ae=W(ae),["altKey","ctrlKey","metaKey","shiftKey"].some(function(xe){return!!ae[xe]!==ie[xe]&&ae[xe]!==null})?!1:ae.key===(ie.which||ie.keyCode)}}]);function X(J,ie){O(this,X);var ae=I(this,(X.__proto__||Object.getPrototypeOf(X)).call(this,J,ie));return ae.bindings={},Object.keys(ae.options.bindings).forEach(function(xe){xe==="list autofill"&&J.scroll.whitelist!=null&&!J.scroll.whitelist.list||ae.options.bindings[xe]&&ae.addBinding(ae.options.bindings[xe])}),ae.addBinding({key:X.keys.ENTER,shiftKey:null},F),ae.addBinding({key:X.keys.ENTER,metaKey:null,ctrlKey:null,altKey:null},function(){}),/Firefox/i.test(navigator.userAgent)?(ae.addBinding({key:X.keys.BACKSPACE},{collapsed:!0},_),ae.addBinding({key:X.keys.DELETE},{collapsed:!0},z)):(ae.addBinding({key:X.keys.BACKSPACE},{collapsed:!0,prefix:/^.?$/},_),ae.addBinding({key:X.keys.DELETE},{collapsed:!0,suffix:/^.?$/},z)),ae.addBinding({key:X.keys.BACKSPACE},{collapsed:!1},T),ae.addBinding({key:X.keys.DELETE},{collapsed:!1},T),ae.addBinding({key:X.keys.BACKSPACE,altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},_),ae.listen(),ae}return d(X,[{key:"addBinding",value:function(ie){var ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},xe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ce=W(ie);if(ce==null||ce.key==null)return G.warn("Attempted to add invalid keyboard binding",ce);typeof ae=="function"&&(ae={handler:ae}),typeof xe=="function"&&(xe={handler:xe}),ce=(0,u.default)(ce,ae,xe),this.bindings[ce.key]=this.bindings[ce.key]||[],this.bindings[ce.key].push(ce)}},{key:"listen",value:function(){var ie=this;this.quill.root.addEventListener("keydown",function(ae){if(!ae.defaultPrevented){var xe=ae.which||ae.keyCode,ce=(ie.bindings[xe]||[]).filter(function(mt){return X.match(ae,mt)});if(ce.length!==0){var we=ie.quill.getSelection();if(!(we==null||!ie.quill.hasFocus())){var ke=ie.quill.getLine(we.index),Xe=o(ke,2),Ot=Xe[0],bt=Xe[1],te=ie.quill.getLeaf(we.index),ve=o(te,2),qe=ve[0],ge=ve[1],Be=we.length===0?[qe,ge]:ie.quill.getLeaf(we.index+we.length),ut=o(Be,2),ht=ut[0],it=ut[1],Tt=qe instanceof C.default.Text?qe.value().slice(0,ge):"",It=ht instanceof C.default.Text?ht.value().slice(it):"",he={collapsed:we.length===0,empty:we.length===0&&Ot.length()<=1,format:ie.quill.getFormat(we),offset:bt,prefix:Tt,suffix:It},vt=ce.some(function(mt){if(mt.collapsed!=null&&mt.collapsed!==he.collapsed||mt.empty!=null&&mt.empty!==he.empty||mt.offset!=null&&mt.offset!==he.offset)return!1;if(Array.isArray(mt.format)){if(mt.format.every(function(_e){return he.format[_e]==null}))return!1}else if(l(mt.format)==="object"&&!Object.keys(mt.format).every(function(_e){return mt.format[_e]===!0?he.format[_e]!=null:mt.format[_e]===!1?he.format[_e]==null:(0,h.default)(mt.format[_e],he.format[_e])}))return!1;return mt.prefix!=null&&!mt.prefix.test(he.prefix)||mt.suffix!=null&&!mt.suffix.test(he.suffix)?!1:mt.handler.call(ie,we,he)!==!0});vt&&ae.preventDefault()}}}})}}]),X})($.default);V.keys={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},V.DEFAULTS={bindings:{bold:K("bold"),italic:K("italic"),underline:K("underline"),indent:{key:V.keys.TAB,format:["blockquote","indent","list"],handler:function(X,J){if(J.collapsed&&J.offset!==0)return!0;this.quill.format("indent","+1",D.default.sources.USER)}},outdent:{key:V.keys.TAB,shiftKey:!0,format:["blockquote","indent","list"],handler:function(X,J){if(J.collapsed&&J.offset!==0)return!0;this.quill.format("indent","-1",D.default.sources.USER)}},"outdent backspace":{key:V.keys.BACKSPACE,collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler:function(X,J){J.format.indent!=null?this.quill.format("indent","-1",D.default.sources.USER):J.format.list!=null&&this.quill.format("list",!1,D.default.sources.USER)}},"indent code-block":B(!0),"outdent code-block":B(!1),"remove tab":{key:V.keys.TAB,shiftKey:!0,collapsed:!0,prefix:/\t$/,handler:function(X){this.quill.deleteText(X.index-1,1,D.default.sources.USER)}},tab:{key:V.keys.TAB,handler:function(X){this.quill.history.cutoff();var J=new v.default().retain(X.index).delete(X.length).insert(" ");this.quill.updateContents(J,D.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(X.index+1,D.default.sources.SILENT)}},"list empty enter":{key:V.keys.ENTER,collapsed:!0,format:["list"],empty:!0,handler:function(X,J){this.quill.format("list",!1,D.default.sources.USER),J.format.indent&&this.quill.format("indent",!1,D.default.sources.USER)}},"checklist enter":{key:V.keys.ENTER,collapsed:!0,format:{list:"checked"},handler:function(X){var J=this.quill.getLine(X.index),ie=o(J,2),ae=ie[0],xe=ie[1],ce=(0,u.default)({},ae.formats(),{list:"checked"}),we=new v.default().retain(X.index).insert(`
|
||
`,ce).retain(ae.length()-xe-1).retain(1,{list:"unchecked"});this.quill.updateContents(we,D.default.sources.USER),this.quill.setSelection(X.index+1,D.default.sources.SILENT),this.quill.scrollIntoView()}},"header enter":{key:V.keys.ENTER,collapsed:!0,format:["header"],suffix:/^$/,handler:function(X,J){var ie=this.quill.getLine(X.index),ae=o(ie,2),xe=ae[0],ce=ae[1],we=new v.default().retain(X.index).insert(`
|
||
`,J.format).retain(xe.length()-ce-1).retain(1,{header:null});this.quill.updateContents(we,D.default.sources.USER),this.quill.setSelection(X.index+1,D.default.sources.SILENT),this.quill.scrollIntoView()}},"list autofill":{key:" ",collapsed:!0,format:{list:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler:function(X,J){var ie=J.prefix.length,ae=this.quill.getLine(X.index),xe=o(ae,2),ce=xe[0],we=xe[1];if(we>ie)return!0;var ke=void 0;switch(J.prefix.trim()){case"[]":case"[ ]":ke="unchecked";break;case"[x]":ke="checked";break;case"-":case"*":ke="bullet";break;default:ke="ordered"}this.quill.insertText(X.index," ",D.default.sources.USER),this.quill.history.cutoff();var Xe=new v.default().retain(X.index-we).delete(ie+1).retain(ce.length()-2-we).retain(1,{list:ke});this.quill.updateContents(Xe,D.default.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(X.index-ie,D.default.sources.SILENT)}},"code exit":{key:V.keys.ENTER,collapsed:!0,format:["code-block"],prefix:/\n\n$/,suffix:/^\s+$/,handler:function(X){var J=this.quill.getLine(X.index),ie=o(J,2),ae=ie[0],xe=ie[1],ce=new v.default().retain(X.index+ae.length()-xe-2).retain(1,{"code-block":null}).delete(1);this.quill.updateContents(ce,D.default.sources.USER)}},"embed left":Q(V.keys.LEFT,!1),"embed left shift":Q(V.keys.LEFT,!0),"embed right":Q(V.keys.RIGHT,!1),"embed right shift":Q(V.keys.RIGHT,!0)}};function Q(H,X){var J,ie=H===V.keys.LEFT?"prefix":"suffix";return J={key:H,shiftKey:X,altKey:null},E(J,ie,/^$/),E(J,"handler",function(xe){var ce=xe.index;H===V.keys.RIGHT&&(ce+=xe.length+1);var we=this.quill.getLeaf(ce),ke=o(we,1),Xe=ke[0];return Xe instanceof C.default.Embed?(H===V.keys.LEFT?X?this.quill.setSelection(xe.index-1,xe.length+1,D.default.sources.USER):this.quill.setSelection(xe.index-1,D.default.sources.USER):X?this.quill.setSelection(xe.index,xe.length+1,D.default.sources.USER):this.quill.setSelection(xe.index+xe.length+1,D.default.sources.USER),!1):!0}),J}function _(H,X){if(!(H.index===0||this.quill.getLength()<=1)){var J=this.quill.getLine(H.index),ie=o(J,1),ae=ie[0],xe={};if(X.offset===0){var ce=this.quill.getLine(H.index-1),we=o(ce,1),ke=we[0];if(ke!=null&&ke.length()>1){var Xe=ae.formats(),Ot=this.quill.getFormat(H.index-1,1);xe=j.default.attributes.diff(Xe,Ot)||{}}}var bt=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(X.prefix)?2:1;this.quill.deleteText(H.index-bt,bt,D.default.sources.USER),Object.keys(xe).length>0&&this.quill.formatLine(H.index-bt,bt,xe,D.default.sources.USER),this.quill.focus()}}function z(H,X){var J=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(X.suffix)?2:1;if(!(H.index>=this.quill.getLength()-J)){var ie={},ae=0,xe=this.quill.getLine(H.index),ce=o(xe,1),we=ce[0];if(X.offset>=we.length()-1){var ke=this.quill.getLine(H.index+1),Xe=o(ke,1),Ot=Xe[0];if(Ot){var bt=we.formats(),te=this.quill.getFormat(H.index,1);ie=j.default.attributes.diff(bt,te)||{},ae=Ot.length()}}this.quill.deleteText(H.index,J,D.default.sources.USER),Object.keys(ie).length>0&&this.quill.formatLine(H.index+ae-1,J,ie,D.default.sources.USER)}}function T(H){var X=this.quill.getLines(H),J={};if(X.length>1){var ie=X[0].formats(),ae=X[X.length-1].formats();J=j.default.attributes.diff(ae,ie)||{}}this.quill.deleteText(H,D.default.sources.USER),Object.keys(J).length>0&&this.quill.formatLine(H.index,1,J,D.default.sources.USER),this.quill.setSelection(H.index,D.default.sources.SILENT),this.quill.focus()}function F(H,X){var J=this;H.length>0&&this.quill.scroll.deleteAt(H.index,H.length);var ie=Object.keys(X.format).reduce(function(ae,xe){return C.default.query(xe,C.default.Scope.BLOCK)&&!Array.isArray(X.format[xe])&&(ae[xe]=X.format[xe]),ae},{});this.quill.insertText(H.index,`
|
||
`,ie,D.default.sources.USER),this.quill.setSelection(H.index+1,D.default.sources.SILENT),this.quill.focus(),Object.keys(X.format).forEach(function(ae){ie[ae]==null&&(Array.isArray(X.format[ae])||ae!=="link"&&J.quill.format(ae,X.format[ae],D.default.sources.USER))})}function B(H){return{key:V.keys.TAB,shiftKey:!H,format:{"code-block":!0},handler:function(J){var ie=C.default.query("code-block"),ae=J.index,xe=J.length,ce=this.quill.scroll.descendant(ie,ae),we=o(ce,2),ke=we[0],Xe=we[1];if(ke!=null){var Ot=this.quill.getIndex(ke),bt=ke.newlineIndex(Xe,!0)+1,te=ke.newlineIndex(Ot+Xe+xe),ve=ke.domNode.textContent.slice(bt,te).split(`
|
||
`);Xe=0,ve.forEach(function(qe,ge){H?(ke.insertAt(bt+Xe,ie.TAB),Xe+=ie.TAB.length,ge===0?ae+=ie.TAB.length:xe+=ie.TAB.length):qe.startsWith(ie.TAB)&&(ke.deleteAt(bt+Xe,ie.TAB.length),Xe-=ie.TAB.length,ge===0?ae-=ie.TAB.length:xe-=ie.TAB.length),Xe+=qe.length+1}),this.quill.update(D.default.sources.USER),this.quill.setSelection(ae,xe,D.default.sources.SILENT)}}}}function K(H){return{key:H[0].toUpperCase(),shortKey:!0,handler:function(J,ie){this.quill.format(H,!ie.format[H],D.default.sources.USER)}}}function W(H){if(typeof H=="string"||typeof H=="number")return W({key:H});if((typeof H>"u"?"undefined":l(H))==="object"&&(H=(0,f.default)(H,!1)),typeof H.key=="string")if(V.keys[H.key.toUpperCase()]!=null)H.key=V.keys[H.key.toUpperCase()];else if(H.key.length===1)H.key=H.key.toUpperCase().charCodeAt(0);else return null;return H.shortKey&&(H[Y]=H.shortKey,delete H.shortKey),H}r.default=V,r.SHORTKEY=Y}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function j(y,C){var S=[],D=!0,R=!1,A=void 0;try{for(var L=y[Symbol.iterator](),$;!(D=($=L.next()).done)&&(S.push($.value),!(C&&S.length===C));D=!0);}catch(P){R=!0,A=P}finally{try{!D&&L.return&&L.return()}finally{if(R)throw A}}return S}return function(y,C){if(Array.isArray(y))return y;if(Symbol.iterator in Object(y))return j(y,C);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function j(y,C,S){y===null&&(y=Function.prototype);var D=Object.getOwnPropertyDescriptor(y,C);if(D===void 0){var R=Object.getPrototypeOf(y);return R===null?void 0:j(R,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(y,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(y,D.key,D)}}return function(y,C,S){return C&&j(y.prototype,C),S&&j(y,S),y}})(),m=a(0),f=p(m),x=a(7),h=p(x);function p(j){return j&&j.__esModule?j:{default:j}}function u(j,y){if(!(j instanceof y))throw new TypeError("Cannot call a class as a function")}function w(j,y){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:j}function v(j,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);j.prototype=Object.create(y&&y.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(j,y):j.__proto__=y)}var N=(function(j){v(y,j),d(y,null,[{key:"value",value:function(){}}]);function y(C,S){u(this,y);var D=w(this,(y.__proto__||Object.getPrototypeOf(y)).call(this,C));return D.selection=S,D.textNode=document.createTextNode(y.CONTENTS),D.domNode.appendChild(D.textNode),D._length=0,D}return d(y,[{key:"detach",value:function(){this.parent!=null&&this.parent.removeChild(this)}},{key:"format",value:function(S,D){if(this._length!==0)return o(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"format",this).call(this,S,D);for(var R=this,A=0;R!=null&&R.statics.scope!==f.default.Scope.BLOCK_BLOT;)A+=R.offset(R.parent),R=R.parent;R!=null&&(this._length=y.CONTENTS.length,R.optimize(),R.formatAt(A,y.CONTENTS.length,S,D),this._length=0)}},{key:"index",value:function(S,D){return S===this.textNode?0:o(y.prototype.__proto__||Object.getPrototypeOf(y.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(y.prototype.__proto__||Object.getPrototypeOf(y.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(),R=void 0,A=void 0,L=void 0;if(D!=null&&D.start.node===S&&D.end.node===S){var $=[S,D.start.offset,D.end.offset];R=$[0],A=$[1],L=$[2]}for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);if(this.textNode.data!==y.CONTENTS){var P=this.textNode.data.split(y.CONTENTS).join("");this.next instanceof h.default?(R=this.next.domNode,this.next.insertAt(0,P),this.textNode.data=y.CONTENTS):(this.textNode.data=P,this.parent.insertBefore(f.default.create(this.textNode),this),this.textNode=document.createTextNode(y.CONTENTS),this.domNode.appendChild(this.textNode))}if(this.remove(),A!=null){var E=[A,L].map(function(I){return Math.max(0,Math.min(R.data.length,I-1))}),O=l(E,2);return A=O[0],L=O[1],{startNode:R,startOffset:A,endNode:R,endOffset:L}}}}},{key:"update",value:function(S,D){var R=this;if(S.some(function(L){return L.type==="characterData"&&L.target===R.textNode})){var A=this.restore();A&&(D.range=A)}}},{key:"value",value:function(){return""}}]),y})(f.default.Embed);N.blotName="cursor",N.className="ql-cursor",N.tagName="span",N.CONTENTS="\uFEFF",r.default=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(0),o=f(l),d=a(4),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function x(w,v){if(!(w instanceof v))throw new TypeError("Cannot call a class as a function")}function h(w,v){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:w}function p(w,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);w.prototype=Object.create(v&&v.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(w,v):w.__proto__=v)}var u=(function(w){p(v,w);function v(){return x(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 l=(function(){function N(j,y){for(var C=0;C<y.length;C++){var S=y[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,y,C){return y&&N(j.prototype,y),C&&N(j,C),j}})(),o=function N(j,y,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,y);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:N(D,y,C)}else{if("value"in S)return S.value;var R=S.get;return R===void 0?void 0:R.call(C)}},d=a(0),m=f(d);function f(N){return N&&N.__esModule?N:{default:N}}function x(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")}function h(N,j){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:N}function p(N,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);N.prototype=Object.create(j&&j.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(N,j):N.__proto__=j)}var u=(function(N){p(j,N);function j(){return x(this,j),h(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return l(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),w=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=w,r.ColorStyle=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.sanitize=r.default=void 0;var l=(function(){function v(N,j){for(var y=0;y<j.length;y++){var C=j[y];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(N,C.key,C)}}return function(N,j,y){return j&&v(N.prototype,j),y&&v(N,y),N}})(),o=function v(N,j,y){N===null&&(N=Function.prototype);var C=Object.getOwnPropertyDescriptor(N,j);if(C===void 0){var S=Object.getPrototypeOf(N);return S===null?void 0:v(S,j,y)}else{if("value"in C)return C.value;var D=C.get;return D===void 0?void 0:D.call(y)}},d=a(6),m=f(d);function f(v){return v&&v.__esModule?v:{default:v}}function x(v,N){if(!(v instanceof N))throw new TypeError("Cannot call a class as a function")}function h(v,N){if(!v)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:v}function p(v,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);v.prototype=Object.create(N&&N.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(v,N):v.__proto__=N)}var u=(function(v){p(N,v);function N(){return x(this,N),h(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return l(N,[{key:"format",value:function(y,C){if(y!==this.statics.blotName||!C)return o(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"format",this).call(this,y,C);C=this.constructor.sanitize(C),this.domNode.setAttribute("href",C)}}],[{key:"create",value:function(y){var C=o(N.__proto__||Object.getPrototypeOf(N),"create",this).call(this,y);return y=this.sanitize(y),C.setAttribute("href",y),C.setAttribute("rel","noopener noreferrer"),C.setAttribute("target","_blank"),C}},{key:"formats",value:function(y){return y.getAttribute("href")}},{key:"sanitize",value:function(y){return w(y,this.PROTOCOL_WHITELIST)?y:this.SANITIZED_URL}}]),N})(m.default);u.blotName="link",u.tagName="A",u.SANITIZED_URL="about:blank",u.PROTOCOL_WHITELIST=["http","https","mailto","tel"];function w(v,N){var j=document.createElement("a");j.href=v;var y=j.href.slice(0,j.href.indexOf(":"));return N.indexOf(y)>-1}r.default=u,r.sanitize=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(N){return typeof N}:function(N){return N&&typeof Symbol=="function"&&N.constructor===Symbol&&N!==Symbol.prototype?"symbol":typeof N},o=(function(){function N(j,y){for(var C=0;C<y.length;C++){var S=y[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,y,C){return y&&N(j.prototype,y),C&&N(j,C),j}})(),d=a(23),m=h(d),f=a(107),x=h(f);function h(N){return N&&N.__esModule?N:{default:N}}function p(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")}var u=0;function w(N,j){N.setAttribute(j,N.getAttribute(j)!=="true")}var v=(function(){function N(j){var y=this;p(this,N),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(){y.togglePicker()}),this.label.addEventListener("keydown",function(C){switch(C.keyCode){case m.default.keys.ENTER:y.togglePicker();break;case m.default.keys.ESCAPE:y.escape(),C.preventDefault();break}}),this.select.addEventListener("change",this.update.bind(this))}return o(N,[{key:"togglePicker",value:function(){this.container.classList.toggle("ql-expanded"),w(this.label,"aria-expanded"),w(this.options,"aria-hidden")}},{key:"buildItem",value:function(y){var C=this,S=document.createElement("span");return S.tabIndex="0",S.setAttribute("role","button"),S.classList.add("ql-picker-item"),y.hasAttribute("value")&&S.setAttribute("data-value",y.getAttribute("value")),y.textContent&&S.setAttribute("data-label",y.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 y=document.createElement("span");return y.classList.add("ql-picker-label"),y.innerHTML=x.default,y.tabIndex="0",y.setAttribute("role","button"),y.setAttribute("aria-expanded","false"),this.container.appendChild(y),y}},{key:"buildOptions",value:function(){var y=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=y.buildItem(S);C.appendChild(D),S.selected===!0&&y.selectItem(D)}),this.container.appendChild(C)}},{key:"buildPicker",value:function(){var y=this;[].slice.call(this.select.attributes).forEach(function(C){y.container.setAttribute(C.name,C.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}},{key:"escape",value:function(){var y=this;this.close(),setTimeout(function(){return y.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(y){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,S=this.container.querySelector(".ql-selected");if(y!==S&&(S!=null&&S.classList.remove("ql-selected"),y!=null&&(y.classList.add("ql-selected"),this.select.selectedIndex=[].indexOf.call(y.parentNode.children,y),y.hasAttribute("data-value")?this.label.setAttribute("data-value",y.getAttribute("data-value")):this.label.removeAttribute("data-value"),y.hasAttribute("data-label")?this.label.setAttribute("data-label",y.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":l(Event))==="object"){var D=document.createEvent("Event");D.initEvent("change",!0,!0),this.select.dispatchEvent(D)}this.close()}}},{key:"update",value:function(){var y=void 0;if(this.select.selectedIndex>-1){var C=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];y=this.select.options[this.select.selectedIndex],this.selectItem(C)}else this.selectItem(null);var S=y!=null&&y!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",S)}}]),N})();r.default=v}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(0),o=G(l),d=a(5),m=G(d),f=a(4),x=G(f),h=a(16),p=G(h),u=a(25),w=G(u),v=a(24),N=G(v),j=a(35),y=G(j),C=a(6),S=G(C),D=a(22),R=G(D),A=a(7),L=G(A),$=a(55),P=G($),E=a(42),O=G(E),I=a(23),q=G(I);function G(Y){return Y&&Y.__esModule?Y:{default:Y}}m.default.register({"blots/block":x.default,"blots/block/embed":f.BlockEmbed,"blots/break":p.default,"blots/container":w.default,"blots/cursor":N.default,"blots/embed":y.default,"blots/inline":S.default,"blots/scroll":R.default,"blots/text":L.default,"modules/clipboard":P.default,"modules/history":O.default,"modules/keyboard":q.default}),o.default.register(x.default,p.default,N.default,S.default,R.default,L.default),r.default=m.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(1),o=(function(){function d(m){this.domNode=m,this.domNode[l.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 l.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 l.create(m)},d.prototype.detach=function(){this.parent!=null&&this.parent.removeChild(this),delete this.domNode[l.DATA_KEY]},d.prototype.deleteAt=function(m,f){var x=this.isolate(m,f);x.remove()},d.prototype.formatAt=function(m,f,x,h){var p=this.isolate(m,f);if(l.query(x,l.Scope.BLOT)!=null&&h)p.wrap(x,h);else if(l.query(x,l.Scope.ATTRIBUTE)!=null){var u=l.create(this.statics.scope);p.wrap(u),u.format(x,h)}},d.prototype.insertAt=function(m,f,x){var h=x==null?l.create("text",f):l.create(f,x),p=this.split(m);this.parent.insertBefore(h,p)},d.prototype.insertInto=function(m,f){f===void 0&&(f=null),this.parent!=null&&this.parent.children.remove(this);var x=null;m.children.insertBefore(this,f),f!=null&&(x=f.domNode),(this.domNode.parentNode!=m.domNode||this.domNode.nextSibling!=x)&&m.domNode.insertBefore(this.domNode,x),this.parent=m,this.attach()},d.prototype.isolate=function(m,f){var x=this.split(m);return x.split(f),x},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[l.DATA_KEY]!=null&&delete this.domNode[l.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 x=typeof m=="string"?l.create(m,f):m;return x.replace(this),x},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 x=typeof m=="string"?l.create(m,f):m;return this.parent!=null&&this.parent.insertBefore(x,this.next),x.appendChild(this),x},d.blotName="abstract",d})();r.default=o}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(12),o=a(32),d=a(33),m=a(1),f=(function(){function x(h){this.attributes={},this.domNode=h,this.build()}return x.prototype.attribute=function(h,p){p?h.add(this.domNode,p)&&(h.value(this.domNode)!=null?this.attributes[h.attrName]=h:delete this.attributes[h.attrName]):(h.remove(this.domNode),delete this.attributes[h.attrName])},x.prototype.build=function(){var h=this;this.attributes={};var p=l.default.keys(this.domNode),u=o.default.keys(this.domNode),w=d.default.keys(this.domNode);p.concat(u).concat(w).forEach(function(v){var N=m.query(v,m.Scope.ATTRIBUTE);N instanceof l.default&&(h.attributes[N.attrName]=N)})},x.prototype.copy=function(h){var p=this;Object.keys(this.attributes).forEach(function(u){var w=p.attributes[u].value(p.domNode);h.format(u,w)})},x.prototype.move=function(h){var p=this;this.copy(h),Object.keys(this.attributes).forEach(function(u){p.attributes[u].remove(p.domNode)}),this.attributes={}},x.prototype.values=function(){var h=this;return Object.keys(this.attributes).reduce(function(p,u){return p[u]=h.attributes[u].value(h.domNode),p},{})},x})();r.default=f}),(function(n,r,a){var l=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,h){x.__proto__=h}||function(x,h){for(var p in h)h.hasOwnProperty(p)&&(x[p]=h[p])};return function(x,h){f(x,h);function p(){this.constructor=x}x.prototype=h===null?Object.create(h):(p.prototype=h.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f,x){var h=f.getAttribute("class")||"";return h.split(/\s+/).filter(function(p){return p.indexOf(x+"-")===0})}var m=(function(f){l(x,f);function x(){return f!==null&&f.apply(this,arguments)||this}return x.keys=function(h){return(h.getAttribute("class")||"").split(/\s+/).map(function(p){return p.split("-").slice(0,-1).join("-")})},x.prototype.add=function(h,p){return this.canAdd(h,p)?(this.remove(h),h.classList.add(this.keyName+"-"+p),!0):!1},x.prototype.remove=function(h){var p=d(h,this.keyName);p.forEach(function(u){h.classList.remove(u)}),h.classList.length===0&&h.removeAttribute("class")},x.prototype.value=function(h){var p=d(h,this.keyName)[0]||"",u=p.slice(this.keyName.length+1);return this.canAdd(h,u)?u:""},x})(o.default);r.default=m}),(function(n,r,a){var l=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,h){x.__proto__=h}||function(x,h){for(var p in h)h.hasOwnProperty(p)&&(x[p]=h[p])};return function(x,h){f(x,h);function p(){this.constructor=x}x.prototype=h===null?Object.create(h):(p.prototype=h.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(12);function d(f){var x=f.split("-"),h=x.slice(1).map(function(p){return p[0].toUpperCase()+p.slice(1)}).join("");return x[0]+h}var m=(function(f){l(x,f);function x(){return f!==null&&f.apply(this,arguments)||this}return x.keys=function(h){return(h.getAttribute("style")||"").split(";").map(function(p){var u=p.split(":");return u[0].trim()})},x.prototype.add=function(h,p){return this.canAdd(h,p)?(h.style[d(this.keyName)]=p,!0):!1},x.prototype.remove=function(h){h.style[d(this.keyName)]="",h.getAttribute("style")||h.removeAttribute("style")},x.prototype.value=function(h){var p=h.style[d(this.keyName)];return this.canAdd(h,p)?p:""},x})(o.default);r.default=m}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function m(f,x){for(var h=0;h<x.length;h++){var p=x[h];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(f,p.key,p)}}return function(f,x,h){return x&&m(f.prototype,x),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,x){o(this,m),this.quill=f,this.options=x,this.modules={}}return l(m,[{key:"init",value:function(){var x=this;Object.keys(this.options.modules).forEach(function(h){x.modules[h]==null&&x.addModule(h)})}},{key:"addModule",value:function(x){var h=this.quill.constructor.import("modules/"+x);return this.modules[x]=new h(this.quill,this.options.modules[x]||{}),this.modules[x]}}]),m})();d.DEFAULTS={modules:{}},d.themes={default:d},r.default=d}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function j(y,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(y,D.key,D)}}return function(y,C,S){return C&&j(y.prototype,C),S&&j(y,S),y}})(),o=function j(y,C,S){y===null&&(y=Function.prototype);var D=Object.getOwnPropertyDescriptor(y,C);if(D===void 0){var R=Object.getPrototypeOf(y);return R===null?void 0:j(R,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),x=h(f);function h(j){return j&&j.__esModule?j:{default:j}}function p(j,y){if(!(j instanceof y))throw new TypeError("Cannot call a class as a function")}function u(j,y){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:j}function w(j,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);j.prototype=Object.create(y&&y.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(j,y):j.__proto__=y)}var v="\uFEFF",N=(function(j){w(y,j);function y(C){p(this,y);var S=u(this,(y.__proto__||Object.getPrototypeOf(y)).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 l(y,[{key:"index",value:function(S,D){return S===this.leftGuard?0:S===this.rightGuard?1:o(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"index",this).call(this,S,D)}},{key:"restore",value:function(S){var D=void 0,R=void 0,A=S.data.split(v).join("");if(S===this.leftGuard)if(this.prev instanceof x.default){var L=this.prev.length();this.prev.insertAt(L,A),D={startNode:this.prev.domNode,startOffset:L+A.length}}else R=document.createTextNode(A),this.parent.insertBefore(m.default.create(R),this),D={startNode:R,startOffset:A.length};else S===this.rightGuard&&(this.next instanceof x.default?(this.next.insertAt(0,A),D={startNode:this.next.domNode,startOffset:A.length}):(R=document.createTextNode(A),this.parent.insertBefore(m.default.create(R),this.next),D={startNode:R,startOffset:A.length}));return S.data=v,D}},{key:"update",value:function(S,D){var R=this;S.forEach(function(A){if(A.type==="characterData"&&(A.target===R.leftGuard||A.target===R.rightGuard)){var L=R.restore(A.target);L&&(D.range=L)}})}}]),y})(m.default.Embed);r.default=N}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.AlignStyle=r.AlignClass=r.AlignAttribute=void 0;var l=a(0),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}var m={scope:o.default.Scope.BLOCK,whitelist:["right","center","justify"]},f=new o.default.Attributor.Attribute("align","align",m),x=new o.default.Attributor.Class("align","ql-align",m),h=new o.default.Attributor.Style("align","text-align",m);r.AlignAttribute=f,r.AlignClass=x,r.AlignStyle=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.BackgroundStyle=r.BackgroundClass=void 0;var l=a(0),o=m(l),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}),x=new d.ColorAttributor("background","background-color",{scope:o.default.Scope.INLINE});r.BackgroundClass=f,r.BackgroundStyle=x}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.DirectionStyle=r.DirectionClass=r.DirectionAttribute=void 0;var l=a(0),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}var m={scope:o.default.Scope.BLOCK,whitelist:["rtl"]},f=new o.default.Attributor.Attribute("direction","dir",m),x=new o.default.Attributor.Class("direction","ql-direction",m),h=new o.default.Attributor.Style("direction","direction",m);r.DirectionAttribute=f,r.DirectionClass=x,r.DirectionStyle=h}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.FontClass=r.FontStyle=void 0;var l=(function(){function j(y,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(y,D.key,D)}}return function(y,C,S){return C&&j(y.prototype,C),S&&j(y,S),y}})(),o=function j(y,C,S){y===null&&(y=Function.prototype);var D=Object.getOwnPropertyDescriptor(y,C);if(D===void 0){var R=Object.getPrototypeOf(y);return R===null?void 0:j(R,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 x(j,y){if(!(j instanceof y))throw new TypeError("Cannot call a class as a function")}function h(j,y){if(!j)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:j}function p(j,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);j.prototype=Object.create(y&&y.prototype,{constructor:{value:j,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(j,y):j.__proto__=y)}var u={scope:m.default.Scope.INLINE,whitelist:["serif","monospace"]},w=new m.default.Attributor.Class("font","ql-font",u),v=(function(j){p(y,j);function y(){return x(this,y),h(this,(y.__proto__||Object.getPrototypeOf(y)).apply(this,arguments))}return l(y,[{key:"value",value:function(S){return o(y.prototype.__proto__||Object.getPrototypeOf(y.prototype),"value",this).call(this,S).replace(/["']/g,"")}}]),y})(m.default.Attributor.Style),N=new v("font","font-family",u);r.FontStyle=N,r.FontClass=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.SizeStyle=r.SizeClass=void 0;var l=a(0),o=d(l);function d(x){return x&&x.__esModule?x:{default:x}}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 l=(function(){function C(S,D){for(var R=0;R<D.length;R++){var A=D[R];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(S,A.key,A)}}return function(S,D,R){return D&&C(S.prototype,D),R&&C(S,R),S}})(),o=a(0),d=p(o),m=a(5),f=p(m),x=a(9),h=p(x);function p(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 w(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 N=(function(C){v(S,C);function S(D,R){u(this,S);var A=w(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,D,R));return A.lastRecorded=0,A.ignoreChange=!1,A.clear(),A.quill.on(f.default.events.EDITOR_CHANGE,function(L,$,P,E){L!==f.default.events.TEXT_CHANGE||A.ignoreChange||(!A.options.userOnly||E===f.default.sources.USER?A.record($,P):A.transform($))}),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 l(S,[{key:"change",value:function(R,A){if(this.stack[R].length!==0){var L=this.stack[R].pop();this.stack[A].push(L),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(L[R],f.default.sources.USER),this.ignoreChange=!1;var $=y(L[R]);this.quill.setSelection($)}}},{key:"clear",value:function(){this.stack={undo:[],redo:[]}}},{key:"cutoff",value:function(){this.lastRecorded=0}},{key:"record",value:function(R,A){if(R.ops.length!==0){this.stack.redo=[];var L=this.quill.getContents().diff(A),$=Date.now();if(this.lastRecorded+this.options.delay>$&&this.stack.undo.length>0){var P=this.stack.undo.pop();L=L.compose(P.undo),R=P.redo.compose(R)}else this.lastRecorded=$;this.stack.undo.push({redo:R,undo:L}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift()}}},{key:"redo",value:function(){this.change("redo","undo")}},{key:"transform",value:function(R){this.stack.undo.forEach(function(A){A.undo=R.transform(A.undo,!0),A.redo=R.transform(A.redo,!0)}),this.stack.redo.forEach(function(A){A.undo=R.transform(A.undo,!0),A.redo=R.transform(A.redo,!0)})}},{key:"undo",value:function(){this.change("undo","redo")}}]),S})(h.default);N.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 y(C){var S=C.reduce(function(R,A){return R+=A.delete||0,R},0),D=C.length()-S;return j(C)&&(D-=1),D}r.default=N,r.getLastChangeIndex=y}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.BaseTooltip=void 0;var l=(function(){function F(B,K){for(var W=0;W<K.length;W++){var H=K[W];H.enumerable=H.enumerable||!1,H.configurable=!0,"value"in H&&(H.writable=!0),Object.defineProperty(B,H.key,H)}}return function(B,K,W){return K&&F(B.prototype,K),W&&F(B,W),B}})(),o=function F(B,K,W){B===null&&(B=Function.prototype);var H=Object.getOwnPropertyDescriptor(B,K);if(H===void 0){var X=Object.getPrototypeOf(B);return X===null?void 0:F(X,K,W)}else{if("value"in H)return H.value;var J=H.get;return J===void 0?void 0:J.call(W)}},d=a(3),m=$(d),f=a(2),x=$(f),h=a(8),p=$(h),u=a(23),w=$(u),v=a(34),N=$(v),j=a(59),y=$(j),C=a(60),S=$(C),D=a(28),R=$(D),A=a(61),L=$(A);function $(F){return F&&F.__esModule?F:{default:F}}function P(F,B){if(!(F instanceof B))throw new TypeError("Cannot call a class as a function")}function E(F,B){if(!F)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return B&&(typeof B=="object"||typeof B=="function")?B:F}function O(F,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof B);F.prototype=Object.create(B&&B.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),B&&(Object.setPrototypeOf?Object.setPrototypeOf(F,B):F.__proto__=B)}var I=[!1,"center","right","justify"],q=["#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"],G=[!1,"serif","monospace"],Y=["1","2","3",!1],V=["small",!1,"large","huge"],Q=(function(F){O(B,F);function B(K,W){P(this,B);var H=E(this,(B.__proto__||Object.getPrototypeOf(B)).call(this,K,W)),X=function J(ie){if(!document.body.contains(K.root))return document.body.removeEventListener("click",J);H.tooltip!=null&&!H.tooltip.root.contains(ie.target)&&document.activeElement!==H.tooltip.textbox&&!H.quill.hasFocus()&&H.tooltip.hide(),H.pickers!=null&&H.pickers.forEach(function(ae){ae.container.contains(ie.target)||ae.close()})};return K.emitter.listenDOM("click",document.body,X),H}return l(B,[{key:"addModule",value:function(W){var H=o(B.prototype.__proto__||Object.getPrototypeOf(B.prototype),"addModule",this).call(this,W);return W==="toolbar"&&this.extendToolbar(H),H}},{key:"buildButtons",value:function(W,H){W.forEach(function(X){var J=X.getAttribute("class")||"";J.split(/\s+/).forEach(function(ie){if(ie.startsWith("ql-")&&(ie=ie.slice(3),H[ie]!=null))if(ie==="direction")X.innerHTML=H[ie][""]+H[ie].rtl;else if(typeof H[ie]=="string")X.innerHTML=H[ie];else{var ae=X.value||"";ae!=null&&H[ie][ae]&&(X.innerHTML=H[ie][ae])}})})}},{key:"buildPickers",value:function(W,H){var X=this;this.pickers=W.map(function(ie){if(ie.classList.contains("ql-align"))return ie.querySelector("option")==null&&T(ie,I),new S.default(ie,H.align);if(ie.classList.contains("ql-background")||ie.classList.contains("ql-color")){var ae=ie.classList.contains("ql-background")?"background":"color";return ie.querySelector("option")==null&&T(ie,q,ae==="background"?"#ffffff":"#000000"),new y.default(ie,H[ae])}else return ie.querySelector("option")==null&&(ie.classList.contains("ql-font")?T(ie,G):ie.classList.contains("ql-header")?T(ie,Y):ie.classList.contains("ql-size")&&T(ie,V)),new R.default(ie)});var J=function(){X.pickers.forEach(function(ae){ae.update()})};this.quill.on(p.default.events.EDITOR_CHANGE,J)}}]),B})(N.default);Q.DEFAULTS=(0,m.default)(!0,{},N.default.DEFAULTS,{modules:{toolbar:{handlers:{formula:function(){this.quill.theme.tooltip.edit("formula")},image:function(){var B=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 W=new FileReader;W.onload=function(H){var X=B.quill.getSelection(!0);B.quill.updateContents(new x.default().retain(X.index).delete(X.length).insert({image:H.target.result}),p.default.sources.USER),B.quill.setSelection(X.index+1,p.default.sources.SILENT),K.value=""},W.readAsDataURL(K.files[0])}}),this.container.appendChild(K)),K.click()},video:function(){this.quill.theme.tooltip.edit("video")}}}}});var _=(function(F){O(B,F);function B(K,W){P(this,B);var H=E(this,(B.__proto__||Object.getPrototypeOf(B)).call(this,K,W));return H.textbox=H.root.querySelector('input[type="text"]'),H.listen(),H}return l(B,[{key:"listen",value:function(){var W=this;this.textbox.addEventListener("keydown",function(H){w.default.match(H,"enter")?(W.save(),H.preventDefault()):w.default.match(H,"escape")&&(W.cancel(),H.preventDefault())})}},{key:"cancel",value:function(){this.hide()}},{key:"edit",value:function(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),H!=null?this.textbox.value=H:W!==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-"+W)||""),this.root.setAttribute("data-mode",W)}},{key:"restoreFocus",value:function(){var W=this.quill.scrollingContainer.scrollTop;this.quill.focus(),this.quill.scrollingContainer.scrollTop=W}},{key:"save",value:function(){var W=this.textbox.value;switch(this.root.getAttribute("data-mode")){case"link":{var H=this.quill.root.scrollTop;this.linkRange?(this.quill.formatText(this.linkRange,"link",W,p.default.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",W,p.default.sources.USER)),this.quill.root.scrollTop=H;break}case"video":W=z(W);case"formula":{if(!W)break;var X=this.quill.getSelection(!0);if(X!=null){var J=X.index+X.length;this.quill.insertEmbed(J,this.root.getAttribute("data-mode"),W,p.default.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(J+1," ",p.default.sources.USER),this.quill.setSelection(J+2,p.default.sources.USER)}break}}this.textbox.value="",this.hide()}}]),B})(L.default);function z(F){var B=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 B?(B[1]||"https")+"://www.youtube.com/embed/"+B[2]+"?showinfo=0":(B=F.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?(B[1]||"https")+"://player.vimeo.com/video/"+B[2]+"/":F}function T(F,B){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;B.forEach(function(W){var H=document.createElement("option");W===K?H.setAttribute("selected","selected"):H.setAttribute("value",W),F.appendChild(H)})}r.BaseTooltip=_,r.default=Q}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(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,x=this.iterator();f=x();){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 x=this.find(d),h=x[0],p=x[1],u,w=d-p,v=this.iterator(h);(u=v())&&w<d+m;){var N=u.length();d>w?f(u,d-w,Math.min(m,w+N-d)):f(u,0,Math.min(N,d+m-w)),w+=N}},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,x=this.iterator();f=x();)m=d(m,f);return m},o})();r.default=l}),(function(n,r,a){var l=this&&this.__extends||(function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,u){p.__proto__=u}||function(p,u){for(var w in u)u.hasOwnProperty(w)&&(p[w]=u[w])};return function(p,u){h(p,u);function w(){this.constructor=p}p.prototype=u===null?Object.create(u):(w.prototype=u.prototype,new w)}})();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,x=(function(h){l(p,h);function p(u){var w=h.call(this,u)||this;return w.scroll=w,w.observer=new MutationObserver(function(v){w.update(v)}),w.observer.observe(w.domNode,m),w.attach(),w}return p.prototype.detach=function(){h.prototype.detach.call(this),this.observer.disconnect()},p.prototype.deleteAt=function(u,w){this.update(),u===0&&w===this.length()?this.children.forEach(function(v){v.remove()}):h.prototype.deleteAt.call(this,u,w)},p.prototype.formatAt=function(u,w,v,N){this.update(),h.prototype.formatAt.call(this,u,w,v,N)},p.prototype.insertAt=function(u,w,v){this.update(),h.prototype.insertAt.call(this,u,w,v)},p.prototype.optimize=function(u,w){var v=this;u===void 0&&(u=[]),w===void 0&&(w={}),h.prototype.optimize.call(this,w);for(var N=[].slice.call(this.observer.takeRecords());N.length>0;)u.push(N.pop());for(var j=function(D,R){R===void 0&&(R=!0),!(D==null||D===v)&&D.domNode.parentNode!=null&&(D.domNode[d.DATA_KEY].mutations==null&&(D.domNode[d.DATA_KEY].mutations=[]),R&&j(D.parent))},y=function(D){D.domNode[d.DATA_KEY]==null||D.domNode[d.DATA_KEY].mutations==null||(D instanceof o.default&&D.children.forEach(y),D.optimize(w))},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 R=d.find(D.target,!0);R!=null&&(R.domNode===D.target&&(D.type==="childList"?(j(d.find(D.previousSibling,!1)),[].forEach.call(D.addedNodes,function(A){var L=d.find(A,!1);j(L,!1),L instanceof o.default&&L.children.forEach(function($){j($,!1)})})):D.type==="attributes"&&j(R.prev)),j(R))}),this.children.forEach(y),C=[].slice.call(this.observer.takeRecords()),N=C.slice();N.length>0;)u.push(N.pop())}},p.prototype.update=function(u,w){var v=this;w===void 0&&(w={}),u=u||this.observer.takeRecords(),u.map(function(N){var j=d.find(N.target,!0);return j==null?null:j.domNode[d.DATA_KEY].mutations==null?(j.domNode[d.DATA_KEY].mutations=[N],j):(j.domNode[d.DATA_KEY].mutations.push(N),null)}).forEach(function(N){N==null||N===v||N.domNode[d.DATA_KEY]==null||N.update(N.domNode[d.DATA_KEY].mutations||[],w)}),this.domNode[d.DATA_KEY].mutations!=null&&h.prototype.update.call(this,this.domNode[d.DATA_KEY].mutations,w),this.optimize(u,w)},p.blotName="scroll",p.defaultChild="block",p.scope=d.Scope.BLOCK_BLOT,p.tagName="DIV",p})(o.default);r.default=x}),(function(n,r,a){var l=this&&this.__extends||(function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,p){h.__proto__=p}||function(h,p){for(var u in p)p.hasOwnProperty(u)&&(h[u]=p[u])};return function(h,p){x(h,p);function u(){this.constructor=h}h.prototype=p===null?Object.create(p):(u.prototype=p.prototype,new u)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1);function m(x,h){if(Object.keys(x).length!==Object.keys(h).length)return!1;for(var p in x)if(x[p]!==h[p])return!1;return!0}var f=(function(x){l(h,x);function h(){return x!==null&&x.apply(this,arguments)||this}return h.formats=function(p){if(p.tagName!==h.tagName)return x.formats.call(this,p)},h.prototype.format=function(p,u){var w=this;p===this.statics.blotName&&!u?(this.children.forEach(function(v){v instanceof o.default||(v=v.wrap(h.blotName,!0)),w.attributes.copy(v)}),this.unwrap()):x.prototype.format.call(this,p,u)},h.prototype.formatAt=function(p,u,w,v){if(this.formats()[w]!=null||d.query(w,d.Scope.ATTRIBUTE)){var N=this.isolate(p,u);N.format(w,v)}else x.prototype.formatAt.call(this,p,u,w,v)},h.prototype.optimize=function(p){x.prototype.optimize.call(this,p);var u=this.formats();if(Object.keys(u).length===0)return this.unwrap();var w=this.next;w instanceof h&&w.prev===this&&m(u,w.formats())&&(w.moveChildren(this),w.remove())},h.blotName="inline",h.scope=d.Scope.INLINE_BLOT,h.tagName="SPAN",h})(o.default);r.default=f}),(function(n,r,a){var l=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,h){x.__proto__=h}||function(x,h){for(var p in h)h.hasOwnProperty(p)&&(x[p]=h[p])};return function(x,h){f(x,h);function p(){this.constructor=x}x.prototype=h===null?Object.create(h):(p.prototype=h.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(18),d=a(1),m=(function(f){l(x,f);function x(){return f!==null&&f.apply(this,arguments)||this}return x.formats=function(h){var p=d.query(x.blotName).tagName;if(h.tagName!==p)return f.formats.call(this,h)},x.prototype.format=function(h,p){d.query(h,d.Scope.BLOCK)!=null&&(h===this.statics.blotName&&!p?this.replaceWith(x.blotName):f.prototype.format.call(this,h,p))},x.prototype.formatAt=function(h,p,u,w){d.query(u,d.Scope.BLOCK)!=null?this.format(u,w):f.prototype.formatAt.call(this,h,p,u,w)},x.prototype.insertAt=function(h,p,u){if(u==null||d.query(p,d.Scope.INLINE)!=null)f.prototype.insertAt.call(this,h,p,u);else{var w=this.split(h),v=d.create(p,u);w.parent.insertBefore(v,w)}},x.prototype.update=function(h,p){navigator.userAgent.match(/Trident/)?this.build():f.prototype.update.call(this,h,p)},x.blotName="block",x.scope=d.Scope.BLOCK_BLOT,x.tagName="P",x})(o.default);r.default=m}),(function(n,r,a){var l=this&&this.__extends||(function(){var m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,x){f.__proto__=x}||function(f,x){for(var h in x)x.hasOwnProperty(h)&&(f[h]=x[h])};return function(f,x){m(f,x);function h(){this.constructor=f}f.prototype=x===null?Object.create(x):(h.prototype=x.prototype,new h)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=(function(m){l(f,m);function f(){return m!==null&&m.apply(this,arguments)||this}return f.formats=function(x){},f.prototype.format=function(x,h){m.prototype.formatAt.call(this,0,this.length(),x,h)},f.prototype.formatAt=function(x,h,p,u){x===0&&h===this.length()?this.format(p,u):m.prototype.formatAt.call(this,x,h,p,u)},f.prototype.formats=function(){return this.statics.formats(this.domNode)},f})(o.default);r.default=d}),(function(n,r,a){var l=this&&this.__extends||(function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,h){x.__proto__=h}||function(x,h){for(var p in h)h.hasOwnProperty(p)&&(x[p]=h[p])};return function(x,h){f(x,h);function p(){this.constructor=x}x.prototype=h===null?Object.create(h):(p.prototype=h.prototype,new p)}})();Object.defineProperty(r,"__esModule",{value:!0});var o=a(19),d=a(1),m=(function(f){l(x,f);function x(h){var p=f.call(this,h)||this;return p.text=p.statics.value(p.domNode),p}return x.create=function(h){return document.createTextNode(h)},x.value=function(h){var p=h.data;return p.normalize&&(p=p.normalize()),p},x.prototype.deleteAt=function(h,p){this.domNode.data=this.text=this.text.slice(0,h)+this.text.slice(h+p)},x.prototype.index=function(h,p){return this.domNode===h?p:-1},x.prototype.insertAt=function(h,p,u){u==null?(this.text=this.text.slice(0,h)+p+this.text.slice(h),this.domNode.data=this.text):f.prototype.insertAt.call(this,h,p,u)},x.prototype.length=function(){return this.text.length},x.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 x&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())},x.prototype.position=function(h,p){return[this.domNode,h]},x.prototype.split=function(h,p){if(p===void 0&&(p=!1),!p){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},x.prototype.update=function(h,p){var u=this;h.some(function(w){return w.type==="characterData"&&w.target===u.domNode})&&(this.text=this.statics.value(this.domNode))},x.prototype.value=function(){return this.text},x.blotName="text",x.scope=d.Scope.INLINE_BLOT,x})(o.default);r.default=m}),(function(n,r,a){var l=document.createElement("div");if(l.classList.toggle("test-class",!1),l.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 x=f.indexOf(d,m);return x!==-1&&x===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),x=f.length>>>0,h=arguments[1],p,u=0;u<x;u++)if(p=f[u],m.call(h,p,u,f))return p}}),document.addEventListener("DOMContentLoaded",function(){document.execCommand("enableObjectResizing",!1,!1),document.execCommand("autoUrlDetect",!1,!1)})}),(function(n,r){var a=-1,l=1,o=0;function d(S,D,R){if(S==D)return S?[[o,S]]:[];(R<0||S.length<R)&&(R=null);var A=h(S,D),L=S.substring(0,A);S=S.substring(A),D=D.substring(A),A=p(S,D);var $=S.substring(S.length-A);S=S.substring(0,S.length-A),D=D.substring(0,D.length-A);var P=m(S,D);return L&&P.unshift([o,L]),$&&P.push([o,$]),w(P),R!=null&&(P=j(P,R)),P=y(P),P}function m(S,D){var R;if(!S)return[[l,D]];if(!D)return[[a,S]];var A=S.length>D.length?S:D,L=S.length>D.length?D:S,$=A.indexOf(L);if($!=-1)return R=[[l,A.substring(0,$)],[o,L],[l,A.substring($+L.length)]],S.length>D.length&&(R[0][0]=R[2][0]=a),R;if(L.length==1)return[[a,S],[l,D]];var P=u(S,D);if(P){var E=P[0],O=P[1],I=P[2],q=P[3],G=P[4],Y=d(E,I),V=d(O,q);return Y.concat([[o,G]],V)}return f(S,D)}function f(S,D){for(var R=S.length,A=D.length,L=Math.ceil((R+A)/2),$=L,P=2*L,E=new Array(P),O=new Array(P),I=0;I<P;I++)E[I]=-1,O[I]=-1;E[$+1]=0,O[$+1]=0;for(var q=R-A,G=q%2!=0,Y=0,V=0,Q=0,_=0,z=0;z<L;z++){for(var T=-z+Y;T<=z-V;T+=2){var F=$+T,B;T==-z||T!=z&&E[F-1]<E[F+1]?B=E[F+1]:B=E[F-1]+1;for(var K=B-T;B<R&&K<A&&S.charAt(B)==D.charAt(K);)B++,K++;if(E[F]=B,B>R)V+=2;else if(K>A)Y+=2;else if(G){var W=$+q-T;if(W>=0&&W<P&&O[W]!=-1){var H=R-O[W];if(B>=H)return x(S,D,B,K)}}}for(var X=-z+Q;X<=z-_;X+=2){var W=$+X,H;X==-z||X!=z&&O[W-1]<O[W+1]?H=O[W+1]:H=O[W-1]+1;for(var J=H-X;H<R&&J<A&&S.charAt(R-H-1)==D.charAt(A-J-1);)H++,J++;if(O[W]=H,H>R)_+=2;else if(J>A)Q+=2;else if(!G){var F=$+q-X;if(F>=0&&F<P&&E[F]!=-1){var B=E[F],K=$+B-F;if(H=R-H,B>=H)return x(S,D,B,K)}}}}return[[a,S],[l,D]]}function x(S,D,R,A){var L=S.substring(0,R),$=D.substring(0,A),P=S.substring(R),E=D.substring(A),O=d(L,$),I=d(P,E);return O.concat(I)}function h(S,D){if(!S||!D||S.charAt(0)!=D.charAt(0))return 0;for(var R=0,A=Math.min(S.length,D.length),L=A,$=0;R<L;)S.substring($,L)==D.substring($,L)?(R=L,$=R):A=L,L=Math.floor((A-R)/2+R);return L}function p(S,D){if(!S||!D||S.charAt(S.length-1)!=D.charAt(D.length-1))return 0;for(var R=0,A=Math.min(S.length,D.length),L=A,$=0;R<L;)S.substring(S.length-L,S.length-$)==D.substring(D.length-L,D.length-$)?(R=L,$=R):A=L,L=Math.floor((A-R)/2+R);return L}function u(S,D){var R=S.length>D.length?S:D,A=S.length>D.length?D:S;if(R.length<4||A.length*2<R.length)return null;function L(V,Q,_){for(var z=V.substring(_,_+Math.floor(V.length/4)),T=-1,F="",B,K,W,H;(T=Q.indexOf(z,T+1))!=-1;){var X=h(V.substring(_),Q.substring(T)),J=p(V.substring(0,_),Q.substring(0,T));F.length<J+X&&(F=Q.substring(T-J,T)+Q.substring(T,T+X),B=V.substring(0,_-J),K=V.substring(_+X),W=Q.substring(0,T-J),H=Q.substring(T+X))}return F.length*2>=V.length?[B,K,W,H,F]:null}var $=L(R,A,Math.ceil(R.length/4)),P=L(R,A,Math.ceil(R.length/2)),E;if(!$&&!P)return null;P?$?E=$[4].length>P[4].length?$:P:E=P:E=$;var O,I,q,G;S.length>D.length?(O=E[0],I=E[1],q=E[2],G=E[3]):(q=E[0],G=E[1],O=E[2],I=E[3]);var Y=E[4];return[O,I,q,G,Y]}function w(S){S.push([o,""]);for(var D=0,R=0,A=0,L="",$="",P;D<S.length;)switch(S[D][0]){case l:A++,$+=S[D][1],D++;break;case a:R++,L+=S[D][1],D++;break;case o:R+A>1?(R!==0&&A!==0&&(P=h($,L),P!==0&&(D-R-A>0&&S[D-R-A-1][0]==o?S[D-R-A-1][1]+=$.substring(0,P):(S.splice(0,0,[o,$.substring(0,P)]),D++),$=$.substring(P),L=L.substring(P)),P=p($,L),P!==0&&(S[D][1]=$.substring($.length-P)+S[D][1],$=$.substring(0,$.length-P),L=L.substring(0,L.length-P))),R===0?S.splice(D-A,R+A,[l,$]):A===0?S.splice(D-R,R+A,[a,L]):S.splice(D-R-A,R+A,[a,L],[l,$]),D=D-R-A+(R?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,R=0,L="",$="";break}S[S.length-1][1]===""&&S.pop();var E=!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),E=!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),E=!0)),D++;E&&w(S)}var v=d;v.INSERT=l,v.DELETE=a,v.EQUAL=o,n.exports=v;function N(S,D){if(D===0)return[o,S];for(var R=0,A=0;A<S.length;A++){var L=S[A];if(L[0]===a||L[0]===o){var $=R+L[1].length;if(D===$)return[A+1,S];if(D<$){S=S.slice();var P=D-R,E=[L[0],L[1].slice(0,P)],O=[L[0],L[1].slice(P)];return S.splice(A,1,E,O),[A+1,S]}else R=$}}throw new Error("cursor_pos is out of bounds!")}function j(S,D){var R=N(S,D),A=R[1],L=R[0],$=A[L],P=A[L+1];if($==null)return S;if($[0]!==o)return S;if(P!=null&&$[1]+P[1]===P[1]+$[1])return A.splice(L,2,P,$),C(A,L,2);if(P!=null&&P[1].indexOf($[1])===0){A.splice(L,2,[P[0],$[1]],[0,$[1]]);var E=P[1].slice($[1].length);return E.length>0&&A.splice(L+2,0,[P[0],E]),C(A,L,3)}else return S}function y(S){for(var D=!1,R=function(P){return P.charCodeAt(0)>=56320&&P.charCodeAt(0)<=57343},A=function(P){return P.charCodeAt(P.length-1)>=55296&&P.charCodeAt(P.length-1)<=56319},L=2;L<S.length;L+=1)S[L-2][0]===o&&A(S[L-2][1])&&S[L-1][0]===a&&R(S[L-1][1])&&S[L][0]===l&&R(S[L][1])&&(D=!0,S[L-1][1]=S[L-2][1].slice(-1)+S[L-1][1],S[L][1]=S[L-2][1].slice(-1)+S[L][1],S[L-2][1]=S[L-2][1].slice(0,-1));if(!D)return S;for(var $=[],L=0;L<S.length;L+=1)S[L][1].length>0&&$.push(S[L]);return $}function C(S,D,R){for(var A=D+R-1;A>=0&&A>=D-1;A--)if(A+1<S.length){var L=S[A],$=S[A+1];L[0]===$[1]&&S.splice(A,2,[L[0],L[1]+$[1]])}return S}}),(function(n,r){r=n.exports=typeof Object.keys=="function"?Object.keys:a,r.shim=a;function a(l){var o=[];for(var d in l)o.push(d);return o}}),(function(n,r){var a=(function(){return Object.prototype.toString.call(arguments)})()=="[object Arguments]";r=n.exports=a?l:o,r.supported=l;function l(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,l="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(l=!1));function d(f,x,h){this.fn=f,this.context=x,this.once=h||!1}function m(){this._events=new o,this._eventsCount=0}m.prototype.eventNames=function(){var x=[],h,p;if(this._eventsCount===0)return x;for(p in h=this._events)a.call(h,p)&&x.push(l?p.slice(1):p);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(h)):x},m.prototype.listeners=function(x,h){var p=l?l+x:x,u=this._events[p];if(h)return!!u;if(!u)return[];if(u.fn)return[u.fn];for(var w=0,v=u.length,N=new Array(v);w<v;w++)N[w]=u[w].fn;return N},m.prototype.emit=function(x,h,p,u,w,v){var N=l?l+x:x;if(!this._events[N])return!1;var j=this._events[N],y=arguments.length,C,S;if(j.fn){switch(j.once&&this.removeListener(x,j.fn,void 0,!0),y){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,p),!0;case 4:return j.fn.call(j.context,h,p,u),!0;case 5:return j.fn.call(j.context,h,p,u,w),!0;case 6:return j.fn.call(j.context,h,p,u,w,v),!0}for(S=1,C=new Array(y-1);S<y;S++)C[S-1]=arguments[S];j.fn.apply(j.context,C)}else{var D=j.length,R;for(S=0;S<D;S++)switch(j[S].once&&this.removeListener(x,j[S].fn,void 0,!0),y){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,p);break;case 4:j[S].fn.call(j[S].context,h,p,u);break;default:if(!C)for(R=1,C=new Array(y-1);R<y;R++)C[R-1]=arguments[R];j[S].fn.apply(j[S].context,C)}}return!0},m.prototype.on=function(x,h,p){var u=new d(h,p||this),w=l?l+x:x;return this._events[w]?this._events[w].fn?this._events[w]=[this._events[w],u]:this._events[w].push(u):(this._events[w]=u,this._eventsCount++),this},m.prototype.once=function(x,h,p){var u=new d(h,p||this,!0),w=l?l+x:x;return this._events[w]?this._events[w].fn?this._events[w]=[this._events[w],u]:this._events[w].push(u):(this._events[w]=u,this._eventsCount++),this},m.prototype.removeListener=function(x,h,p,u){var w=l?l+x:x;if(!this._events[w])return this;if(!h)return--this._eventsCount===0?this._events=new o:delete this._events[w],this;var v=this._events[w];if(v.fn)v.fn===h&&(!u||v.once)&&(!p||v.context===p)&&(--this._eventsCount===0?this._events=new o:delete this._events[w]);else{for(var N=0,j=[],y=v.length;N<y;N++)(v[N].fn!==h||u&&!v[N].once||p&&v[N].context!==p)&&j.push(v[N]);j.length?this._events[w]=j.length===1?j[0]:j:--this._eventsCount===0?this._events=new o:delete this._events[w]}return this},m.prototype.removeAllListeners=function(x){var h;return x?(h=l?l+x:x,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=l,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 l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(te){return typeof te}:function(te){return te&&typeof Symbol=="function"&&te.constructor===Symbol&&te!==Symbol.prototype?"symbol":typeof te},o=(function(){function te(ve,qe){var ge=[],Be=!0,ut=!1,ht=void 0;try{for(var it=ve[Symbol.iterator](),Tt;!(Be=(Tt=it.next()).done)&&(ge.push(Tt.value),!(qe&&ge.length===qe));Be=!0);}catch(It){ut=!0,ht=It}finally{try{!Be&&it.return&&it.return()}finally{if(ut)throw ht}}return ge}return function(ve,qe){if(Array.isArray(ve))return ve;if(Symbol.iterator in Object(ve))return te(ve,qe);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=(function(){function te(ve,qe){for(var ge=0;ge<qe.length;ge++){var Be=qe[ge];Be.enumerable=Be.enumerable||!1,Be.configurable=!0,"value"in Be&&(Be.writable=!0),Object.defineProperty(ve,Be.key,Be)}}return function(ve,qe,ge){return qe&&te(ve.prototype,qe),ge&&te(ve,ge),ve}})(),m=a(3),f=O(m),x=a(2),h=O(x),p=a(0),u=O(p),w=a(5),v=O(w),N=a(10),j=O(N),y=a(9),C=O(y),S=a(36),D=a(37),R=a(13),A=O(R),L=a(26),$=a(38),P=a(39),E=a(40);function O(te){return te&&te.__esModule?te:{default:te}}function I(te,ve,qe){return ve in te?Object.defineProperty(te,ve,{value:qe,enumerable:!0,configurable:!0,writable:!0}):te[ve]=qe,te}function q(te,ve){if(!(te instanceof ve))throw new TypeError("Cannot call a class as a function")}function G(te,ve){if(!te)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return ve&&(typeof ve=="object"||typeof ve=="function")?ve:te}function Y(te,ve){if(typeof ve!="function"&&ve!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof ve);te.prototype=Object.create(ve&&ve.prototype,{constructor:{value:te,enumerable:!1,writable:!0,configurable:!0}}),ve&&(Object.setPrototypeOf?Object.setPrototypeOf(te,ve):te.__proto__=ve)}var V=(0,j.default)("quill:clipboard"),Q="__ql-matcher",_=[[Node.TEXT_NODE,bt],[Node.TEXT_NODE,ke],["br",xe],[Node.ELEMENT_NODE,ke],[Node.ELEMENT_NODE,ae],[Node.ELEMENT_NODE,Xe],[Node.ELEMENT_NODE,ie],[Node.ELEMENT_NODE,Ot],["li",we],["b",J.bind(J,"bold")],["i",J.bind(J,"italic")],["style",ce]],z=[S.AlignAttribute,$.DirectionAttribute].reduce(function(te,ve){return te[ve.keyName]=ve,te},{}),T=[S.AlignStyle,D.BackgroundStyle,L.ColorStyle,$.DirectionStyle,P.FontStyle,E.SizeStyle].reduce(function(te,ve){return te[ve.keyName]=ve,te},{}),F=(function(te){Y(ve,te);function ve(qe,ge){q(this,ve);var Be=G(this,(ve.__proto__||Object.getPrototypeOf(ve)).call(this,qe,ge));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=[],_.concat(Be.options.matchers).forEach(function(ut){var ht=o(ut,2),it=ht[0],Tt=ht[1];!ge.matchVisual&&Tt===Xe||Be.addMatcher(it,Tt)}),Be}return d(ve,[{key:"addMatcher",value:function(ge,Be){this.matchers.push([ge,Be])}},{key:"convert",value:function(ge){if(typeof ge=="string")return this.container.innerHTML=ge.replace(/\>\r?\n +\</g,"><"),this.convert();var Be=this.quill.getFormat(this.quill.selection.savedRange.index);if(Be[A.default.blotName]){var ut=this.container.innerText;return this.container.innerHTML="",new h.default().insert(ut,I({},A.default.blotName,Be[A.default.blotName]))}var ht=this.prepareMatching(),it=o(ht,2),Tt=it[0],It=it[1],he=X(this.container,Tt,It);return W(he,`
|
||
`)&&he.ops[he.ops.length-1].attributes==null&&(he=he.compose(new h.default().retain(he.length()-1).delete(1))),V.log("convert",this.container.innerHTML,he),this.container.innerHTML="",he}},{key:"dangerouslyPasteHTML",value:function(ge,Be){var ut=arguments.length>2&&arguments[2]!==void 0?arguments[2]:v.default.sources.API;if(typeof ge=="string")this.quill.setContents(this.convert(ge),Be),this.quill.setSelection(0,v.default.sources.SILENT);else{var ht=this.convert(Be);this.quill.updateContents(new h.default().retain(ge).concat(ht),ut),this.quill.setSelection(ge+ht.length(),v.default.sources.SILENT)}}},{key:"onPaste",value:function(ge){var Be=this;if(!(ge.defaultPrevented||!this.quill.isEnabled())){var ut=this.quill.getSelection(),ht=new h.default().retain(ut.index),it=this.quill.scrollingContainer.scrollTop;this.container.focus(),this.quill.selection.update(v.default.sources.SILENT),setTimeout(function(){ht=ht.concat(Be.convert()).delete(ut.length),Be.quill.updateContents(ht,v.default.sources.USER),Be.quill.setSelection(ht.length()-ut.length,v.default.sources.SILENT),Be.quill.scrollingContainer.scrollTop=it,Be.quill.focus()},1)}}},{key:"prepareMatching",value:function(){var ge=this,Be=[],ut=[];return this.matchers.forEach(function(ht){var it=o(ht,2),Tt=it[0],It=it[1];switch(Tt){case Node.TEXT_NODE:ut.push(It);break;case Node.ELEMENT_NODE:Be.push(It);break;default:[].forEach.call(ge.container.querySelectorAll(Tt),function(he){he[Q]=he[Q]||[],he[Q].push(It)});break}}),[Be,ut]}}]),ve})(C.default);F.DEFAULTS={matchers:[],matchVisual:!0};function B(te,ve,qe){return(typeof ve>"u"?"undefined":l(ve))==="object"?Object.keys(ve).reduce(function(ge,Be){return B(ge,Be,ve[Be])},te):te.reduce(function(ge,Be){return Be.attributes&&Be.attributes[ve]?ge.push(Be):ge.insert(Be.insert,(0,f.default)({},I({},ve,qe),Be.attributes))},new h.default)}function K(te){if(te.nodeType!==Node.ELEMENT_NODE)return{};var ve="__ql-computed-style";return te[ve]||(te[ve]=window.getComputedStyle(te))}function W(te,ve){for(var qe="",ge=te.ops.length-1;ge>=0&&qe.length<ve.length;--ge){var Be=te.ops[ge];if(typeof Be.insert!="string")break;qe=Be.insert+qe}return qe.slice(-1*ve.length)===ve}function H(te){if(te.childNodes.length===0)return!1;var ve=K(te);return["block","list-item"].indexOf(ve.display)>-1}function X(te,ve,qe){return te.nodeType===te.TEXT_NODE?qe.reduce(function(ge,Be){return Be(te,ge)},new h.default):te.nodeType===te.ELEMENT_NODE?[].reduce.call(te.childNodes||[],function(ge,Be){var ut=X(Be,ve,qe);return Be.nodeType===te.ELEMENT_NODE&&(ut=ve.reduce(function(ht,it){return it(Be,ht)},ut),ut=(Be[Q]||[]).reduce(function(ht,it){return it(Be,ht)},ut)),ge.concat(ut)},new h.default):new h.default}function J(te,ve,qe){return B(qe,te,!0)}function ie(te,ve){var qe=u.default.Attributor.Attribute.keys(te),ge=u.default.Attributor.Class.keys(te),Be=u.default.Attributor.Style.keys(te),ut={};return qe.concat(ge).concat(Be).forEach(function(ht){var it=u.default.query(ht,u.default.Scope.ATTRIBUTE);it!=null&&(ut[it.attrName]=it.value(te),ut[it.attrName])||(it=z[ht],it!=null&&(it.attrName===ht||it.keyName===ht)&&(ut[it.attrName]=it.value(te)||void 0),it=T[ht],it!=null&&(it.attrName===ht||it.keyName===ht)&&(it=T[ht],ut[it.attrName]=it.value(te)||void 0))}),Object.keys(ut).length>0&&(ve=B(ve,ut)),ve}function ae(te,ve){var qe=u.default.query(te);if(qe==null)return ve;if(qe.prototype instanceof u.default.Embed){var ge={},Be=qe.value(te);Be!=null&&(ge[qe.blotName]=Be,ve=new h.default().insert(ge,qe.formats(te)))}else typeof qe.formats=="function"&&(ve=B(ve,qe.blotName,qe.formats(te)));return ve}function xe(te,ve){return W(ve,`
|
||
`)||ve.insert(`
|
||
`),ve}function ce(){return new h.default}function we(te,ve){var qe=u.default.query(te);if(qe==null||qe.blotName!=="list-item"||!W(ve,`
|
||
`))return ve;for(var ge=-1,Be=te.parentNode;!Be.classList.contains("ql-clipboard");)(u.default.query(Be)||{}).blotName==="list"&&(ge+=1),Be=Be.parentNode;return ge<=0?ve:ve.compose(new h.default().retain(ve.length()-1).retain(1,{indent:ge}))}function ke(te,ve){return W(ve,`
|
||
`)||(H(te)||ve.length()>0&&te.nextSibling&&H(te.nextSibling))&&ve.insert(`
|
||
`),ve}function Xe(te,ve){if(H(te)&&te.nextElementSibling!=null&&!W(ve,`
|
||
|
||
`)){var qe=te.offsetHeight+parseFloat(K(te).marginTop)+parseFloat(K(te).marginBottom);te.nextElementSibling.offsetTop>te.offsetTop+qe*1.5&&ve.insert(`
|
||
`)}return ve}function Ot(te,ve){var qe={},ge=te.style||{};return ge.fontStyle&&K(te).fontStyle==="italic"&&(qe.italic=!0),ge.fontWeight&&(K(te).fontWeight.startsWith("bold")||parseInt(K(te).fontWeight)>=700)&&(qe.bold=!0),Object.keys(qe).length>0&&(ve=B(ve,qe)),parseFloat(ge.textIndent||0)>0&&(ve=new h.default().insert(" ").concat(ve)),ve}function bt(te,ve){var qe=te.data;if(te.parentNode.tagName==="O:P")return ve.insert(qe.trim());if(qe.trim().length===0&&te.parentNode.classList.contains("ql-clipboard"))return ve;if(!K(te.parentNode).whiteSpace.startsWith("pre")){var ge=function(ut,ht){return ht=ht.replace(/[^\u00a0]/g,""),ht.length<1&&ut?" ":ht};qe=qe.replace(/\r\n/g," ").replace(/\n/g," "),qe=qe.replace(/\s\s+/g,ge.bind(ge,!0)),(te.previousSibling==null&&H(te.parentNode)||te.previousSibling!=null&&H(te.previousSibling))&&(qe=qe.replace(/^\s+/,ge.bind(ge,!1))),(te.nextSibling==null&&H(te.parentNode)||te.nextSibling!=null&&H(te.nextSibling))&&(qe=qe.replace(/\s+$/,ge.bind(ge,!1)))}return ve.insert(qe)}r.default=F,r.matchAttributor=ie,r.matchBlot=ae,r.matchNewline=ke,r.matchSpacing=Xe,r.matchText=bt}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=(function(){function w(v,N){for(var j=0;j<N.length;j++){var y=N[j];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}return function(v,N,j){return N&&w(v.prototype,N),j&&w(v,j),v}})(),o=function w(v,N,j){v===null&&(v=Function.prototype);var y=Object.getOwnPropertyDescriptor(v,N);if(y===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:w(C,N,j)}else{if("value"in y)return y.value;var S=y.get;return S===void 0?void 0:S.call(j)}},d=a(6),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function x(w,v){if(!(w instanceof v))throw new TypeError("Cannot call a class as a function")}function h(w,v){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:w}function p(w,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);w.prototype=Object.create(v&&v.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(w,v):w.__proto__=v)}var u=(function(w){p(v,w);function v(){return x(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return l(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 l=(function(){function E(O,I){var q=[],G=!0,Y=!1,V=void 0;try{for(var Q=O[Symbol.iterator](),_;!(G=(_=Q.next()).done)&&(q.push(_.value),!(I&&q.length===I));G=!0);}catch(z){Y=!0,V=z}finally{try{!G&&Q.return&&Q.return()}finally{if(Y)throw V}}return q}return function(O,I){if(Array.isArray(O))return O;if(Symbol.iterator in Object(O))return E(O,I);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=(function(){function E(O,I){for(var q=0;q<I.length;q++){var G=I[q];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(O,G.key,G)}}return function(O,I,q){return I&&E(O.prototype,I),q&&E(O,q),O}})(),d=a(2),m=j(d),f=a(0),x=j(f),h=a(5),p=j(h),u=a(10),w=j(u),v=a(9),N=j(v);function j(E){return E&&E.__esModule?E:{default:E}}function y(E,O,I){return O in E?Object.defineProperty(E,O,{value:I,enumerable:!0,configurable:!0,writable:!0}):E[O]=I,E}function C(E,O){if(!(E instanceof O))throw new TypeError("Cannot call a class as a function")}function S(E,O){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O&&(typeof O=="object"||typeof O=="function")?O:E}function D(E,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof O);E.prototype=Object.create(O&&O.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),O&&(Object.setPrototypeOf?Object.setPrototypeOf(E,O):E.__proto__=O)}var R=(0,w.default)("quill:toolbar"),A=(function(E){D(O,E);function O(I,q){C(this,O);var G=S(this,(O.__proto__||Object.getPrototypeOf(O)).call(this,I,q));if(Array.isArray(G.options.container)){var Y=document.createElement("div");$(Y,G.options.container),I.container.parentNode.insertBefore(Y,I.container),G.container=Y}else typeof G.options.container=="string"?G.container=document.querySelector(G.options.container):G.container=G.options.container;if(!(G.container instanceof HTMLElement)){var V;return V=R.error("Container required for toolbar",G.options),S(G,V)}return G.container.classList.add("ql-toolbar"),G.controls=[],G.handlers={},Object.keys(G.options.handlers).forEach(function(Q){G.addHandler(Q,G.options.handlers[Q])}),[].forEach.call(G.container.querySelectorAll("button, select"),function(Q){G.attach(Q)}),G.quill.on(p.default.events.EDITOR_CHANGE,function(Q,_){Q===p.default.events.SELECTION_CHANGE&&G.update(_)}),G.quill.on(p.default.events.SCROLL_OPTIMIZE,function(){var Q=G.quill.selection.getRange(),_=l(Q,1),z=_[0];G.update(z)}),G}return o(O,[{key:"addHandler",value:function(q,G){this.handlers[q]=G}},{key:"attach",value:function(q){var G=this,Y=[].find.call(q.classList,function(Q){return Q.indexOf("ql-")===0});if(Y){if(Y=Y.slice(3),q.tagName==="BUTTON"&&q.setAttribute("type","button"),this.handlers[Y]==null){if(this.quill.scroll.whitelist!=null&&this.quill.scroll.whitelist[Y]==null){R.warn("ignoring attaching to disabled format",Y,q);return}if(x.default.query(Y)==null){R.warn("ignoring attaching to nonexistent format",Y,q);return}}var V=q.tagName==="SELECT"?"change":"click";q.addEventListener(V,function(Q){var _=void 0;if(q.tagName==="SELECT"){if(q.selectedIndex<0)return;var z=q.options[q.selectedIndex];z.hasAttribute("selected")?_=!1:_=z.value||!1}else q.classList.contains("ql-active")?_=!1:_=q.value||!q.hasAttribute("value"),Q.preventDefault();G.quill.focus();var T=G.quill.selection.getRange(),F=l(T,1),B=F[0];if(G.handlers[Y]!=null)G.handlers[Y].call(G,_);else if(x.default.query(Y).prototype instanceof x.default.Embed){if(_=prompt("Enter "+Y),!_)return;G.quill.updateContents(new m.default().retain(B.index).delete(B.length).insert(y({},Y,_)),p.default.sources.USER)}else G.quill.format(Y,_,p.default.sources.USER);G.update(B)}),this.controls.push([Y,q])}}},{key:"update",value:function(q){var G=q==null?{}:this.quill.getFormat(q);this.controls.forEach(function(Y){var V=l(Y,2),Q=V[0],_=V[1];if(_.tagName==="SELECT"){var z=void 0;if(q==null)z=null;else if(G[Q]==null)z=_.querySelector("option[selected]");else if(!Array.isArray(G[Q])){var T=G[Q];typeof T=="string"&&(T=T.replace(/\"/g,'\\"')),z=_.querySelector('option[value="'+T+'"]')}z==null?(_.value="",_.selectedIndex=-1):z.selected=!0}else if(q==null)_.classList.remove("ql-active");else if(_.hasAttribute("value")){var F=G[Q]===_.getAttribute("value")||G[Q]!=null&&G[Q].toString()===_.getAttribute("value")||G[Q]==null&&!_.getAttribute("value");_.classList.toggle("ql-active",F)}else _.classList.toggle("ql-active",G[Q]!=null)})}}]),O})(N.default);A.DEFAULTS={};function L(E,O,I){var q=document.createElement("button");q.setAttribute("type","button"),q.classList.add("ql-"+O),I!=null&&(q.value=I),E.appendChild(q)}function $(E,O){Array.isArray(O[0])||(O=[O]),O.forEach(function(I){var q=document.createElement("span");q.classList.add("ql-formats"),I.forEach(function(G){if(typeof G=="string")L(q,G);else{var Y=Object.keys(G)[0],V=G[Y];Array.isArray(V)?P(q,Y,V):L(q,Y,V)}}),E.appendChild(q)})}function P(E,O,I){var q=document.createElement("select");q.classList.add("ql-"+O),I.forEach(function(G){var Y=document.createElement("option");G!==!1?Y.setAttribute("value",G):Y.setAttribute("selected","selected"),q.appendChild(Y)}),E.appendChild(q)}A.DEFAULTS={container:null,handlers:{clean:function(){var O=this,I=this.quill.getSelection();if(I!=null)if(I.length==0){var q=this.quill.getFormat();Object.keys(q).forEach(function(G){x.default.query(G,x.default.Scope.INLINE)!=null&&O.quill.format(G,!1)})}else this.quill.removeFormat(I,p.default.sources.USER)},direction:function(O){var I=this.quill.getFormat().align;O==="rtl"&&I==null?this.quill.format("align","right",p.default.sources.USER):!O&&I==="right"&&this.quill.format("align",!1,p.default.sources.USER),this.quill.format("direction",O,p.default.sources.USER)},indent:function(O){var I=this.quill.getSelection(),q=this.quill.getFormat(I),G=parseInt(q.indent||0);if(O==="+1"||O==="-1"){var Y=O==="+1"?1:-1;q.direction==="rtl"&&(Y*=-1),this.quill.format("indent",G+Y,p.default.sources.USER)}},link:function(O){O===!0&&(O=prompt("Enter link URL:")),this.quill.format("link",O,p.default.sources.USER)},list:function(O){var I=this.quill.getSelection(),q=this.quill.getFormat(I);O==="check"?q.list==="checked"||q.list==="unchecked"?this.quill.format("list",!1,p.default.sources.USER):this.quill.format("list","unchecked",p.default.sources.USER):this.quill.format("list",O,p.default.sources.USER)}}},r.default=A,r.addControls=$}),(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 l=(function(){function w(v,N){for(var j=0;j<N.length;j++){var y=N[j];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}return function(v,N,j){return N&&w(v.prototype,N),j&&w(v,j),v}})(),o=function w(v,N,j){v===null&&(v=Function.prototype);var y=Object.getOwnPropertyDescriptor(v,N);if(y===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:w(C,N,j)}else{if("value"in y)return y.value;var S=y.get;return S===void 0?void 0:S.call(j)}},d=a(28),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function x(w,v){if(!(w instanceof v))throw new TypeError("Cannot call a class as a function")}function h(w,v){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:w}function p(w,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);w.prototype=Object.create(v&&v.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(w,v):w.__proto__=v)}var u=(function(w){p(v,w);function v(N,j){x(this,v);var y=h(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,N));return y.label.innerHTML=j,y.container.classList.add("ql-color-picker"),[].slice.call(y.container.querySelectorAll(".ql-picker-item"),0,7).forEach(function(C){C.classList.add("ql-primary")}),y}return l(v,[{key:"buildItem",value:function(j){var y=o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"buildItem",this).call(this,j);return y.style.backgroundColor=j.getAttribute("value")||"",y}},{key:"selectItem",value:function(j,y){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"selectItem",this).call(this,j,y);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 l=(function(){function w(v,N){for(var j=0;j<N.length;j++){var y=N[j];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}return function(v,N,j){return N&&w(v.prototype,N),j&&w(v,j),v}})(),o=function w(v,N,j){v===null&&(v=Function.prototype);var y=Object.getOwnPropertyDescriptor(v,N);if(y===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:w(C,N,j)}else{if("value"in y)return y.value;var S=y.get;return S===void 0?void 0:S.call(j)}},d=a(28),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function x(w,v){if(!(w instanceof v))throw new TypeError("Cannot call a class as a function")}function h(w,v){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:w}function p(w,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);w.prototype=Object.create(v&&v.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(w,v):w.__proto__=v)}var u=(function(w){p(v,w);function v(N,j){x(this,v);var y=h(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,N));return y.container.classList.add("ql-icon-picker"),[].forEach.call(y.container.querySelectorAll(".ql-picker-item"),function(C){C.innerHTML=j[C.getAttribute("data-value")||""]}),y.defaultItem=y.container.querySelector(".ql-selected"),y.selectItem(y.defaultItem),y}return l(v,[{key:"selectItem",value:function(j,y){o(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"selectItem",this).call(this,j,y),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 l=(function(){function m(f,x){for(var h=0;h<x.length;h++){var p=x[h];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(f,p.key,p)}}return function(f,x,h){return x&&m(f.prototype,x),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,x){var h=this;o(this,m),this.quill=f,this.boundsContainer=x||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 l(m,[{key:"hide",value:function(){this.root.classList.add("ql-hidden")}},{key:"position",value:function(x){var h=x.left+x.width/2-this.root.offsetWidth/2,p=x.bottom+this.quill.root.scrollTop;this.root.style.left=h+"px",this.root.style.top=p+"px",this.root.classList.remove("ql-flip");var u=this.boundsContainer.getBoundingClientRect(),w=this.root.getBoundingClientRect(),v=0;if(w.right>u.right&&(v=u.right-w.right,this.root.style.left=h+v+"px"),w.left<u.left&&(v=u.left-w.left,this.root.style.left=h+v+"px"),w.bottom>u.bottom){var N=w.bottom-w.top,j=x.bottom-x.top+N;this.root.style.top=p-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 l=(function(){function P(E,O){var I=[],q=!0,G=!1,Y=void 0;try{for(var V=E[Symbol.iterator](),Q;!(q=(Q=V.next()).done)&&(I.push(Q.value),!(O&&I.length===O));q=!0);}catch(_){G=!0,Y=_}finally{try{!q&&V.return&&V.return()}finally{if(G)throw Y}}return I}return function(E,O){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return P(E,O);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),o=function P(E,O,I){E===null&&(E=Function.prototype);var q=Object.getOwnPropertyDescriptor(E,O);if(q===void 0){var G=Object.getPrototypeOf(E);return G===null?void 0:P(G,O,I)}else{if("value"in q)return q.value;var Y=q.get;return Y===void 0?void 0:Y.call(I)}},d=(function(){function P(E,O){for(var I=0;I<O.length;I++){var q=O[I];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(E,q.key,q)}}return function(E,O,I){return O&&P(E.prototype,O),I&&P(E,I),E}})(),m=a(3),f=C(m),x=a(8),h=C(x),p=a(43),u=C(p),w=a(27),v=C(w),N=a(15),j=a(41),y=C(j);function C(P){return P&&P.__esModule?P:{default:P}}function S(P,E){if(!(P instanceof E))throw new TypeError("Cannot call a class as a function")}function D(P,E){if(!P)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:P}function R(P,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);P.prototype=Object.create(E&&E.prototype,{constructor:{value:P,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(P,E):P.__proto__=E)}var A=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],L=(function(P){R(E,P);function E(O,I){S(this,E),I.modules.toolbar!=null&&I.modules.toolbar.container==null&&(I.modules.toolbar.container=A);var q=D(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,O,I));return q.quill.container.classList.add("ql-snow"),q}return d(E,[{key:"extendToolbar",value:function(I){I.container.classList.add("ql-snow"),this.buildButtons([].slice.call(I.container.querySelectorAll("button")),y.default),this.buildPickers([].slice.call(I.container.querySelectorAll("select")),y.default),this.tooltip=new $(this.quill,this.options.bounds),I.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"K",shortKey:!0},function(q,G){I.handlers.link.call(I,!G.format.link)})}}]),E})(u.default);L.DEFAULTS=(0,f.default)(!0,{},u.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(E){if(E){var O=this.quill.getSelection();if(O==null||O.length==0)return;var I=this.quill.getText(O);/^\S+@\S+\.\S+$/.test(I)&&I.indexOf("mailto:")!==0&&(I="mailto:"+I);var q=this.quill.theme.tooltip;q.edit("link",I)}else this.quill.format("link",!1)}}}}});var $=(function(P){R(E,P);function E(O,I){S(this,E);var q=D(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,O,I));return q.preview=q.root.querySelector("a.ql-preview"),q}return d(E,[{key:"listen",value:function(){var I=this;o(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"listen",this).call(this),this.root.querySelector("a.ql-action").addEventListener("click",function(q){I.root.classList.contains("ql-editing")?I.save():I.edit("link",I.preview.textContent),q.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",function(q){if(I.linkRange!=null){var G=I.linkRange;I.restoreFocus(),I.quill.formatText(G,"link",!1,h.default.sources.USER),delete I.linkRange}q.preventDefault(),I.hide()}),this.quill.on(h.default.events.SELECTION_CHANGE,function(q,G,Y){if(q!=null){if(q.length===0&&Y===h.default.sources.USER){var V=I.quill.scroll.descendant(v.default,q.index),Q=l(V,2),_=Q[0],z=Q[1];if(_!=null){I.linkRange=new N.Range(q.index-z,_.length());var T=v.default.formats(_.domNode);I.preview.textContent=T,I.preview.setAttribute("href",T),I.show(),I.position(I.quill.getBounds(I.linkRange));return}}else delete I.linkRange;I.hide()}})}},{key:"show",value:function(){o(E.prototype.__proto__||Object.getPrototypeOf(E.prototype),"show",this).call(this),this.root.removeAttribute("data-mode")}}]),E})(p.BaseTooltip);$.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=L}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(29),o=Be(l),d=a(36),m=a(38),f=a(64),x=a(65),h=Be(x),p=a(66),u=Be(p),w=a(67),v=Be(w),N=a(37),j=a(26),y=a(39),C=a(40),S=a(56),D=Be(S),R=a(68),A=Be(R),L=a(27),$=Be(L),P=a(69),E=Be(P),O=a(70),I=Be(O),q=a(71),G=Be(q),Y=a(72),V=Be(Y),Q=a(73),_=Be(Q),z=a(13),T=Be(z),F=a(74),B=Be(F),K=a(75),W=Be(K),H=a(57),X=Be(H),J=a(41),ie=Be(J),ae=a(28),xe=Be(ae),ce=a(59),we=Be(ce),ke=a(60),Xe=Be(ke),Ot=a(61),bt=Be(Ot),te=a(108),ve=Be(te),qe=a(62),ge=Be(qe);function Be(ut){return ut&&ut.__esModule?ut:{default:ut}}o.default.register({"attributors/attribute/direction":m.DirectionAttribute,"attributors/class/align":d.AlignClass,"attributors/class/background":N.BackgroundClass,"attributors/class/color":j.ColorClass,"attributors/class/direction":m.DirectionClass,"attributors/class/font":y.FontClass,"attributors/class/size":C.SizeClass,"attributors/style/align":d.AlignStyle,"attributors/style/background":N.BackgroundStyle,"attributors/style/color":j.ColorStyle,"attributors/style/direction":m.DirectionStyle,"attributors/style/font":y.FontStyle,"attributors/style/size":C.SizeStyle},!0),o.default.register({"formats/align":d.AlignClass,"formats/direction":m.DirectionClass,"formats/indent":f.IndentClass,"formats/background":N.BackgroundStyle,"formats/color":j.ColorStyle,"formats/font":y.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":$.default,"formats/script":E.default,"formats/strike":I.default,"formats/underline":G.default,"formats/image":V.default,"formats/video":_.default,"formats/list/item":w.ListItem,"modules/formula":B.default,"modules/syntax":W.default,"modules/toolbar":X.default,"themes/bubble":ve.default,"themes/snow":ge.default,"ui/icons":ie.default,"ui/picker":xe.default,"ui/icon-picker":Xe.default,"ui/color-picker":we.default,"ui/tooltip":bt.default},!0),r.default=o.default}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.IndentClass=void 0;var l=(function(){function v(N,j){for(var y=0;y<j.length;y++){var C=j[y];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(N,C.key,C)}}return function(N,j,y){return j&&v(N.prototype,j),y&&v(N,y),N}})(),o=function v(N,j,y){N===null&&(N=Function.prototype);var C=Object.getOwnPropertyDescriptor(N,j);if(C===void 0){var S=Object.getPrototypeOf(N);return S===null?void 0:v(S,j,y)}else{if("value"in C)return C.value;var D=C.get;return D===void 0?void 0:D.call(y)}},d=a(0),m=f(d);function f(v){return v&&v.__esModule?v:{default:v}}function x(v,N){if(!(v instanceof N))throw new TypeError("Cannot call a class as a function")}function h(v,N){if(!v)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N&&(typeof N=="object"||typeof N=="function")?N:v}function p(v,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof N);v.prototype=Object.create(N&&N.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),N&&(Object.setPrototypeOf?Object.setPrototypeOf(v,N):v.__proto__=N)}var u=(function(v){p(N,v);function N(){return x(this,N),h(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}return l(N,[{key:"add",value:function(y,C){if(C==="+1"||C==="-1"){var S=this.value(y)||0;C=C==="+1"?S+1:S-1}return C===0?(this.remove(y),!0):o(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"add",this).call(this,y,C)}},{key:"canAdd",value:function(y,C){return o(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"canAdd",this).call(this,y,C)||o(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"canAdd",this).call(this,y,parseInt(C))}},{key:"value",value:function(y){return parseInt(o(N.prototype.__proto__||Object.getPrototypeOf(N.prototype),"value",this).call(this,y))||void 0}}]),N})(m.default.Attributor.Class),w=new u("indent","ql-indent",{scope:m.default.Scope.BLOCK,whitelist:[1,2,3,4,5,6,7,8]});r.IndentClass=w}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(4),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function m(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function f(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function x(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var h=(function(p){x(u,p);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 l=(function(){function u(w,v){for(var N=0;N<v.length;N++){var j=v[N];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(w,j.key,j)}}return function(w,v,N){return v&&u(w.prototype,v),N&&u(w,N),w}})(),o=a(4),d=m(o);function m(u){return u&&u.__esModule?u:{default:u}}function f(u,w){if(!(u instanceof w))throw new TypeError("Cannot call a class as a function")}function x(u,w){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w&&(typeof w=="object"||typeof w=="function")?w:u}function h(u,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof w);u.prototype=Object.create(w&&w.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),w&&(Object.setPrototypeOf?Object.setPrototypeOf(u,w):u.__proto__=w)}var p=(function(u){h(w,u);function w(){return f(this,w),x(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}return l(w,null,[{key:"formats",value:function(N){return this.tagName.indexOf(N.tagName)+1}}]),w})(d.default);p.blotName="header",p.tagName=["H1","H2","H3","H4","H5","H6"],r.default=p}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.ListItem=void 0;var l=(function(){function S(D,R){for(var A=0;A<R.length;A++){var L=R[A];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(D,L.key,L)}}return function(D,R,A){return R&&S(D.prototype,R),A&&S(D,A),D}})(),o=function S(D,R,A){D===null&&(D=Function.prototype);var L=Object.getOwnPropertyDescriptor(D,R);if(L===void 0){var $=Object.getPrototypeOf(D);return $===null?void 0:S($,R,A)}else{if("value"in L)return L.value;var P=L.get;return P===void 0?void 0:P.call(A)}},d=a(0),m=u(d),f=a(4),x=u(f),h=a(25),p=u(h);function u(S){return S&&S.__esModule?S:{default:S}}function w(S,D,R){return D in S?Object.defineProperty(S,D,{value:R,enumerable:!0,configurable:!0,writable:!0}):S[D]=R,S}function v(S,D){if(!(S instanceof D))throw new TypeError("Cannot call a class as a function")}function N(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 y=(function(S){j(D,S);function D(){return v(this,D),N(this,(D.__proto__||Object.getPrototypeOf(D)).apply(this,arguments))}return l(D,[{key:"format",value:function(A,L){A===C.blotName&&!L?this.replaceWith(m.default.create(this.statics.scope)):o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"format",this).call(this,A,L)}},{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,L){return this.parent.isolate(this.offset(this.parent),this.length()),A===this.parent.statics.blotName?(this.parent.replaceWith(A,L),this):(this.parent.unwrap(),o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"replaceWith",this).call(this,A,L))}}],[{key:"formats",value:function(A){return A.tagName===this.tagName?void 0:o(D.__proto__||Object.getPrototypeOf(D),"formats",this).call(this,A)}}]),D})(x.default);y.blotName="list-item",y.tagName="LI";var C=(function(S){j(D,S),l(D,null,[{key:"create",value:function(A){var L=A==="ordered"?"OL":"UL",$=o(D.__proto__||Object.getPrototypeOf(D),"create",this).call(this,L);return(A==="checked"||A==="unchecked")&&$.setAttribute("data-checked",A==="checked"),$}},{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(R){v(this,D);var A=N(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,R)),L=function(P){if(P.target.parentNode===R){var E=A.statics.formats(R),O=m.default.find(P.target);E==="checked"?O.format("list","unchecked"):E==="unchecked"&&O.format("list","checked")}};return R.addEventListener("touchstart",L),R.addEventListener("mousedown",L),A}return l(D,[{key:"format",value:function(A,L){this.children.length>0&&this.children.tail.format(A,L)}},{key:"formats",value:function(){return w({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(A,L){if(A instanceof y)o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"insertBefore",this).call(this,A,L);else{var $=L==null?this.length():L.offset(this),P=this.split($);P.parent.insertBefore(A,P)}}},{key:"optimize",value:function(A){o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"optimize",this).call(this,A);var L=this.next;L!=null&&L.prev===this&&L.statics.blotName===this.statics.blotName&&L.domNode.tagName===this.domNode.tagName&&L.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(L.moveChildren(this),L.remove())}},{key:"replace",value:function(A){if(A.statics.blotName!==this.statics.blotName){var L=m.default.create(this.statics.defaultChild);A.moveChildren(L),this.appendChild(L)}o(D.prototype.__proto__||Object.getPrototypeOf(D.prototype),"replace",this).call(this,A)}}]),D})(p.default);C.blotName="list",C.scope=m.default.Scope.BLOCK_BLOT,C.tagName=["OL","UL"],C.defaultChild="list-item",C.allowedChildren=[y],r.ListItem=y,r.default=C}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0});var l=a(56),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function m(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function f(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function x(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var h=(function(p){x(u,p);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 l=(function(){function w(v,N){for(var j=0;j<N.length;j++){var y=N[j];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}return function(v,N,j){return N&&w(v.prototype,N),j&&w(v,j),v}})(),o=function w(v,N,j){v===null&&(v=Function.prototype);var y=Object.getOwnPropertyDescriptor(v,N);if(y===void 0){var C=Object.getPrototypeOf(v);return C===null?void 0:w(C,N,j)}else{if("value"in y)return y.value;var S=y.get;return S===void 0?void 0:S.call(j)}},d=a(6),m=f(d);function f(w){return w&&w.__esModule?w:{default:w}}function x(w,v){if(!(w instanceof v))throw new TypeError("Cannot call a class as a function")}function h(w,v){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:w}function p(w,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);w.prototype=Object.create(v&&v.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(w,v):w.__proto__=v)}var u=(function(w){p(v,w);function v(){return x(this,v),h(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}return l(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 l=a(6),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function m(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function f(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function x(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var h=(function(p){x(u,p);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 l=a(6),o=d(l);function d(p){return p&&p.__esModule?p:{default:p}}function m(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function f(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function x(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var h=(function(p){x(u,p);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 l=(function(){function N(j,y){for(var C=0;C<y.length;C++){var S=y[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,y,C){return y&&N(j.prototype,y),C&&N(j,C),j}})(),o=function N(j,y,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,y);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:N(D,y,C)}else{if("value"in S)return S.value;var R=S.get;return R===void 0?void 0:R.call(C)}},d=a(0),m=x(d),f=a(27);function x(N){return N&&N.__esModule?N:{default:N}}function h(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")}function p(N,j){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:N}function u(N,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);N.prototype=Object.create(j&&j.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(N,j):N.__proto__=j)}var w=["alt","height","width"],v=(function(N){u(j,N);function j(){return h(this,j),p(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return l(j,[{key:"format",value:function(C,S){w.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 w.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 l=(function(){function N(j,y){for(var C=0;C<y.length;C++){var S=y[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(j,S.key,S)}}return function(j,y,C){return y&&N(j.prototype,y),C&&N(j,C),j}})(),o=function N(j,y,C){j===null&&(j=Function.prototype);var S=Object.getOwnPropertyDescriptor(j,y);if(S===void 0){var D=Object.getPrototypeOf(j);return D===null?void 0:N(D,y,C)}else{if("value"in S)return S.value;var R=S.get;return R===void 0?void 0:R.call(C)}},d=a(4),m=a(27),f=x(m);function x(N){return N&&N.__esModule?N:{default:N}}function h(N,j){if(!(N instanceof j))throw new TypeError("Cannot call a class as a function")}function p(N,j){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j&&(typeof j=="object"||typeof j=="function")?j:N}function u(N,j){if(typeof j!="function"&&j!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof j);N.prototype=Object.create(j&&j.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),j&&(Object.setPrototypeOf?Object.setPrototypeOf(N,j):N.__proto__=j)}var w=["height","width"],v=(function(N){u(j,N);function j(){return h(this,j),p(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}return l(j,[{key:"format",value:function(C,S){w.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 w.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 l=(function(){function C(S,D){for(var R=0;R<D.length;R++){var A=D[R];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(S,A.key,A)}}return function(S,D,R){return D&&C(S.prototype,D),R&&C(S,R),S}})(),o=function C(S,D,R){S===null&&(S=Function.prototype);var A=Object.getOwnPropertyDescriptor(S,D);if(A===void 0){var L=Object.getPrototypeOf(S);return L===null?void 0:C(L,D,R)}else{if("value"in A)return A.value;var $=A.get;return $===void 0?void 0:$.call(R)}},d=a(35),m=u(d),f=a(5),x=u(f),h=a(9),p=u(h);function u(C){return C&&C.__esModule?C:{default:C}}function w(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 N(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){N(S,C);function S(){return w(this,S),v(this,(S.__proto__||Object.getPrototypeOf(S)).apply(this,arguments))}return l(S,null,[{key:"create",value:function(R){var A=o(S.__proto__||Object.getPrototypeOf(S),"create",this).call(this,R);return typeof R=="string"&&(window.katex.render(R,A,{throwOnError:!1,errorColor:"#f00"}),A.setAttribute("data-value",R)),A}},{key:"value",value:function(R){return R.getAttribute("data-value")}}]),S})(m.default);j.blotName="formula",j.className="ql-formula",j.tagName="SPAN";var y=(function(C){N(S,C),l(S,null,[{key:"register",value:function(){x.default.register(j,!0)}}]);function S(){w(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})(p.default);r.FormulaBlot=j,r.default=y}),(function(n,r,a){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.CodeToken=r.CodeBlock=void 0;var l=(function(){function R(A,L){for(var $=0;$<L.length;$++){var P=L[$];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(A,P.key,P)}}return function(A,L,$){return L&&R(A.prototype,L),$&&R(A,$),A}})(),o=function R(A,L,$){A===null&&(A=Function.prototype);var P=Object.getOwnPropertyDescriptor(A,L);if(P===void 0){var E=Object.getPrototypeOf(A);return E===null?void 0:R(E,L,$)}else{if("value"in P)return P.value;var O=P.get;return O===void 0?void 0:O.call($)}},d=a(0),m=v(d),f=a(5),x=v(f),h=a(9),p=v(h),u=a(13),w=v(u);function v(R){return R&&R.__esModule?R:{default:R}}function N(R,A){if(!(R instanceof A))throw new TypeError("Cannot call a class as a function")}function j(R,A){if(!R)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A&&(typeof A=="object"||typeof A=="function")?A:R}function y(R,A){if(typeof A!="function"&&A!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof A);R.prototype=Object.create(A&&A.prototype,{constructor:{value:R,enumerable:!1,writable:!0,configurable:!0}}),A&&(Object.setPrototypeOf?Object.setPrototypeOf(R,A):R.__proto__=A)}var C=(function(R){y(A,R);function A(){return N(this,A),j(this,(A.__proto__||Object.getPrototypeOf(A)).apply(this,arguments))}return l(A,[{key:"replaceWith",value:function($){this.domNode.textContent=this.domNode.textContent,this.attach(),o(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"replaceWith",this).call(this,$)}},{key:"highlight",value:function($){var P=this.domNode.textContent;this.cachedText!==P&&((P.trim().length>0||this.cachedText==null)&&(this.domNode.innerHTML=$(P),this.domNode.normalize(),this.attach()),this.cachedText=P)}}]),A})(w.default);C.className="ql-syntax";var S=new m.default.Attributor.Class("token","hljs",{scope:m.default.Scope.INLINE}),D=(function(R){y(A,R),l(A,null,[{key:"register",value:function(){x.default.register(S,!0),x.default.register(C,!0)}}]);function A(L,$){N(this,A);var P=j(this,(A.__proto__||Object.getPrototypeOf(A)).call(this,L,$));if(typeof P.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var E=null;return P.quill.on(x.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(E),E=setTimeout(function(){P.highlight(),E=null},P.options.interval)}),P.highlight(),P}return l(A,[{key:"highlight",value:function(){var $=this;if(!this.quill.selection.composing){this.quill.update(x.default.sources.USER);var P=this.quill.getSelection();this.quill.scroll.descendants(C).forEach(function(E){E.highlight($.options.highlight)}),this.quill.update(x.default.sources.SILENT),P!=null&&this.quill.setSelection(P,x.default.sources.SILENT)}}}]),A})(p.default);D.DEFAULTS={highlight:(function(){return window.hljs==null?null:function(R){var A=window.hljs.highlightAuto(R);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 l=function A(L,$,P){L===null&&(L=Function.prototype);var E=Object.getOwnPropertyDescriptor(L,$);if(E===void 0){var O=Object.getPrototypeOf(L);return O===null?void 0:A(O,$,P)}else{if("value"in E)return E.value;var I=E.get;return I===void 0?void 0:I.call(P)}},o=(function(){function A(L,$){for(var P=0;P<$.length;P++){var E=$[P];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(L,E.key,E)}}return function(L,$,P){return $&&A(L.prototype,$),P&&A(L,P),L}})(),d=a(3),m=N(d),f=a(8),x=N(f),h=a(43),p=N(h),u=a(15),w=a(41),v=N(w);function N(A){return A&&A.__esModule?A:{default:A}}function j(A,L){if(!(A instanceof L))throw new TypeError("Cannot call a class as a function")}function y(A,L){if(!A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return L&&(typeof L=="object"||typeof L=="function")?L:A}function C(A,L){if(typeof L!="function"&&L!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof L);A.prototype=Object.create(L&&L.prototype,{constructor:{value:A,enumerable:!1,writable:!0,configurable:!0}}),L&&(Object.setPrototypeOf?Object.setPrototypeOf(A,L):A.__proto__=L)}var S=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],D=(function(A){C(L,A);function L($,P){j(this,L),P.modules.toolbar!=null&&P.modules.toolbar.container==null&&(P.modules.toolbar.container=S);var E=y(this,(L.__proto__||Object.getPrototypeOf(L)).call(this,$,P));return E.quill.container.classList.add("ql-bubble"),E}return o(L,[{key:"extendToolbar",value:function(P){this.tooltip=new R(this.quill,this.options.bounds),this.tooltip.root.appendChild(P.container),this.buildButtons([].slice.call(P.container.querySelectorAll("button")),v.default),this.buildPickers([].slice.call(P.container.querySelectorAll("select")),v.default)}}]),L})(p.default);D.DEFAULTS=(0,m.default)(!0,{},p.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(L){L?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});var R=(function(A){C(L,A);function L($,P){j(this,L);var E=y(this,(L.__proto__||Object.getPrototypeOf(L)).call(this,$,P));return E.quill.on(x.default.events.EDITOR_CHANGE,function(O,I,q,G){if(O===x.default.events.SELECTION_CHANGE)if(I!=null&&I.length>0&&G===x.default.sources.USER){E.show(),E.root.style.left="0px",E.root.style.width="",E.root.style.width=E.root.offsetWidth+"px";var Y=E.quill.getLines(I.index,I.length);if(Y.length===1)E.position(E.quill.getBounds(I));else{var V=Y[Y.length-1],Q=E.quill.getIndex(V),_=Math.min(V.length()-1,I.index+I.length-Q),z=E.quill.getBounds(new u.Range(Q,_));E.position(z)}}else document.activeElement!==E.textbox&&E.quill.hasFocus()&&E.hide()}),E}return o(L,[{key:"listen",value:function(){var P=this;l(L.prototype.__proto__||Object.getPrototypeOf(L.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){P.root.classList.remove("ql-editing")}),this.quill.on(x.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!P.root.classList.contains("ql-hidden")){var E=P.quill.getSelection();E!=null&&P.position(P.quill.getBounds(E))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(P){var E=l(L.prototype.__proto__||Object.getPrototypeOf(L.prototype),"position",this).call(this,P),O=this.root.querySelector(".ql-tooltip-arrow");if(O.style.marginLeft="",E===0)return E;O.style.marginLeft=-1*E-O.offsetWidth/2+"px"}}]),L})(h.BaseTooltip);R.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,r.default=D}),(function(n,r,a){n.exports=a(63)})]).default})})(Gm)),Gm.exports}var li,AC;function bG(){if(AC)return li;AC=1;var t=li&&li.__extends||(function(){var x=function(h,p){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,w){u.__proto__=w}||function(u,w){for(var v in w)w.hasOwnProperty(v)&&(u[v]=w[v])},x(h,p)};return function(h,p){x(h,p);function u(){this.constructor=h}h.prototype=p===null?Object.create(p):(u.prototype=p.prototype,new u)}})(),s=li&&li.__assign||function(){return s=Object.assign||function(x){for(var h,p=1,u=arguments.length;p<u;p++){h=arguments[p];for(var w in h)Object.prototype.hasOwnProperty.call(h,w)&&(x[w]=h[w])}return x},s.apply(this,arguments)},n=li&&li.__spreadArrays||function(){for(var x=0,h=0,p=arguments.length;h<p;h++)x+=arguments[h].length;for(var u=Array(x),w=0,h=0;h<p;h++)for(var v=arguments[h],N=0,j=v.length;N<j;N++,w++)u[w]=v[N];return u},r=li&&li.__importDefault||function(x){return x&&x.__esModule?x:{default:x}},a=r(fd()),l=r(Iy()),o=r(gG()),d=r(yG()),m=(function(x){t(h,x);function h(p){var u=x.call(this,p)||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,N,j,y){var C,S,D,R;v==="text-change"?(S=(C=u).onEditorChangeText)===null||S===void 0||S.call(C,u.editor.root.innerHTML,N,y,u.unprivilegedEditor):v==="selection-change"&&((R=(D=u).onEditorChangeSelection)===null||R===void 0||R.call(D,N,y,u.unprivilegedEditor))};var w=u.isControlled()?p.value:p.defaultValue;return u.value=w??"",u}return h.prototype.validateProps=function(p){var u;if(a.default.Children.count(p.children)>1)throw new Error("The Quill editing area can only be composed of a single React element.");if(a.default.Children.count(p.children)){var w=a.default.Children.only(p.children);if(((u=w)===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&&p.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(p,u){var w=this,v;if(this.validateProps(p),!this.editor||this.state.generation!==u.generation)return!0;if("value"in p){var N=this.getEditorContents(),j=(v=p.value,v??"");this.isEqualValue(j,N)||this.setEditorContents(this.editor,j)}return p.readOnly!==this.props.readOnly&&this.setEditorReadOnly(this.editor,p.readOnly),n(this.cleanProps,this.dirtyProps).some(function(y){return!o.default(p[y],w.props[y])})},h.prototype.shouldComponentRegenerate=function(p){var u=this;return this.dirtyProps.some(function(w){return!o.default(p[w],u.props[w])})},h.prototype.componentDidMount=function(){this.instantiateEditor(),this.setEditorContents(this.editor,this.getEditorContents())},h.prototype.componentWillUnmount=function(){this.destroyEditor()},h.prototype.componentDidUpdate=function(p,u){var w=this;if(this.editor&&this.shouldComponentRegenerate(p)){var v=this.editor.getContents(),N=this.editor.getSelection();this.regenerationSnapshot={delta:v,selection:N},this.setState({generation:this.state.generation+1}),this.destroyEditor()}if(this.state.generation!==u.generation){var j=this.regenerationSnapshot,v=j.delta,y=j.selection;delete this.regenerationSnapshot,this.instantiateEditor();var C=this.editor;C.setContents(v),f(function(){return w.setEditorSelection(C,y)})}},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(p,u){var w=new d.default(p,u);return u.tabIndex!=null&&this.setEditorTabIndex(w,u.tabIndex),this.hookEditor(w),w},h.prototype.hookEditor=function(p){this.unprivilegedEditor=this.makeUnprivilegedEditor(p),p.on("editor-change",this.onEditorChange)},h.prototype.unhookEditor=function(p){p.off("editor-change",this.onEditorChange)},h.prototype.getEditorContents=function(){return this.value},h.prototype.getEditorSelection=function(){return this.selection},h.prototype.isDelta=function(p){return p&&p.ops},h.prototype.isEqualValue=function(p,u){return this.isDelta(p)&&this.isDelta(u)?o.default(p.ops,u.ops):o.default(p,u)},h.prototype.setEditorContents=function(p,u){var w=this;this.value=u;var v=this.getEditorSelection();typeof u=="string"?p.setContents(p.clipboard.convert(u)):p.setContents(u),f(function(){return w.setEditorSelection(p,v)})},h.prototype.setEditorSelection=function(p,u){if(this.selection=u,u){var w=p.getLength();u.index=Math.max(0,Math.min(u.index,w-1)),u.length=Math.max(0,Math.min(u.length,w-1-u.index)),p.setSelection(u)}},h.prototype.setEditorTabIndex=function(p,u){var w,v;!((v=(w=p)===null||w===void 0?void 0:w.scroll)===null||v===void 0)&&v.domNode&&(p.scroll.domNode.tabIndex=u)},h.prototype.setEditorReadOnly=function(p,u){u?p.disable():p.enable()},h.prototype.makeUnprivilegedEditor=function(p){var u=p;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 p=l.default.findDOMNode(this.editingArea);if(!p)throw new Error("Cannot find element for editing area");if(p.nodeType===3)throw new Error("Editing area cannot be a text node");return p},h.prototype.renderEditingArea=function(){var p=this,u=this.props,w=u.children,v=u.preserveWhitespace,N=this.state.generation,j={key:N,ref:function(y){p.editingArea=y}};return a.default.Children.count(w)?a.default.cloneElement(a.default.Children.only(w),j):v?a.default.createElement("pre",s({},j)):a.default.createElement("div",s({},j))},h.prototype.render=function(){var p;return a.default.createElement("div",{id:this.props.id,style:this.props.style,key:this.state.generation,className:"quill "+(p=this.props.className,p??""),onKeyPress:this.props.onKeyPress,onKeyDown:this.props.onKeyDown,onKeyUp:this.props.onKeyUp},this.renderEditingArea())},h.prototype.onEditorChangeText=function(p,u,w,v){var N,j;if(this.editor){var y=this.isDelta(this.value)?v.getContents():v.getHTML();y!==this.getEditorContents()&&(this.lastDeltaChangeSet=u,this.value=y,(j=(N=this.props).onChange)===null||j===void 0||j.call(N,p,u,w,v))}},h.prototype.onEditorChangeSelection=function(p,u,w){var v,N,j,y,C,S;if(this.editor){var D=this.getEditorSelection(),R=!D&&p,A=D&&!p;o.default(p,D)||(this.selection=p,(N=(v=this.props).onChangeSelection)===null||N===void 0||N.call(v,p,u,w),R?(y=(j=this.props).onFocus)===null||y===void 0||y.call(j,p,u,w):A&&((S=(C=this.props).onBlur)===null||S===void 0||S.call(C,D,u,w)))}},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(x){Promise.resolve().then(x)}return li=m,li}var jG=bG();const NG=wf(jG),wG={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline"],[{list:"ordered"},{list:"bullet"}],["link"],["blockquote"],["clean"]]},SG=["header","bold","italic","underline","list","bullet","link","blockquote"];function Km(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 Z_=g.forwardRef(({value:t,onChange:s,tab:n,onTabChange:r,textareaRef:a},l)=>{const o=g.useRef(null),d=g.useMemo(()=>Km(t),[t]);return g.useImperativeHandle(l,()=>({insertPlaceholder:m=>{var u,w;const f=`{{${m}}}`;if(n==="html"&&a.current){const v=a.current,N=v.selectionStart??0,j=v.selectionEnd??0,y=t.slice(0,N)+f+t.slice(j);s(y),requestAnimationFrame(()=>{v.focus();const C=N+f.length;v.setSelectionRange(C,C)});return}const x=(w=(u=o.current)==null?void 0:u.getEditor)==null?void 0:w.call(u);if(!x)return;const h=x.getSelection(!0),p=(h==null?void 0:h.index)??x.getLength();x.insertText(p,f,"user")}})),e.jsx("div",{className:"flex flex-col gap-2 flex-1 min-h-0",children:e.jsxs($n,{value:n,onValueChange:r,className:"flex flex-col flex-1 gap-2 min-h-0",children:[e.jsxs(qn,{className:"w-fit",children:[e.jsx(zt,{value:"visual",disabled:d,className:"text-xs",children:"Rich text"}),e.jsx(zt,{value:"html",className:"text-xs font-mono",children:"HTML source"})]}),d&&e.jsxs(di,{className:"border-red-200 bg-red-50 py-2",children:[e.jsx(_a,{className:"h-4 w-4 text-re-red-hover"}),e.jsxs(ui,{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(qt,{value:"visual",className:"flex-1 flex flex-col gap-2 mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx("div",{className:jt("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(NG,{ref:o,theme:"snow",value:t||"",onChange:s,modules:wG,formats:SG})}),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(qt,{value:"html",className:"flex-1 flex flex-col mt-2 min-h-[420px] data-[state=inactive]:hidden",children:[e.jsx(Gs,{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."]})]})]})})});Z_.displayName="EmailTemplateBodyEditor";function CG(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 AG=/\{\{\s*>\s*email_header\s*\}\}/i,kG=/\{\{\s*>\s*email_footer\s*\}\}/i,DG=/\{\{\s*>\s*primary_cta\s*\}\}/i,RG=/^[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_header\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*/i,EG=/[\s\r\n]*(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*email_footer\s*\}\}\s*(?:<\/(?:p|div)>)?[\s\r\n]*$/i,_G=/(?:<(?:p|div)[^>]*>)?\s*\{\{\s*>\s*primary_cta\s*\}\}\s*(?:<\/(?:p|div)>)?/gi;function TG(t){const s=t||"",n=CG(s);if(!AG.test(n)||!kG.test(n))return{isShellTemplate:!1,editableHtml:s,includesCta:!1};const r=DG.test(n);let a=n.replace(RG,"").replace(EG,"").replace(_G,"");return a=a.trim(),{isShellTemplate:!0,editableHtml:a,includesCta:r}}function PG(t,s){return`{{> email_header}}
|
||
${(t||"").trim()}${s?`
|
||
{{> primary_cta}}
|
||
`:`
|
||
`}{{> email_footer}}`}const OG=({isOpen:t,onOpenChange:s,editingTemplate:n,setEditingTemplate:r,testDataInput:a,setTestDataInput:l,previewLoading:o,handlePreviewTemplate:d,previewContent:m,handleSaveTemplate:f})=>{var $;const x=wt.useRef(null),h=wt.useRef(null),[p,u]=wt.useState("visual"),[w,v]=wt.useState(""),[N,j]=wt.useState(!1),[y,C]=wt.useState(!1);wt.useEffect(()=>{if(!t||!n)return;const P=TG(n.body||"");j(P.isShellTemplate),C(P.includesCta);const E=P.isShellTemplate?P.editableHtml:n.body||"";v(E);const O=Km(E);u(O?"html":"visual")},[t,n==null?void 0:n.id,n==null?void 0:n.body]);const S=wt.useCallback(()=>N?PG(w,y):(n==null?void 0:n.body)||"",[N,w,y,n==null?void 0:n.body]),D=P=>{var E;(E=h.current)==null||E.insertPlaceholder(P)},R=(n==null?void 0:n.placeholders)||[],A=N?w:(n==null?void 0:n.body)||"",L=P=>{N?(v(P),Km(P)&&u("html")):(r({...n,body:P}),Km(P)&&u("html"))};return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"sm:max-w-7xl w-full max-h-[95vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Edit Email Template"}),e.jsx(bs,{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(de,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Template Name"}),e.jsx(at,{placeholder:"e.g., Application Received",className:"mt-1.5 bg-white",value:(n==null?void 0:n.name)||"",onChange:P=>r({...n,name:P.target.value})})]}),e.jsxs("div",{children:[e.jsx(de,{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(Ce,{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(de,{className:"text-xs uppercase tracking-wider text-slate-500",children:"Description"}),e.jsx(at,{placeholder:"Brief purpose of this email",className:"mt-1.5 bg-white",value:(n==null?void 0:n.description)||"",onChange:P=>r({...n,description:P.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(jp,{id:"active",checked:(n==null?void 0:n.isActive)??!0,onCheckedChange:P=>r({...n,isActive:P})}),e.jsx(de,{htmlFor:"active",className:"text-sm cursor-pointer",children:"Active"})]}),e.jsx(Ce,{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(_a,{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:R.length>0?R.map(P=>e.jsx("button",{type:"button",onClick:()=>D(P),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:`{{${P}}}`},P)):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(Cr,{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(de,{className:"text-xs font-semibold",children:"Subject Line"}),e.jsx(at,{placeholder:"Subject line with {{variables}}",className:"mt-1.5 text-slate-900 font-medium",value:(n==null?void 0:n.subject)||"",onChange:P=>r({...n,subject:P.target.value})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-[480px]",children:[e.jsx(de,{className:"text-xs font-semibold mb-1.5",children:"Email Body"}),e.jsx(Z_,{ref:h,tab:p,onTabChange:P=>u(P),textareaRef:x,value:A,onChange:L})]})]})]}),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(vg,{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(de,{className:"text-xs font-semibold",children:"Mock Test Data (JSON)"}),e.jsx("button",{type:"button",onClick:()=>l('{"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(Gs,{placeholder:'{"applicant_name": "John Doe"}',className:"font-mono text-[11px] text-slate-900 bg-slate-50",rows:6,value:a,onChange:P=>l(P.target.value)})]}),e.jsxs(se,{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(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(vg,{className:"w-4 h-4 mr-2"}),"Generate Mock Preview"]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx(de,{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(Ce,{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(vg,{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(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{className:"flex-1 bg-re-red hover:bg-re-red-hover",type:"button",onClick:()=>f(S()),disabled:!(n!=null&&n.id)||!(($=n==null?void 0:n.templateCode)!=null&&$.trim()),children:"Save Template"})]})]})})},LG=({isOpen:t,onOpenChange:s,editingLocationId:n,locationState:r,setLocationState:a,locationDistrict:l,setLocationDistrict:o,locationCity:d,setLocationCity:m,locationActiveFrom:f,setLocationActiveFrom:x,locationActiveTo:h,setLocationActiveTo:p,locationStatus:u,setLocationStatus:w,allStates:v,allDistricts:N,onSave:j})=>{const y=wt.useMemo(()=>r?(N||[]).filter(C=>C.stateId===r):[],[N,r]);return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:n?"Edit Location":"Add Location"}),e.jsx(bs,{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(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"State"}),e.jsxs(At,{value:r,onValueChange:C=>{a(C),o("")},children:[e.jsx(Dt,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(kt,{placeholder:"Select state"})}),e.jsx(Rt,{children:(v||[]).map(C=>e.jsx(Me,{value:C.id,children:C.name||C.stateName},C.id))})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"City"}),e.jsx(at,{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(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"District"}),e.jsxs(At,{value:l,onValueChange:o,disabled:!r,children:[e.jsx(Dt,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(kt,{placeholder:r?"Select district":"Select state first"})}),e.jsx(Rt,{children:y.map(C=>e.jsx(Me,{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(de,{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(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Start Date"}),e.jsx(at,{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=>x(C.target.value)})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"End Date"}),e.jsx(at,{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=>p(C.target.value)})]})]})]}),e.jsxs("div",{children:[e.jsx(de,{className:"flex items-center gap-2 text-sm leading-none font-medium text-slate-700",children:"Opportunity"}),e.jsxs(At,{value:u,onValueChange:w,children:[e.jsx(Dt,{className:"mt-2 text-slate-900 border-slate-200 focus:ring-red-500/30 focus:border-red-500",children:e.jsx(kt,{placeholder:"Is this an active Opportunity?"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"active",children:"Yes"}),e.jsx(Me,{value:"inactive",children:"No"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(se,{variant:"outline",className:"flex-1",onClick:()=>s(!1),children:"Cancel"}),e.jsx(se,{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"})]})]})]})})},IG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,l]=g.useState(null),o=async()=>{try{r(!0);const f=await Fs.getSystemConfigs({category:"SECURITY_DEPOSIT"});f.success&&s(f.data)}catch(f){console.error("Fetch error:",f),ee.error("Failed to load deposit configurations")}finally{r(!1)}};g.useEffect(()=>{o()},[]);const d=(f,x)=>{s(h=>h.map(p=>p.id===f?{...p,value:{...p.value,amount:parseInt(x)||0}}:p))},m=async f=>{try{l(f.id),(await Fs.saveSystemConfig(f)).success&&ee.success(`Configuration for ${f.key} updated successfully`)}catch{ee.error("Failed to save configuration")}finally{l(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(Le,{className:"border-none shadow-lg bg-white/80 backdrop-blur-md",children:[e.jsx(Qe,{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(et,{className:"text-lg font-bold text-slate-900",children:"Global Payment Settings"}),e.jsx(Qt,{className:"text-xs",children:"Configure base Security Deposit amounts for onboarding workflows."})]})]})}),e.jsxs(Fe,{className:"p-4",children:[e.jsx("div",{className:"grid gap-3",children:t.map(f=>{var x;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(de,{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(ka,{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(at,{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:((x=f.value)==null?void 0:x.amount)||"",onChange:h=>d(f.id,h.target.value)})]})]}),e.jsx("div",{className:"pt-4",children:e.jsx(se,{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(pr,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(pl,{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(se,{variant:"outline",className:"mt-4 rounded-lg h-9 text-xs",onClick:o,children:[e.jsx(pr,{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."})]})]})]})},MG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,l]=g.useState(!1),[o,d]=g.useState(!1),[m,f]=g.useState(null),[x,h]=g.useState([]),[p,u]=g.useState({}),[w,v]=g.useState(!0),[N,j]=g.useState(""),[y,C]=g.useState(1),[S]=g.useState(10),[D,R]=g.useState(""),[A,L]=g.useState({total:0,pages:1}),$=g.useRef(!0),[P,E]=g.useState({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:""}),O=["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 ds.getDocumentConfigMetadata();T&&(h(T.modules||[]),u(T.stages||{}),((z=T.modules)==null?void 0:z.length)>0&&(R(T.modules[0]),E(F=>({...F,module:T.modules[0]}))))}catch{ee.error("Failed to load system metadata")}finally{v(!1)}})()},[]);const I=g.useCallback(async()=>{if(D){$.current?r(!0):l(!0);try{const _=await ds.getDocumentConfigs({search:N,page:y,limit:S,module:D,isAdminView:!0});_&&_.pagination?(s(_.data||[]),L(_.pagination)):Array.isArray(_)&&(s(_),L({total:_.length,pages:1}))}catch(_){console.error("Fetch Configs Error:",_),$.current||ee.error("Failed to sync configuration database")}finally{r(!1),l(!1),$.current=!1}}},[N,y,S,D]);g.useEffect(()=>{const _=setTimeout(()=>{I()},300);return()=>clearTimeout(_)},[I]);const q=async()=>{try{m?(await ds.updateDocumentConfig(m.id,P),ee.success("Configuration updated")):(await ds.createDocumentConfig(P),ee.success("Configuration created")),d(!1),I()}catch{ee.error("Failed to save configuration")}},G=async _=>{if(window.confirm("Are you sure you want to delete this configuration?"))try{await ds.deleteDocumentConfig(_),ee.success("Configuration deleted"),I()}catch{ee.error("Failed to delete configuration")}},Y=()=>{f(null),E({documentType:"",stageCode:"General",allowedRoles:[],isMandatory:!1,isActive:!0,module:D}),d(!0)},V=_=>{f(_),E({documentType:_.documentType,stageCode:_.stageCode,allowedRoles:_.allowedRoles||[],isMandatory:_.isMandatory,isActive:_.isActive,module:_.module||"ONBOARDING"}),d(!0)},Q=_=>{E(z=>({...z,allowedRoles:z.allowedRoles.includes(_)?z.allowedRoles.filter(T=>T!==_):[...z.allowedRoles,_]}))};return w?e.jsxs("div",{className:"h-96 flex flex-col items-center justify-center gap-4",children:[e.jsx(ny,{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(Le,{className:"border-slate-200 shadow-sm overflow-hidden bg-white",children:[e.jsxs(Qe,{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(WI,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx(et,{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(se,{onClick:Y,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(Dn,{className:"w-4 h-4"})," Add Policy"]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-64",children:e.jsxs(At,{value:D,onValueChange:_=>{R(_),C(1)},children:[e.jsx(Dt,{className:"h-10 rounded-xl bg-white border-slate-200 focus:ring-red-500 font-bold text-slate-700 shadow-sm",children:e.jsx(kt,{placeholder:"Target Module"})}),e.jsx(Rt,{className:"rounded-xl shadow-2xl border-none",children:x.map(_=>e.jsx(Me,{value:_,className:"font-bold text-xs py-2.5 uppercase",children:_.replace(/_/g," ")},_))})]})}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{placeholder:"Search policies, stages or documents...",value:N,onChange:_=>{j(_.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(Fe,{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(es,{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(Ps,{children:[e.jsx(Os,{className:"bg-slate-50/50",children:e.jsxs(lt,{className:"border-none",children:[e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Policy Detail"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Process Stage"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Module"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Stakeholders"}),e.jsx(fe,{className:"font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Compliance Rules"}),e.jsx(fe,{className:"text-right font-bold text-slate-500 text-[11px] uppercase tracking-wider",children:"Action"})]})}),e.jsx(Ls,{children:!n&&t.length===0?e.jsx(lt,{children:e.jsx(ue,{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(Ta,{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(_=>{var z,T;return e.jsxs(lt,{className:"hover:bg-slate-50/80 transition-colors group h-14",children:[e.jsx(ue,{children:e.jsx("div",{className:"font-bold text-slate-900 group-hover:text-re-red-hover transition-colors uppercase text-[12px]",children:_.documentType})}),e.jsx(ue,{children:e.jsx(Ce,{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:_.stageCode})}),e.jsx(ue,{children:e.jsx("div",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-tighter",children:(z=_.module)==null?void 0:z.replace(/_/g," ")})}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:((T=_.allowedRoles)==null?void 0:T.length)>0?e.jsxs(e.Fragment,{children:[_.allowedRoles.slice(0,2).map(F=>e.jsx(Ce,{variant:"secondary",className:"bg-white text-slate-600 text-[9px] border-slate-200 font-bold uppercase",children:F},F)),_.allowedRoles.length>2&&e.jsxs(Ce,{variant:"outline",className:"text-[9px] text-slate-400 font-bold border-dashed",children:["+",_.allowedRoles.length-2]})]}):e.jsx(Ce,{variant:"secondary",className:"bg-slate-50 text-slate-400 text-[9px] border-slate-100 uppercase",children:"Inherited"})})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex gap-2",children:[_.isMandatory&&e.jsx(Ce,{className:"bg-re-red text-white border-transparent text-[10px] font-bold h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"BLOCKING"}),!_.isActive&&e.jsx(Ce,{className:"bg-slate-200 text-slate-500 border-transparent text-[10px] h-5 px-1.5 rounded-sm uppercase tracking-tighter",children:"DORMANT"}),_.isActive&&!_.isMandatory&&e.jsx(Ce,{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(ue,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>V(_),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(Cr,{className:"w-4 h-4"})}),e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>G(_.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(ar,{className:"w-4 h-4"})})]})})]},_.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?(y-1)*S+1:0," - ",Math.min(y*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(se,{variant:"outline",size:"sm",disabled:y===1,onClick:()=>{C(_=>Math.max(1,_-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(lo,{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:y})," ",e.jsx("span",{className:"mx-2 text-slate-300",children:"/"})," ",A.pages]}),e.jsxs(se,{variant:"outline",size:"sm",disabled:y>=A.pages,onClick:()=>{C(_=>Math.min(A.pages,_+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(ji,{className:"w-4 h-4 ml-1 text-slate-600"})]})]})]})]}),e.jsx(ls,{open:o,onOpenChange:d,children:e.jsxs(as,{className:"max-w-2xl rounded-2xl border-none shadow-2xl p-0 overflow-hidden ring-1 ring-black/5",children:[e.jsx(fs,{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(Bf,{className:"w-7 h-7 text-red-400"})}),e.jsxs("div",{children:[e.jsx(us,{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 ",P.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(de,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Process Stream"}),e.jsxs(At,{value:P.module,onValueChange:_=>E(z=>({...z,module:_,stageCode:"General"})),children:[e.jsx(Dt,{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(kt,{placeholder:"Module"})}),e.jsx(Rt,{className:"rounded-xl border-none shadow-2xl",children:x.map(_=>e.jsx(Me,{value:_,className:"py-3 px-4 rounded-lg focus:bg-red-50 font-black text-[10px] uppercase",children:_.replace(/_/g," ")},_))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Milestone Stage"}),e.jsxs(At,{value:P.stageCode,onValueChange:_=>E(z=>({...z,stageCode:_})),children:[e.jsx(Dt,{className:"h-12 rounded-xl border-slate-200 focus:ring-red-500 shadow-sm bg-white font-black text-xs uppercase",children:e.jsx(kt,{placeholder:"Select Stage"})}),e.jsx(Rt,{className:"rounded-xl border-none shadow-2xl",children:(p[P.module]||["General"]).map(_=>e.jsx(Me,{value:_,className:"py-3 px-4 rounded-lg focus:bg-red-50 font-black text-[10px] uppercase",children:_},_))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-slate-900 font-black px-1 text-[11px] uppercase tracking-wider",children:"Document Label Identifier"}),e.jsx(at,{value:P.documentType,onChange:_=>E(z=>({...z,documentType:_.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(de,{className:"text-slate-900 font-black flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider",children:[e.jsx(no,{className:"w-4 h-4 text-re-red"})," Visibility Matrix"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:O.map(_=>e.jsxs("div",{className:`flex items-center space-x-2 p-3 rounded-xl border transition-all cursor-pointer group active:scale-95 ${P.allowedRoles.includes(_)?"bg-red-50 border-red-300 shadow-sm":"bg-white border-slate-200 hover:border-red-200 hover:shadow-sm"}`,onClick:()=>Q(_),children:[e.jsx(Tn,{id:`role-${_}`,checked:P.allowedRoles.includes(_),onCheckedChange:()=>Q(_),className:"w-4 h-4 data-[state=checked]:bg-re-red data-[state=checked]:border-re-red rounded"}),e.jsx(de,{htmlFor:`role-${_}`,className:`text-[10px] font-black cursor-pointer uppercase truncate ${P.allowedRoles.includes(_)?"text-red-800":"text-slate-500 group-hover:text-re-red-hover"}`,children:_})]},_))})]}),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 ${P.isMandatory?"bg-red-50 border-red-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-red-50/30"}`,onClick:()=>E(_=>({..._,isMandatory:!_.isMandatory})),children:[e.jsx(Tn,{id:"mandatory",checked:P.isMandatory,onCheckedChange:_=>E(z=>({...z,isMandatory:!!_})),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(de,{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 ${P.isActive?"bg-emerald-50 border-emerald-200 shadow-sm":"bg-slate-50 border-slate-100 hover:bg-emerald-50/30"}`,onClick:()=>E(_=>({..._,isActive:!_.isActive})),children:[e.jsx(Tn,{id:"active",checked:P.isActive,onCheckedChange:_=>E(z=>({...z,isActive:!!_})),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(de,{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(xn,{className:"bg-slate-50 p-7 flex gap-4 border-t",children:[e.jsx(se,{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(se,{onClick:q,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"})]})]})})]})},FG=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),a=async()=>{r(!0);try{const m=await Fs.getSystemConfigs({category:"ASSIGNMENT"});m.success&&s(m.data)}catch{ee.error("Failed to load assignment configurations")}finally{r(!1)}};g.useEffect(()=>{a()},[]);const l=(m,f)=>{s(x=>x.map(h=>h.key===m?{...h,value:{...h.value,enabled:f}}:h))},o=async m=>{try{(await Fs.saveSystemConfig({key:m.key,value:m.value,category:m.category,description:m.description})).success&&ee.success(`${m.key.replace("AUTO_ASSIGN_","")} setting updated`)}catch{ee.error("Failed to save configuration")}},d=[{key:"AUTO_ASSIGN_ONBOARDING",label:"Onboarding",icon:ac,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RELOCATION",label:"Relocation",icon:iM,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_TERMINATION",label:"Termination",icon:qI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_CONSTITUTIONAL",label:"Constitutional",icon:UI,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_RESIGNATION",label:"Resignation",icon:Ns,color:"text-slate-500",bg:"bg-slate-100"},{key:"AUTO_ASSIGN_FNF",label:"F&F Settlement",icon:OI,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(fl,{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(Le,{className:"border-none shadow-md overflow-hidden bg-white/50 backdrop-blur-sm",children:[e.jsx(Qe,{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(Bf,{className:"w-6 h-6 text-red-400"})}),e.jsxs("div",{children:[e.jsx(et,{className:"text-xl font-bold",children:"Auto-Assignment Governance"}),e.jsx(Qt,{className:"text-slate-300",children:"Control the automated mapping of participants across different business modules"})]})]})}),e.jsxs(Fe,{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(p=>p.key===m.key),x=((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:jt("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(vp,{children:e.jsxs(uj,{children:[e.jsx(hj,{children:e.jsx(_a,{className:"w-3.5 h-3.5 text-slate-400"})}),e.jsx(mj,{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(Ce,{variant:x?"default":"secondary",className:x?"bg-emerald-50 text-emerald-700 border-emerald-200 hover:bg-emerald-100":"bg-slate-50 text-slate-500 border-slate-200",children:x?"Auto-Assign ON":"Manual Mode"})})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsx(jp,{className:"data-[state=checked]:bg-re-red",checked:x,onCheckedChange:p=>{l(m.key,p);const u=t.find(w=>w.key===m.key);u&&o({...u,value:{enabled:p}})}})})]},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(_a,{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.'})]})]})]})]})})},mn={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"},kC={ONBOARDING:{General:mn.DD_ADMIN,KYC:mn.DD_ADMIN,"Level 1 Interview":mn.RBM,"Level 2 Interview":mn.ZBH,"Level 3 Interview":mn.NBH,FDD:mn.FDD,"LOI Approval":`${mn.DD_HEAD},${mn.NBH}`,"LOA Approval":mn.NBH,"LOI Issue":mn.DD_ADMIN,"Architecture Team Assigned":mn.ARCHITECTURE,"Architecture Document Upload":mn.ARCHITECTURE,"Architecture Team Completion":mn.ARCHITECTURE,EOR:mn.DD_ADMIN,Inauguration:mn.DD_ADMIN},RESIGNATION:{Submission:mn.DEALER,"Regional Review":mn.RBM,"ZM Review":mn.DD_ZM,"ZBH Review":mn.ZBH,"Finance Review":mn.FINANCE,"DDL Review":mn.DD_LEAD,Approved:mn.DD_HEAD},RELOCATION:{Initiated:mn.DEALER,"ASM Review":mn.ASM,"ZM Review":mn.DD_ZM,"ZBH Review":mn.ZBH,Completed:mn.DD_HEAD},CONSTITUTIONAL_CHANGE:{Draft:mn.DEALER,"Legal Review":mn.LEGAL_ADMIN,Approved:mn.DD_HEAD},TERMINATION:{Hearing:mn.NBH,Review:mn.DD_LEAD,Closed:mn.DD_HEAD}},DC={async getPolicies(){var t,s;try{return(await Ee.getApprovalPolicies()).data}catch(n){return ee.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 l=await Ee.upsertApprovalPolicy(t,s);return(n=l==null?void 0:l.data)!=null&&n.success&&ee.success("Approval policy updated"),l.data}catch(l){return ee.error(((a=(r=l==null?void 0:l.response)==null?void 0:r.data)==null?void 0:a.message)||"Failed to update approval policy"),{success:!1}}}},BG=Object.values(mn).sort(),$G=[{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 Q_(){const[t,s]=g.useState(!1),[n,r]=g.useState([]),[a,l]=g.useState(!1),[o,d]=g.useState(!1),[m,f]=g.useState(!1),[x,h]=g.useState({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),p=g.useMemo(()=>[...n].sort((j,y)=>j.stageCode.localeCompare(y.stageCode)),[n]),u=async()=>{s(!0);try{const j=await DC.getPolicies();j!=null&&j.success&&r(j.data||[])}finally{s(!1)}};g.useEffect(()=>{u()},[]);const w=()=>{d(!1),f(!1),h({stageCode:"",minApprovals:1,approvalMode:"MIN_N",requiredRoles:[],isActive:!0}),l(!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}),l(!0)},N=async()=>{if(!x.stageCode.trim())return;if(x.approvalMode==="ROLE_MANDATORY"&&x.requiredRoles.length>0&&x.minApprovals>x.requiredRoles.length){alert("In ROLE_MANDATORY mode, min approvals cannot exceed the number of required roles.");return}const j={minApprovals:Number(x.minApprovals)||1,approvalMode:x.approvalMode,requiredRoles:x.requiredRoles,isActive:x.isActive},y=x.stageCode.trim().toUpperCase().replace(/\s+/g,"_"),C=await DC.savePolicy(y,j);C!=null&&C.success&&(await u(),l(!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(Bf,{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(se,{variant:"outline",onClick:u,disabled:t,children:[e.jsx(pr,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"Refresh"]}),e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:w,children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add New Policy"]})]})]}),e.jsxs(Le,{className:"border-slate-200 overflow-hidden shadow-sm",children:[e.jsx(Qe,{className:"bg-slate-50 px-6 py-4 border-b",children:e.jsx(et,{className:"text-lg font-semibold text-slate-800",children:"Configured Stages"})}),e.jsx(Fe,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim",children:e.jsxs(Ps,{children:[e.jsx(Os,{className:"bg-slate-50/50",children:e.jsxs(lt,{children:[e.jsx(fe,{className:"w-[200px]",children:"Stage Code"}),e.jsx(fe,{children:"Approval Mode"}),e.jsx(fe,{children:"Min Appr."}),e.jsx(fe,{className:"min-w-[300px]",children:"Required Roles"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:p.map(j=>e.jsxs(lt,{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx(ue,{className:"font-mono text-xs font-semibold text-slate-700",children:j.stageCode}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"font-medium px-2 py-0.5 text-slate-600 border-slate-300 uppercase",children:j.approvalMode})}),e.jsx(ue,{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(ue,{children:e.jsx("div",{className:"flex flex-wrap gap-1.5 py-1",children:(j.requiredRoles||[]).map(y=>e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-slate-600 border-transparent hover:bg-slate-200 text-[11px] font-normal",children:y},y))})}),e.jsx(ue,{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(ue,{className:"text-right",children:e.jsxs(se,{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(Cr,{className:"w-4 h-4 mr-1.5"}),"Edit"]})})]},j.stageCode))})]})})})]}),e.jsx(ls,{open:a,onOpenChange:l,children:e.jsxs(as,{className:"sm:max-w-[480px] overflow-visible",children:[e.jsxs(fs,{className:"gap-1 pb-2 border-b",children:[e.jsxs(us,{className:"text-base flex items-center gap-2",children:[o?e.jsx(Cr,{className:"w-4 h-4 text-re-red"}):e.jsx(Dn,{className:"w-4 h-4 text-re-red"}),o?"Edit Policy":"Create New Policy"]}),e.jsx(bs,{className:"text-[11px]",children:o?`Update configuration for stage ${x.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(de,{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(At,{value:x.stageCode,onValueChange:j=>{j==="CUSTOM"?(f(!0),h({...x,stageCode:""})):h({...x,stageCode:j})},children:[e.jsx(Dt,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(kt,{placeholder:"Select a workflow stage..."})}),e.jsxs(Rt,{className:"max-h-[300px]",children:[$G.map(j=>e.jsxs(gS,{children:[e.jsx(O7,{className:"text-[10px] uppercase text-slate-400 font-bold bg-slate-50 px-2 py-1",children:j.label}),j.stages.map(y=>e.jsxs(Me,{value:y.value,className:"text-xs",children:[y.label," ",e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono ml-1",children:["(",y.value,")"]})]},y.value))]},j.label)),e.jsxs(gS,{children:[e.jsx(Z8,{}),e.jsx(Me,{value:"CUSTOM",className:"text-xs font-semibold text-re-red italic",children:"+ Enter Custom Stage Code"})]})]})]})}):e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"w-full font-mono text-xs h-8 pr-8",placeholder:"e.g. FNF_SETTLEMENT",disabled:o,value:x.stageCode,onChange:j=>h({...x,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({...x,stageCode:""})}})]})})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx(de,{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(At,{value:x.approvalMode,onValueChange:j=>h({...x,approvalMode:j}),children:[e.jsx(Dt,{className:"w-full h-8 text-[11px] font-medium border-slate-200",children:e.jsx(kt,{placeholder:"Select mode"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"ALL",className:"text-xs",children:"ALL (Everyone must approve)"}),e.jsx(Me,{value:"MIN_N",className:"text-xs",children:"MIN_N (First N approvals count)"}),e.jsx(Me,{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(de,{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(at,{type:"number",min:1,value:x.minApprovals,onChange:j=>h({...x,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(de,{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(Nb,{children:[e.jsx(wb,{asChild:!0,children:e.jsxs(se,{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(Dn,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{children:"Add Roles..."})]}),e.jsx(Ce,{variant:"secondary",className:"bg-red-50 text-re-red-hover border-transparent text-[9px] px-1 h-4",children:x.requiredRoles.length})]})}),e.jsxs(Sb,{className:"w-[280px] max-h-[250px] overflow-y-auto shadow-xl",align:"start",children:[e.jsx(Y8,{className:"text-[10px] uppercase tracking-wider text-slate-400 font-bold px-2 py-1 border-b",children:"Available Roles"}),BG.map(j=>e.jsx(K8,{className:"text-xs",checked:x.requiredRoles.includes(j),onCheckedChange:y=>{h(y?{...x,requiredRoles:[...x.requiredRoles,j]}:{...x,requiredRoles:x.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:[x.requiredRoles.map(j=>e.jsxs(Ce,{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({...x,requiredRoles:x.requiredRoles.filter(y=>y!==j)})})]},j)),x.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(de,{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(At,{value:x.isActive?"active":"inactive",onValueChange:j=>h({...x,isActive:j==="active"}),children:[e.jsx(Dt,{className:"w-24 h-8 text-[11px] font-medium border-slate-200",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"active",className:"text-xs",children:"Active"}),e.jsx(Me,{value:"inactive",className:"text-xs",children:"Inactive"})]})]})})]})]}),e.jsxs(xn,{className:"gap-2 pt-3 border-t",children:[e.jsx(se,{variant:"outline",size:"sm",className:"text-xs h-8",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover h-8 text-xs font-semibold",onClick:N,children:[e.jsx(pl,{className:"w-3 h-3 mr-1.5"}),o?"Save Changes":"Create Policy"]})]})]})})]})}const qG=()=>{const{fetchInitialData:t,fetchAreas:s}=IV(),{asms:n,zonalManagerMappings:r,allStates:a,allDistricts:l,users:o,roles:d,loading:m}=Fn(We=>We.master),[f,x]=g.useState("hierarchy"),[h,p]=g.useState("all"),[u,w]=g.useState(!1),[v,N]=g.useState(!1),[j,y]=g.useState(!1),[C,S]=g.useState(!1),[D,R]=g.useState(!1),[A,L]=g.useState(null),[$,P]=g.useState(""),[E,O]=g.useState("active"),[I,q]=g.useState(""),[G,Y]=g.useState(""),[V,Q]=g.useState([]),[_,z]=g.useState([]),[T,F]=g.useState("DD-AM"),[B,K]=g.useState(!1),[W,H]=g.useState(null),[X,J]=g.useState(""),[ie,ae]=g.useState("active"),[xe,ce]=g.useState(""),[we,ke]=g.useState([]),[Xe,Ot]=g.useState(!1),[bt,te]=g.useState(null),[ve,qe]=g.useState(!1),[ge,Be]=g.useState(null),[ut,ht]=g.useState(""),[it,Tt]=g.useState(""),[It,he]=g.useState(""),[vt,mt]=g.useState("none"),[_e,Vt]=g.useState(null),[Et,Ds]=g.useState(""),[ln,Bs]=g.useState(""),[Ys,Xs]=g.useState(""),[Js,Ws]=g.useState(""),[Z,oe]=g.useState([]),[Ne,Oe]=g.useState(null),[De,ye]=g.useState('{"applicant_name": "John Doe"}'),[Ve,Ge]=g.useState(!1),[st,Kt]=g.useState(null),[Xt,ot]=g.useState(null),[ft,Es]=g.useState(""),[ts,vs]=g.useState(""),[Te,je]=g.useState(""),[nt,Ye]=g.useState(""),[pt,yt]=g.useState(""),[Jt,ss]=g.useState("active"),[Ss,Zs]=g.useState(""),[on,en]=g.useState(1),[tn,cn]=g.useState("all"),[Ae,Ht]=g.useState("all");g.useEffect(()=>{t()},[t]),g.useEffect(()=>{if(bt&&d.length>0){const We=d.find(Ft=>Ft.id===bt.id);We&&te(We)}},[d,bt==null?void 0:bt.id]);const Pe=g.useMemo(()=>{const We={};return[...n,...r].forEach(Ft=>{(Ft.areasManaged||Ft.districts||[]).forEach(rt=>{const Is=typeof rt=="string"?rt:rt.id;We[Is]||(We[Is]=[]),We[Is].includes(Ft.name)||We[Is].push(Ft.name)})}),We},[n,r]),ct=g.useCallback((We,Ft)=>l.filter(gt=>{var rt;return((rt=gt.stateName)==null?void 0:rt.toUpperCase())===(We==null?void 0:We.toUpperCase())&&(!Ft||gt.regionId===Ft)}).map(gt=>({id:gt.id,name:gt.name})),[l]),tt=async()=>{var We,Ft;if(!$){ee.error("Please select a DD-AM user");return}try{const gt={userId:$,roleCode:T,districts:_,status:E},rt=await Fs.saveASM(gt);rt.success?(ee.success(`DD Area Manager ${A?"updated":"assigned"} successfully`),w(!1),t()):ee.error(rt.message||"Failed to save ASM")}catch(gt){const rt=((Ft=(We=gt==null?void 0:gt.response)==null?void 0:We.data)==null?void 0:Ft.message)||(gt==null?void 0:gt.message)||"Failed to save ASM";ee.error(rt)}},Nt=We=>{var Ft;L(We.id),P(We.id),O(We.status.toLowerCase()),q(We.zoneId),Y(We.regionId),Q(We.stateNames||[]),z(((Ft=We.areasManaged)==null?void 0:Ft.map(gt=>gt.id))||[]),F("DD-AM"),w(!0)},Mt=We=>{var Ft;H(We.id),J(We.id),ae(((Ft=We.status)==null?void 0:Ft.toLowerCase())==="active"?"active":"inactive"),ce(We.zoneId||""),ke(We.assignedRegionIds||[]),K(!0)},Pt=async()=>{var We,Ft;if(!X||!xe){ee.error("Manager and Zone are required");return}try{const gt={userId:X,zoneId:xe,regionIds:we,status:ie},rt=await Fs.saveZonalManager(gt);rt.success?(ee.success(`Zonal Manager ${W?"updated":"assigned"} successfully`),K(!1),t()):ee.error(rt.message||"Failed to save Zonal Manager")}catch(gt){const rt=((Ft=(We=gt==null?void 0:gt.response)==null?void 0:We.data)==null?void 0:Ft.message)||(gt==null?void 0:gt.message)||"Failed to save Zonal Manager";ee.error(rt)}},ys=async()=>{var We,Ft;try{const gt={id:ge,name:ut,code:it,description:It,managerId:vt==="none"?null:vt},rt=await Fs.saveZone(gt);rt.success?(ee.success("Zone saved successfully"),N(!1),t()):ee.error(rt.message||"Error saving zone")}catch(gt){const rt=((Ft=(We=gt==null?void 0:gt.response)==null?void 0:We.data)==null?void 0:Ft.message)||(gt==null?void 0:gt.message)||"Error saving zone";ee.error(rt)}},Yt=async()=>{var We,Ft;try{const gt={..._e?{id:_e}:{},name:Et,description:ln,parentId:Ys,managerId:Js,districts:Z,status:"Active"},rt=await Fs.saveRegion(gt);rt.success?(ee.success("Region saved successfully"),y(!1),t()):ee.error(rt.message||"Error saving region")}catch(gt){const rt=((Ft=(We=gt==null?void 0:gt.response)==null?void 0:We.data)==null?void 0:Ft.message)||(gt==null?void 0:gt.message)||"Error saving region";ee.error(rt)}},ps=async We=>{var Ft,gt;try{if(!(Ne!=null&&Ne.id)){ee.error("Open a template from the list to edit.");return}const rt=await Fs.updateEmailTemplate(Ne.id,{...Ne,body:We});rt.success?(ee.success("Template saved"),S(!1),t()):ee.error(rt.message||"Error saving template")}catch(rt){const Is=((gt=(Ft=rt==null?void 0:rt.response)==null?void 0:Ft.data)==null?void 0:gt.message)||(rt==null?void 0:rt.message)||"Error saving template";ee.error(Is)}},ks=async We=>{var Ft;Ge(!0);try{let gt;try{gt=JSON.parse(De)}catch{ee.error("Mock test data must be valid JSON");return}const rt=await Fs.previewEmailTemplate({subject:Ne==null?void 0:Ne.subject,body:We,data:gt});rt.success?Kt(rt.data):ee.error(rt.message||"Preview failed")}catch(gt){const rt=(Ft=gt==null?void 0:gt.response)==null?void 0:Ft.data,Is=(rt==null?void 0:rt.error)||(rt==null?void 0:rt.message);ee.error(Is||(gt==null?void 0:gt.message)||"Preview failed")}finally{Ge(!1)}},hs=async(We,Ft)=>{var gt,rt;try{const Is=await Fs.updateRole(We,{permissions:Ft});Is.success?(ee.success("Role permissions updated successfully"),Ot(!1),t()):ee.error(Is.message||"Error saving role permissions")}catch(Is){const xs=((rt=(gt=Is==null?void 0:Is.response)==null?void 0:gt.data)==null?void 0:rt.message)||(Is==null?void 0:Is.message)||"Error saving role permissions";ee.error(xs)}},gn=We=>{te(We),Ot(!0)},$s=async We=>{var Ft,gt;try{const rt={...We,permissionIds:[]},Is=await Fs.createRole(rt);if(Is!=null&&Is.success){ee.success("Role created successfully"),t();return}throw new Error((Is==null?void 0:Is.message)||"Failed to create role")}catch(rt){const Is=((gt=(Ft=rt==null?void 0:rt.response)==null?void 0:Ft.data)==null?void 0:gt.message)||(rt==null?void 0:rt.message)||"Failed to create role";throw ee.error(Is),rt}},dn=We=>{const Ft=l.find(gt=>gt.id===We.districtId);ot(We.id),Es((Ft==null?void 0:Ft.stateId)||We.stateId||""),je(We.city||""),vs(We.districtId||""),Ye(We.openFrom?new Date(We.openFrom).toISOString().split("T")[0]:""),yt(We.openTo?new Date(We.openTo).toISOString().split("T")[0]:""),ss(We.isOpportunity?"active":"inactive"),R(!0)},sn=async()=>{try{if(!ft){ee.error("Please select a state");return}if(!ts){ee.error("Please select a district");return}const We=a.find(Is=>Is.id===ft),Ft=l.find(Is=>Is.id===ts),gt={id:Xt,stateId:ft,stateName:(We==null?void 0:We.name)||(We==null?void 0:We.stateName)||"",districtId:ts,name:Te||(Ft==null?void 0:Ft.name)||"New Location",city:Te,status:Jt,openFrom:nt,openTo:pt,isOpportunity:Jt==="active"};(await(Xt?Fs.updateArea(Xt,gt):Fs.createArea(gt))).success&&(ee.success("Location saved"),R(!1),s({search:Ss,page:on}))}catch{ee.error("Error saving location")}};return g.useEffect(()=>{const We=setTimeout(()=>{s({search:Ss,page:on,stateId:tn==="all"?void 0:tn,isOpportunity:Ae==="all"?void 0:Ae==="active"?"true":"false"})},500);return()=>clearTimeout(We)},[Ss,on,tn,Ae,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($n,{value:f,onValueChange:x,className:"space-y-6",children:[e.jsxs(qn,{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(zt,{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(Du,{className:"w-4 h-4"})," Organisation"]}),e.jsxs(zt,{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(mc,{className:"w-4 h-4"})," Roles"]}),e.jsxs(zt,{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(Dr,{className:"w-4 h-4"})," Emails"]}),e.jsxs(zt,{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(Vr,{className:"w-4 h-4"})," Locations"]}),e.jsxs(zt,{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(eM,{className:"w-4 h-4"})," Approvals"]}),e.jsxs(zt,{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(Ns,{className:"w-4 h-4"})," Docs Config"]}),e.jsxs(zt,{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(Bf,{className:"w-4 h-4"})," Governance"]}),e.jsxs(zt,{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(qt,{value:"hierarchy",className:"space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e.jsx(MV,{selectedZone:h,onZoneClick:We=>p(h===We?"all":We)}),e.jsx(FV,{selectedZone:h,onAddZone:()=>{Be(null),ht(""),Tt(""),he(""),mt("none"),N(!0)},onEditZone:We=>{var Ft;Be(We.id),ht(We.name),Tt(We.code),he(We.description),mt(((Ft=We.zonalBusinessHead)==null?void 0:Ft.id)||"none"),N(!0)}}),e.jsx(BV,{selectedZone:h,onAddRegion:()=>{Vt(null),Ds(""),Xs(h==="all"?"":h),Ws(""),oe([]),y(!0)},onEditRegion:We=>{var Ft,gt;Vt(We.id),Ds(We.name),Xs(We.zoneId),Ws(((Ft=We.regionalManager)==null?void 0:Ft.id)||""),oe(((gt=We.districts)==null?void 0:gt.map(rt=>rt.id))||[]),y(!0)},onDeleteRegion:()=>ee.error("Regional office deletion is restricted via portal")}),e.jsx(qV,{selectedZone:h,onAddZM:()=>{H(null),J(""),ae("active"),ce(h==="all"?"":h),ke([]),K(!0)},onEditZM:Mt,onDeleteZM:()=>ee.error("ZM deletion restricted")}),e.jsx($V,{selectedZone:h,onAddASM:()=>{L(null),P(""),q(h==="all"?"":h),Y(""),Q([]),z([]),F("DD-AM"),w(!0)},onEditASM:Nt,onDeleteASM:()=>ee.error("ASM deletion restricted")}),e.jsx(KH,{}),e.jsx(zV,{userAssignedData:o.length>0?o:n})]}),e.jsx(qt,{value:"roles",className:"animate-in fade-in duration-300",children:e.jsx(UV,{onAddRole:()=>qe(!0),onEditRole:gn})}),e.jsx(qt,{value:"templates",className:"animate-in fade-in duration-300",children:e.jsx(WV,{onEditTemplate:We=>{if(Oe(We),We.placeholders&&Array.isArray(We.placeholders)){const Ft=We.placeholders.reduce((gt,rt)=>(gt[rt]=`[${rt}]`,gt),{});ye(JSON.stringify(Ft,null,2))}else ye("{}");S(!0)},onDeleteTemplate:()=>ee.error("Delete Template restricted")})}),e.jsx(qt,{value:"locations",className:"animate-in fade-in duration-300",children:e.jsx(GV,{states:a,stateFilter:tn,onStateFilterChange:We=>{cn(We),en(1)},statusFilter:Ae,onStatusFilterChange:We=>{Ht(We),en(1)},onAddLocation:()=>{ot(null),Es(""),je(""),vs(""),Ye(""),yt(""),ss("active"),R(!0)},onEditLocation:dn,onDeleteLocation:We=>{window.confirm("Are you sure you want to delete this location?")&&Fs.deleteArea(We).then(Ft=>{Ft.success&&(ee.success("Location deleted"),s({search:Ss,page:on,stateId:tn==="all"?void 0:tn}))})},onSearch:We=>{Zs(We),en(1)},onPageChange:en,searchTerm:Ss})}),e.jsx(qt,{value:"approvals",className:"animate-in fade-in duration-300",children:e.jsx(Q_,{})}),e.jsx(qt,{value:"documents",className:"animate-in fade-in duration-300",children:e.jsx(MG,{})}),e.jsx(qt,{value:"governance",className:"animate-in fade-in duration-300",children:e.jsx(FG,{})}),e.jsx(qt,{value:"settings",className:"animate-in fade-in duration-300",children:e.jsx(IG,{})})]}),e.jsx(ZH,{isOpen:v,onOpenChange:N,editingZoneId:ge,zoneName:ut,setZoneName:ht,zoneCode:it,setZoneCode:Tt,zoneDescription:It,setZoneDescription:he,zonalBusinessHeadId:vt,setZonalBusinessHeadId:mt,onSave:ys,userAssignedData:o.length>0?o.map(We=>{var Ft,gt;return{...We,name:We.fullName||We.name,role:(Ft=We.role)==null?void 0:Ft.roleName,roleCode:(gt=We.role)==null?void 0:gt.roleCode,allRoles:We.allRoles}}):n}),e.jsx(QH,{isOpen:j,onOpenChange:y,editingRegionId:_e,regionName:Et,setRegionName:Ds,regionDescription:ln,setRegionDescription:Bs,selectedRegionZone:Ys,setSelectedRegionZone:Xs,regionalManagerId:Js,setRegionalManagerId:Ws,selectedRegionStates:Z,setSelectedRegionStates:oe,onSave:Yt,userAssignedData:o.length>0?o.map(We=>{var Ft,gt;return{...We,name:We.fullName||We.name,role:(Ft=We.role)==null?void 0:Ft.roleName,roleCode:(gt=We.role)==null?void 0:gt.roleCode,allRoles:We.allRoles}}):n}),e.jsx(gH,{isOpen:u,onOpenChange:w,editingASMId:A,asmManagerId:$,setAsmManagerId:P,asmStatus:E,setAsmStatus:O,selectedASMZone:I,setSelectedASMZone:q,selectedASMRegion:G,setSelectedASMRegion:Y,selectedASMStates:V,setSelectedASMStates:Q,selectedASMDistricts:_,setSelectedASMDistricts:z,onSave:tt,asmRoleCode:T,setAsmRoleCode:F,userAssignedData:o.length>0?o.map(We=>{var Ft,gt;return{...We,name:We.fullName||We.name,role:(Ft=We.role)==null?void 0:Ft.roleName,roleCode:(gt=We.role)==null?void 0:gt.roleCode,allRoles:We.allRoles}}):n,districtsAssignedToOthers:Pe,getDistrictsForSelectedState:We=>ct(We,G||void 0)}),e.jsx(YH,{isOpen:B,onOpenChange:K,editingZMId:W,zmManagerId:X,setZmManagerId:J,zmStatus:ie,setZmStatus:ae,selectedZone:xe,setSelectedZone:ce,selectedRegions:we,setSelectedRegions:ke,onSave:Pt,userAssignedData:o.length>0?o.map(We=>{var Ft,gt;return{...We,name:We.fullName||We.name,role:(Ft=We.role)==null?void 0:Ft.roleName,roleCode:(gt=We.role)==null?void 0:gt.roleCode,allRoles:We.allRoles}}):n}),e.jsx(OG,{isOpen:C,onOpenChange:S,editingTemplate:Ne,setEditingTemplate:Oe,testDataInput:De,setTestDataInput:ye,previewLoading:Ve,handlePreviewTemplate:ks,previewContent:st,handleSaveTemplate:ps}),e.jsx(LG,{isOpen:D,onOpenChange:R,editingLocationId:Xt,locationState:ft,setLocationState:Es,locationDistrict:ts,setLocationDistrict:vs,locationCity:Te,setLocationCity:je,locationActiveFrom:nt,setLocationActiveFrom:Ye,locationActiveTo:pt,setLocationActiveTo:yt,locationStatus:Jt,setLocationStatus:ss,allStates:a,allDistricts:l,onSave:sn}),e.jsx(VV,{isOpen:Xe,onOpenChange:Ot,role:bt,onSave:hs}),e.jsx(HV,{isOpen:ve,onOpenChange:qe,onSave:$s})]})},Dm={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 Ee.getUsers(t)).data}catch(r){return console.error("Error fetching users:",r),ee.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 Ee.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 ee.error(r),{success:!1,message:r}}},async updateUser(t,s){var n,r,a;try{const l=await Ee.updateUser(t,s);return l.ok&&((n=l.data)!=null&&n.success)&&ee.success(l.data.message||"User updated successfully"),l.data}catch(l){return console.error("Error updating user:",l),ee.error(((a=(r=l.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,l;try{const o=await Ee.updateUserStatus(t,{status:s,isActive:n});return o.ok&&((r=o.data)!=null&&r.success)&&ee.success(o.data.message||"User status updated"),o.data}catch(o){return console.error("Error updating status:",o),ee.error(((l=(a=o.response)==null?void 0:a.data)==null?void 0:l.message)||"Failed to update status"),{success:!1}}}};function zG(){const t=(V,Q)=>{if(!(V!=null&&V.parents)||!Array.isArray(V.parents))return"";const _=V.parents.find(z=>(z==null?void 0:z.type)===Q);return(_==null?void 0:_.id)||""},s=(V,Q)=>V?Array.isArray(V[Q])?V[Q]:Array.isArray(V.data)?V.data:[]:[],[n,r]=g.useState([]),[a,l]=g.useState([]),[o,d]=g.useState([]),[m,f]=g.useState([]),[x,h]=g.useState([]),[p,u]=g.useState([]),[w,v]=g.useState(!0),[N,j]=g.useState(""),[y,C]=g.useState("all"),[S,D]=g.useState("all"),[R,A]=g.useState(!1),[L,$]=g.useState(null),[P,E]=g.useState({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""});g.useEffect(()=>{O()},[]);const O=async()=>{v(!0);try{const[V,Q,_,z]=await Promise.all([Dm.getAllUsers(),Fs.getRoles(),Fs.getZones(),Fs.getRegions()]);V.success&&r(V.data),Q.success&&l(Q.data),_.success&&d(_.data),z.success&&f(z.data)}catch{ee.error("Failed to load user management data")}finally{v(!1)}};g.useEffect(()=>{P.zoneId?Fs.getStates(P.zoneId).then(V=>{V&&V.success&&h(s(V,"states"))}):h([])},[P.zoneId]),g.useEffect(()=>{P.stateId?Fs.getDistricts(P.stateId).then(V=>{V&&V.success&&u(s(V,"districts"))}):u([])},[P.stateId]),g.useEffect(()=>{},[P.districtId]);const I=V=>{const Q=V.location,_=Q==null?void 0:Q.type,z=V.zoneId||(_==="zone"?Q==null?void 0:Q.id:t(Q,"zone")),T=V.regionId||(_==="region"?Q==null?void 0:Q.id:t(Q,"region")),F=V.stateId||(_==="state"?Q==null?void 0:Q.id:t(Q,"state")),B=V.districtId||(_==="district"?Q==null?void 0:Q.id:t(Q,"district"));$(V),E({fullName:V.fullName||"",email:V.email||"",roleCode:V.roleCode||"",status:V.status||"active",isActive:V.isActive??!0,mobileNumber:V.mobileNumber||"",department:V.department||"",designation:V.designation||"",employeeId:V.employeeId||"",zoneId:z||"",regionId:T||"",stateId:F||"",districtId:B||""}),A(!0)},q=async()=>{var V,Q;if(!P.fullName||!P.email||!P.roleCode){ee.error("Please fill in all required fields");return}try{const _=P.districtId||P.stateId||P.regionId||P.zoneId||null,z={...P,locationId:_};if(L)(await Dm.updateUser(L.id,z)).success&&(A(!1),O());else{const T=await Dm.createUser(z);T.success?(ee.success("User created successfully"),E({fullName:"",email:"",roleCode:"",status:"active",isActive:!0,mobileNumber:"",department:"",designation:"",employeeId:"",zoneId:"",regionId:"",stateId:"",districtId:""}),A(!1),O()):ee.error(T.message||"Failed to create user")}}catch(_){const z=((Q=(V=_==null?void 0:_.response)==null?void 0:V.data)==null?void 0:Q.message)||(_==null?void 0:_.message)||"Operation failed";ee.error(z)}},G=async V=>{const Q=V.status==="active"?"inactive":"active",_=!V.isActive;(await Dm.updateUserStatus(V.id,Q,_)).success&&O()},Y=n.filter(V=>{var T,F,B;const Q=((T=V.fullName)==null?void 0:T.toLowerCase().includes(N.toLowerCase()))||((F=V.email)==null?void 0:F.toLowerCase().includes(N.toLowerCase()))||((B=V.employeeId)==null?void 0:B.toLowerCase().includes(N.toLowerCase())),_=y==="all"||V.roleCode===y,z=S==="all"||V.status===S;return Q&&_&&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(Ra,{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(se,{onClick:()=>{$(null),E({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(ab,{className:"w-4 h-4 mr-2"}),"Add New User"]})]}),e.jsx(Le,{className:"border-slate-200",children:e.jsx(Fe,{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(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(at,{placeholder:"Search by name, email, ID...",className:"pl-10",value:N,onChange:V=>j(V.target.value)})]}),e.jsxs(At,{value:y,onValueChange:C,children:[e.jsxs(Dt,{children:[e.jsx(sb,{className:"w-4 h-4 mr-2 text-slate-400"}),e.jsx(kt,{placeholder:"Filter by Role"})]}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Roles"}),a.map(V=>e.jsx(Me,{value:V.roleCode,children:V.roleName},V.id))]})]}),e.jsxs(At,{value:S,onValueChange:D,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Filter by Status"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"all",children:"All Status"}),e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{value:"inactive",children:"Inactive"})]})]}),e.jsxs(se,{variant:"outline",onClick:O,disabled:w,children:[e.jsx(pr,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),"Refresh"]})]})})}),e.jsx(Le,{className:"border-slate-200 overflow-hidden",children:e.jsx(Fe,{className:"p-0",children:e.jsxs(Ps,{children:[e.jsx(Os,{className:"bg-slate-50",children:e.jsxs(lt,{children:[e.jsx(fe,{children:"User Information"}),e.jsx(fe,{children:"Geographical Mapping"}),e.jsx(fe,{children:"Account Details"}),e.jsx(fe,{children:"Role & Department"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{className:"text-right",children:"Actions"})]})}),e.jsx(Ls,{children:w?e.jsx(lt,{children:e.jsx(ue,{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(pr,{className:"w-8 h-8 animate-spin"}),e.jsx("p",{children:"Loading users..."})]})})}):Y.length===0?e.jsx(lt,{children:e.jsxs(ue,{colSpan:5,className:"h-40 text-center text-slate-500",children:[e.jsx(Ra,{className:"w-12 h-12 mx-auto mb-2 opacity-20"}),"No users found matching your criteria."]})}):Y.map(V=>{var Q,_,z,T;return e.jsxs(lt,{className:"hover:bg-slate-50/50",children:[e.jsx(ue,{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:((Q=V.fullName)==null?void 0:Q.charAt(0))||((_=V.email)==null?void 0:_.charAt(0))}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-slate-900",children:V.fullName}),e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(Dr,{className:"w-3 h-3"}),V.email]})]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(Ce,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:["Location: ",((z=V.location)==null?void 0:z.name)||"N/A"]})}),e.jsxs("div",{className:"text-xs text-slate-500",children:["Type: ",(T=V.location)!=null&&T.type?V.location.type.toUpperCase():"N/A"]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:["ID: ",V.employeeId||"N/A"]}),e.jsxs("div",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(nb,{className:"w-3 h-3"}),V.mobileNumber||"No phone"]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ce,{variant:"outline",className:"bg-purple-50 text-purple-700 border-purple-200",children:[e.jsx(mc,{className:"w-3 h-3 mr-1"}),V.roleCode]}),e.jsx("div",{className:"text-xs text-slate-500",children:V.department||"No department"})]})}),e.jsx(ue,{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(Ce,{variant:V.status==="active"?"default":"destructive",className:`text-xs ${V.status==="active"?"bg-green-600 hover:bg-green-700":""}`,children:[V.status==="active"?e.jsx(fn,{className:"w-3 h-3 mr-1"}):e.jsx(mi,{className:"w-3 h-3 mr-1"}),V.status]})}),e.jsx(jp,{checked:V.isActive,onCheckedChange:()=>G(V)})]})}),e.jsx(ue,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>I(V),children:e.jsx(Cr,{className:"w-4 h-4 text-slate-400 hover:text-re-red"})}),e.jsx(se,{variant:"ghost",size:"icon",children:e.jsx(ar,{className:"w-4 h-4 text-slate-400 hover:text-red-600"})})]})})]},V.id)})})]})})}),e.jsx(ls,{open:R,onOpenChange:A,children:e.jsxs(as,{className:"max-w-2xl bg-white",children:[e.jsxs(fs,{children:[e.jsx(us,{children:L?"Edit User":"Add New User"}),e.jsx(bs,{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(de,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(at,{id:"fullName",value:P.fullName,onChange:V=>E({...P,fullName:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"email",children:"Email Address *"}),e.jsx(at,{id:"email",type:"email",value:P.email,onChange:V=>E({...P,email:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"employeeId",children:"Employee ID"}),e.jsx(at,{id:"employeeId",value:P.employeeId,onChange:V=>E({...P,employeeId:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"roleCode",children:"Role *"}),e.jsxs(At,{value:P.roleCode,onValueChange:V=>E({...P,roleCode:V}),children:[e.jsx(Dt,{id:"roleCode",children:e.jsx(kt,{placeholder:"Select a role"})}),e.jsx(Rt,{children:a.map(V=>e.jsx(Me,{value:V.roleCode,children:V.roleName},V.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"department",children:"Department"}),e.jsx(at,{id:"department",value:P.department,onChange:V=>E({...P,department:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"designation",children:"Designation"}),e.jsx(at,{id:"designation",value:P.designation,onChange:V=>E({...P,designation:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"mobileNumber",children:"Mobile Number"}),e.jsx(at,{id:"mobileNumber",value:P.mobileNumber,onChange:V=>E({...P,mobileNumber:V.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"status",children:"Account Status"}),e.jsxs(At,{value:P.status,onValueChange:V=>E({...P,status:V}),children:[e.jsx(Dt,{id:"status",children:e.jsx(kt,{placeholder:"Select status"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"active",children:"Active"}),e.jsx(Me,{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(de,{htmlFor:"zoneId",children:"Zone (Top Level)"}),e.jsxs(At,{value:P.zoneId,onValueChange:V=>E({...P,zoneId:V,regionId:"",stateId:"",districtId:""}),children:[e.jsx(Dt,{id:"zoneId",children:e.jsx(kt,{placeholder:"Select Zone"})}),e.jsx(Rt,{children:o.map(V=>e.jsx(Me,{value:V.id,children:V.name||V.zoneName},V.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"regionId",children:"Region"}),e.jsxs(At,{value:P.regionId,onValueChange:V=>E({...P,regionId:V}),disabled:!P.zoneId,children:[e.jsx(Dt,{id:"regionId",children:e.jsx(kt,{placeholder:"Select Region"})}),e.jsx(Rt,{children:m.filter(V=>V.parents&&V.parents.some(Q=>Q.id===P.zoneId)||V.zoneId===P.zoneId).map(V=>e.jsx(Me,{value:V.id,children:V.name||V.regionName},V.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"stateId",children:"State"}),e.jsxs(At,{value:P.stateId,onValueChange:V=>E({...P,stateId:V,districtId:""}),disabled:!P.zoneId,children:[e.jsx(Dt,{id:"stateId",children:e.jsx(kt,{placeholder:"Select State"})}),e.jsx(Rt,{children:x.filter(V=>V.parents&&V.parents.some(Q=>Q.id===P.zoneId)||V.zoneId===P.zoneId).map(V=>e.jsx(Me,{value:V.id,children:V.name||V.stateName},V.id))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(de,{htmlFor:"districtId",children:"District"}),e.jsxs(At,{value:P.districtId,onValueChange:V=>E({...P,districtId:V}),disabled:!P.stateId,children:[e.jsx(Dt,{id:"districtId",children:e.jsx(kt,{placeholder:"Select District"})}),e.jsx(Rt,{children:p.filter(V=>V.parents&&V.parents.some(Q=>Q.id===P.stateId)||V.stateId===P.stateId).map(V=>e.jsx(Me,{value:V.id,children:V.name||V.districtName},V.id))})]})]})]})]})]}),e.jsxs(xn,{className:"bg-slate-50 -mx-6 -mb-6 p-4 rounded-b-lg",children:[e.jsx(se,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover text-white",onClick:q,children:L?"Save Changes":"Create User"})]})]})})]})}const Oy={healthy:"0–25% elapsed",warning:"26–75% elapsed",critical:"76–99% elapsed",breached:"Breached"},X_={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"},UG=["ALL","ONBOARDING","TERMINATION","RESIGNATION","RELOCATION","CONSTITUTIONAL","FNF"];function VG({bucket:t}){return e.jsx(Ce,{variant:"outline",className:`text-[10px] font-semibold ${X_[t]}`,children:Oy[t]})}function HG({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(VG,{bucket:s})})]})}function Ov({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(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Case"}),e.jsx(fe,{children:"Module"}),e.jsx(fe,{children:"Stage"}),e.jsx(fe,{children:"Owner"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Time"}),e.jsx(fe,{className:"w-10"})]})}),e.jsx(Ls,{children:t.map(n=>e.jsxs(lt,{className:n.bucket==="breached"?"bg-red-50/40":void 0,children:[e.jsx(ue,{className:"font-medium text-slate-900",children:n.caseRef}),e.jsx(ue,{children:e.jsx(Ce,{variant:"secondary",className:"text-[10px]",children:n.module})}),e.jsx(ue,{className:"text-slate-700 max-w-[200px] truncate",title:n.stageName,children:n.stageName}),e.jsx(ue,{className:"text-slate-600 text-xs",children:n.ownerRole}),e.jsx(ue,{children:e.jsx(HG,{percent:n.percentUsed,bucket:n.bucket})}),e.jsxs(ue,{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(ue,{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(ck,{className:"w-4 h-4"})})})]},n.trackingId))})]})}const WG=()=>{var A,L,$,P,E,O,I,q,G;const[t,s]=g.useState(null),[n,r]=g.useState(!0),[a,l]=g.useState("ALL"),[o,d]=g.useState("queue"),[m,f]=g.useState(!1),[x,h]=g.useState(null),[p,u]=g.useState({}),[w,v]=g.useState(!1),N=g.useCallback(async()=>{r(!0);try{const Y=await Zl.getOperationsDashboard({module:a==="ALL"?void 0:a,mineOnly:m});Y!=null&&Y.success?s(Y.data):ee.error("Failed to load SLA monitor")}catch{ee.error("Failed to load SLA monitor")}finally{r(!1)}},[a,o,m]);g.useEffect(()=>{N()},[N]),g.useEffect(()=>{Zl.getQuestionnaireReminderSettings().then(Y=>{Y!=null&&Y.success&&Y.data&&(h(Y.data),u(Y.data))}).catch(()=>{})},[]);const j=async()=>{v(!0);try{const Y=await Zl.updateQuestionnaireReminderSettings(p);Y!=null&&Y.success&&(h(Y.data),u(Y.data),ee.success("Questionnaire reminder settings saved"))}catch{ee.error("Failed to save settings")}finally{v(!1)}},y=t==null?void 0:t.summary,C=t==null?void 0:t.analytics,S=(t==null?void 0:t.activeQueue)??[],D=S.filter(Y=>Y.bucket==="breached"),R=S.filter(Y=>Y.bucket==="warning"||Y.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:Y=>f(!!Y)}),e.jsx(de,{htmlFor:"sla-mine-only",className:"text-sm cursor-pointer",children:"My queue only"})]}),e.jsxs(At,{value:a,onValueChange:l,children:[e.jsx(Dt,{className:"w-[180px] h-9",children:e.jsx(kt,{placeholder:"Module"})}),e.jsx(Rt,{children:UG.map(Y=>e.jsx(Me,{value:Y,children:Y==="ALL"?"All modules":Y},Y))})]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:()=>Zl.exportOperationsCsv({module:a==="ALL"?void 0:a,mineOnly:m}).catch(()=>ee.error("Export failed")),children:[e.jsx(Ni,{className:"w-4 h-4 mr-1"}),"Export CSV"]}),e.jsxs(se,{variant:"outline",size:"sm",onClick:N,disabled:n,children:[e.jsx(pr,{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(uu,{label:"In queue",value:(y==null?void 0:y.activeCount)??"—",icon:e.jsx(yn,{className:"w-4 h-4 text-blue-600"})}),e.jsx(uu,{label:"Breached",value:(y==null?void 0:y.breachedCount)??"—",icon:e.jsx(Ha,{className:"w-4 h-4 text-red-600"}),highlight:"red"}),e.jsx(uu,{label:"Due soon",value:(y==null?void 0:y.dueSoonCount)??"—",icon:e.jsx(aM,{className:"w-4 h-4 text-re-red"})}),e.jsx(uu,{label:"On track",value:(y==null?void 0:y.onTrackCount)??"—",icon:e.jsx(Hn,{className:"w-4 h-4 text-emerald-600"})}),e.jsx(uu,{label:"Open breaches",value:(y==null?void 0:y.openBreachesCount)??"—",icon:e.jsx(Ha,{className:"w-4 h-4 text-re-red"})})]}),C&&e.jsxs(Le,{className:"border-slate-200",children:[e.jsxs(Qe,{className:"pb-2",children:[e.jsxs(et,{className:"text-sm flex items-center gap-2",children:[e.jsx(LI,{className:"w-4 h-4 text-re-red"}),"Analytics (last ",C.periodDays," days)"]}),e.jsx(Qt,{children:"Breach rate, resolution time, and top delayed stages"})]}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(Rm,{label:"Tracks started",value:C.tracksStarted}),e.jsx(Rm,{label:"Breach rate",value:`${C.breachRatePercent}%`,highlight:!0}),e.jsx(Rm,{label:"Avg resolution",value:C.avgResolutionHours!=null?`${C.avgResolutionHours}h`:"—"}),e.jsx(Rm,{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(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Stage"}),e.jsx(fe,{children:"Breaches (30d)"}),e.jsx(fe,{children:"Active breached"})]})}),e.jsx(Ls,{children:C.topDelayedStages.map(Y=>e.jsxs(lt,{children:[e.jsx(ue,{className:"font-medium",children:Y.stageName}),e.jsx(ue,{children:Y.breachCount}),e.jsx(ue,{children:Y.currentlyBreached})]},Y.stageName))})]})]}),Object.keys(C.breachesByModule).length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(C.breachesByModule).map(([Y,V])=>e.jsxs(Ce,{variant:"outline",children:[Y,": ",V," breaches"]},Y))})]})]}),y&&e.jsxs(Le,{className:"border-slate-200",children:[e.jsxs(Qe,{className:"pb-2",children:[e.jsx(et,{className:"text-sm",children:"Aging buckets"}),e.jsx(Qt,{children:"Percent of configured TAT elapsed"})]}),e.jsxs(Fe,{className:"flex flex-wrap gap-2",children:[Object.keys(Oy).map(Y=>e.jsxs(Ce,{variant:"outline",className:`px-3 py-1 ${X_[Y]}`,children:[Oy[Y],": ",y.buckets[Y]??0]},Y)),y.tracksWithoutConfig>0&&e.jsxs(Ce,{variant:"outline",className:"bg-slate-100 text-slate-600",children:["No config match: ",y.tracksWithoutConfig]})]})]}),e.jsxs($n,{value:o,onValueChange:d,children:[e.jsxs(qn,{className:"bg-slate-100",children:[e.jsxs(zt,{value:"queue",children:["Active queue (",S.length,")"]}),e.jsxs(zt,{value:"breached",children:["Breached (",D.length,")"]}),e.jsxs(zt,{value:"due",children:["Due soon (",R.length,")"]}),e.jsxs(zt,{value:"breach-log",children:["Open breaches (",((A=t==null?void 0:t.breaches)==null?void 0:A.length)??0,")"]}),e.jsx(zt,{value:"schedulers",children:"Schedulers"})]}),e.jsx(qt,{value:"queue",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:e.jsx(Ov,{items:S,emptyMessage:"No active SLA timers in queue."})})})}),e.jsx(qt,{value:"breached",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:e.jsx(Ov,{items:D,emptyMessage:"No breached items — all active SLAs are within TAT."})})})}),e.jsx(qt,{value:"due",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:e.jsx(Ov,{items:R,emptyMessage:"Nothing in the 26–99% window right now."})})})}),e.jsx(qt,{value:"breach-log",className:"mt-4",children:e.jsx(Le,{children:e.jsx(Fe,{className:"pt-4",children:(L=t==null?void 0:t.breaches)!=null&&L.length?e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Case"}),e.jsx(fe,{children:"Module"}),e.jsx(fe,{children:"Stage"}),e.jsx(fe,{children:"Breached at"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{})]})}),e.jsx(Ls,{children:t.breaches.map(Y=>e.jsxs(lt,{children:[e.jsx(ue,{className:"font-medium",children:Y.caseRef}),e.jsx(ue,{children:e.jsx(Ce,{variant:"secondary",className:"text-[10px]",children:Y.module})}),e.jsx(ue,{className:"truncate max-w-[200px]",children:Y.stageName}),e.jsx(ue,{className:"text-xs",children:new Date(Y.breachedAt).toLocaleString()}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:Y.status})}),e.jsx(ue,{children:e.jsx("a",{href:Y.link,target:"_blank",rel:"noopener noreferrer",className:"text-re-red",children:e.jsx(ck,{className:"w-4 h-4"})})})]},Y.id))})]}):e.jsx("p",{className:"text-sm text-slate-500 py-8 text-center",children:"No open breach records."})})})}),e.jsx(qt,{value:"schedulers",className:"mt-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"text-sm flex items-center gap-2",children:[e.jsx(Dr,{className:"w-4 h-4"}),"Prospect questionnaire reminders"]}),e.jsxs(Qt,{children:["Email/WhatsApp to applicants in Questionnaire Pending (not internal SLA)",(x==null?void 0:x.source)&&e.jsxs("span",{className:"block text-slate-400",children:["Source: ",x.source]})]})]}),e.jsxs(Fe,{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{id:"q-enabled",checked:!!p.enabled,onCheckedChange:Y=>u(V=>({...V,enabled:!!Y}))}),e.jsx(de,{htmlFor:"q-enabled",children:"Scheduler enabled"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(de,{className:"text-xs",children:"First after (days)"}),e.jsx(at,{type:"number",min:1,value:p.firstAfterDays??"",onChange:Y=>u(V=>({...V,firstAfterDays:Number(Y.target.value)}))})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs",children:"Interval (days)"}),e.jsx(at,{type:"number",min:1,value:p.intervalDays??"",onChange:Y=>u(V=>({...V,intervalDays:Number(Y.target.value)}))})]}),e.jsxs("div",{children:[e.jsx(de,{className:"text-xs",children:"Max reminders"}),e.jsx(at,{type:"number",min:1,value:p.maxCount??"",onChange:Y=>u(V=>({...V,maxCount:Number(Y.target.value)}))})]})]}),e.jsx(se,{size:"sm",onClick:j,disabled:w,children:w?"Saving…":"Save reminder settings"})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"text-sm flex items-center gap-2",children:[e.jsx(XI,{className:"w-4 h-4"}),"Infrastructure"]})}),e.jsxs(Fe,{className:"space-y-2 text-sm",children:[e.jsx(Lv,{label:"Redis",value:($=t==null?void 0:t.scheduler)!=null&&$.redisEnabled?"Enabled":"Disabled",ok:(P=t==null?void 0:t.scheduler)==null?void 0:P.redisEnabled}),e.jsx(Lv,{label:"SLA fast mode",value:(E=t==null?void 0:t.scheduler)!=null&&E.slaFastMode?"On":"Off",ok:!((O=t==null?void 0:t.scheduler)!=null&&O.slaFastMode)}),e.jsx(Lv,{label:"Questionnaire fast mode",value:(I=t==null?void 0:t.scheduler)!=null&&I.questionnaireFastMode?"On":"Off",ok:!((q=t==null?void 0:t.scheduler)!=null&&q.questionnaireFastMode)})]})]}),(((G=t==null?void 0:t.scheduler)==null?void 0:G.queues)??[]).map(Y=>{var V;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"pb-2",children:[e.jsx(et,{className:"text-sm",children:Y.name}),Y.key&&e.jsx(Qt,{children:Y.key})]}),e.jsx(Fe,{className:"text-sm",children:Y.error?e.jsx("p",{className:"text-red-600",children:Y.error}):e.jsxs(e.Fragment,{children:[Y.counts&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Object.entries(Y.counts).map(([Q,_])=>e.jsxs(Ce,{variant:"outline",children:[Q,": ",_]},Q))}),(V=Y.repeatable)!=null&&V.length?e.jsx("ul",{className:"text-xs text-slate-600 space-y-1",children:Y.repeatable.map((Q,_)=>e.jsxs("li",{children:[Q.name||Q.pattern,Q.next?` · next ${new Date(Q.next).toLocaleString()}`:""]},_))}):e.jsx("p",{className:"text-slate-400 text-xs",children:"No repeatable jobs registered"})]})})]},Y.name)})]})})]})]})};function Rm({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 uu({label:t,value:s,icon:n,highlight:r}){return e.jsx(Le,{className:r==="red"?"border-red-200 bg-red-50/30":"border-slate-200",children:e.jsx(Fe,{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 Lv({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 GG=({isOpen:t,onClose:s,sla:n,onSave:r})=>{const[a,l]=g.useState({activityName:"",tatHours:24,tatUnit:"hours",isActive:!0,reminders:[],escalationConfigs:[]}),[o,d]=g.useState(!1);g.useEffect(()=>{n&&l({...n,reminders:n.reminders||[],escalationConfigs:n.escalationConfigs||[]})},[n]);const m=()=>{l({...a,reminders:[...a.reminders,{timeValue:1,timeUnit:"days",isEnabled:!0}]})},f=u=>{const w=[...a.reminders];w.splice(u,1),l({...a,reminders:w})},x=()=>{l({...a,escalationConfigs:[...a.escalationConfigs,{level:a.escalationConfigs.length+1,timeValue:1,timeUnit:"days",notifyEmail:""}]})},h=u=>{const w=[...a.escalationConfigs];w.splice(u,1);const v=w.map((N,j)=>({...N,level:j+1}));l({...a,escalationConfigs:v})},p=async u=>{if(u.preventDefault(),!a.activityName||!a.ownerRole){ee.error("Activity Name and Owner Role are required");return}try{d(!0),await Fs.saveSlaConfig(a),ee.success(n!=null&&n.id?"SLA Configuration updated":"New SLA Configuration created"),r(),s()}catch(w){console.error("Save SLA error:",w),ee.error("Failed to save SLA configuration")}finally{d(!1)}};return e.jsx(ls,{open:t,onOpenChange:s,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsxs(us,{children:[n!=null&&n.id?"Configure SLA":"Add New SLA",": ",a.activityName||"New Activity"]}),e.jsx(bs,{children:"Define the Turn Around Time and notification rules for this stage."})]}),e.jsxs("form",{onSubmit:p,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(de,{htmlFor:"activityName",children:"Activity Name (Workflow Stage)"}),e.jsxs(At,{value:a.activityName,onValueChange:u=>{let w=a.ownerRole;for(const v of Object.values(kC))if(v[u]){w=v[u];break}l({...a,activityName:u,ownerRole:w})},disabled:!!(n!=null&&n.id),children:[e.jsx(Dt,{id:"activityName",children:e.jsx(kt,{placeholder:"Select Stage"})}),e.jsx(Rt,{children:Object.entries(kC).map(([u,w])=>e.jsxs(wt.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(w).map(v=>e.jsx(Me,{value:v,children:v},v))]},u))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"ownerRole",children:"Owner Role (Auto-resolved)"}),e.jsxs(At,{value:a.ownerRole,onValueChange:u=>l({...a,ownerRole:u}),disabled:!!(n!=null&&n.id),children:[e.jsx(Dt,{id:"ownerRole",children:e.jsx(kt,{placeholder:"Select Role"})}),e.jsx(Rt,{children:Object.values(mn).map(u=>e.jsx(Me,{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(de,{htmlFor:"tatHours",children:"Target TAT"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(at,{id:"tatHours",type:"number",value:a.tatHours,onChange:u=>l({...a,tatHours:parseInt(u.target.value)})}),e.jsxs(At,{value:a.tatUnit,onValueChange:u=>l({...a,tatUnit:u}),children:[e.jsx(Dt,{className:"w-32",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"hours",children:"Hours"}),e.jsx(Me,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 pt-8",children:[e.jsx(jp,{id:"isActive",className:"data-[state=checked]:bg-re-red",checked:a.isActive,onCheckedChange:u=>l({...a,isActive:u})}),e.jsx(de,{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(ku,{className:"w-4 h-4 text-blue-600"}),e.jsx("h4",{className:"font-medium text-sm",children:"Reminders"})]}),e.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7 text-xs",children:[e.jsx(Dn,{className:"w-3 h-3 mr-1"})," Add Reminder"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.reminders.map((u,w)=>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(at,{type:"number",className:"w-20 h-8",value:u.timeValue,onChange:v=>{const N=[...a.reminders];N[w].timeValue=parseInt(v.target.value),l({...a,reminders:N})}}),e.jsxs(At,{value:u.timeUnit,onValueChange:v=>{const N=[...a.reminders];N[w].timeUnit=v,l({...a,reminders:N})},children:[e.jsx(Dt,{className:"w-24 h-8 text-xs",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"hours",children:"Hours"}),e.jsx(Me,{value:"days",children:"Days"})]})]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(w),className:"h-8 w-8 p-0 text-slate-400 hover:text-red-500",children:e.jsx(ar,{className:"w-4 h-4"})})]},w)),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(Ha,{className:"w-4 h-4 text-re-red"}),e.jsx("h4",{className:"font-medium text-sm",children:"Escalation Levels"})]}),e.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:x,className:"h-7 text-xs",children:[e.jsx(Dn,{className:"w-3 h-3 mr-1"})," Add Level"]})]}),e.jsxs("div",{className:"space-y-3",children:[a.escalationConfigs.map((u,w)=>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(Ce,{variant:"outline",className:"bg-red-50 text-re-red-hover border-red-100",children:["Level ",u.level]}),e.jsx(se,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(w),className:"h-7 w-7 p-0 text-slate-400 hover:text-red-500",children:e.jsx(ar,{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(de,{className:"text-[10px] uppercase text-slate-500",children:"Escalate After Breaching By"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(at,{type:"number",className:"h-8",value:u.timeValue,onChange:v=>{const N=[...a.escalationConfigs];N[w].timeValue=parseInt(v.target.value),l({...a,escalationConfigs:N})}}),e.jsxs(At,{value:u.timeUnit,onValueChange:v=>{const N=[...a.escalationConfigs];N[w].timeUnit=v,l({...a,escalationConfigs:N})},children:[e.jsx(Dt,{className:"w-24 h-8 text-xs",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"hours",children:"Hours"}),e.jsx(Me,{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{className:"text-[10px] uppercase text-slate-500",children:"Notification Recipient (Role)"}),e.jsxs(At,{value:u.notifyRole||"",onValueChange:v=>{const N=[...a.escalationConfigs];N[w].notifyRole=v,N[w].notifyEmail="",l({...a,escalationConfigs:N})},children:[e.jsx(Dt,{className:"h-8 text-xs",children:e.jsx(kt,{placeholder:"Select Recipient Role"})}),e.jsx(Rt,{children:Object.values(mn).map(v=>e.jsx(Me,{value:v,children:v},v))})]})]})]})]},w)),a.escalationConfigs.length===0&&e.jsx("p",{className:"text-center text-xs text-slate-400 py-2",children:"No escalation levels defined"})]})]}),e.jsxs(xn,{className:"pt-4 border-t",children:[e.jsx(se,{type:"button",variant:"outline",onClick:s,disabled:o,children:"Cancel"}),e.jsx(se,{type:"submit",disabled:o,className:"bg-re-red hover:bg-re-red-hover text-white",children:o?"Saving...":"Save Configuration"})]})]})]})})},KG=()=>{const t=Iu(),{slaConfigs:s,loading:n}=Fn(v=>v.master),[r,a]=g.useState(!1),[l,o]=g.useState(null),[d,m]=g.useState(!1),[f,x]=g.useState("monitor"),h=async()=>{try{const v=await Fs.getSlaConfigs();v&&v.success&&t(RA({slaConfigs:v.data}))}catch{ee.error("Failed to fetch SLA configurations")}};g.useEffect(()=>{h()},[]);const p=async()=>{try{m(!0);const v=await Fs.initializeDefaultSlas();v&&v.success&&(ee.success("Default SLAs initialized successfully"),h())}catch{ee.error("Failed to initialize default SLAs")}finally{m(!1)}},u=v=>{o(v),a(!0)},w=()=>{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(yn,{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($n,{value:f,onValueChange:x,children:[e.jsxs(qn,{className:"bg-slate-100",children:[e.jsxs(zt,{value:"monitor",className:"flex items-center gap-1.5",children:[e.jsx(rd,{className:"w-4 h-4"}),"Operations monitor"]}),e.jsx(zt,{value:"config",children:"Configuration matrix"})]}),e.jsx(qt,{value:"monitor",className:"mt-6",children:e.jsx(WG,{})}),e.jsxs(qt,{value:"config",className:"mt-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsxs(se,{variant:"outline",onClick:p,disabled:n||d,children:[e.jsx(pr,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Initialize Defaults"]}),e.jsxs(se,{onClick:w,disabled:n,className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"Add Manual SLA"]}),e.jsx(se,{variant:"ghost",size:"icon",onClick:h,disabled:n,children:e.jsx(pr,{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 N,j;return e.jsxs(Le,{className:"border-slate-200 hover:shadow-md transition-shadow group overflow-hidden",children:[e.jsx(Qe,{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(yn,{className:"w-5 h-5 text-re-red"})}),e.jsxs("div",{children:[e.jsx(et,{className:"text-lg",children:v.activityName}),e.jsx(Qt,{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(Ce,{variant:v.isActive?"default":"secondary",className:v.isActive?"bg-emerald-600":"bg-slate-400",children:v.isActive?e.jsxs(e.Fragment,{children:[e.jsx(fn,{className:"w-3 h-3 mr-1"})," Active"]}):"Disabled"}),e.jsx(se,{variant:"ghost",size:"icon",onClick:()=>u(v),className:"h-8 w-8 text-slate-400 hover:text-re-red",children:e.jsx(Cr,{className:"w-4 h-4"})})]})]})}),e.jsxs(Fe,{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(ku,{className:"w-4 h-4 text-blue-600"}),e.jsxs("span",{className:"text-xs font-bold text-slate-700 uppercase tracking-wider",children:["Reminders (",((N=v.reminders)==null?void 0:N.length)||0,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[(v.reminders||[]).map((y,C)=>e.jsxs("div",{className:"text-xs text-slate-600 flex items-center gap-1",children:[e.jsxs(Ce,{variant:"outline",className:"text-[10px] h-4.5 bg-blue-50 border-blue-200",children:[y.timeValue," ",y.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(Ha,{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((y,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(Ce,{variant:"outline",className:"text-[9px] h-4 px-1 bg-red-50 border-red-200 text-re-red-hover",children:["L",y.level]}),e.jsxs("span",{children:["after ",y.timeValue," ",y.timeUnit]})]}),e.jsx("p",{className:"text-slate-500 ml-8 font-mono truncate",children:y.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(yn,{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(GG,{isOpen:r,onClose:()=>a(!1),sla:l,onSave:h})]})},J_="Private Limited",eT="LLP",tT="Partnership",vj="Proprietorship",sT=[vj,tT,eT,J_];function YG(t){return sT.includes(t)}function ZG(t){const s=String(t||"").trim();if(!s)return null;if(YG(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"?J_:n.includes("llp")?eT:n.includes("partnership")?tT:n.includes("proprietorship")||n==="sole proprietorship"?vj:sT.find(a=>a.toLowerCase()===s.toLowerCase())||null}function nT(t){return ZG(t)||vj}const QG={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]},XG=99,JG={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",[XG]:"Other"},RC=(t,s)=>Xb(t,s),dl=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 eK({onViewDetails:t}){var ke,Xe,Ot,bt;const[s,n]=g.useState(!1),[r,a]=g.useState([]),[l,o]=g.useState([]),[d,m]=g.useState([]),[f,x]=g.useState(""),[h,p]=g.useState(""),[u,w]=g.useState([]),[v,N]=g.useState(null),[j,y]=g.useState(""),[C,S]=g.useState(""),[D,R]=g.useState([]),[A,L]=g.useState([]),[$,P]=g.useState(!0),[E,O]=g.useState(1),[I,q]=g.useState(null),[G,Y]=g.useState("all"),V=10,Q=A.map(te=>({entityType:"constitutional",entityId:te.id||te.requestId})),{get:_}=xc(Q,A.length>0),[z,T]=g.useState(!1),[F,B]=g.useState(!1),K=te=>te.status==="Completed"||te.status==="Closed"||te.currentStage==="Completed",W=te=>te.status==="Rejected"||te.status==="Revoked"||te.currentStage==="Rejected"||te.currentStage==="Revoked",H=te=>!K(te)&&!W(te)&&te.status!=="Submitted",X=te=>te.status==="Submitted"||te.currentStage==="Submitted",J=te=>{Y(te),O(1)};g.useEffect(()=>{ie()},[E,G]),g.useEffect(()=>{if(!s)return;let te=!1;return(async()=>{var ve,qe,ge,Be;try{B(!0);const[ut,ht,it]=await Promise.all([Ee.getConstitutionalChangeMeta(),Ee.getDealers({onboarded:"true"}),Ee.getOutlets()]);if(te)return;(ve=ut.data)!=null&&ve.success&&Array.isArray(ut.data.structureTargets)&&a(ut.data.structureTargets);const Tt=((qe=ht.data)==null?void 0:qe.data)??((ge=ht.data)==null?void 0:ge.dealers)??[];o(Array.isArray(Tt)?Tt:[]);const It=((Be=it.data)==null?void 0:Be.outlets)??[];m(Array.isArray(It)?It:[])}catch(ut){console.error(ut),ee.error("Failed to load dealers or form options")}finally{te||B(!1)}})(),()=>{te=!0}},[s]);const ie=async()=>{try{P(!0);const te=await Ee.getConstitutionalChanges({page:E,limit:V,status:G==="all"?void 0:G});te.data.success&&(L(te.data.requests||[]),q(te.meta))}catch(te){console.error("Fetch requests error:",te),ee.error("Failed to fetch requests")}finally{P(!1)}},ae=te=>{var Be,ut,ht;if(x(te),p(""),y(""),R([]),!te){N(null),w([]);return}const ve=l.find(it=>{var Tt;return((Tt=it.user)==null?void 0:Tt.id)===te});if(!((Be=ve==null?void 0:ve.user)!=null&&Be.id)){N(null),w([]);return}const qe=nT(ve.constitutionType),ge=d.filter(it=>String(it.dealerId)===String(te));w(ge),ge.length===1&&p(ge[0].id),N({dealerUserId:ve.user.id,dealerName:ve.businessName,dealershipName:ve.legalName||ve.businessName,address:ve.registeredAddress||((ut=ve.application)==null?void 0:ut.preferredLocation)||"—",gst:ve.gstNumber||"N/A",currentType:qe,dealerCode:((ht=ve.dealerCode)==null?void 0:ht.dealerCode)||"—",region:"—",zone:"—"})},xe=te=>{y(te),R(QG[te]||[])},ce=async te=>{var ve,qe;if(te.preventDefault(),!(v!=null&&v.dealerUserId)){ee.error("Please select a dealer");return}if(u.length>1&&!h){ee.error("Please select an outlet for this dealer");return}if(!j){ee.error("Please select proposed constitution type");return}if(!C.trim()){ee.error("Please provide a reason for constitutional change");return}if(v.currentType===j){ee.error("Proposed type cannot be the same as the current constitution");return}try{T(!0);const ge={forDealerUserId:v.dealerUserId,outletId:h||void 0,changeType:j,reason:C.trim(),currentConstitution:v.currentType};(await Ee.createConstitutionalChange(ge)).data.success&&(ee.success("Constitutional change request submitted successfully"),n(!1),ie(),x(""),p(""),w([]),N(null),y(""),S(""),R([]))}catch(ge){console.error("Submit request error:",ge);const Be=((qe=(ve=ge==null?void 0:ge.response)==null?void 0:ve.data)==null?void 0:qe.message)||"Failed to submit request";ee.error(Be)}finally{T(!1)}},we=[{title:"Total Requests",value:((ke=I==null?void 0:I.stats)==null?void 0:ke.total)||0,icon:Ns,color:"bg-blue-500"},{title:"Submitted / Review",value:((Xe=I==null?void 0:I.stats)==null?void 0:Xe.pending)||0,icon:dr,color:"bg-re-red"},{title:"Completed",value:((Ot=I==null?void 0:I.stats)==null?void 0:Ot.completed)||0,icon:mc,color:"bg-green-500"},{title:"Rejected / Revoked",value:((bt=I==null?void 0:I.stats)==null?void 0:bt.rejected)||0,icon:ad,color:"bg-red-500"}];return e.jsxs("div",{className:"space-y-6",children:[$&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/20 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsx(es,{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(ls,{open:s,onOpenChange:n,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"New Request"]})}),e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Create Constitutional Change Request"}),e.jsx(bs,{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(es,{className:"h-4 w-4 animate-spin"}),"Loading dealers and options…"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"dealerUser",children:"Dealer *"}),e.jsxs(At,{value:f,onValueChange:ae,disabled:F,required:!0,children:[e.jsx(Dt,{id:"dealerUser",children:e.jsx(kt,{placeholder:"Select dealer account"})}),e.jsx(Rt,{className:"max-h-72",children:l.filter(te=>{var ve;return(ve=te.user)==null?void 0:ve.id}).map(te=>{var ve;return e.jsx(Me,{value:te.user.id,children:(((ve=te.dealerCode)==null?void 0:ve.dealerCode)||"No code")+" — "+(te.businessName||te.legalName||"Dealer")},te.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(de,{htmlFor:"outletPick",children:"Outlet *"}),e.jsxs(At,{value:h,onValueChange:p,required:!0,children:[e.jsx(Dt,{id:"outletPick",children:e.jsx(kt,{placeholder:"Select outlet"})}),e.jsx(Rt,{children:u.map(te=>e.jsxs(Me,{value:te.id,children:[te.code," — ",te.name]},te.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(Ce,{className:dl(v.currentType),children:v.currentType})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"targetType",children:"Proposed constitution *"}),e.jsxs(At,{value:j,onValueChange:xe,required:!0,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select proposed constitution"})}),e.jsx(Rt,{children:r.filter(te=>te.value!==(v==null?void 0:v.currentType)).map(te=>e.jsx(Me,{value:te.value,children:te.label},te.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(te=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"text-blue-600 font-medium",children:[te,"."]}),e.jsx("span",{className:"text-blue-800",children:JG[te]})]},te))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Constitutional Change *"}),e.jsx(Gs,{id:"reason",placeholder:"Provide detailed reason for the constitutional change request...",value:C,onChange:te=>S(te.target.value),rows:4,required:!0})]}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{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(es,{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:we.map((te,ve)=>{const qe=te.icon;return e.jsx(Le,{children:e.jsx(Fe,{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:te.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:te.value})]}),e.jsx("div",{className:`${te.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(qe,{className:"w-6 h-6 text-white"})})]})})},ve)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Constitutional Change Requests"}),e.jsx(Qt,{children:"Track and manage all constitutional change requests across all stages"})]}),e.jsxs(Fe,{children:[e.jsxs($n,{value:G,onValueChange:J,className:"w-full",children:[e.jsxs(qn,{className:"grid w-full grid-cols-4",children:[e.jsx(zt,{value:"all",children:"All Requests"}),e.jsx(zt,{value:"pending",children:"Submitted / Review"}),e.jsx(zt,{value:"rejected",children:"Rejected / Revoked"}),e.jsx(zt,{value:"completed",children:"Completed"})]}),e.jsx(qt,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:A.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:7,className:"text-center py-8 text-slate-500",children:"No constitutional change requests found"})}):A.map(te=>{var ve,qe,ge,Be,ut,ht,it,Tt,It,he,vt,mt,_e,Vt,Et,Ds;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:te.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ge=(qe=(ve=te.dealer)==null?void 0:ve.dealerProfile)==null?void 0:qe.dealerCode)==null?void 0:ge.dealerCode)||((Be=te.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(ut=te.dealer)==null?void 0:ut.dealerProfile)==null?void 0:ht.businessName)||((it=te.outlet)==null?void 0:it.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Tt=te.dealer)==null?void 0:Tt.dealerProfile)==null?void 0:It.registeredAddress)||((he=te.outlet)!=null&&he.city&&((vt=te.outlet)!=null&&vt.state)?`${te.outlet.city}, ${te.outlet.state}`:((Vt=(_e=(mt=te.dealer)==null?void 0:mt.dealerProfile)==null?void 0:_e.application)==null?void 0:Vt.city)||((Et=te.outlet)==null?void 0:Et.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:dl(te.currentConstitution||"Proprietorship"),children:te.currentConstitution||"—"}),e.jsx(Yo,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:dl(te.changeType),children:te.changeType})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Ce,{className:eo(te.currentStage,te.status),children:te.currentStage}),e.jsx(kr,{status:_("constitutional",te.id||te.requestId),compact:!0})]})}),e.jsx(ue,{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 ${vi(te.status,te.currentStage)}`,style:{width:`${te.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[te.progressPercentage||0,"%"]})]})}),e.jsxs(ue,{children:[e.jsx("div",{className:"text-slate-900",children:Gt(te.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((Ds=te.dealer)==null?void 0:Ds.fullName)||"Dealer"]})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(te.requestId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},te.requestId)})})]})})}),e.jsx(qt,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Ls,{children:[A.filter(te=>X(te)||H(te)).map(te=>{var ve,qe,ge,Be,ut,ht,it,Tt,It,he,vt,mt;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:te.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ge=(qe=(ve=te.dealer)==null?void 0:ve.dealerProfile)==null?void 0:qe.dealerCode)==null?void 0:ge.dealerCode)||((Be=te.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(ut=te.dealer)==null?void 0:ut.dealerProfile)==null?void 0:ht.businessName)||((it=te.outlet)==null?void 0:it.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Tt=te.dealer)==null?void 0:Tt.dealerProfile)==null?void 0:It.registeredAddress)||((he=te.outlet)!=null&&he.city&&((vt=te.outlet)!=null&&vt.state)?`${te.outlet.city}, ${te.outlet.state}`:((mt=te.outlet)==null?void 0:mt.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:dl(te.currentConstitution||"Proprietorship"),children:te.currentConstitution||"—"}),e.jsx(Yo,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:dl(te.changeType),children:te.changeType})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Ce,{className:eo(te.currentStage,te.status),children:te.currentStage}),e.jsx(kr,{status:_("constitutional",te.id||te.requestId),compact:!0})]})}),e.jsx(ue,{children:e.jsx(Ce,{className:RC(te.status,te.currentStage),children:te.status})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(te.requestId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},te.requestId)}),A.filter(te=>X(te)||H(te)).length===0&&e.jsx(lt,{children:e.jsx(ue,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No pending requests found"})})]})]})})}),e.jsx(qt,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Ls,{children:[A.filter(te=>W(te)).map(te=>{var ve,qe,ge,Be,ut,ht,it,Tt,It,he,vt,mt,_e,Vt,Et;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:te.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ge=(qe=(ve=te.dealer)==null?void 0:ve.dealerProfile)==null?void 0:qe.dealerCode)==null?void 0:ge.dealerCode)||((Be=te.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(ut=te.dealer)==null?void 0:ut.dealerProfile)==null?void 0:ht.businessName)||((it=te.outlet)==null?void 0:it.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Tt=te.dealer)==null?void 0:Tt.dealerProfile)==null?void 0:It.registeredAddress)||((he=te.outlet)!=null&&he.city&&((vt=te.outlet)!=null&&vt.state)?`${te.outlet.city}, ${te.outlet.state}`:((Vt=(_e=(mt=te.dealer)==null?void 0:mt.dealerProfile)==null?void 0:_e.application)==null?void 0:Vt.city)||((Et=te.outlet)==null?void 0:Et.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:dl(te.currentConstitution||"Proprietorship"),children:te.currentConstitution||"—"}),e.jsx(Yo,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:dl(te.changeType),children:te.changeType})]})}),e.jsx(ue,{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 ${vi(te.status,te.currentStage)}`,style:{width:`${te.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[te.progressPercentage||0,"%"]})]})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Ce,{className:eo(te.currentStage,te.status),children:te.currentStage}),e.jsx(kr,{status:_("constitutional",te.id||te.requestId),compact:!0})]})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(te.requestId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},te.requestId)}),A.filter(te=>W(te)).length===0&&e.jsx(lt,{children:e.jsx(ue,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No in-progress requests found"})})]})]})})}),e.jsx(qt,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Constitutional Change"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(Ls,{children:[A.filter(te=>K(te)).map(te=>{var ve,qe,ge,Be,ut,ht,it,Tt,It,he,vt,mt;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:te.requestId}),e.jsx("div",{className:"text-slate-600 text-sm",children:((ge=(qe=(ve=te.dealer)==null?void 0:ve.dealerProfile)==null?void 0:qe.dealerCode)==null?void 0:ge.dealerCode)||((Be=te.outlet)==null?void 0:Be.code)||"N/A"})]}),e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:((ht=(ut=te.dealer)==null?void 0:ut.dealerProfile)==null?void 0:ht.businessName)||((it=te.outlet)==null?void 0:it.name)||"N/A"}),e.jsx("div",{className:"text-slate-600 text-sm",children:((It=(Tt=te.dealer)==null?void 0:Tt.dealerProfile)==null?void 0:It.registeredAddress)||((he=te.outlet)!=null&&he.city&&((vt=te.outlet)!=null&&vt.state)?`${te.outlet.city}, ${te.outlet.state}`:((mt=te.outlet)==null?void 0:mt.address)||"N/A")})]}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:dl(te.currentConstitution||"Proprietorship"),children:te.currentConstitution||"—"}),e.jsx(Yo,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:dl(te.changeType),children:te.changeType})]})}),e.jsx(ue,{children:e.jsx(Ce,{className:RC(te.status,te.currentStage),children:te.status})}),e.jsx(ue,{children:e.jsx("div",{className:"text-slate-900",children:Gt(te.createdAt)})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>t(te.requestId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},te.requestId)}),A.filter(te=>K(te)).length===0&&e.jsx(lt,{children:e.jsx(ue,{colSpan:6,className:"text-center py-8 text-slate-500",children:"No completed requests found"})})]})]})})})]}),I&&I.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>O(te=>Math.max(1,te-1)),className:E===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(I.totalPages)].map((te,ve)=>{const qe=ve+1;return qe===1||qe===I.totalPages||qe>=E-1&&qe<=E+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:E===qe,onClick:()=>O(qe),className:"cursor-pointer",children:qe})},qe):qe===2&&E>3||qe===I.totalPages-1&&E<I.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},qe):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>O(te=>Math.min(I.totalPages,te+1)),className:E===I.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Em={APPROVE:"approve",SEND_BACK:"sendBack",REVOKE:"revoke",REJECT:"reject",WITHDRAWAL:"withdrawal",ASSIGN:"assign",PUSH_FNF:"pushfnf",RECONSIDER:"reconsider",ISSUE_SCN:"issueSCN",SCN_RESPONSE:"scnResponse"},_m=[{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"}],EC=t=>t==="ZM/RBM Review"?"ZM+RBM Review":t,_C=t=>t==="ZM/RBM"?"ZM+RBM":t,TC={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]},Wo=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",[Wo]:"Other"},PC=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"}},Iv=t=>HE(t),tK=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",sK=t=>{const s=String(t.action||"").toUpperCase(),n=String(t.description||"").toUpperCase(),r=String(t.remarks||"").toUpperCase(),a=t.details||t.newData||{},l=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"}:l==="COMPLETED"||d.includes("COMPLET")?{variant:"success",badge:"COMPLETED"}:l?{variant:"success",badge:"APPROVED"}:{variant:"neutral",badge:s.replace(/_/g," ")||"EVENT"}},OC=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 nK({requestId:t,onBack:s,currentUser:n}){var Ys,Xs,Js,Ws,Z,oe,Ne,Oe,De,ye,Ve,Ge,st,Kt,Xt,ot,ft,Es,ts,vs,Te,je,nt,Ye,pt,yt,Jt,ss,Ss,Zs,on,en,tn,cn,Ae,Ht;const r=tr(),[a,l]=g.useState(!1),[o,d]=g.useState("approve"),[m,f]=g.useState(""),[x,h]=g.useState(!1),[p,u]=g.useState(null),[w,v]=g.useState(null),[N,j]=g.useState(!1),[y,C]=g.useState("workflow"),[S,D]=g.useState("required"),[R,A]=g.useState(null),L=(R==null?void 0:R.id)||"",{get:$}=xc(L?[{entityType:"constitutional",entityId:L}]:[],!!L),[P,E]=g.useState([]),[O,I]=g.useState(!0),[q,G]=g.useState(!1),[Y,V]=g.useState(null),[Q,_]=g.useState(!1),[z,T]=g.useState(!1),[F,B]=g.useState(null),[K,W]=g.useState(""),[H,X]=g.useState(!1),J=async Pe=>{if(Pe)try{const ct=await Ee.getAuditLogs("constitutional_change",Pe);ct.data&&ct.data.success&&E(ct.data.data||[])}catch(ct){console.error("Error fetching audit logs:",ct)}},ie=async Pe=>{try{Pe!=null&&Pe.silent||I(!0);const ct=await Ee.getConstitutionalChangeById(t);if(ct.data.success){const tt=ct.data.request;A(tt),await J((tt==null?void 0:tt.id)||t)}else ee.error("Failed to fetch request details")}catch(ct){console.error("Fetch request details error:",ct),ee.error("Error loading request details")}finally{Pe!=null&&Pe.silent||I(!1)}};g.useEffect(()=>{ie()},[t]);const ae=g.useMemo(()=>P.length>0?P:((R==null?void 0:R.timeline)||[]).map((ct,tt)=>({id:`timeline-${tt}`,action:String(ct.action||"UPDATED"),description:ct.remarks||ct.action||"Updated",stage:ct.stage||null,userName:ct.user||ct.userName||"System",remarks:ct.remarks,timestamp:ct.timestamp||ct.createdAt})),[P,R==null?void 0:R.timeline]),xe=g.useMemo(()=>{const Pe=OC(String((R==null?void 0:R.changeType)||"")),tt=[...TC[Pe]||[]];return tt.includes(Wo)||tt.push(Wo),tt.sort((Nt,Mt)=>Nt===Wo?1:Mt===Wo?-1:Nt-Mt)},[R==null?void 0:R.changeType]);if(O)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(es,{className:"w-8 h-8 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-600",children:"Loading request details..."})]});if(!R)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(se,{onClick:s,children:"Go Back"})]});const ce=OC(R.changeType),we=TC[ce]||[],ke=Pe=>{const ct=R.documents||[],tt=Hc[Pe];return ct.find(Nt=>{const Mt=Number(Nt==null?void 0:Nt.docNumber);return!!(!Number.isNaN(Mt)&&Mt===Pe||tt&&typeof(Nt==null?void 0:Nt.name)=="string"&&Nt.name.includes(tt))})},Xe=Pe=>{const ct=ke(Pe);return!!ct&&String(ct.status||"")!=="Rejected"},bt=(()=>{let Pe=R.currentStage||"";if(["Rejected","Revoked","Withdrawn"].includes(R.status)&&(Pe==="Rejected"||Pe==="Revoked"||!Pe)){const Nt=[...R.timeline||[]].reverse().find(Mt=>Mt.stage&&!["Rejected","Revoked","REJECTED","REVOKED"].includes(Mt.stage));Nt&&(Pe=Nt.stage)}const ct={"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(ct[Pe])return ct[Pe];const tt=Pe.trim().toLowerCase();for(const[Nt,Mt]of Object.entries(ct))if(Nt.toLowerCase()===tt||Nt.toLowerCase().includes(tt)||tt.includes(Nt.toLowerCase()))return Mt;return 1})(),te=R.currentStage==="Completed"||String(R.status||"")==="Completed"&&!["Rejected","Revoked"].includes(String(R.currentStage||"")),ve=Ad(R.status,R.currentStage),qe=vi(R.status,R.currentStage),ge=Jb(R.status,R.currentStage),Be=Pe=>{const tt={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"]}[Pe]||[Pe],Nt=(R.timeline||[]).filter(Mt=>{const Pt=String(Mt.stage||Mt.targetStage||"").trim();return tt.includes(Pt)});return Nt.length?Nt[Nt.length-1]:null},ht=(()=>{var We,Ft;if(!R||!n)return{canApprove:!1,canReject:!1,canSendBack:!1,canRevoke:!1,isFinalState:!1,hasCurrentUserApprovedZmRbm:!1};const Pe=R.currentStage,ct=R.status,tt=n.role||n.roleCode,Nt=String(n.roleCode||n.role||"").trim().toUpperCase(),Mt=["Completed","Rejected","Revoked"].includes(String(ct||""))||["Rejected","Revoked","Completed"].includes(String(Pe||"")),Pt=_m.find(gt=>gt.name===Pe||gt.key===Pe),ys=Pe==="Submitted",Yt=n.roleCode==="SUPER_ADMIN"||ys&&(tt==="ASM"||n.roleCode==="ASM")||!ys&&((Pt==null?void 0:Pt.role)==="ASM"&&tt==="ASM"||((Pt==null?void 0:Pt.role)==="ZM/RBM"||(Pt==null?void 0:Pt.role)==="ZM+RBM")&&(tt==="DD-ZM"||tt==="RBM")||(Pt==null?void 0:Pt.role)==="ZBH"&&tt==="ZBH"||(Pt==null?void 0:Pt.role)==="DD Lead"&&tt==="DD Lead"||(Pt==null?void 0:Pt.role)==="DD Head"&&tt==="DD Head"||(Pt==null?void 0:Pt.role)==="NBH"&&tt==="NBH"||(Pt==null?void 0:Pt.role)==="Legal Team"&&tt==="Legal Admin"),ps=["ZBH","DD Lead","DD Head","NBH"],ks=Yt&&!Mt&&(n.roleCode==="SUPER_ADMIN"||ps.includes(tt))&&Pe!=="Legal Review"&&Pe!=="Submitted";let hs=R.metadata||{};if(typeof hs=="string")try{hs=JSON.parse(hs)}catch(gt){console.error("Failed to parse metadata",gt),hs={}}const gn=((We=hs==null?void 0:hs.jointApprovals)==null?void 0:We.zmRbm)||{},$s=Pe==="ZM/RBM Review"||Pe==="ZM+RBM Review",dn=Nt==="RBM"?"RBM":Nt==="DD-ZM"||Nt==="DD ZM"||Nt==="ZM"?"DD-ZM":null,sn=$s&&dn&&!!((Ft=gn==null?void 0:gn[dn])!=null&&Ft.approvedByUserId);return{canApprove:Yt&&!Mt&&!sn,canReject:Yt&&!Mt&&!sn,canSendBack:ks,canRevoke:ks,isFinalState:Mt,hasCurrentUserApprovedZmRbm:sn}})(),it=(Ys=R.dealer)==null?void 0:Ys.dealerProfile,Tt=it==null?void 0:it.application,It=((Tt==null?void 0:Tt.loiRequests)||[]).find(Pe=>/approved/i.test(String((Pe==null?void 0:Pe.status)||""))),he=((Tt==null?void 0:Tt.loaRequests)||[]).find(Pe=>/approved/i.test(String((Pe==null?void 0:Pe.status)||""))),vt=(it==null?void 0:it.loiDate)??(It==null?void 0:It.approvedAt),mt=(it==null?void 0:it.loaDate)??(he==null?void 0:he.approvedAt),_e=Pe=>{d(Pe),V(null),l(!0)},Vt=async Pe=>{var Nt,Mt,Pt;Pe.preventDefault();const ct=String(m||"").trim();if((o==="sendBack"||o==="revoke")&&ct.length<5){ee.error("Detailed remarks (minimum 5 characters) are required for Send Back and Revoke actions.");return}if(!ct&&o!=="approve"){ee.error("Remarks are required for this action.");return}try{G(!0),V(null);const ys=o==="approve"?Em.APPROVE:o==="reject"?Em.REJECT:o==="sendBack"?Em.SEND_BACK:Em.REVOKE,Yt=await Ee.updateConstitutionalChange(t,ys,{comments:m}),ps=Yt==null?void 0:Yt.data;if(Yt!=null&&Yt.ok&&(ps!=null&&ps.success)){const gn=o==="approve"?"approved":o==="reject"?"rejected":o==="sendBack"?"sent back":"revoked";ee.success(`Request ${gn} successfully`),l(!1),f(""),V(null),await ie();return}const ks=(ps==null?void 0:ps.message)||((Nt=Yt==null?void 0:Yt.data)==null?void 0:Nt.error)||"Failed to submit action";V(ks);const hs=/mandatory documents/i.test(ks);ee.error(ks,{duration:hs?14e3:8e3})}catch(ys){console.error("Submit action error:",ys);const Yt=((Pt=(Mt=ys==null?void 0:ys.response)==null?void 0:Mt.data)==null?void 0:Pt.message)||(ys==null?void 0:ys.message)||"Failed to submit action";V(Yt),ee.error(Yt,{duration:/mandatory documents/i.test(Yt)?14e3:8e3})}finally{G(!1)}},Et=async()=>{var Pe,ct,tt;if(!p||!w){ee.error("Please select document type and file");return}try{_(!0);const Nt=Array.isArray(R.documents)?[...R.documents]:[],Pt=p!==Wo?Nt.findIndex(ps=>Number(ps==null?void 0:ps.docNumber)===p):-1,ys={id:((ct=(Pe=globalThis.crypto)==null?void 0:Pe.randomUUID)==null?void 0:ct.call(Pe))??`doc-${Date.now()}-${p}`,docNumber:p,name:Hc[p]||"Other",fileName:w.name,status:"Pending Verification",uploadedOn:new Date().toISOString(),uploadedBy:(n==null?void 0:n.name)||"Dealer"};Pt>=0?Nt[Pt]={...Nt[Pt],...ys}:Nt.push(ys),(tt=(await Ee.uploadConstitutionalDocuments(t,Nt)).data)!=null&&tt.success?(ee.success("Document uploaded successfully"),h(!1),u(null),v(null),await ie({silent:!0})):ee.error("Failed to upload document")}catch(Nt){console.error("Upload document error:",Nt),ee.error("Failed to upload document")}finally{_(!1)}},Ds=(Pe,ct)=>(Pe==null?void 0:Pe.id)!=null?String(Pe.id):String(ct),ln=async(Pe,ct)=>{var tt,Nt;try{const Mt=Ds(Pe,ct),Pt=await Ee.verifyConstitutionalDocument(t,Mt);(tt=Pt.data)!=null&&tt.success?(ee.success("Document verified successfully"),await ie({silent:!0}),R!=null&&R.id&&await J(R.id)):ee.error(((Nt=Pt.data)==null?void 0:Nt.message)||"Failed to verify document")}catch(Mt){console.error("Verify document error:",Mt),ee.error("Failed to verify document")}},Bs=async()=>{var ct,tt;if(F==null||!String(K).trim()){ee.error("Please enter a rejection reason.");return}const Pe=((R==null?void 0:R.documents)||[])[F];if(!Pe){ee.error("Document not found");return}try{X(!0);const Nt=Ds(Pe,F),Mt=await Ee.rejectConstitutionalDocument(t,Nt,{remarks:K.trim()});(ct=Mt.data)!=null&&ct.success?(ee.success("Document marked as rejected"),T(!1),B(null),W(""),await ie({silent:!0}),R!=null&&R.id&&await J(R.id)):ee.error(((tt=Mt.data)==null?void 0:tt.message)||"Failed to reject document")}catch(Nt){console.error("Reject document error:",Nt),ee.error("Failed to reject document")}finally{X(!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(se,{variant:"outline",onClick:s,className:"flex items-center gap-2",children:[e.jsx(Jr,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[R.requestId," - Constitutional Change Details"]}),e.jsxs("p",{className:"text-slate-600",children:[((Js=(Xs=R.dealer)==null?void 0:Xs.dealerProfile)==null?void 0:Js.businessName)||((Ws=R.outlet)==null?void 0:Ws.name)||"N/A"," (",((Ne=(oe=(Z=R.dealer)==null?void 0:Z.dealerProfile)==null?void 0:oe.dealerCode)==null?void 0:Ne.dealerCode)||((Oe=R.outlet)==null?void 0:Oe.code)||"N/A",")"]})]})]}),e.jsx(Ce,{className:ge,children:R.status}),e.jsx(kr,{status:$("constitutional",L)})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Request Overview"})}),e.jsxs(Fe,{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:((ye=(De=R.dealer)==null?void 0:De.dealerProfile)==null?void 0:ye.businessName)||((Ve=R.outlet)==null?void 0:Ve.name)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((Kt=(st=(Ge=R.dealer)==null?void 0:Ge.dealerProfile)==null?void 0:st.dealerCode)==null?void 0:Kt.dealerCode)||((Xt=R.outlet)==null?void 0:Xt.code)||"N/A"}),e.jsx("p",{className:"text-slate-600 text-sm",children:((ft=(ot=R.dealer)==null?void 0:ot.dealerProfile)==null?void 0:ft.registeredAddress)||((Es=R.outlet)==null?void 0:Es.city)||((ts=R.outlet)==null?void 0:ts.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(Ce,{className:PC(R.oldValue||R.currentConstitution||((vs=R.outlet)==null?void 0:vs.type)||"Proprietorship"),children:R.oldValue||R.currentConstitution||((Te=R.outlet)==null?void 0:Te.type)||"Proprietorship"}),e.jsx(Yo,{className:"w-4 h-4 text-slate-400"}),e.jsx(Ce,{className:PC(R.newValue||R.changeType),children:R.newValue||R.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: ",Gt(R.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",((je=R.dealer)==null?void 0:je.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(Ce,{className:eo(R.currentStage,R.status),children:R.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:R.description})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Establishment & Dealer Codes"})}),e.jsx(Fe,{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:((pt=(Ye=(nt=R.dealer)==null?void 0:nt.dealerProfile)==null?void 0:Ye.dealerCode)==null?void 0:pt.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:((ss=(Jt=(yt=R.dealer)==null?void 0:yt.dealerProfile)==null?void 0:Jt.dealerCode)==null?void 0:ss.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:((on=(Zs=(Ss=R.dealer)==null?void 0:Ss.dealerProfile)==null?void 0:Zs.dealerCode)==null?void 0:on.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:((cn=(tn=(en=R.dealer)==null?void 0:en.dealerProfile)==null?void 0:tn.dealerCode)==null?void 0:cn.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:(Ht=(Ae=R.dealer)==null?void 0:Ae.dealerProfile)!=null&&Ht.onboardedAt?Gt(R.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:vt?Gt(vt,"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:mt?Gt(mt,"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(Le,{children:e.jsxs($n,{value:y,onValueChange:C,className:"w-full",children:[e.jsx(Qe,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-6 px-6",children:e.jsxs(qn,{className:"w-max min-w-full justify-start",children:[e.jsx(zt,{value:"workflow",children:"Workflow Progress"}),e.jsx(zt,{value:"documents",children:"Documents"}),e.jsx(zt,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Fe,{children:[e.jsxs(qt,{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(Ce,{className:`${qe} text-white border-transparent hover:opacity-90`,children:[R.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 ${qe}`,style:{width:`${R.progressPercentage}%`}})})]}),ve&&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(R.status)}),". The approval path below is for reference only."]}),e.jsx("div",{className:"space-y-4",children:ve?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:_m.map(Pe=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:EC(Pe.name)})," — ",_C(Pe.role)]},Pe.id))}):_m.map((Pe,ct)=>{var dn;const tt=te||ct<bt-1,Nt=!te&&ct===bt-1,Mt=Be(Pe.name),Pt=(Mt==null?void 0:Mt.comments)||(Mt==null?void 0:Mt.feedback)||(Mt==null?void 0:Mt.remarks),ys=Pe.name==="ZM/RBM Review";let Yt=R.metadata||{};if(typeof Yt=="string")try{Yt=JSON.parse(Yt)}catch{Yt={}}const ps=((dn=Yt==null?void 0:Yt.jointApprovals)==null?void 0:dn.zmRbm)||{},ks=ps==null?void 0:ps.RBM,hs=ps==null?void 0:ps["DD-ZM"],gn=String((n==null?void 0:n.roleCode)||(n==null?void 0:n.role)||"").toUpperCase(),$s=gn==="RBM"?ks:gn==="DD-ZM"||gn==="DD ZM"||gn==="ZM"?hs: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 ${tt?"bg-green-100":Nt?Li.icon:"bg-slate-100"}`,children:tt?e.jsx(Hn,{className:"w-5 h-5 text-green-600"}):Nt?e.jsx(yn,{className:"w-5 h-5 text-re-red"}):e.jsx(an,{className:"w-5 h-5 text-slate-400"})}),ct<_m.length-1&&e.jsx("div",{className:`w-0.5 h-12 ${tt?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${Nt?Li.panel:""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:`${Nt?Li.title:"text-slate-900"}`,children:EC(Pe.name)}),e.jsx("p",{className:`text-sm ${Nt?Li.subtitle:"text-slate-600"}`,children:`Responsible: ${_C(Pe.role)}`})]}),e.jsx(Ce,{className:tt?"bg-green-100 text-green-700 border-green-300":Nt?Li.stageBadge:"bg-slate-100 text-slate-500 border-slate-300",children:tt?"Completed":Nt?"In Progress":"Pending"})]}),Mt&&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(Ce,{variant:"outline",className:"text-[11px] normal-case",children:["Last updated by: ",Mt.user||Mt.userName||"System"]}),e.jsx("span",{children:Gt(Mt.timestamp||Mt.createdAt)})]}),Pt&&e.jsx("div",{className:"p-2 rounded border border-slate-200 bg-slate-50 text-sm text-slate-700",children:Pt})]}),ys&&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(Ce,{className:ks!=null&&ks.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["RBM: ",ks!=null&&ks.approvedByUserId?"Approved":"Pending"]}),e.jsxs(Ce,{className:hs!=null&&hs.approvedByUserId?"bg-green-100 text-green-700 border-green-300":"bg-slate-100 text-slate-500 border-slate-300",children:["DD-ZM: ",hs!=null&&hs.approvedByUserId?"Approved":"Pending"]}),($s==null?void 0:$s.approvedByUserId)&&e.jsx(Ce,{className:"bg-red-50 text-re-red-hover border-red-200",children:"Approved by you"})]}),((ks==null?void 0:ks.remarks)||(hs==null?void 0:hs.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:(ks==null?void 0:ks.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:(hs==null?void 0:hs.remarks)||"-"})]})]})]})]})]},Pe.id)})})]}),e.jsx(qt,{value:"documents",className:"mt-0",children:e.jsxs($n,{value:S,onValueChange:D,className:"w-full",children:[e.jsxs(qn,{className:"w-full justify-start mb-4",children:[e.jsx(zt,{value:"required",children:"Required for Process"}),e.jsx(zt,{value:"existing",children:"Existing Documents"})]}),e.jsx(qt,{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(ls,{open:x,onOpenChange:Pe=>{h(Pe),Pe||(j(!1),v(null))},children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{j(!1),u(null),v(null)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Upload Document"}),e.jsx(bs,{children:N?"Pick a file for the selected document.":"Select the document type and upload the file."})]}),e.jsxs("div",{className:"space-y-4",children:[N&&p!=null?e.jsxs("div",{children:[e.jsx(de,{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(Ce,{className:"bg-re-red text-white border-transparent",children:Hc[p]||`Document ${p}`})})]}):e.jsxs("div",{children:[e.jsx(de,{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:p!=null?String(p):"",onChange:Pe=>{const ct=Pe.target.value;u(ct?Number(ct):null)},children:[e.jsx("option",{value:"",children:"Select document type"}),xe.map(Pe=>e.jsxs("option",{value:String(Pe),children:[Pe!==Wo&&Xe(Pe)?"✓ ":"",Hc[Pe]||`Document ${Pe}`]},Pe))]})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Upload File"}),e.jsx(at,{type:"file",className:"mt-1",onChange:Pe=>{var ct;return v(((ct=Pe.target.files)==null?void 0:ct[0])||null)}})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:Et,disabled:Q,children:Q?"Uploading...":"Upload"})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:we.map(Pe=>{const ct=ke(Pe),tt=ct&&String(ct.status)==="Rejected",Nt=ct&&!tt;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${tt?"bg-red-50 border-red-200":Nt?"bg-green-50 border-green-200":"bg-slate-50 border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[tt?e.jsx(an,{className:"w-5 h-5 text-red-600"}):Nt?e.jsx(Hn,{className:"w-5 h-5 text-green-600"}):e.jsx(an,{className:"w-5 h-5 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:tt?"text-red-900":Nt?"text-green-900":"text-slate-900",children:Hc[Pe]}),ct&&e.jsxs("p",{className:tt?"text-red-700 text-sm":Nt?"text-green-700 text-sm":"text-slate-600 text-sm",children:[ct.fileName||ct.name,tt&&(ct.rejectionReason||ct.rejectionRemarks)?` — ${ct.rejectionReason||ct.rejectionRemarks}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ct?e.jsx(Ce,{className:Iv(ct.status),children:ct.status}):e.jsx(Ce,{className:"bg-slate-100 text-slate-600 border-slate-300",children:"Not Uploaded"}),!Nt&&e.jsxs(se,{size:"sm",variant:"ghost",className:tK(!!tt),onClick:()=>{u(Pe),v(null),j(!0),h(!0)},children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1"}),tt?"Re-upload":"Upload"]})]})]},Pe)})})]})}),e.jsx(qt,{value:"existing",className:"mt-0",children:(R.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(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"File Name"}),e.jsx(fe,{children:"Uploaded On"}),e.jsx(fe,{children:"Uploaded By"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:(R.documents||[]).map((Pe,ct)=>{var tt;return e.jsxs(lt,{className:String(Pe.status)==="Rejected"?"bg-red-50/80":void 0,children:[e.jsx(ue,{className:"text-slate-900",children:Pe.docNumber?Hc[Pe.docNumber]:Pe.name}),e.jsx(ue,{className:"text-slate-600",children:Pe.fileName||Pe.name}),e.jsx(ue,{className:"text-slate-600",children:Gt(Pe.uploadedOn||Pe.createdAt)}),e.jsx(ue,{className:"text-slate-600",children:typeof Pe.uploadedBy=="string"?Pe.uploadedBy:((tt=Pe.uploadedBy)==null?void 0:tt.fullName)||"Dealer"}),e.jsx(ue,{children:e.jsx(Ce,{className:Iv(Pe.status),children:Pe.status})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{size:"sm",variant:"outline",className:"h-8 w-8 p-0",title:"View document",children:e.jsx(bn,{className:"w-4 h-4"})}),e.jsx(se,{size:"sm",variant:"outline",className:"h-8 w-8 p-0",title:"Download document",children:e.jsx(Ni,{className:"w-4 h-4"})}),Pe.status!=="Verified"&&Pe.status!=="Rejected"&&(()=>{const Nt=(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(Nt)})()&&e.jsxs(e.Fragment,{children:[e.jsx(se,{size:"sm",className:"bg-green-600 hover:bg-green-700",onClick:()=>ln(Pe,ct),children:"Verify"}),e.jsx(se,{size:"sm",variant:"outline",className:"border-red-300 text-red-700 hover:bg-red-50",onClick:()=>{B(ct),W(""),T(!0)},children:"Reject"})]})]})})]},ct)})})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(qt,{value:"history",className:"mt-0",children:e.jsxs("div",{className:"space-y-4",children:[ae.map((Pe,ct)=>{var sn;const tt=sK(Pe),Mt=(((sn=Pe.actor)==null?void 0:sn.name)||Pe.userName||"System").split("·").map(We=>We.trim()),Pt=[...new Set(Mt)].join(", "),ps=String(Pe.stage||Pe.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()||tt.badge||"Action",ks=String(Pe.remarks||"").trim(),hs=String(Pe.description||"").trim(),$s=[/^Approval\s*-\s*Stage:/i,/^Record (created|updated)/i,/^Document (uploaded|verified|rejected)/i].some(We=>We.test(hs)),dn=ks||($s?"":hs)||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 ${tt.variant==="success"?"bg-green-100":tt.variant==="danger"?"bg-red-100":tt.variant==="pending"?"bg-red-50":"bg-slate-100"}`,children:tt.variant==="success"?e.jsx(Hn,{className:"w-5 h-5 text-green-600"}):tt.variant==="danger"?e.jsx(an,{className:"w-5 h-5 text-red-600"}):tt.variant==="pending"?e.jsx(yn,{className:"w-5 h-5 text-re-red"}):e.jsx(yn,{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:ps}),e.jsxs("p",{className:"text-slate-500 text-sm",children:["by ",e.jsx("span",{className:"font-medium text-slate-700",children:Pt})]})]}),e.jsx(Ce,{className:Iv(tt.badge),children:tt.badge.replace(/_/g," ")})]}),dn&&e.jsx("div",{className:"mt-2 p-3 bg-slate-50 rounded border border-slate-100 text-slate-700 text-sm",children:dn}),e.jsx("p",{className:"text-slate-400 text-xs mt-2 font-medium uppercase tracking-wider",children:Gt(Pe.timestamp||Pe.createdAt)})]})]},Pe.id||ct)}),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(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Current Status"})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx(Ce,{className:eo(R.currentStage,R.status),children:R.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 ${qe}`,style:{width:`${R.progressPercentage??0}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[R.progressPercentage??0,"%"]})]})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[ht.canApprove&&e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>_e("approve"),disabled:q,children:[q&&o==="approve"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!ht.canApprove&&ht.hasCurrentUserApprovedZmRbm&&e.jsxs(se,{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"]}),ht.canReject&&e.jsxs(se,{variant:"destructive",className:"w-full",onClick:()=>_e("reject"),disabled:q,children:[q&&o==="reject"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(an,{className:"w-4 h-4 mr-2"}),"Reject proposal"]}),ht.canSendBack&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-900 hover:bg-red-50",onClick:()=>_e("sendBack"),disabled:q,children:[q&&o==="sendBack"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(lM,{className:"w-4 h-4 mr-2"}),"Send back"]}),ht.canRevoke&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-re-red-hover hover:bg-red-50",onClick:()=>_e("revoke"),disabled:q,children:[q&&o==="revoke"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(tb,{className:"w-4 h-4 mr-2"}),"Revoke request"]}),!ht.canApprove&&!ht.canReject&&!ht.canSendBack&&!ht.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:ht.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(se,{variant:"outline",className:"w-full border-re-red text-re-red hover:bg-red-50",onClick:()=>{var Pe;return r(`/worknotes/constitutional/${(R==null?void 0:R.id)||t}`,{state:{requestType:"constitutional",applicationName:((Pe=R==null?void 0:R.outlet)==null?void 0:Pe.name)||"Constitutional Change",registrationNumber:(R==null?void 0:R.requestId)||t||"",participants:(R==null?void 0:R.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"Worknotes (",((R==null?void 0:R.worknotes)||[]).length,")"]})})]})]})]})]}),e.jsx(ls,{open:a,onOpenChange:Pe=>{l(Pe),Pe||V(null)},children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:o==="approve"?"Approve request":o==="reject"?"Reject proposal":o==="sendBack"?"Send back to previous stage":"Revoke request"}),e.jsx(bs,{children:o==="sendBack"||o==="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:Vt,className:"space-y-4",children:[Y&&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(an,{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:Y}),/mandatory documents/i.test(Y)&&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(de,{htmlFor:"comments",children:o==="sendBack"||o==="revoke"?"Remarks (required) *":"Comments *"})}),e.jsx(Gs,{id:"comments",value:m,onChange:Pe=>f(Pe.target.value),placeholder:o==="sendBack"||o==="revoke"?"Enter mandatory remarks for Work Notes…":"Enter your comments…",rows:4,required:o!=="approve"}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:o==="approve"?"bg-green-600 hover:bg-green-700":"bg-re-red hover:bg-re-red-hover",disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}),"Processing..."]}):o==="approve"?"Approve":o==="reject"?"Reject":o==="sendBack"?"Send back":"Revoke"})]})]})]})}),e.jsx(ls,{open:z,onOpenChange:T,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Reject document"}),e.jsx(bs,{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(de,{htmlFor:"rejectReason",children:"Rejection reason *"}),e.jsx(Gs,{id:"rejectReason",rows:4,value:K,onChange:Pe=>W(Pe.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>T(!1),children:"Cancel"}),e.jsx(se,{type:"button",variant:"destructive",disabled:H,onClick:()=>void Bs(),children:H?e.jsx(es,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})})]})}const rK=(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},Mv=(t,s)=>eo(t,s);function aK({currentUser:t,onViewDetails:s}){const[n,r]=g.useState([]),[a,l]=g.useState(!0),[o,d]=g.useState(1),[m,f]=g.useState(null),[x,h]=g.useState("all"),p=10,[u,w]=g.useState(!1),[v,N]=g.useState([]),[j,y]=g.useState(null),[C,S]=g.useState(""),[D,R]=g.useState(""),[A,L]=g.useState(""),[$,P]=g.useState(""),[E,O]=g.useState(""),[I,q]=g.useState(""),[G,Y]=g.useState(""),[V,Q]=g.useState(""),[_,z]=g.useState(""),[T,F]=g.useState(!1),[B,K]=g.useState([]),[W,H]=g.useState([]),[X,J]=g.useState(""),[ie,ae]=g.useState(""),[xe,ce]=g.useState(!1),we=(t==null?void 0:t.role)==="Super Admin"||(t==null?void 0:t.roleCode)==="Super Admin",ke=n.map(he=>({entityType:"relocation",entityId:he.id||he.requestId})),{get:Xe}=xc(ke,n.length>0),Ot=he=>he.status==="Completed"||he.status==="Closed"||he.currentStage==="Completed",bt=he=>he.status==="Rejected"||he.status==="Revoked"||he.currentStage==="Rejected",te=he=>!Ot(he)&&!bt(he)&&String(he.status||"").startsWith("Pending");g.useEffect(()=>{Tt()},[o,x]),g.useEffect(()=>{we&&(qe(),ge())},[we]);const ve=he=>{h(he),d(1)},qe=async()=>{var he;try{const vt=await Ee.getOutlets();vt.data.success&&N(vt.data.outlets||((he=vt.data.data)==null?void 0:he.outlets)||vt.data.data||[])}catch(vt){console.error("Fetch outlets error:",vt)}},ge=async()=>{var he,vt,mt,_e;try{ce(!0);const[Vt,Et]=await Promise.all([Ee.getStates().catch(()=>({success:!1})),Ee.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),Ds=(he=Vt==null?void 0:Vt.data)!=null&&he.success?((vt=Vt.data.data)==null?void 0:vt.states)||Vt.data.data||[]:[],ln=(mt=Et==null?void 0:Et.data)!=null&&mt.success?((_e=Et.data.data)==null?void 0:_e.districts)||Et.data.data||[]:[];K(Ds),H(ln)}catch(Vt){console.error("Fetch master data error:",Vt)}finally{ce(!1)}},Be=he=>{J(he),ae("");const vt=B.find(mt=>mt.id===he);vt&&R(vt.name)},ut=he=>{ae(he);const vt=W.find(mt=>mt.id===he);vt&&S(vt.name)},ht=async he=>{if(he.preventDefault(),!j||!C||!D||!A||!$||!E||!I||!G){ee.error("Please fill all mandatory fields");return}try{F(!0);const vt={outletId:j.id,relocationType:"Intercity",currentAddress:j.address||"",currentCity:j.city||"",currentState:j.state||"",newAddress:A,newCity:C,newState:D,newDistrictId:ie||null,newStateId:X||null,reason:$,distance:E,propertyType:I,proposedDate:G,newLatitude:V?parseFloat(V):null,newLongitude:_?parseFloat(_):null,currentLatitude:j.latitude||null,currentLongitude:j.longitude||null};(await Ee.createRelocationRequest(vt)).data.success&&(ee.success(`Relocation request submitted successfully for ${j.name}`),w(!1),Tt(),y(null),S(""),R(""),L(""),P(""),O(""),q(""),Y(""),Q(""),z(""))}catch(vt){console.error("Submit relocation error:",vt),ee.error(rK(vt,"Failed to submit relocation request"))}finally{F(!1)}},it=X?W.filter(he=>he.stateId===X):W,Tt=async()=>{try{l(!0);const he=await Ee.getRelocationRequests({page:o,limit:p,status:x==="all"?void 0:x});he.data.success&&(r(he.data.requests),f(he.meta))}catch(he){console.error("Fetch relocation requests error:",he),ee.error("Failed to fetch relocation requests")}finally{l(!1)}},It=[{title:"Total Requests",value:n.length,icon:Ns,color:"bg-blue-500"},{title:"Pending Review",value:n.filter(he=>te(he)).length,icon:dr,color:"bg-re-red"},{title:"Completed",value:n.filter(he=>Ot(he)).length,icon:Vr,color:"bg-green-500"},{title:"Rejected / Revoked",value:n.filter(he=>bt(he)).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."})]}),we&&e.jsxs(ls,{open:u,onOpenChange:w,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Submit Relocation Request"}),e.jsx(bs,{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(de,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(At,{value:j==null?void 0:j.id,onValueChange:he=>y(v.find(vt=>vt.id===he)),required:!0,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select an outlet"})}),e.jsx(Rt,{children:v.map(he=>e.jsxs(Me,{value:he.id,children:[he.name," (",he.code,")"]},he.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(de,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(At,{value:X,onValueChange:Be,required:!0,disabled:xe,children:[e.jsx(Dt,{id:"newState",children:e.jsx(kt,{placeholder:xe?"Loading...":"Select state"})}),e.jsx(Rt,{children:B.map(he=>e.jsx(Me,{value:he.id,children:he.name},he.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(At,{value:ie,onValueChange:ut,required:!0,disabled:!X||xe,children:[e.jsx(Dt,{id:"newCity",children:e.jsx(kt,{placeholder:X?xe?"Loading...":"Select district":"Select state first"})}),e.jsx(Rt,{children:it.map(he=>e.jsx(Me,{value:he.id,children:he.name},he.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Gs,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:A,onChange:he=>L(he.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(at,{id:"distance",type:"text",placeholder:"e.g. 5.5 km",value:E,onChange:he=>O(he.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(de,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(At,{value:I,onValueChange:q,required:!0,children:[e.jsx(Dt,{id:"propertyType",children:e.jsx(kt,{placeholder:"Select type"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Owned",children:"Owned"}),e.jsx(Me,{value:"Leased",children:"Leased"}),e.jsx(Me,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(at,{id:"expectedDate",type:"date",value:G,onChange:he=>Y(he.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Gs,{id:"reason",placeholder:"Why is this relocation requested?",value:$,onChange:he=>P(he.target.value),rows:4,required:!0})]}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-re-red hover:bg-re-red-hover text-white",disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(es,{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:It.map((he,vt)=>{const mt=he.icon;return e.jsx(Le,{children:e.jsx(Fe,{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:he.title}),e.jsx("p",{className:"text-slate-900 text-2xl mt-1",children:he.value})]}),e.jsx("div",{className:`${he.color} w-12 h-12 rounded-lg flex items-center justify-center`,children:e.jsx(mt,{className:"w-6 h-6 text-white"})})]})})},vt)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Relocation Requests"}),e.jsx(Qt,{children:"Track and manage all dealership relocation requests across all stages"})]}),e.jsxs(Fe,{children:[e.jsxs($n,{value:x,onValueChange:ve,className:"w-full",children:[e.jsxs(qn,{className:"grid w-full grid-cols-4",children:[e.jsx(zt,{value:"all",children:"All Requests"}),e.jsx(zt,{value:"pending",children:"Pending Review"}),e.jsx(zt,{value:"rejected",children:"Rejected / Revoked"}),e.jsx(zt,{value:"completed",children:"Completed"})]}),e.jsx(qt,{value:"all",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Distance"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:a?e.jsx(lt,{children:e.jsx(ue,{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(es,{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(ue,{colSpan:8,className:"h-32 text-center text-slate-500",children:"No relocation requests found"})}):n.map(he=>{var vt,mt,_e;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((vt=he.outlet)==null?void 0:vt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((mt=he.outlet)==null?void 0:mt.name)||he.dealerName})}),e.jsx(ue,{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:he.currentLocation})]}),e.jsxs("div",{className:"flex items-center gap-1 text-slate-900 text-sm",children:[e.jsx(pk,{className:"w-3 h-3 text-re-red"}),e.jsx("span",{className:"text-slate-500",children:"To:"}),e.jsx("span",{children:he.proposedLocation})]})]})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"border-slate-300 text-slate-700",children:he.distance})}),e.jsxs(ue,{children:[e.jsx(kr,{status:Xe("relocation",he.id||he.requestId),compact:!0}),e.jsx(Ce,{className:Mv(he.currentStage,he.status),children:he.currentStage})]}),e.jsx(ue,{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 ${vi(he.status,he.currentStage)}`,style:{width:`${he.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[he.progressPercentage||0,"%"]})]})}),e.jsxs(ue,{children:[e.jsx("div",{className:"text-slate-900",children:Gt(he.createdAt)}),e.jsxs("div",{className:"text-slate-600 text-sm",children:["By ",((_e=he.dealer)==null?void 0:_e.fullName)||"Dealer"]})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})}),e.jsx(qt,{value:"pending",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:a?e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"h-32 text-center",children:e.jsx(es,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(he=>te(he)).map(he=>{var vt,mt;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((vt=he.outlet)==null?void 0:vt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((mt=he.outlet)==null?void 0:mt.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",he.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",he.proposedLocation]})]})}),e.jsxs(ue,{children:[e.jsx(kr,{status:Xe("relocation",he.id||he.requestId),compact:!0}),e.jsx(Ce,{className:Mv(he.currentStage,he.status),children:he.currentStage})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})}),e.jsx(qt,{value:"in-progress",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Current Stage"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:a?e.jsx(lt,{children:e.jsx(ue,{colSpan:6,className:"h-32 text-center",children:e.jsx(es,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(he=>bt(he)).map(he=>{var vt,mt;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((vt=he.outlet)==null?void 0:vt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((mt=he.outlet)==null?void 0:mt.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",he.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",he.proposedLocation]})]})}),e.jsx(ue,{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 ${vi(he.status,he.currentStage)}`,style:{width:`${he.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-slate-600 text-sm",children:[he.progressPercentage||0,"%"]})]})}),e.jsxs(ue,{children:[e.jsx(kr,{status:Xe("relocation",he.id||he.requestId),compact:!0}),e.jsx(Ce,{className:Mv(he.currentStage,he.status),children:he.currentStage})]}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})}),e.jsx(qt,{value:"completed",className:"mt-4",children:e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Dealer Details"}),e.jsx(fe,{children:"Relocation Details"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:a?e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"h-32 text-center",children:e.jsx(es,{className:"w-6 h-6 text-re-red animate-spin mx-auto"})})}):n.filter(he=>Ot(he)).map(he=>{var vt,mt;return e.jsxs(lt,{children:[e.jsxs(ue,{children:[e.jsx("div",{className:"font-medium text-slate-900",children:he.requestId||he.id}),e.jsx("div",{className:"text-slate-600 text-sm",children:((vt=he.outlet)==null?void 0:vt.code)||he.dealerCode})]}),e.jsx(ue,{children:e.jsx("div",{className:"font-medium text-slate-900",children:((mt=he.outlet)==null?void 0:mt.name)||he.dealerName})}),e.jsx(ue,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-slate-600 text-sm",children:["From: ",he.currentLocation]}),e.jsxs("div",{className:"text-slate-900 text-sm",children:["To: ",he.proposedLocation]})]})}),e.jsx(ue,{children:e.jsx("div",{className:"text-slate-900",children:Gt(he.createdAt)})}),e.jsx(ue,{children:e.jsxs(se,{size:"sm",variant:"outline",onClick:()=>s(he.id),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},he.id)})})]})})})]}),m&&m.totalPages>1&&e.jsx("div",{className:"py-4 border-t flex justify-center bg-white rounded-b-lg",children:e.jsx(fo,{children:e.jsxs(po,{children:[e.jsx(Sn,{children:e.jsx(xo,{onClick:()=>d(he=>Math.max(1,he-1)),className:o===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(m.totalPages)].map((he,vt)=>{const mt=vt+1;return mt===1||mt===m.totalPages||mt>=o-1&&mt<=o+1?e.jsx(Sn,{children:e.jsx(Wi,{isActive:o===mt,onClick:()=>d(mt),className:"cursor-pointer",children:mt})},mt):mt===2&&o>3||mt===m.totalPages-1&&o<m.totalPages-2?e.jsx(Sn,{children:e.jsx(vo,{})},mt):null}),e.jsx(Sn,{children:e.jsx(go,{onClick:()=>d(he=>Math.min(m.totalPages,he+1)),className:o===m.totalPages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]})}const Sa=[{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 Ly(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 Sa.length+1;const r=s.match(/^pending\s+(.+)$/i),a=(r?r[1]:s).trim();let l=Sa.findIndex(o=>o.name===a||o.name===s||o.key===a||o.key===s);return l<0&&(l=Sa.findIndex(o=>a.toLowerCase().includes(o.name.toLowerCase())||o.name.toLowerCase().includes(a.toLowerCase()))),l>=0?l+1:0}function iK(t){const s=String(t||"").toLowerCase();return!!(s.includes("sent back")||s.includes("send")&&s.includes("back"))}function lK(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 rT(t,s){if(lK(s))return t;const n=String((s==null?void 0:s.action)||"");if(iK(n)){const a=Ly(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 l=Ly(String(a));l>r&&(r=l)}return r}function oK(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=rT(n,r);return n}function cK(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 l=(r==null?void 0:r.details)||(r==null?void 0:r.newData)||{},o=[a,l==null?void 0:l.action,String((l==null?void 0:l.type)||"")].filter(Boolean).join(" ");n=rT(n,{action:o,stage:(l==null?void 0:l.stage)!==void 0?String(l.stage):(r==null?void 0:r.stage)!==void 0?String(r.stage):void 0,targetStage:(l==null?void 0:l.targetStage)!==void 0?String(l.targetStage):void 0})}return n}function dK(t,s,n){const a=(Array.isArray(t)?[...t]:[]).filter(l=>{const o=String((l==null?void 0:l.stage)||"").trim();return o===s.name||o===s.key||n===0&&(o==="Submitted"||o==="Request submitted")});return a.sort((l,o)=>{const d=new Date((l==null?void 0:l.timestamp)||(l==null?void 0:l.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"],LC=t=>HE(t),uK=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",Vo=(t,s)=>{var r,a,l;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=((l=n.readiness)==null?void 0:l.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 hK({requestId:t,onBack:s,currentUser:n}){var Ve,Ge,st,Kt,Xt,ot,ft,Es,ts,vs;const r=tr(),[a,l]=g.useState(null),o=(a==null?void 0:a.id)||"",{get:d}=xc(o?[{entityType:"relocation",entityId:o}]:[],!!o),[m,f]=g.useState([]),[x,h]=g.useState(!0),[p,u]=g.useState(!1),[w,v]=g.useState(!1),[N,j]=g.useState("approve"),[y,C]=g.useState(""),[S,D]=g.useState(!1),[R,A]=g.useState(null),[L,$]=g.useState(!1),[P,E]=g.useState(!1),[O,I]=g.useState(null),[q,G]=g.useState(Wc[0]),[Y,V]=g.useState(!1),[Q,_]=g.useState(!1),[z,T]=g.useState("workflow"),[F,B]=g.useState(!1),[K,W]=g.useState(null),[H,X]=g.useState(!1),[J,ie]=g.useState(null),[ae,xe]=g.useState(""),[ce,we]=g.useState(!1);g.useEffect(()=>{te(),ke()},[t]);const ke=async()=>{try{const Te=await Ee.getAuditLogs("relocation",t);Te.data&&Te.data.success&&f(Te.data.data||[])}catch(Te){console.error("Error fetching audit logs:",Te)}},Xe=async Te=>{try{$(!0);const je=Te||(a==null?void 0:a.id)||t,nt=await Ee.getEorChecklistForRelocation(je);nt.data.success&&A(nt.data.data)}catch(je){console.error("Fetch EOR checklist error:",je)}finally{$(!1)}},Ot=async(Te,je,nt)=>{if(R)try{(await Ee.updateEorChecklistItem(R.id,{description:Te,isCompliant:je,itemType:nt,remarks:""})).data.success&&Xe()}catch(Ye){console.error("Update EOR item error:",Ye),ee.error(Vo(Ye,"Failed to update item"))}},bt=async()=>{if(R)try{E(!0),(await Ee.submitEorAudit(R.id,{status:"Completed",overallComments:"Relocation EOR Audit Completed"})).data.success&&(ee.success("EOR Audit submitted successfully"),te(),Xe())}catch(Te){console.error("Submit EOR audit error:",Te),ee.error(Vo(Te,"Failed to submit EOR audit"))}finally{E(!1)}},te=async(Te=!1)=>{try{Te||h(!0);const je=await Ee.getRelocationRequestById(t);if(je.data.success){const nt=je.data.request;l(nt)}}catch(je){console.error("Fetch relocation request details error:",je),ee.error(Vo(je,"Failed to fetch request details"))}finally{h(!1)}},ve=()=>{if(!a)return 1;if(a.status==="Completed"||a.currentStage==="Completed")return Sa.length+1;if(a.status==="Rejected"||a.status==="Revoked"||a.status==="Withdrawn"){const Ye=[...a.timeline||[]].filter(Boolean).reverse();for(const pt of Ye){const yt=String(pt.stage||"").trim(),Jt=String(pt.targetStage||"").trim(),ss=Sa.findIndex(Ss=>Ss.name===yt||Ss.key===Jt||Ss.key===yt||Ss.name===Jt);if(ss>=0)return ss+1}return 1}const Te=a.currentStage,je=Sa.findIndex(Ye=>Ye.name===Te||Ye.key===Te||Ye.name.replace(/\s+/g," ")===String(Te||"").replace(/\s+/g," "));if(je>=0)return je+1;const nt=Ly(String(a.status||""));return nt>0?nt:1},qe=Array.isArray(a==null?void 0:a.timeline)?a.timeline:[],ge=oK(qe),Be=cK(m),ut=a?ve():1,ht=!!a&&Math.max(ge,Be)>ut&&(qe.length>0||m.length>0),it=a?Sa[Math.min(Math.max(ut,1),Sa.length)-1]:void 0,Tt=(a==null?void 0:a.status)==="Completed"||(a==null?void 0:a.currentStage)==="Completed"||ut>=Sa.length+1,It=Tt?100:Math.min(100,Math.round(ut/Sa.length*100)),he=Tt?100:It,vt=a?Ad(a.status,a.currentStage):!1,mt=a?vi(a.status,a.currentStage):"bg-status-progress",_e=a?Jb(a.status,a.currentStage):"bg-re-red hover:bg-re-red-hover text-white border-transparent",Vt=a?Wc.filter(Te=>{var je;return!((je=a.documents)!=null&&je.some(nt=>nt.type===Te||nt.name&&nt.name.toLowerCase().includes(Te.toLowerCase().split(" ")[0])))}):[],Et=a?Wc.filter(Te=>{var nt;const je=((nt=a.documents)==null?void 0:nt.filter(Ye=>Ye.type===Te||Ye.name&&Ye.name.toLowerCase().includes(Te.toLowerCase().split(" ")[0])))||[];return je.length>0&&!je.some(Ye=>Ye.status==="Verified")}):[],Ds=Te=>{var nt,Ye,pt;if(!a||!a.participants||a.participants.length===0)return null;const je=a.participants.find(yt=>{var Jt,ss;return((Jt=yt.metadata)==null?void 0:Jt.stage)===Te||((ss=yt.metadata)==null?void 0:ss.stage)===Te.toUpperCase().replace(/ /g,"_")});return je&&(((nt=je.user)==null?void 0:nt.fullName)||((Ye=je.user)==null?void 0:Ye.name)||((pt=je.user)==null?void 0:pt.role))||null},Bs=(!a||!n?!1:(n==null?void 0:n.role)==="Super Admin"||n.role==="Super Admin"?!0:!!(it!=null&&it.role&&n.role===it.role))&&a.status!=="Completed"&&a.status!=="Rejected"&&a.status!=="Revoked",Ys=Bs&&a.currentStage&&a.currentStage!=="ASM Review"&&a.currentStage!=="Rejected",Xs=Bs&&["ZBH","DD Lead","NBH","Legal Admin","Super Admin"].includes((n==null?void 0:n.role)||""),Js=(a==null?void 0:a.currentStage)==="NBH Approval"||(a==null?void 0:a.currentStage)==="Legal Clearance",Ws=Bs&&(!Js||Vt.length===0&&Et.length===0),Z=Te=>{j(Te),v(!0)},oe=async Te=>{Te.preventDefault();const je=String(y||"").trim();if((N==="sendBack"||N==="revoke")&&je.length<5){ee.error(`Remarks are required for ${N==="sendBack"?"Send Back":"Revoke"} (minimum 5 characters).`);return}try{u(!0);const yt={approve:"approve",reject:"reject",hold:"hold",sendBack:"sendBack",revoke:"revoke"}[N]||"approve";if((await Ee.updateRelocationRequest(t,yt,{remarks:je})).data.success){const ss=N==="sendBack"?"sent back":N==="revoke"?"revoked":`${N}ed`;ee.success(`Request ${ss} successfully`),v(!1),C(""),te(),ke(),N==="approve"&&(it==null?void 0:it.key)==="LEGAL_CLEARANCE"&&(a!=null&&a.id)&&Xe(a.id)}}catch(pt){console.error("Submit action error:",pt),ee.error(Vo(pt,"Failed to submit action"))}finally{u(!1)}},Ne=async()=>{if(!O||!q){ee.error("Please select both a document type and a file");return}try{_(!0);const Te=new FormData;Te.append("file",O),Te.append("documentType",q),Te.append("stage",a.currentStage),(await Ee.uploadRelocationDocument(t,Te)).data.success&&(ee.success("Document uploaded successfully"),D(!1),I(null),te(!0),ke())}catch(Te){console.error("Upload document error:",Te),ee.error(Vo(Te,"Failed to upload document"))}finally{_(!1)}},Oe=async Te=>{try{(await Ee.verifyRelocationDocument(t,Te)).data.success&&(ee.success("Document verified successfully"),te(!0),ke())}catch(je){console.error("Verify document error:",je),ee.error(Vo(je,"Failed to verify document"))}},De=async()=>{var Te,je;if(!J||!String(ae).trim()){ee.error("Please enter a rejection reason.");return}try{we(!0);const nt=await Ee.rejectRelocationDocument(t,J,{remarks:ae.trim()});(Te=nt.data)!=null&&Te.success?(ee.success("Document rejected successfully"),X(!1),ie(null),xe(""),te(!0),ke()):ee.error(((je=nt.data)==null?void 0:je.message)||"Failed to reject document")}catch(nt){console.error("Reject document error:",nt),ee.error(Vo(nt,"Failed to reject document"))}finally{we(!1)}},ye=Te=>{W({fileName:Te.name,filePath:Te.url,documentType:Te.type,createdAt:Te.uploadedOn,mimeType:Te.mimeType}),B(!0)};return x?e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[e.jsx(es,{className:"w-10 h-10 text-re-red animate-spin"}),e.jsx("p",{className:"text-slate-500 font-medium",children:"Loading request details..."})]}):a?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(se,{variant:"outline",onClick:s,className:"flex items-center gap-2",children:[e.jsx(Jr,{className:"w-4 h-4"}),"Back"]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-slate-900",children:[a.requestId," - Relocation Request Details"]}),e.jsxs("p",{className:"text-slate-600",children:[(Ve=a.outlet)==null?void 0:Ve.name," (",(Ge=a.outlet)==null?void 0:Ge.code,")"]}),e.jsx("div",{className:"mt-1",children:e.jsx(kr,{status:d("relocation",o)})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(se,{variant:"outline",className:"relative hover:bg-red-50 hover:border-red-300 hover:text-re-red-hover transition-all shadow-sm",onClick:()=>{var Te;return r(`/worknotes/relocation/${t}`,{state:{applicationName:((Te=a==null?void 0:a.outlet)==null?void 0:Te.name)||"Relocation",registrationNumber:(a==null?void 0:a.requestId)||"",participants:(a==null?void 0:a.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"View Work Notes",((st=a==null?void 0:a.worknotes)==null?void 0:st.length)>0&&e.jsx(Ce,{className:"ml-2 bg-re-red hover:bg-re-red-hover text-white h-5 px-2",children:a.worknotes.length})]}),e.jsx(Ce,{className:_e,children:a.status})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Relocation Overview"})}),e.jsxs(Fe,{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:(Kt=a.outlet)==null?void 0:Kt.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:(Xt=a.outlet)==null?void 0:Xt.code}),e.jsx("p",{className:"text-slate-600 text-xs mt-1",children:(ot=a.dealer)==null?void 0:ot.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(Vr,{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:a.currentLocation||(a.outlet?`${a.outlet.address}, ${a.outlet.city}`:"N/A")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pk,{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:a.proposedLocation||`${a.newAddress}, ${a.newCity}`})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Ce,{variant:"outline",className:"border-slate-300 text-slate-700",children:["Type: ",a.relocationType]}),a.distance&&e.jsxs(Ce,{variant:"outline",className:"border-red-200 bg-red-50 text-re-red-hover",children:["Distance: ",a.distance]}),a.propertyType&&e.jsxs(Ce,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700",children:["Property: ",a.propertyType]}),a.expectedRelocationDate&&e.jsxs(Ce,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:["Expected Date: ",a.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: ",Gt(a.createdAt)]}),e.jsxs("p",{className:"text-slate-600 text-sm",children:["By: ",(ft=a.dealer)==null?void 0:ft.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(Ce,{className:eo(a.currentStage,a.status),children:String(a.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:a.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(Le,{children:e.jsxs($n,{value:z,onValueChange:T,className:"w-full",children:[e.jsx(Qe,{className:"pb-4",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar-x-slim -mx-6 px-6",children:e.jsxs(qn,{className:"w-max min-w-full justify-start",children:[e.jsx(zt,{value:"workflow",children:"Workflow Progress"}),e.jsx(zt,{value:"documents",children:"Documents"}),e.jsx(zt,{value:"history",children:"History & Audit Trail"})]})})}),e.jsxs(Fe,{children:[e.jsxs(qt,{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(Ce,{className:`${mt} text-white border-transparent hover:opacity-90`,children:[he,"% 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 ${mt}`,style:{width:`${he}%`}})})]}),vt&&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(a.status)}),". The approval path below is for reference only."]}),ht&&!vt&&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(a.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(Qt,{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:vt?e.jsx("ul",{className:"list-disc space-y-1 pl-5 text-sm text-slate-600",children:Sa.map(Te=>e.jsxs("li",{children:[e.jsx("span",{className:"text-slate-900",children:Te.name})," — ",Te.role]},Te.id))}):Sa.map((Te,je)=>{const nt=Tt||je<ut-1,Ye=!Tt&&je===ut-1,pt=dK(qe,Te,je),yt=pt.length>0?pt[pt.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 ${nt?"bg-green-100 text-green-600":Ye?Li.icon:"bg-slate-100 text-slate-400"}`,children:nt?e.jsx(Hn,{className:"w-5 h-5"}):Ye?e.jsx(yn,{className:"w-5 h-5"}):e.jsx("span",{className:"text-xs font-semibold",children:Te.id})}),je<Sa.length-1&&e.jsx("div",{className:`w-0.5 h-16 ${nt?"bg-green-300":"bg-slate-200"}`})]}),e.jsxs("div",{className:`flex-1 pb-8 ${Ye?Li.panel:""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 gap-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:nt?"text-green-700":Ye?Li.title:"text-slate-900",children:Te.name}),e.jsxs("p",{className:`text-sm ${Ye?Li.subtitle:"text-slate-600"}`,children:["Responsible: ",Te.role]}),Ds(Te.name)&&e.jsxs("p",{className:"text-xs text-blue-600 font-medium mt-1",children:["Assigned: ",Ds(Te.name)]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(Ce,{className:nt?"bg-green-100 text-green-700 border-green-300":Ye?Li.stageBadge:"bg-slate-100 text-slate-500 border-slate-300",children:nt?"Completed":Ye?"In Progress":"Pending"}),yt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[e.jsx(dr,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:Gt(yt.timestamp||yt.createdAt)})]})]})]}),yt&&e.jsxs("div",{className:"space-y-2 mt-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"bg-slate-100 text-[10px] font-bold uppercase",children:yt.user||"System"}),e.jsx("span",{className:"text-[10px] text-slate-500 italic",children:yt.action||"Update"}),yt.targetStage&&yt.targetStage!==yt.stage&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["→ ",String(yt.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:yt.remarks||yt.comments||"No remarks provided."}),pt.length>1&&e.jsxs("p",{className:"text-[10px] text-slate-500",children:[pt.length," events at this stage; showing the latest."]})]})]})]},Te.id)})})]}),e.jsx(qt,{value:"documents",className:"mt-0",children:e.jsxs($n,{defaultValue:"required",className:"w-full",children:[e.jsxs(qn,{className:"w-full justify-start mb-4",children:[e.jsx(zt,{value:"required",children:"Required for Process"}),e.jsx(zt,{value:"existing",children:"Existing Documents"})]}),e.jsx(qt,{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(ls,{open:S,onOpenChange:Te=>{D(Te),Te||(V(!1),I(null))},children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{size:"sm",className:"bg-re-red hover:bg-re-red-hover",onClick:()=>{V(!1),G(Wc[0]),I(null)},children:[e.jsx(or,{className:"w-4 h-4 mr-2"}),"Upload Document"]})}),e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Upload Document"}),e.jsx(bs,{children:Y?"Pick a file for the selected document.":"Select the document type and upload the file."})]}),e.jsxs("div",{className:"space-y-4",children:[Y?e.jsxs("div",{children:[e.jsx(de,{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(Ce,{className:"bg-re-red text-white border-transparent",children:q})})]}):e.jsxs("div",{children:[e.jsx(de,{children:"Document Type"}),e.jsx("select",{className:"w-full mt-1 px-3 py-2 border border-slate-300 rounded-md",value:q,onChange:Te=>G(Te.target.value),children:Wc.map((Te,je)=>{var Ye;const nt=(Ye=a.documents)==null?void 0:Ye.some(pt=>pt.type===Te||pt.name.toLowerCase().includes(Te.toLowerCase().split(" ")[0]));return e.jsx("option",{value:Te,children:nt?`✅ ${Te}`:Te},je)})})]}),e.jsxs("div",{children:[e.jsx(de,{children:"Upload File"}),e.jsx(at,{type:"file",className:"mt-1",onChange:Te=>{var je;return I(((je=Te.target.files)==null?void 0:je[0])||null)}})]})]}),e.jsxs(xn,{children:[e.jsx(se,{variant:"outline",onClick:()=>D(!1),disabled:Q,children:"Cancel"}),e.jsx(se,{className:"bg-re-red hover:bg-re-red-hover",onClick:Ne,disabled:Q,children:Q?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):"Upload"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Wc.map((Te,je)=>{var yt;const nt=(yt=a.documents)==null?void 0:yt.find(Jt=>Jt.type===Te||Jt.name.toLowerCase().includes(Te.toLowerCase().split(" ")[0])),Ye=nt&&String(nt.status)==="Rejected",pt=nt&&!Ye;return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2 rounded border text-sm ${Ye?"bg-red-50 border-red-200":pt?"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:[Ye?e.jsx(an,{className:"w-4 h-4 text-red-600 flex-shrink-0"}):pt?e.jsx(Hn,{className:"w-4 h-4 text-green-600 flex-shrink-0"}):e.jsx(an,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:`truncate ${Ye?"text-red-900":pt?"text-green-900":"text-slate-700"}`,children:Te})]}),!pt&&e.jsxs(se,{size:"sm",variant:"ghost",className:uK(!!Ye),onClick:()=>{G(Te),I(null),V(!0),D(!0)},children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1"}),Ye?"Re-upload":"Upload"]})]},je)})})]})}),e.jsx(qt,{value:"existing",className:"mt-0",children:a.documents&&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(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{children:"Document Name"}),e.jsx(fe,{children:"Category"}),e.jsx(fe,{children:"Uploaded On"}),e.jsx(fe,{children:"Uploaded By"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:a.documents.map(Te=>e.jsxs(lt,{className:String(Te.status)==="Rejected"?"bg-red-50/80":void 0,children:[e.jsx(ue,{className:"text-slate-900",children:Te.name}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",className:"border-slate-300",children:Te.category||"General"})}),e.jsx(ue,{className:"text-slate-600",children:Gt(Te.uploadedOn)}),e.jsx(ue,{className:"text-slate-600",children:Te.uploadedBy}),e.jsx(ue,{children:e.jsx(Ce,{className:LC(Te.status),children:Te.status})}),e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Te.url&&ye(Te),disabled:!Te.url,title:Te.url?"View Document":"File path not available",children:e.jsx(bn,{className:"w-4 h-4"})}),e.jsx(se,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>Te.url&&window.open(`http://localhost:5000/${Te.url}`,"_blank"),disabled:!Te.url,title:Te.url?"Download Document":"File path not available",children:e.jsx(Ni,{className:"w-4 h-4"})}),Te.status==="Pending Verification"&&(()=>{const je=(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(je)})()&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{size:"sm",className:"h-8 bg-green-600 hover:bg-green-700 text-white gap-1",onClick:()=>Oe(Te.id),title:"Verify Document",children:[e.jsx(Hn,{className:"w-4 h-4"}),"Verify"]}),e.jsxs(se,{size:"sm",variant:"destructive",className:"h-8 gap-1",onClick:()=>{ie(Te.id),xe(""),X(!0)},title:"Reject Document",children:[e.jsx(an,{className:"w-4 h-4"}),"Reject"]})]})]})})]},Te.id))})]})})]}):e.jsx("div",{className:"text-center py-8 text-slate-500",children:"No documents uploaded yet"})})]})}),e.jsx(qt,{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)."})]}),R&&e.jsx(Ce,{className:LC(R.status),children:R.status})]}),R?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{className:"bg-slate-50",children:[e.jsx(fe,{className:"w-[50px]"}),e.jsx(fe,{children:"Category"}),e.jsx(fe,{children:"Checklist Item"}),e.jsx(fe,{children:"Proof & Documents"})]})}),e.jsx(Ls,{children:!R.items||R.items.length===0?e.jsx(lt,{children:e.jsx(ue,{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.'})}):R.items.map(Te=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsx("input",{type:"checkbox",checked:Te.isCompliant,onChange:je=>Ot(Te.description,je.target.checked,Te.itemType),disabled:R.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(ue,{children:e.jsx(Ce,{variant:"outline",className:"border-slate-300 capitalize text-xs",children:Te.itemType})}),e.jsx(ue,{className:"text-slate-900 font-medium text-sm",children:Te.description}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-col items-start gap-1",children:Te.proofDocumentId&&Te.proofDocument?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-slate-600 truncate max-w-[220px]",title:Te.proofDocument.fileName,children:Te.proofDocument.fileName}),e.jsxs(se,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-blue-600 px-0",onClick:()=>ye({name:Te.proofDocument.fileName,url:Te.proofDocument.filePath,type:Te.proofDocument.documentType,uploadedOn:Te.proofDocument.updatedAt||Te.proofDocument.createdAt,mimeType:Te.proofDocument.mimeType}),children:[e.jsx(bn,{className:"w-3.5 h-3.5 mr-1"}),"View"]})]}):Te.proofDocumentId?e.jsx("span",{className:"text-xs text-re-red-hover",children:"Proof linked (refresh if file details are missing)"}):e.jsxs(se,{type:"button",size:"sm",variant:"ghost",className:"h-7 text-slate-400",disabled:R.status==="Completed",children:[e.jsx(or,{className:"w-3.5 h-3.5 mr-1"}),"Upload"]})})})]},Te.id))})]})}),((n==null?void 0:n.role)==="NBH"||(n==null?void 0:n.role)==="Super Admin")&&R.status!=="Completed"&&e.jsx("div",{className:"flex justify-end pt-4 border-t border-slate-200",children:e.jsxs(se,{className:"bg-green-600 hover:bg-green-700",onClick:bt,disabled:P||!((Es=R.items)!=null&&Es.length)||!R.items.every(Te=>Te.isCompliant),children:[P?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Finalize EOR & Complete Relocation"]})}),!((ts=R.items)!=null&&ts.every(Te=>Te.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:L?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(es,{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(an,{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(se,{variant:"outline",onClick:()=>Xe(a==null?void 0:a.id),children:"Try Refreshing"})]})})]})}),e.jsx(qt,{value:"history",className:"mt-0",children:e.jsx("div",{className:"space-y-4",children:m.length>0?m.map((Te,je)=>{var nt,Ye,pt,yt,Jt,ss,Ss,Zs,on,en,tn,cn;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(Ce,{className:`
|
||
${(Te.description||Te.action||((nt=Te.details)==null?void 0:nt.action)||"").toLowerCase().includes("reject")||(Te.description||Te.action||((Ye=Te.details)==null?void 0:Ye.action)||"").toLowerCase().includes("revok")?"bg-red-100 text-red-700 border-red-200":(Te.description||Te.action||((pt=Te.details)==null?void 0:pt.action)||"").toLowerCase().includes("sent back")||(Te.description||Te.action||((yt=Te.details)==null?void 0:yt.action)||"").toLowerCase().includes("send back")?"bg-red-50 text-re-red-hover border-red-200":(Te.description||Te.action||((Jt=Te.details)==null?void 0:Jt.action)||"").toLowerCase().includes("approv")||(Te.description||Te.action||((ss=Te.details)==null?void 0:ss.action)||"").toLowerCase().includes("initi")||(Te.action||"").toLowerCase().includes("complete")?"bg-emerald-100 text-emerald-700 border-emerald-200":"bg-slate-100 text-slate-700 border-slate-200"}
|
||
`,children:Te.action}),e.jsxs("span",{className:"text-xs text-slate-500 font-medium italic",children:["by ",((Ss=Te.actor)==null?void 0:Ss.name)||Te.userName||"System"]}),((Zs=Te.details)==null?void 0:Zs.stage)&&e.jsxs("span",{className:"text-[10px] text-slate-400 font-normal",children:["at ",Te.details.stage]})]}),e.jsx("span",{className:"text-xs text-slate-500",children:Gt(Te.timestamp||Te.createdAt)})]}),(Te.remarks||Te.description||((on=Te.newData)==null?void 0:on.remarks)||((en=Te.details)==null?void 0:en.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:Te.remarks||Te.description||((tn=Te.newData)==null?void 0:tn.remarks)||((cn=Te.details)==null?void 0:cn.remarks)})]})]},je)}):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(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Current Status"})}),e.jsxs(Fe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Current Stage"}),e.jsx(Ce,{className:eo(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 ${mt}`,style:{width:`${he}%`}})}),e.jsxs("span",{className:"text-slate-900",children:[he,"%"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-600 text-sm",children:"Distance"}),e.jsx("p",{className:"text-slate-900",children:a.distance})]})]})]}),e.jsxs(Le,{children:[e.jsx(Qe,{children:e.jsx(et,{children:"Actions"})}),e.jsxs(Fe,{className:"space-y-3",children:[Bs&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{className:"w-full bg-green-600 hover:bg-green-700",onClick:()=>Z("approve"),disabled:p||!Ws,children:[p&&N==="approve"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4 mr-2"}),"Approve Request"]}),!Ws&&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(se,{variant:"destructive",className:"w-full",onClick:()=>Z("reject"),disabled:p,children:[p&&N==="reject"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(an,{className:"w-4 h-4 mr-2"}),"Reject Request"]}),Ys&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-900 hover:bg-red-50",onClick:()=>Z("sendBack"),disabled:p,children:[p&&N==="sendBack"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(QI,{className:"w-4 h-4 mr-2"}),"Send Back"]}),Xs&&e.jsxs(se,{variant:"outline",className:"w-full border-red-300 text-red-800 hover:bg-red-50",onClick:()=>Z("revoke"),disabled:p,children:[p&&N==="revoke"?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(tb,{className:"w-4 h-4 mr-2"}),"Revoke Request"]}),e.jsx("div",{className:"border-t border-slate-200 pt-3 mt-3"})]}),e.jsxs(se,{variant:"outline",className:"w-full border-blue-300 text-blue-700 hover:bg-blue-50",onClick:()=>{var Te;return r(`/worknotes/relocation/${t}`,{state:{applicationName:((Te=a==null?void 0:a.outlet)==null?void 0:Te.name)||"Relocation",registrationNumber:(a==null?void 0:a.requestId)||"",participants:(a==null?void 0:a.participants)||[]}})},children:[e.jsx(Ga,{className:"w-4 h-4 mr-2"}),"Worknotes (",((vs=a==null?void 0:a.worknotes)==null?void 0:vs.length)||0,")"]})]})]})]})]}),e.jsx(ls,{open:w,onOpenChange:v,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:N==="approve"?"Approve Request":N==="reject"?"Reject Request":N==="sendBack"?"Send Back Request":N==="revoke"?"Revoke Request":"Put Request on Hold"}),e.jsx(bs,{children:N==="sendBack"||N==="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:oe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(de,{htmlFor:"comments",children:N==="sendBack"||N==="revoke"?"Remarks *":"Comments *"}),e.jsx("div",{className:"space-y-2"})]}),e.jsx(Gs,{id:"comments",value:y,onChange:Te=>C(Te.target.value),placeholder:N==="sendBack"?"Explain what needs to be corrected at the previous stage…":N==="revoke"?"Document why this relocation request is being revoked…":"Enter your comments...",rows:4,required:!0}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>v(!1),disabled:p,children:"Cancel"}),e.jsxs(se,{type:"submit",className:N==="approve"?"bg-green-600 hover:bg-green-700":"bg-re-red hover:bg-re-red-hover",disabled:p,children:[p?e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}):null,N==="approve"?"Approve":N==="reject"?"Reject":N==="sendBack"?"Send Back":N==="revoke"?"Revoke":"Put on Hold"]})]})]})]})}),e.jsx(ls,{open:H,onOpenChange:X,children:e.jsxs(as,{children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Reject document"}),e.jsx(bs,{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(de,{htmlFor:"rejectDocReason",children:"Rejection reason *"}),e.jsx(Gs,{id:"rejectDocReason",rows:4,value:ae,onChange:Te=>xe(Te.target.value),placeholder:"Explain what must be corrected or re-uploaded…"})]}),e.jsxs(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>X(!1),children:"Cancel"}),e.jsx(se,{type:"button",variant:"destructive",disabled:ce,onClick:()=>void De(),children:ce?e.jsx(es,{className:"w-4 h-4 animate-spin"}):"Confirm reject"})]})]})}),e.jsx(mo,{isOpen:F,onClose:()=>B(!1),document:K})]}):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(se,{onClick:s,children:"Go Back"})]})}function mK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(null),[l,o]=g.useState(""),[d,m]=g.useState(""),[f,x]=g.useState(""),[h,p]=g.useState(""),[u,w]=g.useState(""),[v,N]=g.useState([]),[j,y]=g.useState([]),[C,S]=g.useState(!0),[D,R]=g.useState(!1),[A,L]=g.useState(null);g.useEffect(()=>{$()},[]);const $=async()=>{try{S(!0);const I=await Jl.getDashboardData(),q=await sc.getResignations();N(I.outlets||[]),L(I.profile),y(q.resignations||[])}catch(I){console.error("Fetch resignation data error:",I),ee.error("Failed to load outlets and requests")}finally{S(!1)}},P=I=>{a(I),n(!0)},E=async I=>{if(I.preventDefault(),!l){ee.error("Please select resignation type");return}if(!d||!f){ee.error("Please enter last operational dates");return}if(!h.trim()){ee.error("Please provide a reason for resignation");return}try{R(!0);const q={outletId:r==null?void 0:r.id,resignationType:l,lastOperationalDateSales:d,lastOperationalDateServices:f,reason:h,additionalInfo:u};await sc.createResignation(q),ee.success(`Resignation request submitted successfully for ${r==null?void 0:r.name}`),n(!1),$(),a(null),o(""),m(""),x(""),p(""),w("")}catch(q){console.error("Submit resignation error:",q),ee.error("Failed to submit resignation request")}finally{R(!1)}},O=[{title:"Total Outlets",value:v.length,icon:so,color:"bg-blue-500"},{title:"Active Outlets",value:v.filter(I=>I.status==="Active").length,icon:fn,color:"bg-green-500"},{title:"Pending Resignations",value:v.filter(I=>I.status==="Pending Resignation").length,icon:yn,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(es,{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:O.map((I,q)=>{const G=I.icon;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(et,{className:"text-sm",children:I.title}),e.jsx("div",{className:`${I.color} p-2 rounded-lg`,children:e.jsx(G,{className:"h-4 w-4 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:I.value})})]},q)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"My Outlets"}),e.jsx(Qt,{children:"Select an outlet to request resignation"})]}),e.jsx(Fe,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:v.map(I=>{const q=I.type==="Dealership"?so:rM,G=I.status==="Pending Resignation",Y=j.find(V=>V.outletId===I.id&&V.status!=="Completed"&&V.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:`${I.type==="Dealership"?"bg-blue-100":"bg-purple-100"} p-2 rounded-lg`,children:e.jsx(q,{className:`w-5 h-5 ${I.type==="Dealership"?"text-blue-600":"text-purple-600"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-slate-900",children:I.name}),e.jsx("p",{className:"text-slate-600 text-sm",children:I.code})]})]}),e.jsx(Ce,{className:`border ${I.status==="Active"?"bg-green-100 text-green-700 border-green-300":I.status==="Pending Resignation"?"bg-red-50 text-re-red border-red-200":"bg-slate-100 text-slate-700 border-slate-300"}`,children:I.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(Vr,{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:I.location})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(dr,{className:"w-4 h-4 text-slate-400"}),e.jsxs("span",{className:"text-slate-600",children:["Outlet Code: ",I.code]})]})]}),G?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&&(Y==null?void 0:Y.resignationId)&&t(Y.resignationId),children:"View Request"})]})}):e.jsxs(se,{className:"w-full bg-red-600 hover:bg-red-700",onClick:()=>P(I),children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),"Request Resignation"]})]},I.id)})})})]}),e.jsx(ls,{open:s,onOpenChange:n,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Submit Resignation Request"}),e.jsx(bs,{children:"Fill in the details for your resignation request. All fields are mandatory."})]}),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:"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(de,{htmlFor:"resignationType",children:"Resignation Type *"}),e.jsxs(At,{value:l,onValueChange:o,required:!0,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select resignation type"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Voluntary",children:"Voluntary"}),e.jsx(Me,{value:"Retirement",children:"Retirement"}),e.jsx(Me,{value:"Health Issues",children:"Health Issues"}),e.jsx(Me,{value:"Business Closure",children:"Business Closure"}),e.jsx(Me,{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(de,{htmlFor:"lastOpDateSales",children:"Last Operational Date - Sales *"}),e.jsx(at,{id:"lastOpDateSales",type:"date",value:d,onChange:I=>m(I.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"lastOpDateServices",children:"Last Operational Date - Services *"}),e.jsx(at,{id:"lastOpDateServices",type:"date",value:f,onChange:I=>x(I.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Resignation *"}),e.jsx(Gs,{id:"reason",placeholder:"Please provide detailed reason for resignation...",value:h,onChange:I=>p(I.target.value),rows:4,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"additionalInfo",children:"Additional Information (Optional)"}),e.jsx(Gs,{id:"additionalInfo",placeholder:"Any additional details...",value:u,onChange:I=>w(I.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(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>{n(!1),a(null)},children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-red-600 hover:bg-red-700",disabled:D,children:D?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Resignation Request"})]})]})]})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"My Resignation Requests"}),e.jsx(Qt,{children:"View your submitted resignation requests"})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Outlet"}),e.jsx(fe,{children:"Type"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:j.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:5,className:"text-center py-4 text-slate-500",children:"No resignation requests found"})}):j.map(I=>{var q;return e.jsxs(lt,{children:[e.jsx(ue,{className:"font-medium text-slate-900",children:I.resignationId}),e.jsx(ue,{children:(q=I.outlet)==null?void 0:q.name}),e.jsx(ue,{children:I.resignationType}),e.jsx(ue,{children:Gt(I.submittedOn)}),e.jsx(ue,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(I.resignationId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},I.id)})})]})})]})]})]})}var fK=Symbol("radix.slottable");function pK(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=fK,s}var aT="AlertDialog",[xK]=ga(aT,[PR]),Nl=PR(),iT=t=>{const{__scopeAlertDialog:s,...n}=t,r=Nl(s);return e.jsx(zb,{...r,...n,modal:!0})};iT.displayName=aT;var gK="AlertDialogTrigger",vK=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(YR,{...a,...r,ref:s})});vK.displayName=gK;var yK="AlertDialogPortal",lT=t=>{const{__scopeAlertDialog:s,...n}=t,r=Nl(s);return e.jsx(Ub,{...r,...n})};lT.displayName=yK;var bK="AlertDialogOverlay",oT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(op,{...a,...r,ref:s})});oT.displayName=bK;var ed="AlertDialogContent",[jK,NK]=xK(ed),wK=pK("AlertDialogContent"),cT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,children:r,...a}=t,l=Nl(n),o=g.useRef(null),d=Ks(s,o),m=g.useRef(null);return e.jsx(U$,{contentName:ed,titleName:dT,docsSlug:"alert-dialog",children:e.jsx(jK,{scope:n,cancelRef:m,children:e.jsxs(cp,{role:"alertdialog",...l,...a,ref:d,onOpenAutoFocus:Wt(a.onOpenAutoFocus,f=>{var x;f.preventDefault(),(x=m.current)==null||x.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[e.jsx(wK,{children:r}),e.jsx(CK,{contentRef:o})]})})})});cT.displayName=ed;var dT="AlertDialogTitle",uT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(ZR,{...a,...r,ref:s})});uT.displayName=dT;var hT="AlertDialogDescription",mT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(QR,{...a,...r,ref:s})});mT.displayName=hT;var SK="AlertDialogAction",fT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,a=Nl(n);return e.jsx(Vb,{...a,...r,ref:s})});fT.displayName=SK;var pT="AlertDialogCancel",xT=g.forwardRef((t,s)=>{const{__scopeAlertDialog:n,...r}=t,{cancelRef:a}=NK(pT,n),l=Nl(n),o=Ks(s,a);return e.jsx(Vb,{...l,...r,ref:o})});xT.displayName=pT;var CK=({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 \`${hT}\` 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},AK=iT,kK=lT,DK=oT,RK=cT,EK=fT,_K=xT,TK=uT,PK=mT;function OK({...t}){return e.jsx(AK,{"data-slot":"alert-dialog",...t})}function LK({...t}){return e.jsx(kK,{"data-slot":"alert-dialog-portal",...t})}function IK({className:t,...s}){return e.jsx(DK,{"data-slot":"alert-dialog-overlay",className:jt("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 MK({className:t,...s}){return e.jsxs(LK,{children:[e.jsx(IK,{}),e.jsx(RK,{"data-slot":"alert-dialog-content",className:jt("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 FK({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:jt("flex flex-col gap-2 text-center sm:text-left",t),...s})}function BK({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:jt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...s})}function $K({className:t,...s}){return e.jsx(TK,{"data-slot":"alert-dialog-title",className:jt("text-lg font-semibold",t),...s})}function qK({className:t,...s}){return e.jsx(PK,{"data-slot":"alert-dialog-description",className:jt("text-muted-foreground text-sm",t),...s})}function zK({className:t,...s}){return e.jsx(EK,{className:jt(nd(),t),...s})}function UK({className:t,...s}){return e.jsx(_K,{className:jt(nd({variant:"outline"}),t),...s})}function VK({resignationId:t,onBack:s}){var w,v,N;const[n,r]=g.useState(!0),[a,l]=g.useState(null),[o,d]=g.useState(!1),[m,f]=g.useState(!1),[x,h]=g.useState("User requested withdrawal");g.useEffect(()=>{t&&(async()=>{try{r(!0);const y=await sc.getResignationById(t);l(y)}catch(y){console.error("Failed to fetch resignation details:",y),ee.error("Unable to load resignation details")}finally{r(!1)}})()},[t]);const p=async()=>{try{const j=await sc.getResignationById(t);l(j)}catch{ee.error("Unable to refresh resignation details")}},u=async()=>{var j,y;try{d(!0),await sc.withdraw(t,x),ee.success("Resignation request withdrawn successfully"),f(!1),await p()}catch(C){ee.error(((y=(j=C==null?void 0:C.response)==null?void 0:j.data)==null?void 0:y.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(yn,{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(se,{variant:"outline",onClick:s,children:[e.jsx(Jr,{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(se,{variant:"destructive",className:"bg-red-600 hover:bg-red-700",onClick:()=>f(!0),disabled:o,children:[e.jsx(mi,{className:"w-4 h-4 mr-2"}),o?"Withdrawing...":"Withdraw Request"]})]}),e.jsx(OK,{open:m,onOpenChange:f,children:e.jsxs(MK,{children:[e.jsxs(FK,{children:[e.jsx($K,{children:"Are you absolutely sure?"}),e.jsx(qK,{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(de,{htmlFor:"withdrawal-reason",children:"Reason for withdrawal"}),e.jsx(at,{id:"withdrawal-reason",placeholder:"Please enter a reason...",value:x,onChange:j=>h(j.target.value)})]})]}),e.jsxs(BK,{children:[e.jsx(UK,{disabled:o,children:"Cancel"}),e.jsx(zK,{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(Le,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"w-5 h-5 text-re-red"}),"Request Summary"]}),e.jsx(Qt,{children:"Key details about your resignation request"})]}),e.jsxs(Fe,{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:Gt(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(Le,{children:[e.jsx(Qe,{children:e.jsxs(et,{className:"flex items-center gap-2",children:[e.jsx(Ir,{className:"w-5 h-5 text-blue-600"}),"Outlet and Dates"]})}),e.jsxs(Fe,{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:((w=a.outlet)==null?void 0:w.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?Gt(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?Gt(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(Vr,{className:"w-3 h-3"}),"Outlet Address"]}),e.jsx("p",{className:"text-slate-900",children:((N=a.outlet)==null?void 0:N.address)||"-"})]})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(se,{variant:"outline",onClick:s,children:[e.jsx(Jr,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsx(Le,{children:e.jsx(Fe,{className:"py-8 text-center text-slate-600",children:"Resignation details not found."})})]})}const HK=(t,s)=>Xb(t,s);function WK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(""),[l,o]=g.useState(""),[d,m]=g.useState(""),[f,x]=g.useState(""),[h,p]=g.useState(""),[u,w]=g.useState([]),[v,N]=g.useState(!0),[j,y]=g.useState(!1),[C,S]=g.useState(null),[D,R]=g.useState([]);g.useEffect(()=>{A()},[]);const A=async()=>{var P,E;try{N(!0);const[O,I,q]=await Promise.all([Jl.getDashboardData(),Jl.getConstitutionalChanges(),Ee.getConstitutionalChangeMeta()]);S(O.profile);const G=nT((P=O.profile)==null?void 0:P.constitutionType);a(G),w(I.requests||[]),(E=q.data)!=null&&E.success&&Array.isArray(q.data.structureTargets)&&R(q.data.structureTargets)}catch(O){console.error("Fetch constitutional data error:",O),ee.error("Failed to load requests")}finally{N(!1)}},L=async P=>{var E,O;if(P.preventDefault(),!l){ee.error("Please select proposed constitution type");return}if(r===l){ee.error("Proposed constitution must be different from current");return}if(!d.trim()){ee.error("Please provide a reason for constitutional change");return}try{y(!0);const I={currentConstitution:r,changeType:l,reason:d.trim(),newPartnersDetails:f,shareholdingPattern:h};await Jl.submitConstitutionalChange(I),ee.success("Constitutional change request submitted successfully"),n(!1),A(),o(""),m(""),x(""),p("")}catch(I){console.error("Submit constitutional change error:",I);const q=((O=(E=I==null?void 0:I.response)==null?void 0:E.data)==null?void 0:O.message)||"Failed to submit constitutional change request";ee.error(q)}finally{y(!1)}},$=[{title:"Total Requests",value:u.length,icon:fl,color:"bg-re-red"},{title:"Pending",value:u.filter(P=>P.status!=="Completed"&&P.status!=="Rejected").length,icon:dr,color:"bg-re-red"},{title:"Completed",value:u.filter(P=>P.status==="Completed").length,icon:Ns,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(es,{className:"w-8 h-8 text-re-red 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(ls,{open:s,onOpenChange:n,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"New Constitutional Change"]})}),e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Submit Constitutional Change Request"}),e.jsx(bs,{children:"Request to change your dealership's business constitution structure"})]}),e.jsxs("form",{onSubmit:L,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(de,{htmlFor:"currentConstitution",children:"Current Constitution *"}),e.jsx(at,{id:"currentConstitution",value:r,disabled:!0,className:"bg-slate-100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"proposedConstitution",children:"Proposed Constitution *"}),e.jsxs(At,{value:l,onValueChange:o,required:!0,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select new constitution"})}),e.jsx(Rt,{children:D.filter(P=>P.value!==r).map(P=>e.jsx(Me,{value:P.value,children:P.label},P.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Change *"}),e.jsx(Gs,{id:"reason",placeholder:"Please provide detailed reason for constitutional change...",value:d,onChange:P=>m(P.target.value),rows:4,required:!0})]}),(l==="Partnership"||l==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newPartners",children:"Details of New Partners/Members"}),e.jsx(Gs,{id:"newPartners",placeholder:"Name, relationship, and experience of new partners...",value:f,onChange:P=>x(P.target.value),rows:3})]}),(l==="Private Limited"||l==="LLP")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"shareholdingPattern",children:"Proposed Shareholding Pattern"}),e.jsx(Gs,{id:"shareholdingPattern",placeholder:"Details of share distribution among partners/directors...",value:h,onChange:P=>p(P.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-hover mb-2",children:"Documents Required (to be uploaded later)"}),e.jsxs("ul",{className:"text-re-red-hover 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(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-re-red hover:bg-re-red-hover",disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(es,{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:$.map((P,E)=>{const O=P.icon;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(et,{className:"text-sm",children:P.title}),e.jsx("div",{className:`${P.color} p-2 rounded-lg`,children:e.jsx(O,{className:"h-4 w-4 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:P.value})})]},E)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"My Constitutional Change Requests"}),e.jsx(Qt,{children:"View and track all your constitutional change requests"})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Current"}),e.jsx(fe,{children:"Proposed"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Current Status"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:u.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No constitutional change requests found"})}):u.map(P=>e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900",children:P.requestId})}),e.jsx(ue,{children:e.jsx(Ce,{variant:"outline",children:P.currentConstitution})}),e.jsx(ue,{children:e.jsx(Ce,{className:"bg-red-50 text-re-red-hover border-red-200",children:P.changeType})}),e.jsx(ue,{className:"text-slate-600",children:Gt(P.createdAt)}),e.jsx(ue,{children:e.jsx(Ce,{className:`border ${HK(P.status)}`,children:P.status})}),e.jsx(ue,{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:`h-2 rounded-full transition-all duration-300 ${vi(P.status,P.currentStage)}`,style:{width:`${P.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[P.progressPercentage||0,"%"]})]})}),e.jsx(ue,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(P.requestId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},P.id))})]})})]})]})]})}const GK=(t,s)=>Xb(t,s),Fv=(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 KK({onViewDetails:t}){const[s,n]=g.useState(!1),[r,a]=g.useState(null),[l,o]=g.useState(""),[d,m]=g.useState(""),[f,x]=g.useState(""),[h,p]=g.useState(""),[u,w]=g.useState(""),[v,N]=g.useState(""),[j,y]=g.useState(""),[C,S]=g.useState(""),[D,R]=g.useState(""),[A,L]=g.useState([]),[$,P]=g.useState([]),[E,O]=g.useState(""),[I,q]=g.useState(""),[G,Y]=g.useState(!1),[V,Q]=g.useState([]),[_,z]=g.useState([]),[T,F]=g.useState(!0),[B,K]=g.useState(!1);g.useEffect(()=>{H(),X()},[]);const W=E?$.filter(ce=>ce.stateId===E):$,H=async()=>{try{F(!0);const ce=await Jl.getDashboardData(),we=await Jl.getRelocationRequests();Q(ce.outlets||[]),z(we.requests||[])}catch(ce){console.error("Fetch relocation data error:",ce),ee.error(Fv(ce,"Failed to load outlets and requests"))}finally{F(!1)}},X=async()=>{var ce,we;try{Y(!0);const[ke,Xe]=await Promise.all([Fs.getStates().catch(()=>({success:!1})),Fs.getDistricts({limit:"all"}).catch(()=>({success:!1}))]),Ot=ke!=null&&ke.success?((ce=ke.data)==null?void 0:ce.states)||ke.data||[]:[],bt=Xe!=null&&Xe.success?((we=Xe.data)==null?void 0:we.districts)||Xe.data||[]:[];L(Ot),P(bt)}catch(ke){console.error("Fetch master data error:",ke),ee.error(Fv(ke,"Failed to load master data"))}finally{Y(!1)}},J=ce=>{O(ce),q("");const we=A.find(ke=>ke.id===ce);we&&m(we.name)},ie=ce=>{q(ce);const we=$.find(ke=>ke.id===ce);we&&o(we.name)},ae=async ce=>{if(ce.preventDefault(),!r){ee.error("Please select an outlet");return}if(!l.trim()||!d.trim()||!f.trim()){ee.error("Please provide complete relocation details");return}if(!h.trim()){ee.error("Please provide a reason for relocation");return}if(!u.trim()||!v||!j){ee.error("Please fill all mandatory fields (Distance, Property Type, Date)");return}try{K(!0);const we={outletId:r.id,relocationType:"Intercity",currentAddress:r.address||"",currentCity:r.city||"",currentState:r.state||"",newAddress:f,newCity:l,newState:d,newDistrictId:I||null,newStateId:E||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 Jl.submitRelocationRequest(we),ee.success(`Relocation request submitted successfully for ${r.name}`),n(!1),H(),a(null),o(""),m(""),x(""),p(""),w(""),N(""),y(""),S(""),R(""),t&&H()}catch(we){console.error("Submit relocation error:",we),ee.error(Fv(we,"Failed to submit relocation request"))}finally{K(!1)}},xe=[{title:"Total Requests",value:_.length,icon:Vr,color:"bg-blue-500"},{title:"Pending",value:_.filter(ce=>ce.status!=="Completed"&&ce.status!=="Rejected").length,icon:dr,color:"bg-re-red"},{title:"Approved",value:_.filter(ce=>ce.status==="Completed").length,icon:so,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(es,{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(ls,{open:s,onOpenChange:n,children:[e.jsx(co,{asChild:!0,children:e.jsxs(se,{className:"bg-re-red hover:bg-re-red-hover text-white",children:[e.jsx(Dn,{className:"w-4 h-4 mr-2"}),"New Relocation Request"]})}),e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(us,{children:"Submit Relocation Request"}),e.jsx(bs,{children:"Provide details about the outlet you want to relocate and its proposed new location"})]}),e.jsxs("form",{onSubmit:ae,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"outlet",children:"Select Outlet to Relocate *"}),e.jsxs(At,{value:r==null?void 0:r.id,onValueChange:ce=>a(V.find(we=>we.id===ce)),required:!0,children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"Select an outlet"})}),e.jsx(Rt,{children:V.map(ce=>e.jsxs(Me,{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(de,{htmlFor:"newState",children:"Proposed State *"}),e.jsxs(At,{value:E,onValueChange:J,required:!0,disabled:G,children:[e.jsx(Dt,{id:"newState",children:e.jsx(kt,{placeholder:G?"Loading...":"Select state"})}),e.jsx(Rt,{children:A.map(ce=>e.jsx(Me,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newCity",children:"Proposed City/District *"}),e.jsxs(At,{value:I,onValueChange:ie,required:!0,disabled:!E||G,children:[e.jsx(Dt,{id:"newCity",children:e.jsx(kt,{placeholder:E?G?"Loading...":"Select district":"Select state first"})}),e.jsx(Rt,{children:W.map(ce=>e.jsx(Me,{value:ce.id,children:ce.name},ce.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"newAddress",children:"Proposed Full Address *"}),e.jsx(Gs,{id:"newAddress",placeholder:"Enter detailed address of the proposed new location...",value:f,onChange:ce=>x(ce.target.value),rows:3,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"distance",children:"Estimated Distance from Current Location (in km) *"}),e.jsx(at,{id:"distance",placeholder:"e.g. 5.5 km",value:u,onChange:ce=>w(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(de,{htmlFor:"propertyType",children:"Property Type *"}),e.jsxs(At,{value:v,onValueChange:N,required:!0,children:[e.jsx(Dt,{id:"propertyType",children:e.jsx(kt,{placeholder:"Select type"})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"Owned",children:"Owned"}),e.jsx(Me,{value:"Leased",children:"Leased"}),e.jsx(Me,{value:"Rented",children:"Rented"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"expectedDate",children:"Expected Relocation Date *"}),e.jsx(at,{id:"expectedDate",type:"date",value:j,onChange:ce=>y(ce.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{htmlFor:"reason",children:"Reason for Relocation *"}),e.jsx(Gs,{id:"reason",placeholder:"Why do you want to relocate this outlet?",value:h,onChange:ce=>p(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(xn,{children:[e.jsx(se,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(se,{type:"submit",className:"bg-re-red hover:bg-re-red-hover text-white",disabled:B,children:B?e.jsxs(e.Fragment,{children:[e.jsx(es,{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:xe.map((ce,we)=>{const ke=ce.icon;return e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(et,{className:"text-sm",children:ce.title}),e.jsx("div",{className:`${ce.color} p-2 rounded-lg`,children:e.jsx(ke,{className:"h-4 w-4 text-white"})})]}),e.jsx(Fe,{children:e.jsx("div",{className:"text-slate-900 text-2xl",children:ce.value})})]},we)})}),e.jsxs(Le,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"My Relocation Requests"}),e.jsx(Qt,{children:"Track the status of your relocation applications"})]}),e.jsx(Fe,{children:e.jsxs(Ps,{children:[e.jsx(Os,{children:e.jsxs(lt,{children:[e.jsx(fe,{children:"Request ID"}),e.jsx(fe,{children:"Outlet"}),e.jsx(fe,{children:"Target Location"}),e.jsx(fe,{children:"Submitted On"}),e.jsx(fe,{children:"Current Status"}),e.jsx(fe,{children:"Progress"}),e.jsx(fe,{children:"Actions"})]})}),e.jsx(Ls,{children:_.length===0?e.jsx(lt,{children:e.jsx(ue,{colSpan:7,className:"text-center py-4 text-slate-500",children:"No relocation requests found"})}):_.map(ce=>{var we;return e.jsxs(lt,{children:[e.jsx(ue,{children:e.jsx("span",{className:"text-slate-900 font-medium",children:ce.requestId})}),e.jsx(ue,{children:(we=ce.outlet)==null?void 0:we.name}),e.jsx(ue,{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(Yo,{className:"w-3 h-3 text-slate-400"}),e.jsx("span",{className:"text-slate-900",children:ce.newCity})]})}),e.jsx(ue,{className:"text-slate-600",children:Gt(ce.createdAt)}),e.jsx(ue,{children:e.jsx(Ce,{className:`border ${GK(ce.status)}`,children:ce.status})}),e.jsx(ue,{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:`h-2 rounded-full transition-all duration-300 ${vi(ce.status,ce.currentStage)}`,style:{width:`${ce.progressPercentage||0}%`}})}),e.jsxs("span",{className:"text-xs text-slate-600",children:[ce.progressPercentage||0,"%"]})]})}),e.jsx(ue,{children:e.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>t&&t(ce.requestId),children:[e.jsx(bn,{className:"w-4 h-4 mr-1"}),"View"]})})]},ce.id)})})]})})]})]})]})}const YK=["Personal Information","Financial Information","Location & Background","Motivation","Business Structure","Professional Background","Infrastructure","Financial Planning","Growth & Expansion","Brand Affinity","Vision & Strategy"],IC=()=>{const{id:t}=gd(),s=tr(),[n,r]=g.useState(`v${new Date().toISOString().split("T")[0]}`),[a,l]=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&&x(t)},[t]);const x=async C=>{var S;try{f(!0);const D=await Ee.getQuestionnaireById(C);if((S=D.data)!=null&&S.success){const R=D.data.data;r(`${R.version} (Copy)`),R.questions&&R.questions.length>0&&l(R.questions.map(A=>{var P,E;let L=(P=A.inputType)==null?void 0:P.toLowerCase().trim();return L==="mcq"&&(L="select"),["text","number","file","yesno","select","radio","textarea","email","mcq"].includes(L)||(L="text"),{...A,inputType:L,weight:parseFloat(A.weight),options:((E=A.questionOptions)==null?void 0:E.map(O=>({text:O.optionText,score:O.score})))||[]}}))}else ee.error("Failed to load questionnaire"),s("/questionnaires")}catch(D){console.error(D),ee.error("Error fetching questionnaire")}finally{f(!1)}},h=a.reduce((C,S)=>C+(S.weight||0),0),p=()=>{l([...a,{sectionName:"Personal Information",questionText:"",inputType:"text",weight:0,order:a.length+1,isMandatory:!0}])},u=C=>{const D=a.filter((R,A)=>A!==C).map((R,A)=>({...R,order:A+1}));l(D)},w=(C,S,D)=>{var A;const R=[...a];if(S==="weight"){const L=parseFloat(D)||0;R[C].options&&(R[C].options=R[C].options.map($=>({...$,score:Math.min($.score,L)})))}S==="inputType"&&D==="yesno"&&(!R[C].options||((A=R[C].options)==null?void 0:A.length)===0)?R[C].options=[{text:"Yes",score:R[C].weight||5},{text:"No",score:0}]:S==="inputType"&&D==="select"&&!R[C].options&&(R[C].options=[]),R[C]={...R[C],[S]:D},l(R)},v=C=>{const S=[...a];S[C].options||(S[C].options=[]),S[C].options.push({text:"",score:0}),l(S)},N=(C,S,D,R)=>{const A=[...a];if(A[C].options){let L=R;if(D==="score"){const $=A[C].weight||0;L=Math.min(parseFloat(R)||0,$)}A[C].options[S]={...A[C].options[S],[D]:L},l(A)}},j=(C,S)=>{const D=[...a];D[C].options&&(D[C].options=D[C].options.filter((R,A)=>A!==S),l(D))},y=async()=>{var C;if(a.some(S=>!S.questionText)){ee.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 R=(C=D.options)==null?void 0:C.find(A=>A.score>D.weight);if(R){ee.error(`Question ${S+1}: Option "${R.text}" score (${R.score}) exceeds question weightage (${D.weight})`);return}}}if(h!==100){ee.error(`Total weightage must be exactly 100. Current total: ${h}`);return}try{d(!0),await Ee.createQuestionnaireVersion({version:n,questions:a}),ee.success("Questionnaire version created successfully"),s("/questionnaires")}catch(S){console.error(S),ee.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(Jr,{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(an,{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:y,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(pl,{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:R=>w(S,"questionText",R.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:R=>w(S,"sectionName",R.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:YK.map(R=>e.jsx("option",{value:R,children:R},R))})]}),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:R=>w(S,"inputType",R.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:R=>w(S,"weight",parseFloat(R.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((R,A)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:R.text,onChange:L=>N(S,A,"text",L.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(R.score)?0:R.score,max:isNaN(C.weight)?0:C.weight,min:0,onChange:L=>N(S,A,"score",L.target.value),className:`w-20 border ${R.score>C.weight||isNaN(R.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(ar,{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(Dn,{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(ar,{size:18})})]},S)})}),e.jsxs("button",{onClick:p,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(Dn,{size:20})," Add Another Question"]})]})},MC=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),a=tr();g.useEffect(()=>{l()},[]);const l=async()=>{var o;try{r(!0);const d=await Ee.getAllQuestionnaires();(o=d.data)!=null&&o.success?s(d.data.data):ee.error("Failed to load questionnaire versions")}catch(d){console.error(d),ee.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(Dn,{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(fn,{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(mi,{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(dr,{size:14,className:"text-slate-400"}),Ka(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(Cr,{size:14})," Edit / Clone"]})})]},o.id))})]})})]})},Bv=[{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"}],ZK=()=>{const[t,s]=g.useState([]),[,n]=g.useState(!1),[r,a]=g.useState("KT_MATRIX"),[l,o]=g.useState(!1),[d,m]=g.useState(null),[f,x]=g.useState(!1),[h,p]=g.useState(!1),u=g.useCallback(async()=>{var E;try{n(!0);const O=await Ee.getInterviewConfigs();(E=O.data)!=null&&E.success&&s(O.data.data||[])}catch(O){console.error("Fetch configs error:",O),ee.error("Failed to load interview configurations")}finally{n(!1)}},[]);g.useEffect(()=>{u()},[u]);const w=E=>t.find(O=>O.configType===E&&O.isActive),v=E=>{var I;const O={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:E,name:`${((I=Bv.find(q=>q.value===E))==null?void 0:I.label)||"New Config"}`,version:`v${new Date().toISOString().split("T")[0]}`,isActive:!0,items:O[E]||[]}),o(!0)},N=async E=>{var O;try{n(!0);const I=await Ee.getInterviewConfigById(E);(O=I.data)!=null&&O.success&&(m(I.data.data),o(!0))}catch{ee.error("Failed to load configuration for editing")}finally{n(!1)}},j=async()=>{var E,O;if(d){if(!d.name||!d.version){ee.error("Name and version are required");return}if(!d.items||d.items.length===0){ee.error("Add at least one item");return}if(d.configType==="KT_MATRIX"){const I=d.items.reduce((q,G)=>q+(Number(G.weight)||0),0);if(Math.abs(I-100)>.01){ee.error(`KT Matrix total weight must be 100. Current: ${I}`);return}for(const q of d.items)if(q.type==="select"&&(!q.options||q.options.length===0)){ee.error(`Select item "${q.label}" must have options`);return}}try{x(!0);const I={configType:d.configType,name:d.name,version:d.version,items:d.items.map((q,G)=>{var Y;return{...q,order:q.order||G+1,options:(Y=q.options)==null?void 0:Y.map((V,Q)=>({...V,order:V.order||Q+1}))}})};d.id?(await Ee.updateInterviewConfig(d.id,I),ee.success("Configuration updated successfully")):(await Ee.createInterviewConfig(I),ee.success("New configuration published successfully")),o(!1),m(null),await u()}catch(I){console.error("Save error:",I),ee.error(((O=(E=I==null?void 0:I.response)==null?void 0:E.data)==null?void 0:O.message)||"Failed to save configuration")}finally{x(!1)}}},y=async E=>{if(confirm("Are you sure you want to delete this configuration?"))try{await Ee.deleteInterviewConfig(E),ee.success("Configuration deleted"),await u()}catch{ee.error("Failed to delete configuration")}},C=async()=>{if(confirm("This will reset all interview configurations to system defaults. Continue?"))try{p(!0),await Ee.initializeDefaultInterviewConfigs(),ee.success("Default configurations initialized"),await u()}catch{ee.error("Failed to initialize defaults")}finally{p(!1)}},S=()=>{var O,I;if(!d)return;const E={itemKey:`field_${(((O=d.items)==null?void 0:O.length)||0)+1}`,label:"",type:d.configType==="KT_MATRIX"?"select":"textarea",order:(((I=d.items)==null?void 0:I.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||[],E]})},D=E=>{var q;if(!d)return;const I=(((q=d.items)==null?void 0:q.filter((G,Y)=>Y!==E))||[]).map((G,Y)=>({...G,order:Y+1}));m({...d,items:I})},R=(E,O,I)=>{if(!d)return;const q=[...d.items||[]];q[E]={...q[E],[O]:I},m({...d,items:q})},A=E=>{if(!d)return;const O=[...d.items||[]],I=O[E];I.options||(I.options=[]),I.options.push({optionLabel:"",optionValue:"",score:0,order:I.options.length+1}),m({...d,items:O})},L=(E,O,I,q)=>{if(!d)return;const G=[...d.items||[]];G[E].options&&(G[E].options[O]={...G[E].options[O],[I]:q},m({...d,items:G}))},$=(E,O)=>{if(!d)return;const I=[...d.items||[]];I[E].options&&(I[E].options=I[E].options.filter((q,G)=>G!==O),m({...d,items:I}))},P=(d==null?void 0:d.configType)==="KT_MATRIX"?(d.items||[]).reduce((E,O)=>E+(Number(O.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(se,{variant:"outline",onClick:C,disabled:h,className:"gap-2",children:[e.jsx(rb,{size:16})," ",h?"Initializing...":"Reset to Defaults"]})]}),e.jsxs($n,{value:r,onValueChange:a,children:[e.jsx(qn,{className:"grid w-full grid-cols-3",children:Bv.map(E=>e.jsx(zt,{value:E.value,children:E.label},E.value))}),Bv.map(E=>{var q;const O=w(E.value),I=t.filter(G=>G.configType===E.value);return e.jsx(qt,{value:E.value,children:e.jsxs(Le,{children:[e.jsxs(Qe,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(et,{className:"text-lg",children:E.label}),e.jsx("p",{className:"text-sm text-slate-500",children:E.description})]}),e.jsxs(se,{onClick:()=>v(E.value),className:"gap-2",children:[e.jsx(Dn,{size:16})," Publish New Version"]})]}),e.jsxs(Fe,{children:[O?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: ",O.name]}),e.jsxs("p",{className:"text-sm text-green-700",children:["Version ",O.version," • ",((q=O.items)==null?void 0:q.length)||0," items"]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>O.id&&N(O.id),children:e.jsx(R1,{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"}),I.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No versions found."}):e.jsx("div",{className:"space-y-2",children:I.map(G=>{var Y;return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${G.isActive?"bg-green-50 border-green-200":"bg-white border-slate-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[G.isActive&&e.jsx(Ce,{className:"bg-green-600",children:"Active"}),e.jsx("span",{className:"font-medium text-sm",children:G.name}),e.jsx("span",{className:"text-xs text-slate-500",children:G.version}),e.jsxs("span",{className:"text-xs text-slate-400",children:[((Y=G.items)==null?void 0:Y.length)||0," items"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{variant:"ghost",size:"sm",onClick:()=>G.id&&N(G.id),children:e.jsx(R1,{size:14})}),e.jsx(se,{variant:"ghost",size:"sm",className:"text-re-red hover:text-re-red-hover",onClick:()=>G.id&&y(G.id),children:e.jsx(ar,{size:14})})]})]},G.id)})})]})]})},E.value)})]})," ",e.jsx(ls,{open:l,onOpenChange:o,children:e.jsxs(as,{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(us,{className:"text-lg font-bold text-slate-900 leading-none",children:d!=null&&d.id?"Edit Configuration":"New Configuration"}),e.jsxs(bs,{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 ${P===100?"bg-emerald-50 text-emerald-700 border border-emerald-100":"bg-red-50 text-re-red-hover border border-red-100"}`,children:["Weight: ",P,"% / 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(de,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Name"}),e.jsx(at,{value:d.name,onChange:E=>m({...d,name:E.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(de,{className:"text-[10px] font-bold text-slate-400 uppercase tracking-widest pl-1",children:"Version"}),e.jsx(at,{value:d.version,onChange:E=>m({...d,version:E.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(se,{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(Dn,{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((E,O)=>e.jsxs(wt.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(O+1).padStart(2,"0")}),e.jsx("td",{className:"px-4 py-3 align-top",children:e.jsx(at,{value:E.label,onChange:I=>R(O,"label",I.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(at,{value:E.itemKey,onChange:I=>R(O,"itemKey",I.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(At,{value:E.type,onValueChange:I=>R(O,"type",I),children:[e.jsx(Dt,{className:"h-10 border-slate-100 hover:border-slate-300 bg-slate-50/30 text-xs focus:ring-0",children:e.jsx(kt,{})}),e.jsxs(Rt,{children:[e.jsx(Me,{value:"select",children:"Options"}),e.jsx(Me,{value:"text",children:"One Liner"}),e.jsx(Me,{value:"textarea",children:"Paragraph"}),e.jsx(Me,{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(at,{type:"number",value:E.weight||"",onChange:I=>R(O,"weight",parseFloat(I.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:()=>R(O,"weight",(E.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(bu,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>R(O,"weight",Math.max(0,(E.weight||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(Aa,{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(at,{type:"number",value:E.maxScore||"",onChange:I=>R(O,"maxScore",parseFloat(I.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:()=>R(O,"maxScore",(E.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(bu,{size:10,className:"text-slate-600"})}),e.jsx("button",{type:"button",onClick:()=>R(O,"maxScore",Math.max(0,(E.maxScore||0)-1)),className:"flex-1 px-1.5 hover:bg-slate-200/50 flex items-center justify-center",children:e.jsx(Aa,{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:E.isRequired,onChange:I=>R(O,"isRequired",I.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(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-200 hover:text-red-500 hover:bg-red-50",onClick:()=>D(O),children:e.jsx(ar,{size:16})})})]}),E.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(se,{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(O),children:[e.jsx(Dn,{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:(E.options||[]).map((I,q)=>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(at,{placeholder:"Label",value:I.optionLabel,onChange:G=>L(O,q,"optionLabel",G.target.value),className:"h-9 border-slate-200 bg-white text-xs font-normal"})}),e.jsx("div",{className:"col-span-3",children:e.jsx(at,{placeholder:"Value",value:I.optionValue,onChange:G=>L(O,q,"optionValue",G.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(at,{type:"number",placeholder:"0",value:I.score,onChange:G=>L(O,q,"score",parseFloat(G.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:()=>L(O,q,"score",(I.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(bu,{size:8})}),e.jsx("button",{onClick:()=>L(O,q,"score",(I.score||0)-1),className:"flex-1 px-1 hover:bg-slate-200 flex items-center justify-center",children:e.jsx(Aa,{size:8})})]})]})}),e.jsx("div",{className:"col-span-1 flex justify-center",children:e.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-300 hover:text-red-500 opacity-0 group-hover/opt:opacity-100",onClick:()=>$(O,q),children:e.jsx(ar,{size:13})})})]},q))})]})})]})]},O))})]})})})]})}),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(se,{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(se,{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(es,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(pl,{className:"w-4 h-4 mr-2"}),"Commit Changes"]})]})]})})]})},QK=[{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"}],XK=[{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"}],JK={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"},FC=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}},$v=({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)}),eY=()=>{var Y,V,Q;const[t,s]=g.useState([]),[n,r]=g.useState(null),[a,l]=g.useState(!1),[o,d]=g.useState(1),[m]=g.useState(25),[f,x]=g.useState(1),[h,p]=g.useState(0),[u,w]=g.useState("__all__"),[v,N]=g.useState("__all__"),[j,y]=g.useState(""),[C,S]=g.useState(""),[D,R]=g.useState(""),[A,L]=g.useState(""),[$,P]=g.useState(null),E=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]),O=g.useCallback(async()=>{var _,z;l(!0);try{const T=await Ee.getSystemAuditLogs(E),F=T==null?void 0:T.data;T!=null&&T.ok&&(F!=null&&F.success)?(s(F.data||[]),x(((_=F.pagination)==null?void 0:_.totalPages)||1),p(((z=F.pagination)==null?void 0:z.total)||0)):(ee.error((F==null?void 0:F.message)||"Unable to load system logs"),s([]))}catch(T){console.error("[SystemLogsPage] fetchLogs error:",T),ee.error("Failed to load system logs"),s([])}finally{l(!1)}},[E]),I=g.useCallback(async()=>{try{const _=await Ee.getSystemAuditSummary(),z=_==null?void 0:_.data;_!=null&&_.ok&&(z!=null&&z.success)&&r(z.data||null)}catch(_){console.error("[SystemLogsPage] fetchSummary error:",_)}},[]);g.useEffect(()=>{O()},[O]),g.useEffect(()=>{I()},[I]);const q=()=>{d(1),L(j.trim())},G=()=>{w("__all__"),N("__all__"),y(""),L(""),S(""),R(""),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(se,{variant:"outline",onClick:()=>{O(),I()},disabled:a,children:[e.jsx(pr,{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(Le,{className:"border-slate-200",children:[e.jsx(Qe,{className:"pb-2",children:e.jsx(et,{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:"Total Events"})}),e.jsxs(Fe,{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(_=>e.jsxs(Le,{className:"border-slate-200",children:[e.jsx(Qe,{className:"pb-2",children:e.jsx(et,{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:_.moduleLabel})}),e.jsxs(Fe,{children:[e.jsx("p",{className:"text-2xl font-bold text-slate-900",children:_.total}),e.jsx("button",{onClick:()=>{w(_.module),d(1)},className:"text-[11px] text-re-red hover:underline mt-1",children:"View module →"})]})]},_.module))]}),e.jsx(Le,{className:"border-slate-200",children:e.jsxs(Fe,{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(Ta,{className:"w-3 h-3"})," Search"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(at,{placeholder:"Entity name, description, or actor…",value:j,onChange:_=>y(_.target.value),onKeyDown:_=>{_.key==="Enter"&&q()}}),e.jsx(se,{variant:"outline",onClick:q,children:"Go"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"Module"}),e.jsxs(At,{value:u,onValueChange:_=>{w(_),d(1)},children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"All Modules"})}),e.jsx(Rt,{children:QK.map(_=>e.jsx(Me,{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"Action"}),e.jsxs(At,{value:v,onValueChange:_=>{N(_),d(1)},children:[e.jsx(Dt,{children:e.jsx(kt,{placeholder:"All Actions"})}),e.jsx(Rt,{children:XK.map(_=>e.jsx(Me,{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-600 mb-1 block",children:"From"}),e.jsx(at,{type:"date",value:C,onChange:_=>{S(_.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(at,{type:"date",value:D,onChange:_=>{R(_.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(sb,{className:"w-3 h-3"}),"Showing ",t.length," of ",h," matching event(s)"]}),e.jsx(se,{variant:"ghost",size:"sm",onClick:G,children:"Reset filters"})]})]})}),e.jsxs(Le,{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(pr,{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(_=>{var z,T,F;return e.jsxs("tr",{className:"hover:bg-slate-50/70 cursor-pointer",onClick:()=>P(_),children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-slate-700",children:FC(_.timestamp)}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(Ce,{variant:"outline",className:"border-slate-300 text-slate-700",children:_.moduleLabel})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(Ce,{variant:"outline",className:JK[_.action]||"bg-slate-100 text-slate-700 border-slate-200",children:_.actionLabel})}),e.jsxs("td",{className:"px-4 py-3 text-slate-800",children:[e.jsx("div",{className:"font-medium truncate max-w-[260px]",title:_.entityLabel||"",children:_.entityLabel||`${_.entityType}`}),_.entityId&&e.jsx("div",{className:"text-[10px] font-mono text-slate-400 truncate max-w-[260px]",children:_.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=_.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=_.actor)==null?void 0:T.name)||"System"}),((F=_.actor)==null?void 0:F.role)&&e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:_.actor.role})]})]})}),e.jsx("td",{className:"px-4 py-3 text-slate-600",children:e.jsx("div",{className:"truncate max-w-[360px]",title:_.description,children:_.description})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(se,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:B=>{B.stopPropagation(),P(_)},title:"View details",children:e.jsx(bn,{className:"w-4 h-4 text-slate-500"})})})]},_.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(se,{size:"sm",variant:"outline",disabled:a||o<=1,onClick:()=>d(_=>Math.max(1,_-1)),children:[e.jsx(lo,{className:"w-4 h-4 mr-1"}),"Prev"]}),e.jsxs(se,{size:"sm",variant:"outline",disabled:a||o>=f,onClick:()=>d(_=>Math.min(f,_+1)),children:["Next",e.jsx(ji,{className:"w-4 h-4 ml-1"})]})]})]})]}),e.jsx(ls,{open:!!$,onOpenChange:_=>!_&&P(null),children:e.jsx(as,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:$&&e.jsxs(e.Fragment,{children:[e.jsxs(fs,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(rd,{className:"w-5 h-5 text-re-red"}),$.moduleLabel," · ",$.actionLabel]}),e.jsx(bs,{className:"text-slate-600",children:$.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:$.entityLabel||$.entityType}),$.entityId&&e.jsx("p",{className:"text-[11px] font-mono text-slate-400 mt-0.5",children:$.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(Ir,{className:"w-4 h-4 text-slate-400"}),((Y=$.actor)==null?void 0:Y.name)||"System"]}),((V=$.actor)==null?void 0:V.role)&&e.jsx("p",{className:"text-[11px] text-slate-500 uppercase tracking-wider mt-0.5",children:$.actor.role}),((Q=$.actor)==null?void 0:Q.email)&&e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:$.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:FC($.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:$.ipAddress||"—"}),e.jsx("p",{className:"text-[11px] text-slate-500 truncate",title:$.userAgent||"",children:$.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($v,{value:$.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($v,{value:$.newData})]})]}),$.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($v,{value:$.metadata})]})]})})})]})},tY=()=>{const[t,s]=g.useState([]),[n,r]=g.useState(!0),[a,l]=g.useState(1),[o,d]=g.useState(1),m=15,f=tr(),x=async w=>{try{r(!0);const v=await Qo.getNotifications(w,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(()=>{x(a)},[a]);const h=async(w,v)=>{v.stopPropagation(),await Qo.markAsRead(w),x(a)},p=async()=>{await Qo.markAllAsRead(),x(a)},u=async w=>{if(w.isRead||await Qo.markAsRead(w.id),w.link){const v=w.link;try{const N=new URL(v);N.origin===window.location.origin?f(N.pathname+N.search+N.hash):window.open(v,"_blank")}catch{f(v)}}else x(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(ku,{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(se,{variant:"outline",onClick:p,disabled:n||!t.some(w=>!w.isRead),children:[e.jsx(Wn,{className:"w-4 h-4 mr-2"}),"Mark all as read"]})]}),e.jsx(Le,{className:"shadow-sm border-gray-200",children:e.jsx(Fe,{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(ku,{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(w=>e.jsxs("div",{className:`p-4 hover:bg-gray-50 transition-colors flex items-start gap-4 cursor-pointer ${w.isRead?"":"bg-blue-50/50"}`,onClick:()=>u(w),children:[e.jsx("div",{className:"mt-1 flex-shrink-0 cursor-pointer",onClick:v=>h(w.id,v),children:w.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 ${w.isRead?"text-gray-700":"text-gray-900"}`,children:w.title}),e.jsxs("div",{className:"flex items-center text-xs text-gray-500 whitespace-nowrap ml-4",children:[e.jsx(yn,{className:"w-3 h-3 mr-1"}),lR(new Date(w.createdAt),{addSuffix:!0})]})]}),e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2",children:w.message})]})]},w.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(se,{variant:"outline",size:"sm",disabled:a===1,onClick:()=>l(w=>Math.max(1,w-1)),children:[e.jsx(lo,{className:"w-4 h-4"}),"Previous"]}),e.jsxs(se,{variant:"outline",size:"sm",disabled:a===o,onClick:()=>l(w=>Math.min(o,w+1)),children:["Next",e.jsx(ji,{className:"w-4 h-4"})]})]})]})]})},BC=({...t})=>e.jsx(IM,{theme:"light",className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t}),sY=({onLogout:t,title:s,subtitle:n})=>e.jsxs("div",{className:"flex h-screen bg-slate-50 overflow-hidden",children:[e.jsx(WM,{onLogout:t}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(o$,{title:s,subtitle:n,onRefresh:()=>window.location.reload()}),e.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:e.jsx(NL,{})})]})]});function nY(){const t=Iu(),{user:s,isAuthenticated:n,loading:r}=Fn(y=>y.auth),[a,l]=g.useState(!1),o=tr(),d=Ui(),m=(s==null?void 0:s.role)||(s==null?void 0:s.roleCode)||"",f=y=>{const C=y.map(R=>R.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)},x=["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"],p=["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(Mm())},[t]);const w=async(y,C)=>{var S;try{const D=await Ee.login({email:y,password:C});if(D.ok&&D.data){const{token:R,user:A}=D.data;localStorage.setItem("token",R);const L={id:A.id,name:A.fullName||y.split("@")[0],email:A.email,password:C,role:typeof A.role=="string"?A.role:A.roleCode||"User"};t(AA({user:L,token:R})),ee.success(`Welcome back, ${L.name}!`),l(!1)}else{const R=((S=D.data)==null?void 0:S.message)||"Invalid credentials";ee.error(R)}}catch(D){console.error("Login error:",D),ee.error("Something went wrong. Please try again.")}},v=()=>{t(kA()),l(!1),ee.info("Logged out successfully"),o("/")};g.useEffect(()=>{const y=()=>{v(),ee.error("Session expired. Please login again.")};return window.addEventListener("auth:logout",y),()=>window.removeEventListener("auth:logout",y)},[t,o]);const N=y=>y.startsWith("/applications/")&&y.length>14?"Application Details":y.startsWith("/resignation/")&&!y.startsWith("/dealer-resignation")?"Resignation Details":y.startsWith("/dealer-resignation/")?"Resignation Request Details":y.startsWith("/termination/")?"Termination Details":y.startsWith("/fnf/")?"F&F Request Details":y.startsWith("/constitutional-change/")?"Constitutional Change Details":y.startsWith("/relocation-requests/")?"Relocation Request Details":y.startsWith("/finance-onboarding/")?"Payment Details":y.startsWith("/finance-audit/")?"Finance Audit":y.startsWith("/finance-fnf/")?"F&F Settlement Details":y.startsWith("/fdd-details/")?"FDD Audit Workspace":y.startsWith("/questionnaire-builder/")?"Questionnaire Builder":y.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"}[y]||"Dashboard",j=(y,C)=>{const S=(C||"").toLowerCase(),D=S==="dealer"||S.includes("dealer"),R=S.includes("finance");if(y.startsWith("/worknotes/"))return"Collaborative notes and clarifications linked to this onboarding or offboarding record.";if(y.startsWith("/applications/")&&y!=="/applications")return"Review stages, documents, interviews, and decisions for this single dealership onboarding application.";if(y==="/applications")return"Search, filter, and open dealership applications your role can work on.";if(y==="/all-applications")return"Cross-team view of every dealership application in the pipeline.";if(y==="/opportunity-requests")return"Applications tied to an opportunity location for DD prioritisation.";if(y==="/non-opportunities")return"Applications without a mapped opportunity; track for future reference or follow-up.";if(y==="/dashboard")return D?"Your home for outlet actions: constitutional change (how your business is legally registered), relocation, and resignation requests.":R?"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(y.startsWith("/dealer-resignation/"))return"Read-only summary of the resignation you submitted for this outlet.";if(y==="/dealer-resignation")return"Start a new outlet resignation or open a request you already submitted.";if(y==="/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(y==="/dealer-relocation")return"Request a move of your dealership to a new address or territory, and track requests in progress.";if(y.startsWith("/constitutional-change/"))return"Review evidence, comments, and workflow for this constitutional change case.";if(y==="/constitutional-change")return"Process dealer requests to change registered legal constitution, supporting documents, and approvals.";if(y.startsWith("/relocation-requests/"))return"Assess feasibility, documents, and approvals for this relocation request.";if(y==="/relocation-requests")return"Manage dealer relocation proposals: new sites, handovers, and compliance checks.";if(y.startsWith("/resignation/")&&!y.startsWith("/dealer-resignation"))return"HR workflow: clearances, handovers, and settlement steps for this resignation.";if(y==="/resignation")return"Queue of dealership resignation cases across your authorised outlets.";if(y.startsWith("/termination/"))return"Contractual exit details, evidence, and approvals for this termination case.";if(y==="/termination")return"Monitor dealership terminations, disputes, and mandated approvals.";if(y.startsWith("/fnf/"))return"Line items, deductions, and payout status for this full & final settlement.";if(y==="/fnf")return"Track F&F batches from clearance through finance payout.";if(y.startsWith("/finance-onboarding/"))return"Payment schedule, proofs, and audit notes for this onboarding application.";if(y==="/finance-onboarding")return"Validate Security Deposit, first fills, and related onboarding payments.";if(y.startsWith("/finance-audit/"))return"Finance audit trail and checklist for this application.";if(y.startsWith("/finance-fnf/"))return"Settlement calculations and release steps for this F&F record.";if(y==="/finance-fnf")return"Finance queue for F&F approvals and disbursements.";if(y.startsWith("/fdd-details/"))return"Field Development Director audit workspace for this application.";if(y==="/fdd-dashboard")return"FDD workload: audits due, flags raised, and follow-up actions.";if(y.startsWith("/questionnaire-builder/")||y==="/questionnaire-builder")return"Author and publish questionnaire versions used in dealership assessments.";if(y==="/questionnaires"||y==="/questions")return"List of published questionnaire templates and versions.";if(y==="/master")return"Hierarchy, geography, templates, and reference data shared across onboarding.";if(y==="/users")return"Create and maintain internal users, roles, and access for this portal.";if(y==="/approval-policies")return"Configure who must approve each onboarding stage or document type.";if(y==="/sla-configurations")return"Define turnaround targets and escalations for onboarding milestones.";if(y==="/interview-configs")return"Set up interview templates, panels, and scoring used during selection.";if(y==="/system-logs")return"Immutable record of configuration and administrative actions for compliance.";if(y==="/notifications")return"System and workflow alerts for your account.";if(y==="/tasks")return"Tasks assigned to you (placeholder module).";if(y==="/reports")return"Analytics and exports for onboarding performance (placeholder module).";if(y==="/settings")return"Profile, notifications, and security preferences for your account.";const A=N(y);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(H9,{children:[e.jsxs(ey,{children:[e.jsx(Rs,{path:"/prospective-dashboard/*",element:e.jsx(y1,{allowedRoles:["Prospective Dealer"],children:e.jsx($7,{})})}),e.jsxs(Rs,{element:e.jsx(y1,{excludeRoles:["Prospective Dealer"],redirectTo:"/prospective-dashboard",children:e.jsx(sY,{onLogout:v,title:N(d.pathname),subtitle:j(d.pathname,m)})}),children:[e.jsx(Rs,{path:"/",element:e.jsx(Zn,{to:"/dashboard",replace:!0})}),e.jsx(Rs,{path:"/dashboard",element:f(u)?e.jsx(M7,{currentUser:s,onNavigate:y=>o(`/${y}`),onViewPaymentDetails:y=>o(`/finance-onboarding/${y}`),onViewAuditDetails:y=>o(`/finance-audit/${y}`),onViewFnFDetails:y=>o(`/finance-fnf/${y}`)}):f(["Dealer"])?e.jsx(F7,{currentUser:s,onNavigate:y=>o(`/${y}`)}):e.jsx(S$,{onNavigate:y=>o(`/${y}`)})}),e.jsx(Rs,{path:"/applications",element:e.jsx(Rq,{onViewDetails:y=>o(`/applications/${y}`),initialFilter:"all"})}),e.jsx(Rs,{path:"/applications/:id",element:e.jsx(TS,{})}),e.jsx(Rs,{path:"/worknotes/:type/:id",element:e.jsx(FE,{onBack:()=>window.history.back()})}),e.jsx(Rs,{path:"/all-applications",element:f(["DD","DD Admin","Super Admin"])?e.jsx(Eq,{onViewDetails:y=>o(`/applications/${y}`),initialFilter:"all"}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/fdd-dashboard",element:e.jsx(U7,{})}),e.jsx(Rs,{path:"/fdd-details/:id",element:e.jsx(dq,{})}),e.jsx(Rs,{path:"/opportunity-requests",element:e.jsx(RU,{onViewDetails:y=>o(`/applications/${y}`)})}),e.jsx(Rs,{path:"/non-opportunities",element:e.jsx(EU,{onViewDetails:y=>o(`/applications/${y}`)})}),e.jsx(Rs,{path:"/users",element:e.jsx(zG,{})}),e.jsx(Rs,{path:"/notifications",element:e.jsx(tY,{})}),e.jsx(Rs,{path:"/approval-policies",element:f(["Super Admin","DD Admin"])?e.jsx(Q_,{}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/sla-configurations",element:f(["Super Admin","DD Admin","DD Lead"])?e.jsx(KG,{}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/master",element:e.jsx(qG,{})}),e.jsx(Rs,{path:"/questions",element:e.jsx(MC,{})}),e.jsx(Rs,{path:"/questionnaire-builder",element:e.jsx(IC,{})}),e.jsx(Rs,{path:"/questionnaire-builder/:id",element:e.jsx(IC,{})}),e.jsx(Rs,{path:"/questionnaires",element:e.jsx(MC,{})}),e.jsx(Rs,{path:"/interview-configs",element:f(["Super Admin","DD Admin","DD Head"])?e.jsx(ZK,{}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/system-logs",element:f(["Super Admin"])?e.jsx(eY,{}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/resignation",element:f(x)?e.jsx(fV,{currentUser:s,onViewDetails:y=>o(`/resignation/${y}`)}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/resignation/:id",element:f(x)?e.jsx(jV,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/resignation"),currentUser:s}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/termination",element:f(h)?e.jsx(xV,{currentUser:s,onViewDetails:y=>o(`/termination/${y}`)}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/termination/:id",element:f(h)?e.jsx(DV,{terminationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/termination"),currentUser:s}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/fnf",element:f(p)?e.jsx(gV,{currentUser:s,onViewDetails:y=>o(`/fnf/${y}`)}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/fnf/:id",element:f(p)?e.jsx(_V,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/fnf"),currentUser:s}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/finance-onboarding",element:f(u)?e.jsx(TV,{onViewPaymentDetails:y=>o(`/finance-onboarding/${y}`),onViewAuditDetails:y=>o(`/finance-audit/${y}`)}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/finance-onboarding/:id",element:f(u)?e.jsx(OV,{applicationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/finance-onboarding")}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/finance-audit/:id",element:e.jsx(TS,{})}),e.jsx(Rs,{path:"/finance-fnf",element:f(u)?e.jsx(PV,{onViewFnFDetails:y=>o(`/finance-fnf/${y}`)}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/finance-fnf/:id",element:f(u)?e.jsx(LV,{fnfId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/finance-fnf")}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/constitutional-change",element:e.jsx(eK,{currentUser:s,onViewDetails:y=>o(`/constitutional-change/${y}`)})}),e.jsx(Rs,{path:"/constitutional-change/:id",element:e.jsx(nK,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>o(f(["Dealer"])?"/dealer-constitutional":"/constitutional-change"),currentUser:s})}),e.jsx(Rs,{path:"/relocation-requests",element:e.jsx(aK,{currentUser:s,onViewDetails:y=>o(`/relocation-requests/${y}`)})}),e.jsx(Rs,{path:"/relocation-requests/:id",element:e.jsx(hK,{requestId:window.location.pathname.split("/").pop()||"",onBack:()=>o(f(["Dealer"])?"/dealer-relocation":"/relocation-requests"),currentUser:s})}),e.jsx(Rs,{path:"/dealer-resignation",element:e.jsx(mK,{currentUser:s,onViewDetails:y=>o(`/dealer-resignation/${y}`)})}),e.jsx(Rs,{path:"/dealer-resignation/:id",element:f(["Dealer"])?e.jsx(VK,{resignationId:window.location.pathname.split("/").pop()||"",onBack:()=>o("/dealer-resignation")}):e.jsx(Zn,{to:"/dashboard"})}),e.jsx(Rs,{path:"/dealer-constitutional",element:e.jsx(WK,{currentUser:s,onViewDetails:y=>o(`/constitutional-change/${y}`)})}),e.jsx(Rs,{path:"/dealer-relocation",element:e.jsx(KK,{currentUser:s,onViewDetails:y=>o(`/relocation-requests/${y}`)})}),e.jsx(Rs,{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(Rs,{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(Rs,{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(Rs,{path:"*",element:e.jsx(Zn,{to:"/dashboard",replace:!0})})]})]}),e.jsx(BC,{})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ey,{children:[e.jsx(Rs,{path:"/admin-login",element:e.jsx(P1,{onLogin:w})}),e.jsx(Rs,{path:"/prospective-login",element:e.jsx(HM,{})}),e.jsx(Rs,{path:"/questionnaire/:applicationId",element:e.jsx(FM,{})}),e.jsx(Rs,{path:"*",element:a?e.jsx(P1,{onLogin:w}):e.jsx(MM,{onAdminLogin:()=>l(!0)})})]}),e.jsx(BC,{})]})}C4.createRoot(document.getElementById("root")).render(e.jsx(wt.StrictMode,{children:e.jsx($4,{store:E5,children:e.jsx(AL,{children:e.jsx(nY,{})})})}));
|