53 lines
601 KiB
JavaScript
53 lines
601 KiB
JavaScript
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const r of l)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&a(i)}).observe(document,{childList:!0,subtree:!0});function s(l){const r={};return l.integrity&&(r.integrity=l.integrity),l.referrerPolicy&&(r.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?r.credentials="include":l.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function a(l){if(l.ep)return;l.ep=!0;const r=s(l);fetch(l.href,r)}})();var Hu={exports:{}},ai={},Gu={exports:{}},ge={};/**
|
||
* @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 Nl=Symbol.for("react.element"),Og=Symbol.for("react.portal"),Lg=Symbol.for("react.fragment"),Wg=Symbol.for("react.strict_mode"),Ng=Symbol.for("react.profiler"),Bg=Symbol.for("react.provider"),$g=Symbol.for("react.context"),Ug=Symbol.for("react.forward_ref"),Mg=Symbol.for("react.suspense"),Fg=Symbol.for("react.memo"),Hg=Symbol.for("react.lazy"),bc=Symbol.iterator;function Gg(e){return e===null||typeof e!="object"?null:(e=bc&&e[bc]||e["@@iterator"],typeof e=="function"?e:null)}var Qu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ku=Object.assign,Yu={};function $a(e,n,s){this.props=e,this.context=n,this.refs=Yu,this.updater=s||Qu}$a.prototype.isReactComponent={};$a.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,n,"setState")};$a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Xu(){}Xu.prototype=$a.prototype;function md(e,n,s){this.props=e,this.context=n,this.refs=Yu,this.updater=s||Qu}var xd=md.prototype=new Xu;xd.constructor=md;Ku(xd,$a.prototype);xd.isPureReactComponent=!0;var Sc=Array.isArray,qu=Object.prototype.hasOwnProperty,yd={current:null},Ju={key:!0,ref:!0,__self:!0,__source:!0};function Vu(e,n,s){var a,l={},r=null,i=null;if(n!=null)for(a in n.ref!==void 0&&(i=n.ref),n.key!==void 0&&(r=""+n.key),n)qu.call(n,a)&&!Ju.hasOwnProperty(a)&&(l[a]=n[a]);var d=arguments.length-2;if(d===1)l.children=s;else if(1<d){for(var f=Array(d),p=0;p<d;p++)f[p]=arguments[p+2];l.children=f}if(e&&e.defaultProps)for(a in d=e.defaultProps,d)l[a]===void 0&&(l[a]=d[a]);return{$$typeof:Nl,type:e,key:r,ref:i,props:l,_owner:yd.current}}function Qg(e,n){return{$$typeof:Nl,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function vd(e){return typeof e=="object"&&e!==null&&e.$$typeof===Nl}function Kg(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return n[s]})}var _c=/\/+/g;function Hi(e,n){return typeof e=="object"&&e!==null&&e.key!=null?Kg(""+e.key):n.toString(36)}function vr(e,n,s,a,l){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(r){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case Nl:case Og:i=!0}}if(i)return i=e,l=l(i),e=a===""?"."+Hi(i,0):a,Sc(l)?(s="",e!=null&&(s=e.replace(_c,"$&/")+"/"),vr(l,n,s,"",function(p){return p})):l!=null&&(vd(l)&&(l=Qg(l,s+(!l.key||i&&i.key===l.key?"":(""+l.key).replace(_c,"$&/")+"/")+e)),n.push(l)),1;if(i=0,a=a===""?".":a+":",Sc(e))for(var d=0;d<e.length;d++){r=e[d];var f=a+Hi(r,d);i+=vr(r,n,s,f,l)}else if(f=Gg(e),typeof f=="function")for(e=f.call(e),d=0;!(r=e.next()).done;)r=r.value,f=a+Hi(r,d++),i+=vr(r,n,s,f,l);else if(r==="object")throw n=String(e),Error("Objects are not valid as a React child (found: "+(n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return i}function Vl(e,n,s){if(e==null)return e;var a=[],l=0;return vr(e,a,"","",function(r){return n.call(s,r,l++)}),a}function Yg(e){if(e._status===-1){var n=e._result;n=n(),n.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var zt={current:null},jr={transition:null},Xg={ReactCurrentDispatcher:zt,ReactCurrentBatchConfig:jr,ReactCurrentOwner:yd};function Zu(){throw Error("act(...) is not supported in production builds of React.")}ge.Children={map:Vl,forEach:function(e,n,s){Vl(e,function(){n.apply(this,arguments)},s)},count:function(e){var n=0;return Vl(e,function(){n++}),n},toArray:function(e){return Vl(e,function(n){return n})||[]},only:function(e){if(!vd(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ge.Component=$a;ge.Fragment=Lg;ge.Profiler=Ng;ge.PureComponent=md;ge.StrictMode=Wg;ge.Suspense=Mg;ge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Xg;ge.act=Zu;ge.cloneElement=function(e,n,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var a=Ku({},e.props),l=e.key,r=e.ref,i=e._owner;if(n!=null){if(n.ref!==void 0&&(r=n.ref,i=yd.current),n.key!==void 0&&(l=""+n.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(f in n)qu.call(n,f)&&!Ju.hasOwnProperty(f)&&(a[f]=n[f]===void 0&&d!==void 0?d[f]:n[f])}var f=arguments.length-2;if(f===1)a.children=s;else if(1<f){d=Array(f);for(var p=0;p<f;p++)d[p]=arguments[p+2];a.children=d}return{$$typeof:Nl,type:e.type,key:l,ref:r,props:a,_owner:i}};ge.createContext=function(e){return e={$$typeof:$g,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Bg,_context:e},e.Consumer=e};ge.createElement=Vu;ge.createFactory=function(e){var n=Vu.bind(null,e);return n.type=e,n};ge.createRef=function(){return{current:null}};ge.forwardRef=function(e){return{$$typeof:Ug,render:e}};ge.isValidElement=vd;ge.lazy=function(e){return{$$typeof:Hg,_payload:{_status:-1,_result:e},_init:Yg}};ge.memo=function(e,n){return{$$typeof:Fg,type:e,compare:n===void 0?null:n}};ge.startTransition=function(e){var n=jr.transition;jr.transition={};try{e()}finally{jr.transition=n}};ge.unstable_act=Zu;ge.useCallback=function(e,n){return zt.current.useCallback(e,n)};ge.useContext=function(e){return zt.current.useContext(e)};ge.useDebugValue=function(){};ge.useDeferredValue=function(e){return zt.current.useDeferredValue(e)};ge.useEffect=function(e,n){return zt.current.useEffect(e,n)};ge.useId=function(){return zt.current.useId()};ge.useImperativeHandle=function(e,n,s){return zt.current.useImperativeHandle(e,n,s)};ge.useInsertionEffect=function(e,n){return zt.current.useInsertionEffect(e,n)};ge.useLayoutEffect=function(e,n){return zt.current.useLayoutEffect(e,n)};ge.useMemo=function(e,n){return zt.current.useMemo(e,n)};ge.useReducer=function(e,n,s){return zt.current.useReducer(e,n,s)};ge.useRef=function(e){return zt.current.useRef(e)};ge.useState=function(e){return zt.current.useState(e)};ge.useSyncExternalStore=function(e,n,s){return zt.current.useSyncExternalStore(e,n,s)};ge.useTransition=function(){return zt.current.useTransition()};ge.version="18.3.1";Gu.exports=ge;var S=Gu.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 qg=S,Jg=Symbol.for("react.element"),Vg=Symbol.for("react.fragment"),Zg=Object.prototype.hasOwnProperty,em=qg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tm={key:!0,ref:!0,__self:!0,__source:!0};function ep(e,n,s){var a,l={},r=null,i=null;s!==void 0&&(r=""+s),n.key!==void 0&&(r=""+n.key),n.ref!==void 0&&(i=n.ref);for(a in n)Zg.call(n,a)&&!tm.hasOwnProperty(a)&&(l[a]=n[a]);if(e&&e.defaultProps)for(a in n=e.defaultProps,n)l[a]===void 0&&(l[a]=n[a]);return{$$typeof:Jg,type:e,key:r,ref:i,props:l,_owner:em.current}}ai.Fragment=Vg;ai.jsx=ep;ai.jsxs=ep;Hu.exports=ai;var t=Hu.exports,tp={exports:{}},Ft={},np={exports:{}},sp={};/**
|
||
* @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.
|
||
*/(function(e){function n(A,M){var X=A.length;A.push(M);e:for(;0<X;){var L=X-1>>>1,N=A[L];if(0<l(N,M))A[L]=M,A[X]=N,X=L;else break e}}function s(A){return A.length===0?null:A[0]}function a(A){if(A.length===0)return null;var M=A[0],X=A.pop();if(X!==M){A[0]=X;e:for(var L=0,N=A.length,J=N>>>1;L<J;){var se=2*(L+1)-1,oe=A[se],Ye=se+1,ze=A[Ye];if(0>l(oe,X))Ye<N&&0>l(ze,oe)?(A[L]=ze,A[Ye]=X,L=Ye):(A[L]=oe,A[se]=X,L=se);else if(Ye<N&&0>l(ze,X))A[L]=ze,A[Ye]=X,L=Ye;else break e}}return M}function l(A,M){var X=A.sortIndex-M.sortIndex;return X!==0?X:A.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var r=performance;e.unstable_now=function(){return r.now()}}else{var i=Date,d=i.now();e.unstable_now=function(){return i.now()-d}}var f=[],p=[],C=1,j=null,_=3,c=!1,y=!1,z=!1,k=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,o=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(A){for(var M=s(p);M!==null;){if(M.callback===null)a(p);else if(M.startTime<=A)a(p),M.sortIndex=M.expirationTime,n(f,M);else break;M=s(p)}}function x(A){if(z=!1,h(A),!y)if(s(f)!==null)y=!0,$(v);else{var M=s(p);M!==null&&I(x,M.startTime-A)}}function v(A,M){y=!1,z&&(z=!1,g(b),b=-1),c=!0;var X=_;try{for(h(M),j=s(f);j!==null&&(!(j.expirationTime>M)||A&&!F());){var L=j.callback;if(typeof L=="function"){j.callback=null,_=j.priorityLevel;var N=L(j.expirationTime<=M);M=e.unstable_now(),typeof N=="function"?j.callback=N:j===s(f)&&a(f),h(M)}else a(f);j=s(f)}if(j!==null)var J=!0;else{var se=s(p);se!==null&&I(x,se.startTime-M),J=!1}return J}finally{j=null,_=X,c=!1}}var w=!1,u=null,b=-1,T=5,E=-1;function F(){return!(e.unstable_now()-E<T)}function Q(){if(u!==null){var A=e.unstable_now();E=A;var M=!0;try{M=u(!0,A)}finally{M?te():(w=!1,u=null)}}else w=!1}var te;if(typeof o=="function")te=function(){o(Q)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,Y=H.port2;H.port1.onmessage=Q,te=function(){Y.postMessage(null)}}else te=function(){k(Q,0)};function $(A){u=A,w||(w=!0,te())}function I(A,M){b=k(function(){A(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_continueExecution=function(){y||c||(y=!0,$(v))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return s(f)},e.unstable_next=function(A){switch(_){case 1:case 2:case 3:var M=3;break;default:M=_}var X=_;_=M;try{return A()}finally{_=X}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,M){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var X=_;_=A;try{return M()}finally{_=X}},e.unstable_scheduleCallback=function(A,M,X){var L=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?L+X:L):X=L,A){case 1:var N=-1;break;case 2:N=250;break;case 5:N=1073741823;break;case 4:N=1e4;break;default:N=5e3}return N=X+N,A={id:C++,callback:M,priorityLevel:A,startTime:X,expirationTime:N,sortIndex:-1},X>L?(A.sortIndex=X,n(p,A),s(f)===null&&A===s(p)&&(z?(g(b),b=-1):z=!0,I(x,X-L))):(A.sortIndex=N,n(f,A),y||c||(y=!0,$(v))),A},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(A){var M=_;return function(){var X=_;_=M;try{return A.apply(this,arguments)}finally{_=X}}}})(sp);np.exports=sp;var nm=np.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 sm=S,Mt=nm;function q(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)n+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var ap=new Set,vl={};function Fs(e,n){Aa(e,n),Aa(e+"Capture",n)}function Aa(e,n){for(vl[e]=n,e=0;e<n.length;e++)ap.add(n[e])}var Mn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bo=Object.prototype.hasOwnProperty,am=/^[: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]*$/,wc={},kc={};function lm(e){return bo.call(kc,e)?!0:bo.call(wc,e)?!1:am.test(e)?kc[e]=!0:(wc[e]=!0,!1)}function rm(e,n,s,a){if(s!==null&&s.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return a?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function im(e,n,s,a){if(n===null||typeof n>"u"||rm(e,n,s,a))return!0;if(a)return!1;if(s!==null)switch(s.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function It(e,n,s,a,l,r,i){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=a,this.attributeNamespace=l,this.mustUseProperty=s,this.propertyName=e,this.type=n,this.sanitizeURL=r,this.removeEmptyString=i}var gt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){gt[e]=new It(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];gt[n]=new It(n,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){gt[e]=new It(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){gt[e]=new It(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){gt[e]=new It(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){gt[e]=new It(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){gt[e]=new It(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){gt[e]=new It(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){gt[e]=new It(e,5,!1,e.toLowerCase(),null,!1,!1)});var jd=/[\-:]([a-z])/g;function bd(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(jd,bd);gt[n]=new It(n,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(jd,bd);gt[n]=new It(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(jd,bd);gt[n]=new It(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){gt[e]=new It(e,1,!1,e.toLowerCase(),null,!1,!1)});gt.xlinkHref=new It("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){gt[e]=new It(e,1,!1,e.toLowerCase(),null,!0,!0)});function Sd(e,n,s,a){var l=gt.hasOwnProperty(n)?gt[n]:null;(l!==null?l.type!==0:a||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(im(n,s,l,a)&&(s=null),a||l===null?lm(n)&&(s===null?e.removeAttribute(n):e.setAttribute(n,""+s)):l.mustUseProperty?e[l.propertyName]=s===null?l.type===3?!1:"":s:(n=l.attributeName,a=l.attributeNamespace,s===null?e.removeAttribute(n):(l=l.type,s=l===3||l===4&&s===!0?"":""+s,a?e.setAttributeNS(a,n,s):e.setAttribute(n,s))))}var Qn=sm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Zl=Symbol.for("react.element"),pa=Symbol.for("react.portal"),fa=Symbol.for("react.fragment"),_d=Symbol.for("react.strict_mode"),So=Symbol.for("react.profiler"),lp=Symbol.for("react.provider"),rp=Symbol.for("react.context"),wd=Symbol.for("react.forward_ref"),_o=Symbol.for("react.suspense"),wo=Symbol.for("react.suspense_list"),kd=Symbol.for("react.memo"),Xn=Symbol.for("react.lazy"),ip=Symbol.for("react.offscreen"),Cc=Symbol.iterator;function Xa(e){return e===null||typeof e!="object"?null:(e=Cc&&e[Cc]||e["@@iterator"],typeof e=="function"?e:null)}var $e=Object.assign,Gi;function ll(e){if(Gi===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);Gi=n&&n[1]||""}return`
|
||
`+Gi+e}var Qi=!1;function Ki(e,n){if(!e||Qi)return"";Qi=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(p){var a=p}Reflect.construct(e,[],n)}else{try{n.call()}catch(p){a=p}e.call(n.prototype)}else{try{throw Error()}catch(p){a=p}e()}}catch(p){if(p&&a&&typeof p.stack=="string"){for(var l=p.stack.split(`
|
||
`),r=a.stack.split(`
|
||
`),i=l.length-1,d=r.length-1;1<=i&&0<=d&&l[i]!==r[d];)d--;for(;1<=i&&0<=d;i--,d--)if(l[i]!==r[d]){if(i!==1||d!==1)do if(i--,d--,0>d||l[i]!==r[d]){var f=`
|
||
`+l[i].replace(" at new "," at ");return e.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",e.displayName)),f}while(1<=i&&0<=d);break}}}finally{Qi=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?ll(e):""}function om(e){switch(e.tag){case 5:return ll(e.type);case 16:return ll("Lazy");case 13:return ll("Suspense");case 19:return ll("SuspenseList");case 0:case 2:case 15:return e=Ki(e.type,!1),e;case 11:return e=Ki(e.type.render,!1),e;case 1:return e=Ki(e.type,!0),e;default:return""}}function ko(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case fa:return"Fragment";case pa:return"Portal";case So:return"Profiler";case _d:return"StrictMode";case _o:return"Suspense";case wo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case rp:return(e.displayName||"Context")+".Consumer";case lp:return(e._context.displayName||"Context")+".Provider";case wd:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case kd:return n=e.displayName||null,n!==null?n:ko(e.type)||"Memo";case Xn:n=e._payload,e=e._init;try{return ko(e(n))}catch{}}return null}function dm(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ko(n);case 8:return n===_d?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function us(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function op(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function cm(e){var n=op(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),a=""+e[n];if(!e.hasOwnProperty(n)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var l=s.get,r=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return l.call(this)},set:function(i){a=""+i,r.call(this,i)}}),Object.defineProperty(e,n,{enumerable:s.enumerable}),{getValue:function(){return a},setValue:function(i){a=""+i},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function er(e){e._valueTracker||(e._valueTracker=cm(e))}function dp(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var s=n.getValue(),a="";return e&&(a=op(e)?e.checked?"true":"false":e.value),e=a,e!==s?(n.setValue(e),!0):!1}function Pr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Co(e,n){var s=n.checked;return $e({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function zc(e,n){var s=n.defaultValue==null?"":n.defaultValue,a=n.checked!=null?n.checked:n.defaultChecked;s=us(n.value!=null?n.value:s),e._wrapperState={initialChecked:a,initialValue:s,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function cp(e,n){n=n.checked,n!=null&&Sd(e,"checked",n,!1)}function zo(e,n){cp(e,n);var s=us(n.value),a=n.type;if(s!=null)a==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(a==="submit"||a==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?Io(e,n.type,s):n.hasOwnProperty("defaultValue")&&Io(e,n.type,us(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Ic(e,n,s){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var a=n.type;if(!(a!=="submit"&&a!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,s||n===e.value||(e.value=n),e.defaultValue=n}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function Io(e,n,s){(n!=="number"||Pr(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var rl=Array.isArray;function ka(e,n,s,a){if(e=e.options,n){n={};for(var l=0;l<s.length;l++)n["$"+s[l]]=!0;for(s=0;s<e.length;s++)l=n.hasOwnProperty("$"+e[s].value),e[s].selected!==l&&(e[s].selected=l),l&&a&&(e[s].defaultSelected=!0)}else{for(s=""+us(s),n=null,l=0;l<e.length;l++){if(e[l].value===s){e[l].selected=!0,a&&(e[l].defaultSelected=!0);return}n!==null||e[l].disabled||(n=e[l])}n!==null&&(n.selected=!0)}}function Eo(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(q(91));return $e({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ec(e,n){var s=n.value;if(s==null){if(s=n.children,n=n.defaultValue,s!=null){if(n!=null)throw Error(q(92));if(rl(s)){if(1<s.length)throw Error(q(93));s=s[0]}n=s}n==null&&(n=""),s=n}e._wrapperState={initialValue:us(s)}}function up(e,n){var s=us(n.value),a=us(n.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),n.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),a!=null&&(e.defaultValue=""+a)}function Tc(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function pp(e){switch(e){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 To(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?pp(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var tr,fp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,s,a,l){MSApp.execUnsafeLocalFunction(function(){return e(n,s,a,l)})}:e}(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(tr=tr||document.createElement("div"),tr.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=tr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function jl(e,n){if(n){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=n;return}}e.textContent=n}var cl={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},um=["Webkit","ms","Moz","O"];Object.keys(cl).forEach(function(e){um.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),cl[n]=cl[e]})});function hp(e,n,s){return n==null||typeof n=="boolean"||n===""?"":s||typeof n!="number"||n===0||cl.hasOwnProperty(e)&&cl[e]?(""+n).trim():n+"px"}function gp(e,n){e=e.style;for(var s in n)if(n.hasOwnProperty(s)){var a=s.indexOf("--")===0,l=hp(s,n[s],a);s==="float"&&(s="cssFloat"),a?e.setProperty(s,l):e[s]=l}}var pm=$e({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 Ao(e,n){if(n){if(pm[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(q(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(q(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(q(61))}if(n.style!=null&&typeof n.style!="object")throw Error(q(62))}}function Po(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ro=null;function Cd(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Do=null,Ca=null,za=null;function Ac(e){if(e=Ul(e)){if(typeof Do!="function")throw Error(q(280));var n=e.stateNode;n&&(n=di(n),Do(e.stateNode,e.type,n))}}function mp(e){Ca?za?za.push(e):za=[e]:Ca=e}function xp(){if(Ca){var e=Ca,n=za;if(za=Ca=null,Ac(e),n)for(e=0;e<n.length;e++)Ac(n[e])}}function yp(e,n){return e(n)}function vp(){}var Yi=!1;function jp(e,n,s){if(Yi)return e(n,s);Yi=!0;try{return yp(e,n,s)}finally{Yi=!1,(Ca!==null||za!==null)&&(vp(),xp())}}function bl(e,n){var s=e.stateNode;if(s===null)return null;var a=di(s);if(a===null)return null;s=a[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(q(231,n,typeof s));return s}var Oo=!1;if(Mn)try{var qa={};Object.defineProperty(qa,"passive",{get:function(){Oo=!0}}),window.addEventListener("test",qa,qa),window.removeEventListener("test",qa,qa)}catch{Oo=!1}function fm(e,n,s,a,l,r,i,d,f){var p=Array.prototype.slice.call(arguments,3);try{n.apply(s,p)}catch(C){this.onError(C)}}var ul=!1,Rr=null,Dr=!1,Lo=null,hm={onError:function(e){ul=!0,Rr=e}};function gm(e,n,s,a,l,r,i,d,f){ul=!1,Rr=null,fm.apply(hm,arguments)}function mm(e,n,s,a,l,r,i,d,f){if(gm.apply(this,arguments),ul){if(ul){var p=Rr;ul=!1,Rr=null}else throw Error(q(198));Dr||(Dr=!0,Lo=p)}}function Hs(e){var n=e,s=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,n.flags&4098&&(s=n.return),e=n.return;while(e)}return n.tag===3?s:null}function bp(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function Pc(e){if(Hs(e)!==e)throw Error(q(188))}function xm(e){var n=e.alternate;if(!n){if(n=Hs(e),n===null)throw Error(q(188));return n!==e?null:e}for(var s=e,a=n;;){var l=s.return;if(l===null)break;var r=l.alternate;if(r===null){if(a=l.return,a!==null){s=a;continue}break}if(l.child===r.child){for(r=l.child;r;){if(r===s)return Pc(l),e;if(r===a)return Pc(l),n;r=r.sibling}throw Error(q(188))}if(s.return!==a.return)s=l,a=r;else{for(var i=!1,d=l.child;d;){if(d===s){i=!0,s=l,a=r;break}if(d===a){i=!0,a=l,s=r;break}d=d.sibling}if(!i){for(d=r.child;d;){if(d===s){i=!0,s=r,a=l;break}if(d===a){i=!0,a=r,s=l;break}d=d.sibling}if(!i)throw Error(q(189))}}if(s.alternate!==a)throw Error(q(190))}if(s.tag!==3)throw Error(q(188));return s.stateNode.current===s?e:n}function Sp(e){return e=xm(e),e!==null?_p(e):null}function _p(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=_p(e);if(n!==null)return n;e=e.sibling}return null}var wp=Mt.unstable_scheduleCallback,Rc=Mt.unstable_cancelCallback,ym=Mt.unstable_shouldYield,vm=Mt.unstable_requestPaint,Ze=Mt.unstable_now,jm=Mt.unstable_getCurrentPriorityLevel,zd=Mt.unstable_ImmediatePriority,kp=Mt.unstable_UserBlockingPriority,Or=Mt.unstable_NormalPriority,bm=Mt.unstable_LowPriority,Cp=Mt.unstable_IdlePriority,li=null,In=null;function Sm(e){if(In&&typeof In.onCommitFiberRoot=="function")try{In.onCommitFiberRoot(li,e,void 0,(e.current.flags&128)===128)}catch{}}var mn=Math.clz32?Math.clz32:km,_m=Math.log,wm=Math.LN2;function km(e){return e>>>=0,e===0?32:31-(_m(e)/wm|0)|0}var nr=64,sr=4194304;function il(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Lr(e,n){var s=e.pendingLanes;if(s===0)return 0;var a=0,l=e.suspendedLanes,r=e.pingedLanes,i=s&268435455;if(i!==0){var d=i&~l;d!==0?a=il(d):(r&=i,r!==0&&(a=il(r)))}else i=s&~l,i!==0?a=il(i):r!==0&&(a=il(r));if(a===0)return 0;if(n!==0&&n!==a&&!(n&l)&&(l=a&-a,r=n&-n,l>=r||l===16&&(r&4194240)!==0))return n;if(a&4&&(a|=s&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=a;0<n;)s=31-mn(n),l=1<<s,a|=e[s],n&=~l;return a}function Cm(e,n){switch(e){case 1:case 2:case 4:return n+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 n+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 zm(e,n){for(var s=e.suspendedLanes,a=e.pingedLanes,l=e.expirationTimes,r=e.pendingLanes;0<r;){var i=31-mn(r),d=1<<i,f=l[i];f===-1?(!(d&s)||d&a)&&(l[i]=Cm(d,n)):f<=n&&(e.expiredLanes|=d),r&=~d}}function Wo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function zp(){var e=nr;return nr<<=1,!(nr&4194240)&&(nr=64),e}function Xi(e){for(var n=[],s=0;31>s;s++)n.push(e);return n}function Bl(e,n,s){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-mn(n),e[n]=s}function Im(e,n){var s=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var a=e.eventTimes;for(e=e.expirationTimes;0<s;){var l=31-mn(s),r=1<<l;n[l]=0,a[l]=-1,e[l]=-1,s&=~r}}function Id(e,n){var s=e.entangledLanes|=n;for(e=e.entanglements;s;){var a=31-mn(s),l=1<<a;l&n|e[a]&n&&(e[a]|=n),s&=~l}}var we=0;function Ip(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Ep,Ed,Tp,Ap,Pp,No=!1,ar=[],ss=null,as=null,ls=null,Sl=new Map,_l=new Map,Jn=[],Em="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 Dc(e,n){switch(e){case"focusin":case"focusout":ss=null;break;case"dragenter":case"dragleave":as=null;break;case"mouseover":case"mouseout":ls=null;break;case"pointerover":case"pointerout":Sl.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":_l.delete(n.pointerId)}}function Ja(e,n,s,a,l,r){return e===null||e.nativeEvent!==r?(e={blockedOn:n,domEventName:s,eventSystemFlags:a,nativeEvent:r,targetContainers:[l]},n!==null&&(n=Ul(n),n!==null&&Ed(n)),e):(e.eventSystemFlags|=a,n=e.targetContainers,l!==null&&n.indexOf(l)===-1&&n.push(l),e)}function Tm(e,n,s,a,l){switch(n){case"focusin":return ss=Ja(ss,e,n,s,a,l),!0;case"dragenter":return as=Ja(as,e,n,s,a,l),!0;case"mouseover":return ls=Ja(ls,e,n,s,a,l),!0;case"pointerover":var r=l.pointerId;return Sl.set(r,Ja(Sl.get(r)||null,e,n,s,a,l)),!0;case"gotpointercapture":return r=l.pointerId,_l.set(r,Ja(_l.get(r)||null,e,n,s,a,l)),!0}return!1}function Rp(e){var n=As(e.target);if(n!==null){var s=Hs(n);if(s!==null){if(n=s.tag,n===13){if(n=bp(s),n!==null){e.blockedOn=n,Pp(e.priority,function(){Tp(s)});return}}else if(n===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function br(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var s=Bo(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var a=new s.constructor(s.type,s);Ro=a,s.target.dispatchEvent(a),Ro=null}else return n=Ul(s),n!==null&&Ed(n),e.blockedOn=s,!1;n.shift()}return!0}function Oc(e,n,s){br(e)&&s.delete(n)}function Am(){No=!1,ss!==null&&br(ss)&&(ss=null),as!==null&&br(as)&&(as=null),ls!==null&&br(ls)&&(ls=null),Sl.forEach(Oc),_l.forEach(Oc)}function Va(e,n){e.blockedOn===n&&(e.blockedOn=null,No||(No=!0,Mt.unstable_scheduleCallback(Mt.unstable_NormalPriority,Am)))}function wl(e){function n(l){return Va(l,e)}if(0<ar.length){Va(ar[0],e);for(var s=1;s<ar.length;s++){var a=ar[s];a.blockedOn===e&&(a.blockedOn=null)}}for(ss!==null&&Va(ss,e),as!==null&&Va(as,e),ls!==null&&Va(ls,e),Sl.forEach(n),_l.forEach(n),s=0;s<Jn.length;s++)a=Jn[s],a.blockedOn===e&&(a.blockedOn=null);for(;0<Jn.length&&(s=Jn[0],s.blockedOn===null);)Rp(s),s.blockedOn===null&&Jn.shift()}var Ia=Qn.ReactCurrentBatchConfig,Wr=!0;function Pm(e,n,s,a){var l=we,r=Ia.transition;Ia.transition=null;try{we=1,Td(e,n,s,a)}finally{we=l,Ia.transition=r}}function Rm(e,n,s,a){var l=we,r=Ia.transition;Ia.transition=null;try{we=4,Td(e,n,s,a)}finally{we=l,Ia.transition=r}}function Td(e,n,s,a){if(Wr){var l=Bo(e,n,s,a);if(l===null)lo(e,n,a,Nr,s),Dc(e,a);else if(Tm(l,e,n,s,a))a.stopPropagation();else if(Dc(e,a),n&4&&-1<Em.indexOf(e)){for(;l!==null;){var r=Ul(l);if(r!==null&&Ep(r),r=Bo(e,n,s,a),r===null&&lo(e,n,a,Nr,s),r===l)break;l=r}l!==null&&a.stopPropagation()}else lo(e,n,a,null,s)}}var Nr=null;function Bo(e,n,s,a){if(Nr=null,e=Cd(a),e=As(e),e!==null)if(n=Hs(e),n===null)e=null;else if(s=n.tag,s===13){if(e=bp(n),e!==null)return e;e=null}else if(s===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return Nr=e,null}function Dp(e){switch(e){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(jm()){case zd:return 1;case kp:return 4;case Or:case bm:return 16;case Cp:return 536870912;default:return 16}default:return 16}}var Zn=null,Ad=null,Sr=null;function Op(){if(Sr)return Sr;var e,n=Ad,s=n.length,a,l="value"in Zn?Zn.value:Zn.textContent,r=l.length;for(e=0;e<s&&n[e]===l[e];e++);var i=s-e;for(a=1;a<=i&&n[s-a]===l[r-a];a++);return Sr=l.slice(e,1<a?1-a:void 0)}function _r(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function lr(){return!0}function Lc(){return!1}function Ht(e){function n(s,a,l,r,i){this._reactName=s,this._targetInst=l,this.type=a,this.nativeEvent=r,this.target=i,this.currentTarget=null;for(var d in e)e.hasOwnProperty(d)&&(s=e[d],this[d]=s?s(r):r[d]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?lr:Lc,this.isPropagationStopped=Lc,this}return $e(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=lr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=lr)},persist:function(){},isPersistent:lr}),n}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pd=Ht(Ua),$l=$e({},Ua,{view:0,detail:0}),Dm=Ht($l),qi,Ji,Za,ri=$e({},$l,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rd,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Za&&(Za&&e.type==="mousemove"?(qi=e.screenX-Za.screenX,Ji=e.screenY-Za.screenY):Ji=qi=0,Za=e),qi)},movementY:function(e){return"movementY"in e?e.movementY:Ji}}),Wc=Ht(ri),Om=$e({},ri,{dataTransfer:0}),Lm=Ht(Om),Wm=$e({},$l,{relatedTarget:0}),Vi=Ht(Wm),Nm=$e({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),Bm=Ht(Nm),$m=$e({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Um=Ht($m),Mm=$e({},Ua,{data:0}),Nc=Ht(Mm),Fm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Hm={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"},Gm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Qm(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Gm[e])?!!n[e]:!1}function Rd(){return Qm}var Km=$e({},$l,{key:function(e){if(e.key){var n=Fm[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=_r(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Hm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rd,charCode:function(e){return e.type==="keypress"?_r(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_r(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ym=Ht(Km),Xm=$e({},ri,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bc=Ht(Xm),qm=$e({},$l,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rd}),Jm=Ht(qm),Vm=$e({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),Zm=Ht(Vm),ex=$e({},ri,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),tx=Ht(ex),nx=[9,13,27,32],Dd=Mn&&"CompositionEvent"in window,pl=null;Mn&&"documentMode"in document&&(pl=document.documentMode);var sx=Mn&&"TextEvent"in window&&!pl,Lp=Mn&&(!Dd||pl&&8<pl&&11>=pl),$c=" ",Uc=!1;function Wp(e,n){switch(e){case"keyup":return nx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Np(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ha=!1;function ax(e,n){switch(e){case"compositionend":return Np(n);case"keypress":return n.which!==32?null:(Uc=!0,$c);case"textInput":return e=n.data,e===$c&&Uc?null:e;default:return null}}function lx(e,n){if(ha)return e==="compositionend"||!Dd&&Wp(e,n)?(e=Op(),Sr=Ad=Zn=null,ha=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Lp&&n.locale!=="ko"?null:n.data;default:return null}}var rx={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 Mc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!rx[e.type]:n==="textarea"}function Bp(e,n,s,a){mp(a),n=Br(n,"onChange"),0<n.length&&(s=new Pd("onChange","change",null,s,a),e.push({event:s,listeners:n}))}var fl=null,kl=null;function ix(e){qp(e,0)}function ii(e){var n=xa(e);if(dp(n))return e}function ox(e,n){if(e==="change")return n}var $p=!1;if(Mn){var Zi;if(Mn){var eo="oninput"in document;if(!eo){var Fc=document.createElement("div");Fc.setAttribute("oninput","return;"),eo=typeof Fc.oninput=="function"}Zi=eo}else Zi=!1;$p=Zi&&(!document.documentMode||9<document.documentMode)}function Hc(){fl&&(fl.detachEvent("onpropertychange",Up),kl=fl=null)}function Up(e){if(e.propertyName==="value"&&ii(kl)){var n=[];Bp(n,kl,e,Cd(e)),jp(ix,n)}}function dx(e,n,s){e==="focusin"?(Hc(),fl=n,kl=s,fl.attachEvent("onpropertychange",Up)):e==="focusout"&&Hc()}function cx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ii(kl)}function ux(e,n){if(e==="click")return ii(n)}function px(e,n){if(e==="input"||e==="change")return ii(n)}function fx(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:fx;function Cl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var s=Object.keys(e),a=Object.keys(n);if(s.length!==a.length)return!1;for(a=0;a<s.length;a++){var l=s[a];if(!bo.call(n,l)||!yn(e[l],n[l]))return!1}return!0}function Gc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Qc(e,n){var s=Gc(e);e=0;for(var a;s;){if(s.nodeType===3){if(a=e+s.textContent.length,e<=n&&a>=n)return{node:s,offset:n-e};e=a}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Gc(s)}}function Mp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Mp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Fp(){for(var e=window,n=Pr();n instanceof e.HTMLIFrameElement;){try{var s=typeof n.contentWindow.location.href=="string"}catch{s=!1}if(s)e=n.contentWindow;else break;n=Pr(e.document)}return n}function Od(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function hx(e){var n=Fp(),s=e.focusedElem,a=e.selectionRange;if(n!==s&&s&&s.ownerDocument&&Mp(s.ownerDocument.documentElement,s)){if(a!==null&&Od(s)){if(n=a.start,e=a.end,e===void 0&&(e=n),"selectionStart"in s)s.selectionStart=n,s.selectionEnd=Math.min(e,s.value.length);else if(e=(n=s.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var l=s.textContent.length,r=Math.min(a.start,l);a=a.end===void 0?r:Math.min(a.end,l),!e.extend&&r>a&&(l=a,a=r,r=l),l=Qc(s,r);var i=Qc(s,a);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(n=n.createRange(),n.setStart(l.node,l.offset),e.removeAllRanges(),r>a?(e.addRange(n),e.extend(i.node,i.offset)):(n.setEnd(i.node,i.offset),e.addRange(n)))}}for(n=[],e=s;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<n.length;s++)e=n[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gx=Mn&&"documentMode"in document&&11>=document.documentMode,ga=null,$o=null,hl=null,Uo=!1;function Kc(e,n,s){var a=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Uo||ga==null||ga!==Pr(a)||(a=ga,"selectionStart"in a&&Od(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),hl&&Cl(hl,a)||(hl=a,a=Br($o,"onSelect"),0<a.length&&(n=new Pd("onSelect","select",null,n,s),e.push({event:n,listeners:a}),n.target=ga)))}function rr(e,n){var s={};return s[e.toLowerCase()]=n.toLowerCase(),s["Webkit"+e]="webkit"+n,s["Moz"+e]="moz"+n,s}var ma={animationend:rr("Animation","AnimationEnd"),animationiteration:rr("Animation","AnimationIteration"),animationstart:rr("Animation","AnimationStart"),transitionend:rr("Transition","TransitionEnd")},to={},Hp={};Mn&&(Hp=document.createElement("div").style,"AnimationEvent"in window||(delete ma.animationend.animation,delete ma.animationiteration.animation,delete ma.animationstart.animation),"TransitionEvent"in window||delete ma.transitionend.transition);function oi(e){if(to[e])return to[e];if(!ma[e])return e;var n=ma[e],s;for(s in n)if(n.hasOwnProperty(s)&&s in Hp)return to[e]=n[s];return e}var Gp=oi("animationend"),Qp=oi("animationiteration"),Kp=oi("animationstart"),Yp=oi("transitionend"),Xp=new Map,Yc="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 hs(e,n){Xp.set(e,n),Fs(n,[e])}for(var no=0;no<Yc.length;no++){var so=Yc[no],mx=so.toLowerCase(),xx=so[0].toUpperCase()+so.slice(1);hs(mx,"on"+xx)}hs(Gp,"onAnimationEnd");hs(Qp,"onAnimationIteration");hs(Kp,"onAnimationStart");hs("dblclick","onDoubleClick");hs("focusin","onFocus");hs("focusout","onBlur");hs(Yp,"onTransitionEnd");Aa("onMouseEnter",["mouseout","mouseover"]);Aa("onMouseLeave",["mouseout","mouseover"]);Aa("onPointerEnter",["pointerout","pointerover"]);Aa("onPointerLeave",["pointerout","pointerover"]);Fs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Fs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Fs("onBeforeInput",["compositionend","keypress","textInput","paste"]);Fs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Fs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Fs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ol="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(" "),yx=new Set("cancel close invalid load scroll toggle".split(" ").concat(ol));function Xc(e,n,s){var a=e.type||"unknown-event";e.currentTarget=s,mm(a,n,void 0,e),e.currentTarget=null}function qp(e,n){n=(n&4)!==0;for(var s=0;s<e.length;s++){var a=e[s],l=a.event;a=a.listeners;e:{var r=void 0;if(n)for(var i=a.length-1;0<=i;i--){var d=a[i],f=d.instance,p=d.currentTarget;if(d=d.listener,f!==r&&l.isPropagationStopped())break e;Xc(l,d,p),r=f}else for(i=0;i<a.length;i++){if(d=a[i],f=d.instance,p=d.currentTarget,d=d.listener,f!==r&&l.isPropagationStopped())break e;Xc(l,d,p),r=f}}}if(Dr)throw e=Lo,Dr=!1,Lo=null,e}function Ae(e,n){var s=n[Qo];s===void 0&&(s=n[Qo]=new Set);var a=e+"__bubble";s.has(a)||(Jp(n,e,2,!1),s.add(a))}function ao(e,n,s){var a=0;n&&(a|=4),Jp(s,e,a,n)}var ir="_reactListening"+Math.random().toString(36).slice(2);function zl(e){if(!e[ir]){e[ir]=!0,ap.forEach(function(s){s!=="selectionchange"&&(yx.has(s)||ao(s,!1,e),ao(s,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[ir]||(n[ir]=!0,ao("selectionchange",!1,n))}}function Jp(e,n,s,a){switch(Dp(n)){case 1:var l=Pm;break;case 4:l=Rm;break;default:l=Td}s=l.bind(null,n,s,e),l=void 0,!Oo||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(l=!0),a?l!==void 0?e.addEventListener(n,s,{capture:!0,passive:l}):e.addEventListener(n,s,!0):l!==void 0?e.addEventListener(n,s,{passive:l}):e.addEventListener(n,s,!1)}function lo(e,n,s,a,l){var r=a;if(!(n&1)&&!(n&2)&&a!==null)e:for(;;){if(a===null)return;var i=a.tag;if(i===3||i===4){var d=a.stateNode.containerInfo;if(d===l||d.nodeType===8&&d.parentNode===l)break;if(i===4)for(i=a.return;i!==null;){var f=i.tag;if((f===3||f===4)&&(f=i.stateNode.containerInfo,f===l||f.nodeType===8&&f.parentNode===l))return;i=i.return}for(;d!==null;){if(i=As(d),i===null)return;if(f=i.tag,f===5||f===6){a=r=i;continue e}d=d.parentNode}}a=a.return}jp(function(){var p=r,C=Cd(s),j=[];e:{var _=Xp.get(e);if(_!==void 0){var c=Pd,y=e;switch(e){case"keypress":if(_r(s)===0)break e;case"keydown":case"keyup":c=Ym;break;case"focusin":y="focus",c=Vi;break;case"focusout":y="blur",c=Vi;break;case"beforeblur":case"afterblur":c=Vi;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=Wc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=Lm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Jm;break;case Gp:case Qp:case Kp:c=Bm;break;case Yp:c=Zm;break;case"scroll":c=Dm;break;case"wheel":c=tx;break;case"copy":case"cut":case"paste":c=Um;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Bc}var z=(n&4)!==0,k=!z&&e==="scroll",g=z?_!==null?_+"Capture":null:_;z=[];for(var o=p,h;o!==null;){h=o;var x=h.stateNode;if(h.tag===5&&x!==null&&(h=x,g!==null&&(x=bl(o,g),x!=null&&z.push(Il(o,x,h)))),k)break;o=o.return}0<z.length&&(_=new c(_,y,null,s,C),j.push({event:_,listeners:z}))}}if(!(n&7)){e:{if(_=e==="mouseover"||e==="pointerover",c=e==="mouseout"||e==="pointerout",_&&s!==Ro&&(y=s.relatedTarget||s.fromElement)&&(As(y)||y[Fn]))break e;if((c||_)&&(_=C.window===C?C:(_=C.ownerDocument)?_.defaultView||_.parentWindow:window,c?(y=s.relatedTarget||s.toElement,c=p,y=y?As(y):null,y!==null&&(k=Hs(y),y!==k||y.tag!==5&&y.tag!==6)&&(y=null)):(c=null,y=p),c!==y)){if(z=Wc,x="onMouseLeave",g="onMouseEnter",o="mouse",(e==="pointerout"||e==="pointerover")&&(z=Bc,x="onPointerLeave",g="onPointerEnter",o="pointer"),k=c==null?_:xa(c),h=y==null?_:xa(y),_=new z(x,o+"leave",c,s,C),_.target=k,_.relatedTarget=h,x=null,As(C)===p&&(z=new z(g,o+"enter",y,s,C),z.target=h,z.relatedTarget=k,x=z),k=x,c&&y)t:{for(z=c,g=y,o=0,h=z;h;h=na(h))o++;for(h=0,x=g;x;x=na(x))h++;for(;0<o-h;)z=na(z),o--;for(;0<h-o;)g=na(g),h--;for(;o--;){if(z===g||g!==null&&z===g.alternate)break t;z=na(z),g=na(g)}z=null}else z=null;c!==null&&qc(j,_,c,z,!1),y!==null&&k!==null&&qc(j,k,y,z,!0)}}e:{if(_=p?xa(p):window,c=_.nodeName&&_.nodeName.toLowerCase(),c==="select"||c==="input"&&_.type==="file")var v=ox;else if(Mc(_))if($p)v=px;else{v=cx;var w=dx}else(c=_.nodeName)&&c.toLowerCase()==="input"&&(_.type==="checkbox"||_.type==="radio")&&(v=ux);if(v&&(v=v(e,p))){Bp(j,v,s,C);break e}w&&w(e,_,p),e==="focusout"&&(w=_._wrapperState)&&w.controlled&&_.type==="number"&&Io(_,"number",_.value)}switch(w=p?xa(p):window,e){case"focusin":(Mc(w)||w.contentEditable==="true")&&(ga=w,$o=p,hl=null);break;case"focusout":hl=$o=ga=null;break;case"mousedown":Uo=!0;break;case"contextmenu":case"mouseup":case"dragend":Uo=!1,Kc(j,s,C);break;case"selectionchange":if(gx)break;case"keydown":case"keyup":Kc(j,s,C)}var u;if(Dd)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else ha?Wp(e,s)&&(b="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(b="onCompositionStart");b&&(Lp&&s.locale!=="ko"&&(ha||b!=="onCompositionStart"?b==="onCompositionEnd"&&ha&&(u=Op()):(Zn=C,Ad="value"in Zn?Zn.value:Zn.textContent,ha=!0)),w=Br(p,b),0<w.length&&(b=new Nc(b,e,null,s,C),j.push({event:b,listeners:w}),u?b.data=u:(u=Np(s),u!==null&&(b.data=u)))),(u=sx?ax(e,s):lx(e,s))&&(p=Br(p,"onBeforeInput"),0<p.length&&(C=new Nc("onBeforeInput","beforeinput",null,s,C),j.push({event:C,listeners:p}),C.data=u))}qp(j,n)})}function Il(e,n,s){return{instance:e,listener:n,currentTarget:s}}function Br(e,n){for(var s=n+"Capture",a=[];e!==null;){var l=e,r=l.stateNode;l.tag===5&&r!==null&&(l=r,r=bl(e,s),r!=null&&a.unshift(Il(e,r,l)),r=bl(e,n),r!=null&&a.push(Il(e,r,l))),e=e.return}return a}function na(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function qc(e,n,s,a,l){for(var r=n._reactName,i=[];s!==null&&s!==a;){var d=s,f=d.alternate,p=d.stateNode;if(f!==null&&f===a)break;d.tag===5&&p!==null&&(d=p,l?(f=bl(s,r),f!=null&&i.unshift(Il(s,f,d))):l||(f=bl(s,r),f!=null&&i.push(Il(s,f,d)))),s=s.return}i.length!==0&&e.push({event:n,listeners:i})}var vx=/\r\n?/g,jx=/\u0000|\uFFFD/g;function Jc(e){return(typeof e=="string"?e:""+e).replace(vx,`
|
||
`).replace(jx,"")}function or(e,n,s){if(n=Jc(n),Jc(e)!==n&&s)throw Error(q(425))}function $r(){}var Mo=null,Fo=null;function Ho(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Go=typeof setTimeout=="function"?setTimeout:void 0,bx=typeof clearTimeout=="function"?clearTimeout:void 0,Vc=typeof Promise=="function"?Promise:void 0,Sx=typeof queueMicrotask=="function"?queueMicrotask:typeof Vc<"u"?function(e){return Vc.resolve(null).then(e).catch(_x)}:Go;function _x(e){setTimeout(function(){throw e})}function ro(e,n){var s=n,a=0;do{var l=s.nextSibling;if(e.removeChild(s),l&&l.nodeType===8)if(s=l.data,s==="/$"){if(a===0){e.removeChild(l),wl(n);return}a--}else s!=="$"&&s!=="$?"&&s!=="$!"||a++;s=l}while(s);wl(n)}function rs(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function Zc(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(n===0)return e;n--}else s==="/$"&&n++}e=e.previousSibling}return null}var Ma=Math.random().toString(36).slice(2),zn="__reactFiber$"+Ma,El="__reactProps$"+Ma,Fn="__reactContainer$"+Ma,Qo="__reactEvents$"+Ma,wx="__reactListeners$"+Ma,kx="__reactHandles$"+Ma;function As(e){var n=e[zn];if(n)return n;for(var s=e.parentNode;s;){if(n=s[Fn]||s[zn]){if(s=n.alternate,n.child!==null||s!==null&&s.child!==null)for(e=Zc(e);e!==null;){if(s=e[zn])return s;e=Zc(e)}return n}e=s,s=e.parentNode}return null}function Ul(e){return e=e[zn]||e[Fn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function xa(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(q(33))}function di(e){return e[El]||null}var Ko=[],ya=-1;function gs(e){return{current:e}}function Pe(e){0>ya||(e.current=Ko[ya],Ko[ya]=null,ya--)}function Ie(e,n){ya++,Ko[ya]=e.current,e.current=n}var ps={},jt=gs(ps),Rt=gs(!1),Ws=ps;function Pa(e,n){var s=e.type.contextTypes;if(!s)return ps;var a=e.stateNode;if(a&&a.__reactInternalMemoizedUnmaskedChildContext===n)return a.__reactInternalMemoizedMaskedChildContext;var l={},r;for(r in s)l[r]=n[r];return a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=l),l}function Dt(e){return e=e.childContextTypes,e!=null}function Ur(){Pe(Rt),Pe(jt)}function eu(e,n,s){if(jt.current!==ps)throw Error(q(168));Ie(jt,n),Ie(Rt,s)}function Vp(e,n,s){var a=e.stateNode;if(n=n.childContextTypes,typeof a.getChildContext!="function")return s;a=a.getChildContext();for(var l in a)if(!(l in n))throw Error(q(108,dm(e)||"Unknown",l));return $e({},s,a)}function Mr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ps,Ws=jt.current,Ie(jt,e),Ie(Rt,Rt.current),!0}function tu(e,n,s){var a=e.stateNode;if(!a)throw Error(q(169));s?(e=Vp(e,n,Ws),a.__reactInternalMemoizedMergedChildContext=e,Pe(Rt),Pe(jt),Ie(jt,e)):Pe(Rt),Ie(Rt,s)}var Nn=null,ci=!1,io=!1;function Zp(e){Nn===null?Nn=[e]:Nn.push(e)}function Cx(e){ci=!0,Zp(e)}function ms(){if(!io&&Nn!==null){io=!0;var e=0,n=we;try{var s=Nn;for(we=1;e<s.length;e++){var a=s[e];do a=a(!0);while(a!==null)}Nn=null,ci=!1}catch(l){throw Nn!==null&&(Nn=Nn.slice(e+1)),wp(zd,ms),l}finally{we=n,io=!1}}return null}var va=[],ja=0,Fr=null,Hr=0,qt=[],Jt=0,Ns=null,Bn=1,$n="";function Es(e,n){va[ja++]=Hr,va[ja++]=Fr,Fr=e,Hr=n}function ef(e,n,s){qt[Jt++]=Bn,qt[Jt++]=$n,qt[Jt++]=Ns,Ns=e;var a=Bn;e=$n;var l=32-mn(a)-1;a&=~(1<<l),s+=1;var r=32-mn(n)+l;if(30<r){var i=l-l%5;r=(a&(1<<i)-1).toString(32),a>>=i,l-=i,Bn=1<<32-mn(n)+l|s<<l|a,$n=r+e}else Bn=1<<r|s<<l|a,$n=e}function Ld(e){e.return!==null&&(Es(e,1),ef(e,1,0))}function Wd(e){for(;e===Fr;)Fr=va[--ja],va[ja]=null,Hr=va[--ja],va[ja]=null;for(;e===Ns;)Ns=qt[--Jt],qt[Jt]=null,$n=qt[--Jt],qt[Jt]=null,Bn=qt[--Jt],qt[Jt]=null}var Ut=null,$t=null,Le=!1,gn=null;function tf(e,n){var s=Vt(5,null,null,0);s.elementType="DELETED",s.stateNode=n,s.return=e,n=e.deletions,n===null?(e.deletions=[s],e.flags|=16):n.push(s)}function nu(e,n){switch(e.tag){case 5:var s=e.type;return n=n.nodeType!==1||s.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,Ut=e,$t=rs(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Ut=e,$t=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(s=Ns!==null?{id:Bn,overflow:$n}:null,e.memoizedState={dehydrated:n,treeContext:s,retryLane:1073741824},s=Vt(18,null,null,0),s.stateNode=n,s.return=e,e.child=s,Ut=e,$t=null,!0):!1;default:return!1}}function Yo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Xo(e){if(Le){var n=$t;if(n){var s=n;if(!nu(e,n)){if(Yo(e))throw Error(q(418));n=rs(s.nextSibling);var a=Ut;n&&nu(e,n)?tf(a,s):(e.flags=e.flags&-4097|2,Le=!1,Ut=e)}}else{if(Yo(e))throw Error(q(418));e.flags=e.flags&-4097|2,Le=!1,Ut=e}}}function su(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ut=e}function dr(e){if(e!==Ut)return!1;if(!Le)return su(e),Le=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!Ho(e.type,e.memoizedProps)),n&&(n=$t)){if(Yo(e))throw nf(),Error(q(418));for(;n;)tf(e,n),n=rs(n.nextSibling)}if(su(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(q(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(n===0){$t=rs(e.nextSibling);break e}n--}else s!=="$"&&s!=="$!"&&s!=="$?"||n++}e=e.nextSibling}$t=null}}else $t=Ut?rs(e.stateNode.nextSibling):null;return!0}function nf(){for(var e=$t;e;)e=rs(e.nextSibling)}function Ra(){$t=Ut=null,Le=!1}function Nd(e){gn===null?gn=[e]:gn.push(e)}var zx=Qn.ReactCurrentBatchConfig;function el(e,n,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(q(309));var a=s.stateNode}if(!a)throw Error(q(147,e));var l=a,r=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===r?n.ref:(n=function(i){var d=l.refs;i===null?delete d[r]:d[r]=i},n._stringRef=r,n)}if(typeof e!="string")throw Error(q(284));if(!s._owner)throw Error(q(290,e))}return e}function cr(e,n){throw e=Object.prototype.toString.call(n),Error(q(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function au(e){var n=e._init;return n(e._payload)}function sf(e){function n(g,o){if(e){var h=g.deletions;h===null?(g.deletions=[o],g.flags|=16):h.push(o)}}function s(g,o){if(!e)return null;for(;o!==null;)n(g,o),o=o.sibling;return null}function a(g,o){for(g=new Map;o!==null;)o.key!==null?g.set(o.key,o):g.set(o.index,o),o=o.sibling;return g}function l(g,o){return g=cs(g,o),g.index=0,g.sibling=null,g}function r(g,o,h){return g.index=h,e?(h=g.alternate,h!==null?(h=h.index,h<o?(g.flags|=2,o):h):(g.flags|=2,o)):(g.flags|=1048576,o)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function d(g,o,h,x){return o===null||o.tag!==6?(o=go(h,g.mode,x),o.return=g,o):(o=l(o,h),o.return=g,o)}function f(g,o,h,x){var v=h.type;return v===fa?C(g,o,h.props.children,x,h.key):o!==null&&(o.elementType===v||typeof v=="object"&&v!==null&&v.$$typeof===Xn&&au(v)===o.type)?(x=l(o,h.props),x.ref=el(g,o,h),x.return=g,x):(x=Tr(h.type,h.key,h.props,null,g.mode,x),x.ref=el(g,o,h),x.return=g,x)}function p(g,o,h,x){return o===null||o.tag!==4||o.stateNode.containerInfo!==h.containerInfo||o.stateNode.implementation!==h.implementation?(o=mo(h,g.mode,x),o.return=g,o):(o=l(o,h.children||[]),o.return=g,o)}function C(g,o,h,x,v){return o===null||o.tag!==7?(o=Ls(h,g.mode,x,v),o.return=g,o):(o=l(o,h),o.return=g,o)}function j(g,o,h){if(typeof o=="string"&&o!==""||typeof o=="number")return o=go(""+o,g.mode,h),o.return=g,o;if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Zl:return h=Tr(o.type,o.key,o.props,null,g.mode,h),h.ref=el(g,null,o),h.return=g,h;case pa:return o=mo(o,g.mode,h),o.return=g,o;case Xn:var x=o._init;return j(g,x(o._payload),h)}if(rl(o)||Xa(o))return o=Ls(o,g.mode,h,null),o.return=g,o;cr(g,o)}return null}function _(g,o,h,x){var v=o!==null?o.key:null;if(typeof h=="string"&&h!==""||typeof h=="number")return v!==null?null:d(g,o,""+h,x);if(typeof h=="object"&&h!==null){switch(h.$$typeof){case Zl:return h.key===v?f(g,o,h,x):null;case pa:return h.key===v?p(g,o,h,x):null;case Xn:return v=h._init,_(g,o,v(h._payload),x)}if(rl(h)||Xa(h))return v!==null?null:C(g,o,h,x,null);cr(g,h)}return null}function c(g,o,h,x,v){if(typeof x=="string"&&x!==""||typeof x=="number")return g=g.get(h)||null,d(o,g,""+x,v);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Zl:return g=g.get(x.key===null?h:x.key)||null,f(o,g,x,v);case pa:return g=g.get(x.key===null?h:x.key)||null,p(o,g,x,v);case Xn:var w=x._init;return c(g,o,h,w(x._payload),v)}if(rl(x)||Xa(x))return g=g.get(h)||null,C(o,g,x,v,null);cr(o,x)}return null}function y(g,o,h,x){for(var v=null,w=null,u=o,b=o=0,T=null;u!==null&&b<h.length;b++){u.index>b?(T=u,u=null):T=u.sibling;var E=_(g,u,h[b],x);if(E===null){u===null&&(u=T);break}e&&u&&E.alternate===null&&n(g,u),o=r(E,o,b),w===null?v=E:w.sibling=E,w=E,u=T}if(b===h.length)return s(g,u),Le&&Es(g,b),v;if(u===null){for(;b<h.length;b++)u=j(g,h[b],x),u!==null&&(o=r(u,o,b),w===null?v=u:w.sibling=u,w=u);return Le&&Es(g,b),v}for(u=a(g,u);b<h.length;b++)T=c(u,g,b,h[b],x),T!==null&&(e&&T.alternate!==null&&u.delete(T.key===null?b:T.key),o=r(T,o,b),w===null?v=T:w.sibling=T,w=T);return e&&u.forEach(function(F){return n(g,F)}),Le&&Es(g,b),v}function z(g,o,h,x){var v=Xa(h);if(typeof v!="function")throw Error(q(150));if(h=v.call(h),h==null)throw Error(q(151));for(var w=v=null,u=o,b=o=0,T=null,E=h.next();u!==null&&!E.done;b++,E=h.next()){u.index>b?(T=u,u=null):T=u.sibling;var F=_(g,u,E.value,x);if(F===null){u===null&&(u=T);break}e&&u&&F.alternate===null&&n(g,u),o=r(F,o,b),w===null?v=F:w.sibling=F,w=F,u=T}if(E.done)return s(g,u),Le&&Es(g,b),v;if(u===null){for(;!E.done;b++,E=h.next())E=j(g,E.value,x),E!==null&&(o=r(E,o,b),w===null?v=E:w.sibling=E,w=E);return Le&&Es(g,b),v}for(u=a(g,u);!E.done;b++,E=h.next())E=c(u,g,b,E.value,x),E!==null&&(e&&E.alternate!==null&&u.delete(E.key===null?b:E.key),o=r(E,o,b),w===null?v=E:w.sibling=E,w=E);return e&&u.forEach(function(Q){return n(g,Q)}),Le&&Es(g,b),v}function k(g,o,h,x){if(typeof h=="object"&&h!==null&&h.type===fa&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Zl:e:{for(var v=h.key,w=o;w!==null;){if(w.key===v){if(v=h.type,v===fa){if(w.tag===7){s(g,w.sibling),o=l(w,h.props.children),o.return=g,g=o;break e}}else if(w.elementType===v||typeof v=="object"&&v!==null&&v.$$typeof===Xn&&au(v)===w.type){s(g,w.sibling),o=l(w,h.props),o.ref=el(g,w,h),o.return=g,g=o;break e}s(g,w);break}else n(g,w);w=w.sibling}h.type===fa?(o=Ls(h.props.children,g.mode,x,h.key),o.return=g,g=o):(x=Tr(h.type,h.key,h.props,null,g.mode,x),x.ref=el(g,o,h),x.return=g,g=x)}return i(g);case pa:e:{for(w=h.key;o!==null;){if(o.key===w)if(o.tag===4&&o.stateNode.containerInfo===h.containerInfo&&o.stateNode.implementation===h.implementation){s(g,o.sibling),o=l(o,h.children||[]),o.return=g,g=o;break e}else{s(g,o);break}else n(g,o);o=o.sibling}o=mo(h,g.mode,x),o.return=g,g=o}return i(g);case Xn:return w=h._init,k(g,o,w(h._payload),x)}if(rl(h))return y(g,o,h,x);if(Xa(h))return z(g,o,h,x);cr(g,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,o!==null&&o.tag===6?(s(g,o.sibling),o=l(o,h),o.return=g,g=o):(s(g,o),o=go(h,g.mode,x),o.return=g,g=o),i(g)):s(g,o)}return k}var Da=sf(!0),af=sf(!1),Gr=gs(null),Qr=null,ba=null,Bd=null;function $d(){Bd=ba=Qr=null}function Ud(e){var n=Gr.current;Pe(Gr),e._currentValue=n}function qo(e,n,s){for(;e!==null;){var a=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,a!==null&&(a.childLanes|=n)):a!==null&&(a.childLanes&n)!==n&&(a.childLanes|=n),e===s)break;e=e.return}}function Ea(e,n){Qr=e,Bd=ba=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&n&&(Pt=!0),e.firstContext=null)}function tn(e){var n=e._currentValue;if(Bd!==e)if(e={context:e,memoizedValue:n,next:null},ba===null){if(Qr===null)throw Error(q(308));ba=e,Qr.dependencies={lanes:0,firstContext:e}}else ba=ba.next=e;return n}var Ps=null;function Md(e){Ps===null?Ps=[e]:Ps.push(e)}function lf(e,n,s,a){var l=n.interleaved;return l===null?(s.next=s,Md(n)):(s.next=l.next,l.next=s),n.interleaved=s,Hn(e,a)}function Hn(e,n){e.lanes|=n;var s=e.alternate;for(s!==null&&(s.lanes|=n),s=e,e=e.return;e!==null;)e.childLanes|=n,s=e.alternate,s!==null&&(s.childLanes|=n),s=e,e=e.return;return s.tag===3?s.stateNode:null}var qn=!1;function Fd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function rf(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Un(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function is(e,n,s){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,ve&2){var l=a.pending;return l===null?n.next=n:(n.next=l.next,l.next=n),a.pending=n,Hn(e,s)}return l=a.interleaved,l===null?(n.next=n,Md(a)):(n.next=l.next,l.next=n),a.interleaved=n,Hn(e,s)}function wr(e,n,s){if(n=n.updateQueue,n!==null&&(n=n.shared,(s&4194240)!==0)){var a=n.lanes;a&=e.pendingLanes,s|=a,n.lanes=s,Id(e,s)}}function lu(e,n){var s=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,s===a)){var l=null,r=null;if(s=s.firstBaseUpdate,s!==null){do{var i={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};r===null?l=r=i:r=r.next=i,s=s.next}while(s!==null);r===null?l=r=n:r=r.next=n}else l=r=n;s={baseState:a.baseState,firstBaseUpdate:l,lastBaseUpdate:r,shared:a.shared,effects:a.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=n:e.next=n,s.lastBaseUpdate=n}function Kr(e,n,s,a){var l=e.updateQueue;qn=!1;var r=l.firstBaseUpdate,i=l.lastBaseUpdate,d=l.shared.pending;if(d!==null){l.shared.pending=null;var f=d,p=f.next;f.next=null,i===null?r=p:i.next=p,i=f;var C=e.alternate;C!==null&&(C=C.updateQueue,d=C.lastBaseUpdate,d!==i&&(d===null?C.firstBaseUpdate=p:d.next=p,C.lastBaseUpdate=f))}if(r!==null){var j=l.baseState;i=0,C=p=f=null,d=r;do{var _=d.lane,c=d.eventTime;if((a&_)===_){C!==null&&(C=C.next={eventTime:c,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var y=e,z=d;switch(_=n,c=s,z.tag){case 1:if(y=z.payload,typeof y=="function"){j=y.call(c,j,_);break e}j=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=z.payload,_=typeof y=="function"?y.call(c,j,_):y,_==null)break e;j=$e({},j,_);break e;case 2:qn=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,_=l.effects,_===null?l.effects=[d]:_.push(d))}else c={eventTime:c,lane:_,tag:d.tag,payload:d.payload,callback:d.callback,next:null},C===null?(p=C=c,f=j):C=C.next=c,i|=_;if(d=d.next,d===null){if(d=l.shared.pending,d===null)break;_=d,d=_.next,_.next=null,l.lastBaseUpdate=_,l.shared.pending=null}}while(!0);if(C===null&&(f=j),l.baseState=f,l.firstBaseUpdate=p,l.lastBaseUpdate=C,n=l.shared.interleaved,n!==null){l=n;do i|=l.lane,l=l.next;while(l!==n)}else r===null&&(l.shared.lanes=0);$s|=i,e.lanes=i,e.memoizedState=j}}function ru(e,n,s){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var a=e[n],l=a.callback;if(l!==null){if(a.callback=null,a=s,typeof l!="function")throw Error(q(191,l));l.call(a)}}}var Ml={},En=gs(Ml),Tl=gs(Ml),Al=gs(Ml);function Rs(e){if(e===Ml)throw Error(q(174));return e}function Hd(e,n){switch(Ie(Al,n),Ie(Tl,e),Ie(En,Ml),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:To(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=To(n,e)}Pe(En),Ie(En,n)}function Oa(){Pe(En),Pe(Tl),Pe(Al)}function of(e){Rs(Al.current);var n=Rs(En.current),s=To(n,e.type);n!==s&&(Ie(Tl,e),Ie(En,s))}function Gd(e){Tl.current===e&&(Pe(En),Pe(Tl))}var Ne=gs(0);function Yr(e){for(var n=e;n!==null;){if(n.tag===13){var s=n.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if(n.flags&128)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var oo=[];function Qd(){for(var e=0;e<oo.length;e++)oo[e]._workInProgressVersionPrimary=null;oo.length=0}var kr=Qn.ReactCurrentDispatcher,co=Qn.ReactCurrentBatchConfig,Bs=0,Be=null,rt=null,ct=null,Xr=!1,gl=!1,Pl=0,Ix=0;function xt(){throw Error(q(321))}function Kd(e,n){if(n===null)return!1;for(var s=0;s<n.length&&s<e.length;s++)if(!yn(e[s],n[s]))return!1;return!0}function Yd(e,n,s,a,l,r){if(Bs=r,Be=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,kr.current=e===null||e.memoizedState===null?Px:Rx,e=s(a,l),gl){r=0;do{if(gl=!1,Pl=0,25<=r)throw Error(q(301));r+=1,ct=rt=null,n.updateQueue=null,kr.current=Dx,e=s(a,l)}while(gl)}if(kr.current=qr,n=rt!==null&&rt.next!==null,Bs=0,ct=rt=Be=null,Xr=!1,n)throw Error(q(300));return e}function Xd(){var e=Pl!==0;return Pl=0,e}function Cn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ct===null?Be.memoizedState=ct=e:ct=ct.next=e,ct}function nn(){if(rt===null){var e=Be.alternate;e=e!==null?e.memoizedState:null}else e=rt.next;var n=ct===null?Be.memoizedState:ct.next;if(n!==null)ct=n,rt=e;else{if(e===null)throw Error(q(310));rt=e,e={memoizedState:rt.memoizedState,baseState:rt.baseState,baseQueue:rt.baseQueue,queue:rt.queue,next:null},ct===null?Be.memoizedState=ct=e:ct=ct.next=e}return ct}function Rl(e,n){return typeof n=="function"?n(e):n}function uo(e){var n=nn(),s=n.queue;if(s===null)throw Error(q(311));s.lastRenderedReducer=e;var a=rt,l=a.baseQueue,r=s.pending;if(r!==null){if(l!==null){var i=l.next;l.next=r.next,r.next=i}a.baseQueue=l=r,s.pending=null}if(l!==null){r=l.next,a=a.baseState;var d=i=null,f=null,p=r;do{var C=p.lane;if((Bs&C)===C)f!==null&&(f=f.next={lane:0,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null}),a=p.hasEagerState?p.eagerState:e(a,p.action);else{var j={lane:C,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null};f===null?(d=f=j,i=a):f=f.next=j,Be.lanes|=C,$s|=C}p=p.next}while(p!==null&&p!==r);f===null?i=a:f.next=d,yn(a,n.memoizedState)||(Pt=!0),n.memoizedState=a,n.baseState=i,n.baseQueue=f,s.lastRenderedState=a}if(e=s.interleaved,e!==null){l=e;do r=l.lane,Be.lanes|=r,$s|=r,l=l.next;while(l!==e)}else l===null&&(s.lanes=0);return[n.memoizedState,s.dispatch]}function po(e){var n=nn(),s=n.queue;if(s===null)throw Error(q(311));s.lastRenderedReducer=e;var a=s.dispatch,l=s.pending,r=n.memoizedState;if(l!==null){s.pending=null;var i=l=l.next;do r=e(r,i.action),i=i.next;while(i!==l);yn(r,n.memoizedState)||(Pt=!0),n.memoizedState=r,n.baseQueue===null&&(n.baseState=r),s.lastRenderedState=r}return[r,a]}function df(){}function cf(e,n){var s=Be,a=nn(),l=n(),r=!yn(a.memoizedState,l);if(r&&(a.memoizedState=l,Pt=!0),a=a.queue,qd(ff.bind(null,s,a,e),[e]),a.getSnapshot!==n||r||ct!==null&&ct.memoizedState.tag&1){if(s.flags|=2048,Dl(9,pf.bind(null,s,a,l,n),void 0,null),ut===null)throw Error(q(349));Bs&30||uf(s,n,l)}return l}function uf(e,n,s){e.flags|=16384,e={getSnapshot:n,value:s},n=Be.updateQueue,n===null?(n={lastEffect:null,stores:null},Be.updateQueue=n,n.stores=[e]):(s=n.stores,s===null?n.stores=[e]:s.push(e))}function pf(e,n,s,a){n.value=s,n.getSnapshot=a,hf(n)&&gf(e)}function ff(e,n,s){return s(function(){hf(n)&&gf(e)})}function hf(e){var n=e.getSnapshot;e=e.value;try{var s=n();return!yn(e,s)}catch{return!0}}function gf(e){var n=Hn(e,1);n!==null&&xn(n,e,1,-1)}function iu(e){var n=Cn();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Rl,lastRenderedState:e},n.queue=e,e=e.dispatch=Ax.bind(null,Be,e),[n.memoizedState,e]}function Dl(e,n,s,a){return e={tag:e,create:n,destroy:s,deps:a,next:null},n=Be.updateQueue,n===null?(n={lastEffect:null,stores:null},Be.updateQueue=n,n.lastEffect=e.next=e):(s=n.lastEffect,s===null?n.lastEffect=e.next=e:(a=s.next,s.next=e,e.next=a,n.lastEffect=e)),e}function mf(){return nn().memoizedState}function Cr(e,n,s,a){var l=Cn();Be.flags|=e,l.memoizedState=Dl(1|n,s,void 0,a===void 0?null:a)}function ui(e,n,s,a){var l=nn();a=a===void 0?null:a;var r=void 0;if(rt!==null){var i=rt.memoizedState;if(r=i.destroy,a!==null&&Kd(a,i.deps)){l.memoizedState=Dl(n,s,r,a);return}}Be.flags|=e,l.memoizedState=Dl(1|n,s,r,a)}function ou(e,n){return Cr(8390656,8,e,n)}function qd(e,n){return ui(2048,8,e,n)}function xf(e,n){return ui(4,2,e,n)}function yf(e,n){return ui(4,4,e,n)}function vf(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function jf(e,n,s){return s=s!=null?s.concat([e]):null,ui(4,4,vf.bind(null,n,e),s)}function Jd(){}function bf(e,n){var s=nn();n=n===void 0?null:n;var a=s.memoizedState;return a!==null&&n!==null&&Kd(n,a[1])?a[0]:(s.memoizedState=[e,n],e)}function Sf(e,n){var s=nn();n=n===void 0?null:n;var a=s.memoizedState;return a!==null&&n!==null&&Kd(n,a[1])?a[0]:(e=e(),s.memoizedState=[e,n],e)}function _f(e,n,s){return Bs&21?(yn(s,n)||(s=zp(),Be.lanes|=s,$s|=s,e.baseState=!0),n):(e.baseState&&(e.baseState=!1,Pt=!0),e.memoizedState=s)}function Ex(e,n){var s=we;we=s!==0&&4>s?s:4,e(!0);var a=co.transition;co.transition={};try{e(!1),n()}finally{we=s,co.transition=a}}function wf(){return nn().memoizedState}function Tx(e,n,s){var a=ds(e);if(s={lane:a,action:s,hasEagerState:!1,eagerState:null,next:null},kf(e))Cf(n,s);else if(s=lf(e,n,s,a),s!==null){var l=Ct();xn(s,e,a,l),zf(s,n,a)}}function Ax(e,n,s){var a=ds(e),l={lane:a,action:s,hasEagerState:!1,eagerState:null,next:null};if(kf(e))Cf(n,l);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=n.lastRenderedReducer,r!==null))try{var i=n.lastRenderedState,d=r(i,s);if(l.hasEagerState=!0,l.eagerState=d,yn(d,i)){var f=n.interleaved;f===null?(l.next=l,Md(n)):(l.next=f.next,f.next=l),n.interleaved=l;return}}catch{}finally{}s=lf(e,n,l,a),s!==null&&(l=Ct(),xn(s,e,a,l),zf(s,n,a))}}function kf(e){var n=e.alternate;return e===Be||n!==null&&n===Be}function Cf(e,n){gl=Xr=!0;var s=e.pending;s===null?n.next=n:(n.next=s.next,s.next=n),e.pending=n}function zf(e,n,s){if(s&4194240){var a=n.lanes;a&=e.pendingLanes,s|=a,n.lanes=s,Id(e,s)}}var qr={readContext:tn,useCallback:xt,useContext:xt,useEffect:xt,useImperativeHandle:xt,useInsertionEffect:xt,useLayoutEffect:xt,useMemo:xt,useReducer:xt,useRef:xt,useState:xt,useDebugValue:xt,useDeferredValue:xt,useTransition:xt,useMutableSource:xt,useSyncExternalStore:xt,useId:xt,unstable_isNewReconciler:!1},Px={readContext:tn,useCallback:function(e,n){return Cn().memoizedState=[e,n===void 0?null:n],e},useContext:tn,useEffect:ou,useImperativeHandle:function(e,n,s){return s=s!=null?s.concat([e]):null,Cr(4194308,4,vf.bind(null,n,e),s)},useLayoutEffect:function(e,n){return Cr(4194308,4,e,n)},useInsertionEffect:function(e,n){return Cr(4,2,e,n)},useMemo:function(e,n){var s=Cn();return n=n===void 0?null:n,e=e(),s.memoizedState=[e,n],e},useReducer:function(e,n,s){var a=Cn();return n=s!==void 0?s(n):n,a.memoizedState=a.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},a.queue=e,e=e.dispatch=Tx.bind(null,Be,e),[a.memoizedState,e]},useRef:function(e){var n=Cn();return e={current:e},n.memoizedState=e},useState:iu,useDebugValue:Jd,useDeferredValue:function(e){return Cn().memoizedState=e},useTransition:function(){var e=iu(!1),n=e[0];return e=Ex.bind(null,e[1]),Cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,s){var a=Be,l=Cn();if(Le){if(s===void 0)throw Error(q(407));s=s()}else{if(s=n(),ut===null)throw Error(q(349));Bs&30||uf(a,n,s)}l.memoizedState=s;var r={value:s,getSnapshot:n};return l.queue=r,ou(ff.bind(null,a,r,e),[e]),a.flags|=2048,Dl(9,pf.bind(null,a,r,s,n),void 0,null),s},useId:function(){var e=Cn(),n=ut.identifierPrefix;if(Le){var s=$n,a=Bn;s=(a&~(1<<32-mn(a)-1)).toString(32)+s,n=":"+n+"R"+s,s=Pl++,0<s&&(n+="H"+s.toString(32)),n+=":"}else s=Ix++,n=":"+n+"r"+s.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Rx={readContext:tn,useCallback:bf,useContext:tn,useEffect:qd,useImperativeHandle:jf,useInsertionEffect:xf,useLayoutEffect:yf,useMemo:Sf,useReducer:uo,useRef:mf,useState:function(){return uo(Rl)},useDebugValue:Jd,useDeferredValue:function(e){var n=nn();return _f(n,rt.memoizedState,e)},useTransition:function(){var e=uo(Rl)[0],n=nn().memoizedState;return[e,n]},useMutableSource:df,useSyncExternalStore:cf,useId:wf,unstable_isNewReconciler:!1},Dx={readContext:tn,useCallback:bf,useContext:tn,useEffect:qd,useImperativeHandle:jf,useInsertionEffect:xf,useLayoutEffect:yf,useMemo:Sf,useReducer:po,useRef:mf,useState:function(){return po(Rl)},useDebugValue:Jd,useDeferredValue:function(e){var n=nn();return rt===null?n.memoizedState=e:_f(n,rt.memoizedState,e)},useTransition:function(){var e=po(Rl)[0],n=nn().memoizedState;return[e,n]},useMutableSource:df,useSyncExternalStore:cf,useId:wf,unstable_isNewReconciler:!1};function fn(e,n){if(e&&e.defaultProps){n=$e({},n),e=e.defaultProps;for(var s in e)n[s]===void 0&&(n[s]=e[s]);return n}return n}function Jo(e,n,s,a){n=e.memoizedState,s=s(a,n),s=s==null?n:$e({},n,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var pi={isMounted:function(e){return(e=e._reactInternals)?Hs(e)===e:!1},enqueueSetState:function(e,n,s){e=e._reactInternals;var a=Ct(),l=ds(e),r=Un(a,l);r.payload=n,s!=null&&(r.callback=s),n=is(e,r,l),n!==null&&(xn(n,e,l,a),wr(n,e,l))},enqueueReplaceState:function(e,n,s){e=e._reactInternals;var a=Ct(),l=ds(e),r=Un(a,l);r.tag=1,r.payload=n,s!=null&&(r.callback=s),n=is(e,r,l),n!==null&&(xn(n,e,l,a),wr(n,e,l))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var s=Ct(),a=ds(e),l=Un(s,a);l.tag=2,n!=null&&(l.callback=n),n=is(e,l,a),n!==null&&(xn(n,e,a,s),wr(n,e,a))}};function du(e,n,s,a,l,r,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,r,i):n.prototype&&n.prototype.isPureReactComponent?!Cl(s,a)||!Cl(l,r):!0}function If(e,n,s){var a=!1,l=ps,r=n.contextType;return typeof r=="object"&&r!==null?r=tn(r):(l=Dt(n)?Ws:jt.current,a=n.contextTypes,r=(a=a!=null)?Pa(e,l):ps),n=new n(s,r),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=pi,e.stateNode=n,n._reactInternals=e,a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=r),n}function cu(e,n,s,a){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(s,a),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(s,a),n.state!==e&&pi.enqueueReplaceState(n,n.state,null)}function Vo(e,n,s,a){var l=e.stateNode;l.props=s,l.state=e.memoizedState,l.refs={},Fd(e);var r=n.contextType;typeof r=="object"&&r!==null?l.context=tn(r):(r=Dt(n)?Ws:jt.current,l.context=Pa(e,r)),l.state=e.memoizedState,r=n.getDerivedStateFromProps,typeof r=="function"&&(Jo(e,n,r,s),l.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof l.getSnapshotBeforeUpdate=="function"||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(n=l.state,typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount(),n!==l.state&&pi.enqueueReplaceState(l,l.state,null),Kr(e,s,l,a),l.state=e.memoizedState),typeof l.componentDidMount=="function"&&(e.flags|=4194308)}function La(e,n){try{var s="",a=n;do s+=om(a),a=a.return;while(a);var l=s}catch(r){l=`
|
||
Error generating stack: `+r.message+`
|
||
`+r.stack}return{value:e,source:n,stack:l,digest:null}}function fo(e,n,s){return{value:e,source:null,stack:s??null,digest:n??null}}function Zo(e,n){try{console.error(n.value)}catch(s){setTimeout(function(){throw s})}}var Ox=typeof WeakMap=="function"?WeakMap:Map;function Ef(e,n,s){s=Un(-1,s),s.tag=3,s.payload={element:null};var a=n.value;return s.callback=function(){Vr||(Vr=!0,dd=a),Zo(e,n)},s}function Tf(e,n,s){s=Un(-1,s),s.tag=3;var a=e.type.getDerivedStateFromError;if(typeof a=="function"){var l=n.value;s.payload=function(){return a(l)},s.callback=function(){Zo(e,n)}}var r=e.stateNode;return r!==null&&typeof r.componentDidCatch=="function"&&(s.callback=function(){Zo(e,n),typeof a!="function"&&(os===null?os=new Set([this]):os.add(this));var i=n.stack;this.componentDidCatch(n.value,{componentStack:i!==null?i:""})}),s}function uu(e,n,s){var a=e.pingCache;if(a===null){a=e.pingCache=new Ox;var l=new Set;a.set(n,l)}else l=a.get(n),l===void 0&&(l=new Set,a.set(n,l));l.has(s)||(l.add(s),e=Xx.bind(null,e,n,s),n.then(e,e))}function pu(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function fu(e,n,s,a,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===n?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(n=Un(-1,1),n.tag=2,is(s,n,1))),s.lanes|=1),e)}var Lx=Qn.ReactCurrentOwner,Pt=!1;function kt(e,n,s,a){n.child=e===null?af(n,null,s,a):Da(n,e.child,s,a)}function hu(e,n,s,a,l){s=s.render;var r=n.ref;return Ea(n,l),a=Yd(e,n,s,a,r,l),s=Xd(),e!==null&&!Pt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l,Gn(e,n,l)):(Le&&s&&Ld(n),n.flags|=1,kt(e,n,a,l),n.child)}function gu(e,n,s,a,l){if(e===null){var r=s.type;return typeof r=="function"&&!lc(r)&&r.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(n.tag=15,n.type=r,Af(e,n,r,a,l)):(e=Tr(s.type,null,a,n,n.mode,l),e.ref=n.ref,e.return=n,n.child=e)}if(r=e.child,!(e.lanes&l)){var i=r.memoizedProps;if(s=s.compare,s=s!==null?s:Cl,s(i,a)&&e.ref===n.ref)return Gn(e,n,l)}return n.flags|=1,e=cs(r,a),e.ref=n.ref,e.return=n,n.child=e}function Af(e,n,s,a,l){if(e!==null){var r=e.memoizedProps;if(Cl(r,a)&&e.ref===n.ref)if(Pt=!1,n.pendingProps=a=r,(e.lanes&l)!==0)e.flags&131072&&(Pt=!0);else return n.lanes=e.lanes,Gn(e,n,l)}return ed(e,n,s,a,l)}function Pf(e,n,s){var a=n.pendingProps,l=a.children,r=e!==null?e.memoizedState:null;if(a.mode==="hidden")if(!(n.mode&1))n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ie(_a,Bt),Bt|=s;else{if(!(s&1073741824))return e=r!==null?r.baseLanes|s:s,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Ie(_a,Bt),Bt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},a=r!==null?r.baseLanes:s,Ie(_a,Bt),Bt|=a}else r!==null?(a=r.baseLanes|s,n.memoizedState=null):a=s,Ie(_a,Bt),Bt|=a;return kt(e,n,l,s),n.child}function Rf(e,n){var s=n.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(n.flags|=512,n.flags|=2097152)}function ed(e,n,s,a,l){var r=Dt(s)?Ws:jt.current;return r=Pa(n,r),Ea(n,l),s=Yd(e,n,s,a,r,l),a=Xd(),e!==null&&!Pt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l,Gn(e,n,l)):(Le&&a&&Ld(n),n.flags|=1,kt(e,n,s,l),n.child)}function mu(e,n,s,a,l){if(Dt(s)){var r=!0;Mr(n)}else r=!1;if(Ea(n,l),n.stateNode===null)zr(e,n),If(n,s,a),Vo(n,s,a,l),a=!0;else if(e===null){var i=n.stateNode,d=n.memoizedProps;i.props=d;var f=i.context,p=s.contextType;typeof p=="object"&&p!==null?p=tn(p):(p=Dt(s)?Ws:jt.current,p=Pa(n,p));var C=s.getDerivedStateFromProps,j=typeof C=="function"||typeof i.getSnapshotBeforeUpdate=="function";j||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==a||f!==p)&&cu(n,i,a,p),qn=!1;var _=n.memoizedState;i.state=_,Kr(n,a,i,l),f=n.memoizedState,d!==a||_!==f||Rt.current||qn?(typeof C=="function"&&(Jo(n,s,C,a),f=n.memoizedState),(d=qn||du(n,s,d,a,_,f,p))?(j||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(n.flags|=4194308)):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=a,n.memoizedState=f),i.props=a,i.state=f,i.context=p,a=d):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),a=!1)}else{i=n.stateNode,rf(e,n),d=n.memoizedProps,p=n.type===n.elementType?d:fn(n.type,d),i.props=p,j=n.pendingProps,_=i.context,f=s.contextType,typeof f=="object"&&f!==null?f=tn(f):(f=Dt(s)?Ws:jt.current,f=Pa(n,f));var c=s.getDerivedStateFromProps;(C=typeof c=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==j||_!==f)&&cu(n,i,a,f),qn=!1,_=n.memoizedState,i.state=_,Kr(n,a,i,l);var y=n.memoizedState;d!==j||_!==y||Rt.current||qn?(typeof c=="function"&&(Jo(n,s,c,a),y=n.memoizedState),(p=qn||du(n,s,p,a,_,y,f)||!1)?(C||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(a,y,f),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(a,y,f)),typeof i.componentDidUpdate=="function"&&(n.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&_===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&_===e.memoizedState||(n.flags|=1024),n.memoizedProps=a,n.memoizedState=y),i.props=a,i.state=y,i.context=f,a=p):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&_===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&_===e.memoizedState||(n.flags|=1024),a=!1)}return td(e,n,s,a,r,l)}function td(e,n,s,a,l,r){Rf(e,n);var i=(n.flags&128)!==0;if(!a&&!i)return l&&tu(n,s,!1),Gn(e,n,r);a=n.stateNode,Lx.current=n;var d=i&&typeof s.getDerivedStateFromError!="function"?null:a.render();return n.flags|=1,e!==null&&i?(n.child=Da(n,e.child,null,r),n.child=Da(n,null,d,r)):kt(e,n,d,r),n.memoizedState=a.state,l&&tu(n,s,!0),n.child}function Df(e){var n=e.stateNode;n.pendingContext?eu(e,n.pendingContext,n.pendingContext!==n.context):n.context&&eu(e,n.context,!1),Hd(e,n.containerInfo)}function xu(e,n,s,a,l){return Ra(),Nd(l),n.flags|=256,kt(e,n,s,a),n.child}var nd={dehydrated:null,treeContext:null,retryLane:0};function sd(e){return{baseLanes:e,cachePool:null,transitions:null}}function Of(e,n,s){var a=n.pendingProps,l=Ne.current,r=!1,i=(n.flags&128)!==0,d;if((d=i)||(d=e!==null&&e.memoizedState===null?!1:(l&2)!==0),d?(r=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),Ie(Ne,l&1),e===null)return Xo(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(n.mode&1?e.data==="$!"?n.lanes=8:n.lanes=1073741824:n.lanes=1,null):(i=a.children,e=a.fallback,r?(a=n.mode,r=n.child,i={mode:"hidden",children:i},!(a&1)&&r!==null?(r.childLanes=0,r.pendingProps=i):r=gi(i,a,0,null),e=Ls(e,a,s,null),r.return=n,e.return=n,r.sibling=e,n.child=r,n.child.memoizedState=sd(s),n.memoizedState=nd,e):Vd(n,i));if(l=e.memoizedState,l!==null&&(d=l.dehydrated,d!==null))return Wx(e,n,i,a,d,l,s);if(r){r=a.fallback,i=n.mode,l=e.child,d=l.sibling;var f={mode:"hidden",children:a.children};return!(i&1)&&n.child!==l?(a=n.child,a.childLanes=0,a.pendingProps=f,n.deletions=null):(a=cs(l,f),a.subtreeFlags=l.subtreeFlags&14680064),d!==null?r=cs(d,r):(r=Ls(r,i,s,null),r.flags|=2),r.return=n,a.return=n,a.sibling=r,n.child=a,a=r,r=n.child,i=e.child.memoizedState,i=i===null?sd(s):{baseLanes:i.baseLanes|s,cachePool:null,transitions:i.transitions},r.memoizedState=i,r.childLanes=e.childLanes&~s,n.memoizedState=nd,a}return r=e.child,e=r.sibling,a=cs(r,{mode:"visible",children:a.children}),!(n.mode&1)&&(a.lanes=s),a.return=n,a.sibling=null,e!==null&&(s=n.deletions,s===null?(n.deletions=[e],n.flags|=16):s.push(e)),n.child=a,n.memoizedState=null,a}function Vd(e,n){return n=gi({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function ur(e,n,s,a){return a!==null&&Nd(a),Da(n,e.child,null,s),e=Vd(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Wx(e,n,s,a,l,r,i){if(s)return n.flags&256?(n.flags&=-257,a=fo(Error(q(422))),ur(e,n,i,a)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(r=a.fallback,l=n.mode,a=gi({mode:"visible",children:a.children},l,0,null),r=Ls(r,l,i,null),r.flags|=2,a.return=n,r.return=n,a.sibling=r,n.child=a,n.mode&1&&Da(n,e.child,null,i),n.child.memoizedState=sd(i),n.memoizedState=nd,r);if(!(n.mode&1))return ur(e,n,i,null);if(l.data==="$!"){if(a=l.nextSibling&&l.nextSibling.dataset,a)var d=a.dgst;return a=d,r=Error(q(419)),a=fo(r,a,void 0),ur(e,n,i,a)}if(d=(i&e.childLanes)!==0,Pt||d){if(a=ut,a!==null){switch(i&-i){case 4:l=2;break;case 16:l=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:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(a.suspendedLanes|i)?0:l,l!==0&&l!==r.retryLane&&(r.retryLane=l,Hn(e,l),xn(a,e,l,-1))}return ac(),a=fo(Error(q(421))),ur(e,n,i,a)}return l.data==="$?"?(n.flags|=128,n.child=e.child,n=qx.bind(null,e),l._reactRetry=n,null):(e=r.treeContext,$t=rs(l.nextSibling),Ut=n,Le=!0,gn=null,e!==null&&(qt[Jt++]=Bn,qt[Jt++]=$n,qt[Jt++]=Ns,Bn=e.id,$n=e.overflow,Ns=n),n=Vd(n,a.children),n.flags|=4096,n)}function yu(e,n,s){e.lanes|=n;var a=e.alternate;a!==null&&(a.lanes|=n),qo(e.return,n,s)}function ho(e,n,s,a,l){var r=e.memoizedState;r===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:a,tail:s,tailMode:l}:(r.isBackwards=n,r.rendering=null,r.renderingStartTime=0,r.last=a,r.tail=s,r.tailMode=l)}function Lf(e,n,s){var a=n.pendingProps,l=a.revealOrder,r=a.tail;if(kt(e,n,a.children,s),a=Ne.current,a&2)a=a&1|2,n.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&yu(e,s,n);else if(e.tag===19)yu(e,s,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}a&=1}if(Ie(Ne,a),!(n.mode&1))n.memoizedState=null;else switch(l){case"forwards":for(s=n.child,l=null;s!==null;)e=s.alternate,e!==null&&Yr(e)===null&&(l=s),s=s.sibling;s=l,s===null?(l=n.child,n.child=null):(l=s.sibling,s.sibling=null),ho(n,!1,l,s,r);break;case"backwards":for(s=null,l=n.child,n.child=null;l!==null;){if(e=l.alternate,e!==null&&Yr(e)===null){n.child=l;break}e=l.sibling,l.sibling=s,s=l,l=e}ho(n,!0,s,null,r);break;case"together":ho(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function zr(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function Gn(e,n,s){if(e!==null&&(n.dependencies=e.dependencies),$s|=n.lanes,!(s&n.childLanes))return null;if(e!==null&&n.child!==e.child)throw Error(q(153));if(n.child!==null){for(e=n.child,s=cs(e,e.pendingProps),n.child=s,s.return=n;e.sibling!==null;)e=e.sibling,s=s.sibling=cs(e,e.pendingProps),s.return=n;s.sibling=null}return n.child}function Nx(e,n,s){switch(n.tag){case 3:Df(n),Ra();break;case 5:of(n);break;case 1:Dt(n.type)&&Mr(n);break;case 4:Hd(n,n.stateNode.containerInfo);break;case 10:var a=n.type._context,l=n.memoizedProps.value;Ie(Gr,a._currentValue),a._currentValue=l;break;case 13:if(a=n.memoizedState,a!==null)return a.dehydrated!==null?(Ie(Ne,Ne.current&1),n.flags|=128,null):s&n.child.childLanes?Of(e,n,s):(Ie(Ne,Ne.current&1),e=Gn(e,n,s),e!==null?e.sibling:null);Ie(Ne,Ne.current&1);break;case 19:if(a=(s&n.childLanes)!==0,e.flags&128){if(a)return Lf(e,n,s);n.flags|=128}if(l=n.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),Ie(Ne,Ne.current),a)break;return null;case 22:case 23:return n.lanes=0,Pf(e,n,s)}return Gn(e,n,s)}var Wf,ad,Nf,Bf;Wf=function(e,n){for(var s=n.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};ad=function(){};Nf=function(e,n,s,a){var l=e.memoizedProps;if(l!==a){e=n.stateNode,Rs(En.current);var r=null;switch(s){case"input":l=Co(e,l),a=Co(e,a),r=[];break;case"select":l=$e({},l,{value:void 0}),a=$e({},a,{value:void 0}),r=[];break;case"textarea":l=Eo(e,l),a=Eo(e,a),r=[];break;default:typeof l.onClick!="function"&&typeof a.onClick=="function"&&(e.onclick=$r)}Ao(s,a);var i;s=null;for(p in l)if(!a.hasOwnProperty(p)&&l.hasOwnProperty(p)&&l[p]!=null)if(p==="style"){var d=l[p];for(i in d)d.hasOwnProperty(i)&&(s||(s={}),s[i]="")}else p!=="dangerouslySetInnerHTML"&&p!=="children"&&p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(vl.hasOwnProperty(p)?r||(r=[]):(r=r||[]).push(p,null));for(p in a){var f=a[p];if(d=l!=null?l[p]:void 0,a.hasOwnProperty(p)&&f!==d&&(f!=null||d!=null))if(p==="style")if(d){for(i in d)!d.hasOwnProperty(i)||f&&f.hasOwnProperty(i)||(s||(s={}),s[i]="");for(i in f)f.hasOwnProperty(i)&&d[i]!==f[i]&&(s||(s={}),s[i]=f[i])}else s||(r||(r=[]),r.push(p,s)),s=f;else p==="dangerouslySetInnerHTML"?(f=f?f.__html:void 0,d=d?d.__html:void 0,f!=null&&d!==f&&(r=r||[]).push(p,f)):p==="children"?typeof f!="string"&&typeof f!="number"||(r=r||[]).push(p,""+f):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&(vl.hasOwnProperty(p)?(f!=null&&p==="onScroll"&&Ae("scroll",e),r||d===f||(r=[])):(r=r||[]).push(p,f))}s&&(r=r||[]).push("style",s);var p=r;(n.updateQueue=p)&&(n.flags|=4)}};Bf=function(e,n,s,a){s!==a&&(n.flags|=4)};function tl(e,n){if(!Le)switch(e.tailMode){case"hidden":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function yt(e){var n=e.alternate!==null&&e.alternate.child===e.child,s=0,a=0;if(n)for(var l=e.child;l!==null;)s|=l.lanes|l.childLanes,a|=l.subtreeFlags&14680064,a|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)s|=l.lanes|l.childLanes,a|=l.subtreeFlags,a|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=a,e.childLanes=s,n}function Bx(e,n,s){var a=n.pendingProps;switch(Wd(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(n),null;case 1:return Dt(n.type)&&Ur(),yt(n),null;case 3:return a=n.stateNode,Oa(),Pe(Rt),Pe(jt),Qd(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(dr(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&!(n.flags&256)||(n.flags|=1024,gn!==null&&(pd(gn),gn=null))),ad(e,n),yt(n),null;case 5:Gd(n);var l=Rs(Al.current);if(s=n.type,e!==null&&n.stateNode!=null)Nf(e,n,s,a,l),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!a){if(n.stateNode===null)throw Error(q(166));return yt(n),null}if(e=Rs(En.current),dr(n)){a=n.stateNode,s=n.type;var r=n.memoizedProps;switch(a[zn]=n,a[El]=r,e=(n.mode&1)!==0,s){case"dialog":Ae("cancel",a),Ae("close",a);break;case"iframe":case"object":case"embed":Ae("load",a);break;case"video":case"audio":for(l=0;l<ol.length;l++)Ae(ol[l],a);break;case"source":Ae("error",a);break;case"img":case"image":case"link":Ae("error",a),Ae("load",a);break;case"details":Ae("toggle",a);break;case"input":zc(a,r),Ae("invalid",a);break;case"select":a._wrapperState={wasMultiple:!!r.multiple},Ae("invalid",a);break;case"textarea":Ec(a,r),Ae("invalid",a)}Ao(s,r),l=null;for(var i in r)if(r.hasOwnProperty(i)){var d=r[i];i==="children"?typeof d=="string"?a.textContent!==d&&(r.suppressHydrationWarning!==!0&&or(a.textContent,d,e),l=["children",d]):typeof d=="number"&&a.textContent!==""+d&&(r.suppressHydrationWarning!==!0&&or(a.textContent,d,e),l=["children",""+d]):vl.hasOwnProperty(i)&&d!=null&&i==="onScroll"&&Ae("scroll",a)}switch(s){case"input":er(a),Ic(a,r,!0);break;case"textarea":er(a),Tc(a);break;case"select":case"option":break;default:typeof r.onClick=="function"&&(a.onclick=$r)}a=l,n.updateQueue=a,a!==null&&(n.flags|=4)}else{i=l.nodeType===9?l:l.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=pp(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof a.is=="string"?e=i.createElement(s,{is:a.is}):(e=i.createElement(s),s==="select"&&(i=e,a.multiple?i.multiple=!0:a.size&&(i.size=a.size))):e=i.createElementNS(e,s),e[zn]=n,e[El]=a,Wf(e,n,!1,!1),n.stateNode=e;e:{switch(i=Po(s,a),s){case"dialog":Ae("cancel",e),Ae("close",e),l=a;break;case"iframe":case"object":case"embed":Ae("load",e),l=a;break;case"video":case"audio":for(l=0;l<ol.length;l++)Ae(ol[l],e);l=a;break;case"source":Ae("error",e),l=a;break;case"img":case"image":case"link":Ae("error",e),Ae("load",e),l=a;break;case"details":Ae("toggle",e),l=a;break;case"input":zc(e,a),l=Co(e,a),Ae("invalid",e);break;case"option":l=a;break;case"select":e._wrapperState={wasMultiple:!!a.multiple},l=$e({},a,{value:void 0}),Ae("invalid",e);break;case"textarea":Ec(e,a),l=Eo(e,a),Ae("invalid",e);break;default:l=a}Ao(s,l),d=l;for(r in d)if(d.hasOwnProperty(r)){var f=d[r];r==="style"?gp(e,f):r==="dangerouslySetInnerHTML"?(f=f?f.__html:void 0,f!=null&&fp(e,f)):r==="children"?typeof f=="string"?(s!=="textarea"||f!=="")&&jl(e,f):typeof f=="number"&&jl(e,""+f):r!=="suppressContentEditableWarning"&&r!=="suppressHydrationWarning"&&r!=="autoFocus"&&(vl.hasOwnProperty(r)?f!=null&&r==="onScroll"&&Ae("scroll",e):f!=null&&Sd(e,r,f,i))}switch(s){case"input":er(e),Ic(e,a,!1);break;case"textarea":er(e),Tc(e);break;case"option":a.value!=null&&e.setAttribute("value",""+us(a.value));break;case"select":e.multiple=!!a.multiple,r=a.value,r!=null?ka(e,!!a.multiple,r,!1):a.defaultValue!=null&&ka(e,!!a.multiple,a.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=$r)}switch(s){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}}a&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return yt(n),null;case 6:if(e&&n.stateNode!=null)Bf(e,n,e.memoizedProps,a);else{if(typeof a!="string"&&n.stateNode===null)throw Error(q(166));if(s=Rs(Al.current),Rs(En.current),dr(n)){if(a=n.stateNode,s=n.memoizedProps,a[zn]=n,(r=a.nodeValue!==s)&&(e=Ut,e!==null))switch(e.tag){case 3:or(a.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&or(a.nodeValue,s,(e.mode&1)!==0)}r&&(n.flags|=4)}else a=(s.nodeType===9?s:s.ownerDocument).createTextNode(a),a[zn]=n,n.stateNode=a}return yt(n),null;case 13:if(Pe(Ne),a=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Le&&$t!==null&&n.mode&1&&!(n.flags&128))nf(),Ra(),n.flags|=98560,r=!1;else if(r=dr(n),a!==null&&a.dehydrated!==null){if(e===null){if(!r)throw Error(q(318));if(r=n.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(q(317));r[zn]=n}else Ra(),!(n.flags&128)&&(n.memoizedState=null),n.flags|=4;yt(n),r=!1}else gn!==null&&(pd(gn),gn=null),r=!0;if(!r)return n.flags&65536?n:null}return n.flags&128?(n.lanes=s,n):(a=a!==null,a!==(e!==null&&e.memoizedState!==null)&&a&&(n.child.flags|=8192,n.mode&1&&(e===null||Ne.current&1?it===0&&(it=3):ac())),n.updateQueue!==null&&(n.flags|=4),yt(n),null);case 4:return Oa(),ad(e,n),e===null&&zl(n.stateNode.containerInfo),yt(n),null;case 10:return Ud(n.type._context),yt(n),null;case 17:return Dt(n.type)&&Ur(),yt(n),null;case 19:if(Pe(Ne),r=n.memoizedState,r===null)return yt(n),null;if(a=(n.flags&128)!==0,i=r.rendering,i===null)if(a)tl(r,!1);else{if(it!==0||e!==null&&e.flags&128)for(e=n.child;e!==null;){if(i=Yr(e),i!==null){for(n.flags|=128,tl(r,!1),a=i.updateQueue,a!==null&&(n.updateQueue=a,n.flags|=4),n.subtreeFlags=0,a=s,s=n.child;s!==null;)r=s,e=a,r.flags&=14680066,i=r.alternate,i===null?(r.childLanes=0,r.lanes=e,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=i.childLanes,r.lanes=i.lanes,r.child=i.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=i.memoizedProps,r.memoizedState=i.memoizedState,r.updateQueue=i.updateQueue,r.type=i.type,e=i.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return Ie(Ne,Ne.current&1|2),n.child}e=e.sibling}r.tail!==null&&Ze()>Wa&&(n.flags|=128,a=!0,tl(r,!1),n.lanes=4194304)}else{if(!a)if(e=Yr(i),e!==null){if(n.flags|=128,a=!0,s=e.updateQueue,s!==null&&(n.updateQueue=s,n.flags|=4),tl(r,!0),r.tail===null&&r.tailMode==="hidden"&&!i.alternate&&!Le)return yt(n),null}else 2*Ze()-r.renderingStartTime>Wa&&s!==1073741824&&(n.flags|=128,a=!0,tl(r,!1),n.lanes=4194304);r.isBackwards?(i.sibling=n.child,n.child=i):(s=r.last,s!==null?s.sibling=i:n.child=i,r.last=i)}return r.tail!==null?(n=r.tail,r.rendering=n,r.tail=n.sibling,r.renderingStartTime=Ze(),n.sibling=null,s=Ne.current,Ie(Ne,a?s&1|2:s&1),n):(yt(n),null);case 22:case 23:return sc(),a=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==a&&(n.flags|=8192),a&&n.mode&1?Bt&1073741824&&(yt(n),n.subtreeFlags&6&&(n.flags|=8192)):yt(n),null;case 24:return null;case 25:return null}throw Error(q(156,n.tag))}function $x(e,n){switch(Wd(n),n.tag){case 1:return Dt(n.type)&&Ur(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Oa(),Pe(Rt),Pe(jt),Qd(),e=n.flags,e&65536&&!(e&128)?(n.flags=e&-65537|128,n):null;case 5:return Gd(n),null;case 13:if(Pe(Ne),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(q(340));Ra()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Pe(Ne),null;case 4:return Oa(),null;case 10:return Ud(n.type._context),null;case 22:case 23:return sc(),null;case 24:return null;default:return null}}var pr=!1,vt=!1,Ux=typeof WeakSet=="function"?WeakSet:Set,Z=null;function Sa(e,n){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(a){Ke(e,n,a)}else s.current=null}function ld(e,n,s){try{s()}catch(a){Ke(e,n,a)}}var vu=!1;function Mx(e,n){if(Mo=Wr,e=Fp(),Od(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var a=s.getSelection&&s.getSelection();if(a&&a.rangeCount!==0){s=a.anchorNode;var l=a.anchorOffset,r=a.focusNode;a=a.focusOffset;try{s.nodeType,r.nodeType}catch{s=null;break e}var i=0,d=-1,f=-1,p=0,C=0,j=e,_=null;t:for(;;){for(var c;j!==s||l!==0&&j.nodeType!==3||(d=i+l),j!==r||a!==0&&j.nodeType!==3||(f=i+a),j.nodeType===3&&(i+=j.nodeValue.length),(c=j.firstChild)!==null;)_=j,j=c;for(;;){if(j===e)break t;if(_===s&&++p===l&&(d=i),_===r&&++C===a&&(f=i),(c=j.nextSibling)!==null)break;j=_,_=j.parentNode}j=c}s=d===-1||f===-1?null:{start:d,end:f}}else s=null}s=s||{start:0,end:0}}else s=null;for(Fo={focusedElem:e,selectionRange:s},Wr=!1,Z=n;Z!==null;)if(n=Z,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Z=e;else for(;Z!==null;){n=Z;try{var y=n.alternate;if(n.flags&1024)switch(n.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var z=y.memoizedProps,k=y.memoizedState,g=n.stateNode,o=g.getSnapshotBeforeUpdate(n.elementType===n.type?z:fn(n.type,z),k);g.__reactInternalSnapshotBeforeUpdate=o}break;case 3:var h=n.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(q(163))}}catch(x){Ke(n,n.return,x)}if(e=n.sibling,e!==null){e.return=n.return,Z=e;break}Z=n.return}return y=vu,vu=!1,y}function ml(e,n,s){var a=n.updateQueue;if(a=a!==null?a.lastEffect:null,a!==null){var l=a=a.next;do{if((l.tag&e)===e){var r=l.destroy;l.destroy=void 0,r!==void 0&&ld(n,s,r)}l=l.next}while(l!==a)}}function fi(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&e)===e){var a=s.create;s.destroy=a()}s=s.next}while(s!==n)}}function rd(e){var n=e.ref;if(n!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof n=="function"?n(e):n.current=e}}function $f(e){var n=e.alternate;n!==null&&(e.alternate=null,$f(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[zn],delete n[El],delete n[Qo],delete n[wx],delete n[kx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Uf(e){return e.tag===5||e.tag===3||e.tag===4}function ju(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Uf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function id(e,n,s){var a=e.tag;if(a===5||a===6)e=e.stateNode,n?s.nodeType===8?s.parentNode.insertBefore(e,n):s.insertBefore(e,n):(s.nodeType===8?(n=s.parentNode,n.insertBefore(e,s)):(n=s,n.appendChild(e)),s=s._reactRootContainer,s!=null||n.onclick!==null||(n.onclick=$r));else if(a!==4&&(e=e.child,e!==null))for(id(e,n,s),e=e.sibling;e!==null;)id(e,n,s),e=e.sibling}function od(e,n,s){var a=e.tag;if(a===5||a===6)e=e.stateNode,n?s.insertBefore(e,n):s.appendChild(e);else if(a!==4&&(e=e.child,e!==null))for(od(e,n,s),e=e.sibling;e!==null;)od(e,n,s),e=e.sibling}var ft=null,hn=!1;function Kn(e,n,s){for(s=s.child;s!==null;)Mf(e,n,s),s=s.sibling}function Mf(e,n,s){if(In&&typeof In.onCommitFiberUnmount=="function")try{In.onCommitFiberUnmount(li,s)}catch{}switch(s.tag){case 5:vt||Sa(s,n);case 6:var a=ft,l=hn;ft=null,Kn(e,n,s),ft=a,hn=l,ft!==null&&(hn?(e=ft,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):ft.removeChild(s.stateNode));break;case 18:ft!==null&&(hn?(e=ft,s=s.stateNode,e.nodeType===8?ro(e.parentNode,s):e.nodeType===1&&ro(e,s),wl(e)):ro(ft,s.stateNode));break;case 4:a=ft,l=hn,ft=s.stateNode.containerInfo,hn=!0,Kn(e,n,s),ft=a,hn=l;break;case 0:case 11:case 14:case 15:if(!vt&&(a=s.updateQueue,a!==null&&(a=a.lastEffect,a!==null))){l=a=a.next;do{var r=l,i=r.destroy;r=r.tag,i!==void 0&&(r&2||r&4)&&ld(s,n,i),l=l.next}while(l!==a)}Kn(e,n,s);break;case 1:if(!vt&&(Sa(s,n),a=s.stateNode,typeof a.componentWillUnmount=="function"))try{a.props=s.memoizedProps,a.state=s.memoizedState,a.componentWillUnmount()}catch(d){Ke(s,n,d)}Kn(e,n,s);break;case 21:Kn(e,n,s);break;case 22:s.mode&1?(vt=(a=vt)||s.memoizedState!==null,Kn(e,n,s),vt=a):Kn(e,n,s);break;default:Kn(e,n,s)}}function bu(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Ux),n.forEach(function(a){var l=Jx.bind(null,e,a);s.has(a)||(s.add(a),a.then(l,l))})}}function un(e,n){var s=n.deletions;if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];try{var r=e,i=n,d=i;e:for(;d!==null;){switch(d.tag){case 5:ft=d.stateNode,hn=!1;break e;case 3:ft=d.stateNode.containerInfo,hn=!0;break e;case 4:ft=d.stateNode.containerInfo,hn=!0;break e}d=d.return}if(ft===null)throw Error(q(160));Mf(r,i,l),ft=null,hn=!1;var f=l.alternate;f!==null&&(f.return=null),l.return=null}catch(p){Ke(l,n,p)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Ff(n,e),n=n.sibling}function Ff(e,n){var s=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(un(n,e),Sn(e),a&4){try{ml(3,e,e.return),fi(3,e)}catch(z){Ke(e,e.return,z)}try{ml(5,e,e.return)}catch(z){Ke(e,e.return,z)}}break;case 1:un(n,e),Sn(e),a&512&&s!==null&&Sa(s,s.return);break;case 5:if(un(n,e),Sn(e),a&512&&s!==null&&Sa(s,s.return),e.flags&32){var l=e.stateNode;try{jl(l,"")}catch(z){Ke(e,e.return,z)}}if(a&4&&(l=e.stateNode,l!=null)){var r=e.memoizedProps,i=s!==null?s.memoizedProps:r,d=e.type,f=e.updateQueue;if(e.updateQueue=null,f!==null)try{d==="input"&&r.type==="radio"&&r.name!=null&&cp(l,r),Po(d,i);var p=Po(d,r);for(i=0;i<f.length;i+=2){var C=f[i],j=f[i+1];C==="style"?gp(l,j):C==="dangerouslySetInnerHTML"?fp(l,j):C==="children"?jl(l,j):Sd(l,C,j,p)}switch(d){case"input":zo(l,r);break;case"textarea":up(l,r);break;case"select":var _=l._wrapperState.wasMultiple;l._wrapperState.wasMultiple=!!r.multiple;var c=r.value;c!=null?ka(l,!!r.multiple,c,!1):_!==!!r.multiple&&(r.defaultValue!=null?ka(l,!!r.multiple,r.defaultValue,!0):ka(l,!!r.multiple,r.multiple?[]:"",!1))}l[El]=r}catch(z){Ke(e,e.return,z)}}break;case 6:if(un(n,e),Sn(e),a&4){if(e.stateNode===null)throw Error(q(162));l=e.stateNode,r=e.memoizedProps;try{l.nodeValue=r}catch(z){Ke(e,e.return,z)}}break;case 3:if(un(n,e),Sn(e),a&4&&s!==null&&s.memoizedState.isDehydrated)try{wl(n.containerInfo)}catch(z){Ke(e,e.return,z)}break;case 4:un(n,e),Sn(e);break;case 13:un(n,e),Sn(e),l=e.child,l.flags&8192&&(r=l.memoizedState!==null,l.stateNode.isHidden=r,!r||l.alternate!==null&&l.alternate.memoizedState!==null||(tc=Ze())),a&4&&bu(e);break;case 22:if(C=s!==null&&s.memoizedState!==null,e.mode&1?(vt=(p=vt)||C,un(n,e),vt=p):un(n,e),Sn(e),a&8192){if(p=e.memoizedState!==null,(e.stateNode.isHidden=p)&&!C&&e.mode&1)for(Z=e,C=e.child;C!==null;){for(j=Z=C;Z!==null;){switch(_=Z,c=_.child,_.tag){case 0:case 11:case 14:case 15:ml(4,_,_.return);break;case 1:Sa(_,_.return);var y=_.stateNode;if(typeof y.componentWillUnmount=="function"){a=_,s=_.return;try{n=a,y.props=n.memoizedProps,y.state=n.memoizedState,y.componentWillUnmount()}catch(z){Ke(a,s,z)}}break;case 5:Sa(_,_.return);break;case 22:if(_.memoizedState!==null){_u(j);continue}}c!==null?(c.return=_,Z=c):_u(j)}C=C.sibling}e:for(C=null,j=e;;){if(j.tag===5){if(C===null){C=j;try{l=j.stateNode,p?(r=l.style,typeof r.setProperty=="function"?r.setProperty("display","none","important"):r.display="none"):(d=j.stateNode,f=j.memoizedProps.style,i=f!=null&&f.hasOwnProperty("display")?f.display:null,d.style.display=hp("display",i))}catch(z){Ke(e,e.return,z)}}}else if(j.tag===6){if(C===null)try{j.stateNode.nodeValue=p?"":j.memoizedProps}catch(z){Ke(e,e.return,z)}}else if((j.tag!==22&&j.tag!==23||j.memoizedState===null||j===e)&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===e)break e;for(;j.sibling===null;){if(j.return===null||j.return===e)break e;C===j&&(C=null),j=j.return}C===j&&(C=null),j.sibling.return=j.return,j=j.sibling}}break;case 19:un(n,e),Sn(e),a&4&&bu(e);break;case 21:break;default:un(n,e),Sn(e)}}function Sn(e){var n=e.flags;if(n&2){try{e:{for(var s=e.return;s!==null;){if(Uf(s)){var a=s;break e}s=s.return}throw Error(q(160))}switch(a.tag){case 5:var l=a.stateNode;a.flags&32&&(jl(l,""),a.flags&=-33);var r=ju(e);od(e,r,l);break;case 3:case 4:var i=a.stateNode.containerInfo,d=ju(e);id(e,d,i);break;default:throw Error(q(161))}}catch(f){Ke(e,e.return,f)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Fx(e,n,s){Z=e,Hf(e)}function Hf(e,n,s){for(var a=(e.mode&1)!==0;Z!==null;){var l=Z,r=l.child;if(l.tag===22&&a){var i=l.memoizedState!==null||pr;if(!i){var d=l.alternate,f=d!==null&&d.memoizedState!==null||vt;d=pr;var p=vt;if(pr=i,(vt=f)&&!p)for(Z=l;Z!==null;)i=Z,f=i.child,i.tag===22&&i.memoizedState!==null?wu(l):f!==null?(f.return=i,Z=f):wu(l);for(;r!==null;)Z=r,Hf(r),r=r.sibling;Z=l,pr=d,vt=p}Su(e)}else l.subtreeFlags&8772&&r!==null?(r.return=l,Z=r):Su(e)}}function Su(e){for(;Z!==null;){var n=Z;if(n.flags&8772){var s=n.alternate;try{if(n.flags&8772)switch(n.tag){case 0:case 11:case 15:vt||fi(5,n);break;case 1:var a=n.stateNode;if(n.flags&4&&!vt)if(s===null)a.componentDidMount();else{var l=n.elementType===n.type?s.memoizedProps:fn(n.type,s.memoizedProps);a.componentDidUpdate(l,s.memoizedState,a.__reactInternalSnapshotBeforeUpdate)}var r=n.updateQueue;r!==null&&ru(n,r,a);break;case 3:var i=n.updateQueue;if(i!==null){if(s=null,n.child!==null)switch(n.child.tag){case 5:s=n.child.stateNode;break;case 1:s=n.child.stateNode}ru(n,i,s)}break;case 5:var d=n.stateNode;if(s===null&&n.flags&4){s=d;var f=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":f.autoFocus&&s.focus();break;case"img":f.src&&(s.src=f.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var p=n.alternate;if(p!==null){var C=p.memoizedState;if(C!==null){var j=C.dehydrated;j!==null&&wl(j)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(q(163))}vt||n.flags&512&&rd(n)}catch(_){Ke(n,n.return,_)}}if(n===e){Z=null;break}if(s=n.sibling,s!==null){s.return=n.return,Z=s;break}Z=n.return}}function _u(e){for(;Z!==null;){var n=Z;if(n===e){Z=null;break}var s=n.sibling;if(s!==null){s.return=n.return,Z=s;break}Z=n.return}}function wu(e){for(;Z!==null;){var n=Z;try{switch(n.tag){case 0:case 11:case 15:var s=n.return;try{fi(4,n)}catch(f){Ke(n,s,f)}break;case 1:var a=n.stateNode;if(typeof a.componentDidMount=="function"){var l=n.return;try{a.componentDidMount()}catch(f){Ke(n,l,f)}}var r=n.return;try{rd(n)}catch(f){Ke(n,r,f)}break;case 5:var i=n.return;try{rd(n)}catch(f){Ke(n,i,f)}}}catch(f){Ke(n,n.return,f)}if(n===e){Z=null;break}var d=n.sibling;if(d!==null){d.return=n.return,Z=d;break}Z=n.return}}var Hx=Math.ceil,Jr=Qn.ReactCurrentDispatcher,Zd=Qn.ReactCurrentOwner,Zt=Qn.ReactCurrentBatchConfig,ve=0,ut=null,nt=null,ht=0,Bt=0,_a=gs(0),it=0,Ol=null,$s=0,hi=0,ec=0,xl=null,At=null,tc=0,Wa=1/0,Wn=null,Vr=!1,dd=null,os=null,fr=!1,es=null,Zr=0,yl=0,cd=null,Ir=-1,Er=0;function Ct(){return ve&6?Ze():Ir!==-1?Ir:Ir=Ze()}function ds(e){return e.mode&1?ve&2&&ht!==0?ht&-ht:zx.transition!==null?(Er===0&&(Er=zp()),Er):(e=we,e!==0||(e=window.event,e=e===void 0?16:Dp(e.type)),e):1}function xn(e,n,s,a){if(50<yl)throw yl=0,cd=null,Error(q(185));Bl(e,s,a),(!(ve&2)||e!==ut)&&(e===ut&&(!(ve&2)&&(hi|=s),it===4&&Vn(e,ht)),Ot(e,a),s===1&&ve===0&&!(n.mode&1)&&(Wa=Ze()+500,ci&&ms()))}function Ot(e,n){var s=e.callbackNode;zm(e,n);var a=Lr(e,e===ut?ht:0);if(a===0)s!==null&&Rc(s),e.callbackNode=null,e.callbackPriority=0;else if(n=a&-a,e.callbackPriority!==n){if(s!=null&&Rc(s),n===1)e.tag===0?Cx(ku.bind(null,e)):Zp(ku.bind(null,e)),Sx(function(){!(ve&6)&&ms()}),s=null;else{switch(Ip(a)){case 1:s=zd;break;case 4:s=kp;break;case 16:s=Or;break;case 536870912:s=Cp;break;default:s=Or}s=Vf(s,Gf.bind(null,e))}e.callbackPriority=n,e.callbackNode=s}}function Gf(e,n){if(Ir=-1,Er=0,ve&6)throw Error(q(327));var s=e.callbackNode;if(Ta()&&e.callbackNode!==s)return null;var a=Lr(e,e===ut?ht:0);if(a===0)return null;if(a&30||a&e.expiredLanes||n)n=ei(e,a);else{n=a;var l=ve;ve|=2;var r=Kf();(ut!==e||ht!==n)&&(Wn=null,Wa=Ze()+500,Os(e,n));do try{Kx();break}catch(d){Qf(e,d)}while(!0);$d(),Jr.current=r,ve=l,nt!==null?n=0:(ut=null,ht=0,n=it)}if(n!==0){if(n===2&&(l=Wo(e),l!==0&&(a=l,n=ud(e,l))),n===1)throw s=Ol,Os(e,0),Vn(e,a),Ot(e,Ze()),s;if(n===6)Vn(e,a);else{if(l=e.current.alternate,!(a&30)&&!Gx(l)&&(n=ei(e,a),n===2&&(r=Wo(e),r!==0&&(a=r,n=ud(e,r))),n===1))throw s=Ol,Os(e,0),Vn(e,a),Ot(e,Ze()),s;switch(e.finishedWork=l,e.finishedLanes=a,n){case 0:case 1:throw Error(q(345));case 2:Ts(e,At,Wn);break;case 3:if(Vn(e,a),(a&130023424)===a&&(n=tc+500-Ze(),10<n)){if(Lr(e,0)!==0)break;if(l=e.suspendedLanes,(l&a)!==a){Ct(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=Go(Ts.bind(null,e,At,Wn),n);break}Ts(e,At,Wn);break;case 4:if(Vn(e,a),(a&4194240)===a)break;for(n=e.eventTimes,l=-1;0<a;){var i=31-mn(a);r=1<<i,i=n[i],i>l&&(l=i),a&=~r}if(a=l,a=Ze()-a,a=(120>a?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*Hx(a/1960))-a,10<a){e.timeoutHandle=Go(Ts.bind(null,e,At,Wn),a);break}Ts(e,At,Wn);break;case 5:Ts(e,At,Wn);break;default:throw Error(q(329))}}}return Ot(e,Ze()),e.callbackNode===s?Gf.bind(null,e):null}function ud(e,n){var s=xl;return e.current.memoizedState.isDehydrated&&(Os(e,n).flags|=256),e=ei(e,n),e!==2&&(n=At,At=s,n!==null&&pd(n)),e}function pd(e){At===null?At=e:At.push.apply(At,e)}function Gx(e){for(var n=e;;){if(n.flags&16384){var s=n.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var a=0;a<s.length;a++){var l=s[a],r=l.getSnapshot;l=l.value;try{if(!yn(r(),l))return!1}catch{return!1}}}if(s=n.child,n.subtreeFlags&16384&&s!==null)s.return=n,n=s;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Vn(e,n){for(n&=~ec,n&=~hi,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var s=31-mn(n),a=1<<s;e[s]=-1,n&=~a}}function ku(e){if(ve&6)throw Error(q(327));Ta();var n=Lr(e,0);if(!(n&1))return Ot(e,Ze()),null;var s=ei(e,n);if(e.tag!==0&&s===2){var a=Wo(e);a!==0&&(n=a,s=ud(e,a))}if(s===1)throw s=Ol,Os(e,0),Vn(e,n),Ot(e,Ze()),s;if(s===6)throw Error(q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,Ts(e,At,Wn),Ot(e,Ze()),null}function nc(e,n){var s=ve;ve|=1;try{return e(n)}finally{ve=s,ve===0&&(Wa=Ze()+500,ci&&ms())}}function Us(e){es!==null&&es.tag===0&&!(ve&6)&&Ta();var n=ve;ve|=1;var s=Zt.transition,a=we;try{if(Zt.transition=null,we=1,e)return e()}finally{we=a,Zt.transition=s,ve=n,!(ve&6)&&ms()}}function sc(){Bt=_a.current,Pe(_a)}function Os(e,n){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,bx(s)),nt!==null)for(s=nt.return;s!==null;){var a=s;switch(Wd(a),a.tag){case 1:a=a.type.childContextTypes,a!=null&&Ur();break;case 3:Oa(),Pe(Rt),Pe(jt),Qd();break;case 5:Gd(a);break;case 4:Oa();break;case 13:Pe(Ne);break;case 19:Pe(Ne);break;case 10:Ud(a.type._context);break;case 22:case 23:sc()}s=s.return}if(ut=e,nt=e=cs(e.current,null),ht=Bt=n,it=0,Ol=null,ec=hi=$s=0,At=xl=null,Ps!==null){for(n=0;n<Ps.length;n++)if(s=Ps[n],a=s.interleaved,a!==null){s.interleaved=null;var l=a.next,r=s.pending;if(r!==null){var i=r.next;r.next=l,a.next=i}s.pending=a}Ps=null}return e}function Qf(e,n){do{var s=nt;try{if($d(),kr.current=qr,Xr){for(var a=Be.memoizedState;a!==null;){var l=a.queue;l!==null&&(l.pending=null),a=a.next}Xr=!1}if(Bs=0,ct=rt=Be=null,gl=!1,Pl=0,Zd.current=null,s===null||s.return===null){it=1,Ol=n,nt=null;break}e:{var r=e,i=s.return,d=s,f=n;if(n=ht,d.flags|=32768,f!==null&&typeof f=="object"&&typeof f.then=="function"){var p=f,C=d,j=C.tag;if(!(C.mode&1)&&(j===0||j===11||j===15)){var _=C.alternate;_?(C.updateQueue=_.updateQueue,C.memoizedState=_.memoizedState,C.lanes=_.lanes):(C.updateQueue=null,C.memoizedState=null)}var c=pu(i);if(c!==null){c.flags&=-257,fu(c,i,d,r,n),c.mode&1&&uu(r,p,n),n=c,f=p;var y=n.updateQueue;if(y===null){var z=new Set;z.add(f),n.updateQueue=z}else y.add(f);break e}else{if(!(n&1)){uu(r,p,n),ac();break e}f=Error(q(426))}}else if(Le&&d.mode&1){var k=pu(i);if(k!==null){!(k.flags&65536)&&(k.flags|=256),fu(k,i,d,r,n),Nd(La(f,d));break e}}r=f=La(f,d),it!==4&&(it=2),xl===null?xl=[r]:xl.push(r),r=i;do{switch(r.tag){case 3:r.flags|=65536,n&=-n,r.lanes|=n;var g=Ef(r,f,n);lu(r,g);break e;case 1:d=f;var o=r.type,h=r.stateNode;if(!(r.flags&128)&&(typeof o.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(os===null||!os.has(h)))){r.flags|=65536,n&=-n,r.lanes|=n;var x=Tf(r,d,n);lu(r,x);break e}}r=r.return}while(r!==null)}Xf(s)}catch(v){n=v,nt===s&&s!==null&&(nt=s=s.return);continue}break}while(!0)}function Kf(){var e=Jr.current;return Jr.current=qr,e===null?qr:e}function ac(){(it===0||it===3||it===2)&&(it=4),ut===null||!($s&268435455)&&!(hi&268435455)||Vn(ut,ht)}function ei(e,n){var s=ve;ve|=2;var a=Kf();(ut!==e||ht!==n)&&(Wn=null,Os(e,n));do try{Qx();break}catch(l){Qf(e,l)}while(!0);if($d(),ve=s,Jr.current=a,nt!==null)throw Error(q(261));return ut=null,ht=0,it}function Qx(){for(;nt!==null;)Yf(nt)}function Kx(){for(;nt!==null&&!ym();)Yf(nt)}function Yf(e){var n=Jf(e.alternate,e,Bt);e.memoizedProps=e.pendingProps,n===null?Xf(e):nt=n,Zd.current=null}function Xf(e){var n=e;do{var s=n.alternate;if(e=n.return,n.flags&32768){if(s=$x(s,n),s!==null){s.flags&=32767,nt=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{it=6,nt=null;return}}else if(s=Bx(s,n,Bt),s!==null){nt=s;return}if(n=n.sibling,n!==null){nt=n;return}nt=n=e}while(n!==null);it===0&&(it=5)}function Ts(e,n,s){var a=we,l=Zt.transition;try{Zt.transition=null,we=1,Yx(e,n,s,a)}finally{Zt.transition=l,we=a}return null}function Yx(e,n,s,a){do Ta();while(es!==null);if(ve&6)throw Error(q(327));s=e.finishedWork;var l=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(q(177));e.callbackNode=null,e.callbackPriority=0;var r=s.lanes|s.childLanes;if(Im(e,r),e===ut&&(nt=ut=null,ht=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||fr||(fr=!0,Vf(Or,function(){return Ta(),null})),r=(s.flags&15990)!==0,s.subtreeFlags&15990||r){r=Zt.transition,Zt.transition=null;var i=we;we=1;var d=ve;ve|=4,Zd.current=null,Mx(e,s),Ff(s,e),hx(Fo),Wr=!!Mo,Fo=Mo=null,e.current=s,Fx(s),vm(),ve=d,we=i,Zt.transition=r}else e.current=s;if(fr&&(fr=!1,es=e,Zr=l),r=e.pendingLanes,r===0&&(os=null),Sm(s.stateNode),Ot(e,Ze()),n!==null)for(a=e.onRecoverableError,s=0;s<n.length;s++)l=n[s],a(l.value,{componentStack:l.stack,digest:l.digest});if(Vr)throw Vr=!1,e=dd,dd=null,e;return Zr&1&&e.tag!==0&&Ta(),r=e.pendingLanes,r&1?e===cd?yl++:(yl=0,cd=e):yl=0,ms(),null}function Ta(){if(es!==null){var e=Ip(Zr),n=Zt.transition,s=we;try{if(Zt.transition=null,we=16>e?16:e,es===null)var a=!1;else{if(e=es,es=null,Zr=0,ve&6)throw Error(q(331));var l=ve;for(ve|=4,Z=e.current;Z!==null;){var r=Z,i=r.child;if(Z.flags&16){var d=r.deletions;if(d!==null){for(var f=0;f<d.length;f++){var p=d[f];for(Z=p;Z!==null;){var C=Z;switch(C.tag){case 0:case 11:case 15:ml(8,C,r)}var j=C.child;if(j!==null)j.return=C,Z=j;else for(;Z!==null;){C=Z;var _=C.sibling,c=C.return;if($f(C),C===p){Z=null;break}if(_!==null){_.return=c,Z=_;break}Z=c}}}var y=r.alternate;if(y!==null){var z=y.child;if(z!==null){y.child=null;do{var k=z.sibling;z.sibling=null,z=k}while(z!==null)}}Z=r}}if(r.subtreeFlags&2064&&i!==null)i.return=r,Z=i;else e:for(;Z!==null;){if(r=Z,r.flags&2048)switch(r.tag){case 0:case 11:case 15:ml(9,r,r.return)}var g=r.sibling;if(g!==null){g.return=r.return,Z=g;break e}Z=r.return}}var o=e.current;for(Z=o;Z!==null;){i=Z;var h=i.child;if(i.subtreeFlags&2064&&h!==null)h.return=i,Z=h;else e:for(i=o;Z!==null;){if(d=Z,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:fi(9,d)}}catch(v){Ke(d,d.return,v)}if(d===i){Z=null;break e}var x=d.sibling;if(x!==null){x.return=d.return,Z=x;break e}Z=d.return}}if(ve=l,ms(),In&&typeof In.onPostCommitFiberRoot=="function")try{In.onPostCommitFiberRoot(li,e)}catch{}a=!0}return a}finally{we=s,Zt.transition=n}}return!1}function Cu(e,n,s){n=La(s,n),n=Ef(e,n,1),e=is(e,n,1),n=Ct(),e!==null&&(Bl(e,1,n),Ot(e,n))}function Ke(e,n,s){if(e.tag===3)Cu(e,e,s);else for(;n!==null;){if(n.tag===3){Cu(n,e,s);break}else if(n.tag===1){var a=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(os===null||!os.has(a))){e=La(s,e),e=Tf(n,e,1),n=is(n,e,1),e=Ct(),n!==null&&(Bl(n,1,e),Ot(n,e));break}}n=n.return}}function Xx(e,n,s){var a=e.pingCache;a!==null&&a.delete(n),n=Ct(),e.pingedLanes|=e.suspendedLanes&s,ut===e&&(ht&s)===s&&(it===4||it===3&&(ht&130023424)===ht&&500>Ze()-tc?Os(e,0):ec|=s),Ot(e,n)}function qf(e,n){n===0&&(e.mode&1?(n=sr,sr<<=1,!(sr&130023424)&&(sr=4194304)):n=1);var s=Ct();e=Hn(e,n),e!==null&&(Bl(e,n,s),Ot(e,s))}function qx(e){var n=e.memoizedState,s=0;n!==null&&(s=n.retryLane),qf(e,s)}function Jx(e,n){var s=0;switch(e.tag){case 13:var a=e.stateNode,l=e.memoizedState;l!==null&&(s=l.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(q(314))}a!==null&&a.delete(n),qf(e,s)}var Jf;Jf=function(e,n,s){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Pt=!0;else{if(!(e.lanes&s)&&!(n.flags&128))return Pt=!1,Nx(e,n,s);Pt=!!(e.flags&131072)}else Pt=!1,Le&&n.flags&1048576&&ef(n,Hr,n.index);switch(n.lanes=0,n.tag){case 2:var a=n.type;zr(e,n),e=n.pendingProps;var l=Pa(n,jt.current);Ea(n,s),l=Yd(null,n,a,e,l,s);var r=Xd();return n.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Dt(a)?(r=!0,Mr(n)):r=!1,n.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Fd(n),l.updater=pi,n.stateNode=l,l._reactInternals=n,Vo(n,a,e,s),n=td(null,n,a,!0,r,s)):(n.tag=0,Le&&r&&Ld(n),kt(null,n,l,s),n=n.child),n;case 16:a=n.elementType;e:{switch(zr(e,n),e=n.pendingProps,l=a._init,a=l(a._payload),n.type=a,l=n.tag=Zx(a),e=fn(a,e),l){case 0:n=ed(null,n,a,e,s);break e;case 1:n=mu(null,n,a,e,s);break e;case 11:n=hu(null,n,a,e,s);break e;case 14:n=gu(null,n,a,fn(a.type,e),s);break e}throw Error(q(306,a,""))}return n;case 0:return a=n.type,l=n.pendingProps,l=n.elementType===a?l:fn(a,l),ed(e,n,a,l,s);case 1:return a=n.type,l=n.pendingProps,l=n.elementType===a?l:fn(a,l),mu(e,n,a,l,s);case 3:e:{if(Df(n),e===null)throw Error(q(387));a=n.pendingProps,r=n.memoizedState,l=r.element,rf(e,n),Kr(n,a,null,s);var i=n.memoizedState;if(a=i.element,r.isDehydrated)if(r={element:a,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},n.updateQueue.baseState=r,n.memoizedState=r,n.flags&256){l=La(Error(q(423)),n),n=xu(e,n,a,s,l);break e}else if(a!==l){l=La(Error(q(424)),n),n=xu(e,n,a,s,l);break e}else for($t=rs(n.stateNode.containerInfo.firstChild),Ut=n,Le=!0,gn=null,s=af(n,null,a,s),n.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Ra(),a===l){n=Gn(e,n,s);break e}kt(e,n,a,s)}n=n.child}return n;case 5:return of(n),e===null&&Xo(n),a=n.type,l=n.pendingProps,r=e!==null?e.memoizedProps:null,i=l.children,Ho(a,l)?i=null:r!==null&&Ho(a,r)&&(n.flags|=32),Rf(e,n),kt(e,n,i,s),n.child;case 6:return e===null&&Xo(n),null;case 13:return Of(e,n,s);case 4:return Hd(n,n.stateNode.containerInfo),a=n.pendingProps,e===null?n.child=Da(n,null,a,s):kt(e,n,a,s),n.child;case 11:return a=n.type,l=n.pendingProps,l=n.elementType===a?l:fn(a,l),hu(e,n,a,l,s);case 7:return kt(e,n,n.pendingProps,s),n.child;case 8:return kt(e,n,n.pendingProps.children,s),n.child;case 12:return kt(e,n,n.pendingProps.children,s),n.child;case 10:e:{if(a=n.type._context,l=n.pendingProps,r=n.memoizedProps,i=l.value,Ie(Gr,a._currentValue),a._currentValue=i,r!==null)if(yn(r.value,i)){if(r.children===l.children&&!Rt.current){n=Gn(e,n,s);break e}}else for(r=n.child,r!==null&&(r.return=n);r!==null;){var d=r.dependencies;if(d!==null){i=r.child;for(var f=d.firstContext;f!==null;){if(f.context===a){if(r.tag===1){f=Un(-1,s&-s),f.tag=2;var p=r.updateQueue;if(p!==null){p=p.shared;var C=p.pending;C===null?f.next=f:(f.next=C.next,C.next=f),p.pending=f}}r.lanes|=s,f=r.alternate,f!==null&&(f.lanes|=s),qo(r.return,s,n),d.lanes|=s;break}f=f.next}}else if(r.tag===10)i=r.type===n.type?null:r.child;else if(r.tag===18){if(i=r.return,i===null)throw Error(q(341));i.lanes|=s,d=i.alternate,d!==null&&(d.lanes|=s),qo(i,s,n),i=r.sibling}else i=r.child;if(i!==null)i.return=r;else for(i=r;i!==null;){if(i===n){i=null;break}if(r=i.sibling,r!==null){r.return=i.return,i=r;break}i=i.return}r=i}kt(e,n,l.children,s),n=n.child}return n;case 9:return l=n.type,a=n.pendingProps.children,Ea(n,s),l=tn(l),a=a(l),n.flags|=1,kt(e,n,a,s),n.child;case 14:return a=n.type,l=fn(a,n.pendingProps),l=fn(a.type,l),gu(e,n,a,l,s);case 15:return Af(e,n,n.type,n.pendingProps,s);case 17:return a=n.type,l=n.pendingProps,l=n.elementType===a?l:fn(a,l),zr(e,n),n.tag=1,Dt(a)?(e=!0,Mr(n)):e=!1,Ea(n,s),If(n,a,l),Vo(n,a,l,s),td(null,n,a,!0,e,s);case 19:return Lf(e,n,s);case 22:return Pf(e,n,s)}throw Error(q(156,n.tag))};function Vf(e,n){return wp(e,n)}function Vx(e,n,s,a){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vt(e,n,s,a){return new Vx(e,n,s,a)}function lc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zx(e){if(typeof e=="function")return lc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===wd)return 11;if(e===kd)return 14}return 2}function cs(e,n){var s=e.alternate;return s===null?(s=Vt(e.tag,n,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=n,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,n=e.dependencies,s.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function Tr(e,n,s,a,l,r){var i=2;if(a=e,typeof e=="function")lc(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case fa:return Ls(s.children,l,r,n);case _d:i=8,l|=8;break;case So:return e=Vt(12,s,n,l|2),e.elementType=So,e.lanes=r,e;case _o:return e=Vt(13,s,n,l),e.elementType=_o,e.lanes=r,e;case wo:return e=Vt(19,s,n,l),e.elementType=wo,e.lanes=r,e;case ip:return gi(s,l,r,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case lp:i=10;break e;case rp:i=9;break e;case wd:i=11;break e;case kd:i=14;break e;case Xn:i=16,a=null;break e}throw Error(q(130,e==null?e:typeof e,""))}return n=Vt(i,s,n,l),n.elementType=e,n.type=a,n.lanes=r,n}function Ls(e,n,s,a){return e=Vt(7,e,a,n),e.lanes=s,e}function gi(e,n,s,a){return e=Vt(22,e,a,n),e.elementType=ip,e.lanes=s,e.stateNode={isHidden:!1},e}function go(e,n,s){return e=Vt(6,e,null,n),e.lanes=s,e}function mo(e,n,s){return n=Vt(4,e.children!==null?e.children:[],e.key,n),n.lanes=s,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function ey(e,n,s,a,l){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xi(0),this.expirationTimes=Xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xi(0),this.identifierPrefix=a,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function rc(e,n,s,a,l,r,i,d,f){return e=new ey(e,n,s,d,f),n===1?(n=1,r===!0&&(n|=8)):n=0,r=Vt(3,null,null,n),e.current=r,r.stateNode=e,r.memoizedState={element:a,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fd(r),e}function ty(e,n,s){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:pa,key:a==null?null:""+a,children:e,containerInfo:n,implementation:s}}function Zf(e){if(!e)return ps;e=e._reactInternals;e:{if(Hs(e)!==e||e.tag!==1)throw Error(q(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(Dt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(q(171))}if(e.tag===1){var s=e.type;if(Dt(s))return Vp(e,s,n)}return n}function eh(e,n,s,a,l,r,i,d,f){return e=rc(s,a,!0,e,l,r,i,d,f),e.context=Zf(null),s=e.current,a=Ct(),l=ds(s),r=Un(a,l),r.callback=n??null,is(s,r,l),e.current.lanes=l,Bl(e,l,a),Ot(e,a),e}function mi(e,n,s,a){var l=n.current,r=Ct(),i=ds(l);return s=Zf(s),n.context===null?n.context=s:n.pendingContext=s,n=Un(r,i),n.payload={element:e},a=a===void 0?null:a,a!==null&&(n.callback=a),e=is(l,n,i),e!==null&&(xn(e,l,i,r),wr(e,l,i)),i}function ti(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function zu(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<n?s:n}}function ic(e,n){zu(e,n),(e=e.alternate)&&zu(e,n)}function ny(){return null}var th=typeof reportError=="function"?reportError:function(e){console.error(e)};function oc(e){this._internalRoot=e}xi.prototype.render=oc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(q(409));mi(e,n,null,null)};xi.prototype.unmount=oc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Us(function(){mi(null,e,null,null)}),n[Fn]=null}};function xi(e){this._internalRoot=e}xi.prototype.unstable_scheduleHydration=function(e){if(e){var n=Ap();e={blockedOn:null,target:e,priority:n};for(var s=0;s<Jn.length&&n!==0&&n<Jn[s].priority;s++);Jn.splice(s,0,e),s===0&&Rp(e)}};function dc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function yi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Iu(){}function sy(e,n,s,a,l){if(l){if(typeof a=="function"){var r=a;a=function(){var p=ti(i);r.call(p)}}var i=eh(n,a,e,0,null,!1,!1,"",Iu);return e._reactRootContainer=i,e[Fn]=i.current,zl(e.nodeType===8?e.parentNode:e),Us(),i}for(;l=e.lastChild;)e.removeChild(l);if(typeof a=="function"){var d=a;a=function(){var p=ti(f);d.call(p)}}var f=rc(e,0,!1,null,null,!1,!1,"",Iu);return e._reactRootContainer=f,e[Fn]=f.current,zl(e.nodeType===8?e.parentNode:e),Us(function(){mi(n,f,s,a)}),f}function vi(e,n,s,a,l){var r=s._reactRootContainer;if(r){var i=r;if(typeof l=="function"){var d=l;l=function(){var f=ti(i);d.call(f)}}mi(n,i,e,l)}else i=sy(s,n,e,l,a);return ti(i)}Ep=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var s=il(n.pendingLanes);s!==0&&(Id(n,s|1),Ot(n,Ze()),!(ve&6)&&(Wa=Ze()+500,ms()))}break;case 13:Us(function(){var a=Hn(e,1);if(a!==null){var l=Ct();xn(a,e,1,l)}}),ic(e,1)}};Ed=function(e){if(e.tag===13){var n=Hn(e,134217728);if(n!==null){var s=Ct();xn(n,e,134217728,s)}ic(e,134217728)}};Tp=function(e){if(e.tag===13){var n=ds(e),s=Hn(e,n);if(s!==null){var a=Ct();xn(s,e,n,a)}ic(e,n)}};Ap=function(){return we};Pp=function(e,n){var s=we;try{return we=e,n()}finally{we=s}};Do=function(e,n,s){switch(n){case"input":if(zo(e,s),n=s.name,s.type==="radio"&&n!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<s.length;n++){var a=s[n];if(a!==e&&a.form===e.form){var l=di(a);if(!l)throw Error(q(90));dp(a),zo(a,l)}}}break;case"textarea":up(e,s);break;case"select":n=s.value,n!=null&&ka(e,!!s.multiple,n,!1)}};yp=nc;vp=Us;var ay={usingClientEntryPoint:!1,Events:[Ul,xa,di,mp,xp,nc]},nl={findFiberByHostInstance:As,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ly={bundleType:nl.bundleType,version:nl.version,rendererPackageName:nl.rendererPackageName,rendererConfig:nl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Qn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Sp(e),e===null?null:e.stateNode},findFiberByHostInstance:nl.findFiberByHostInstance||ny,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 hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hr.isDisabled&&hr.supportsFiber)try{li=hr.inject(ly),In=hr}catch{}}Ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ay;Ft.createPortal=function(e,n){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!dc(n))throw Error(q(200));return ty(e,n,null,s)};Ft.createRoot=function(e,n){if(!dc(e))throw Error(q(299));var s=!1,a="",l=th;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),n=rc(e,1,!1,null,null,s,!1,a,l),e[Fn]=n.current,zl(e.nodeType===8?e.parentNode:e),new oc(n)};Ft.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(q(188)):(e=Object.keys(e).join(","),Error(q(268,e)));return e=Sp(n),e=e===null?null:e.stateNode,e};Ft.flushSync=function(e){return Us(e)};Ft.hydrate=function(e,n,s){if(!yi(n))throw Error(q(200));return vi(null,e,n,!0,s)};Ft.hydrateRoot=function(e,n,s){if(!dc(e))throw Error(q(405));var a=s!=null&&s.hydratedSources||null,l=!1,r="",i=th;if(s!=null&&(s.unstable_strictMode===!0&&(l=!0),s.identifierPrefix!==void 0&&(r=s.identifierPrefix),s.onRecoverableError!==void 0&&(i=s.onRecoverableError)),n=eh(n,null,e,1,s??null,l,!1,r,i),e[Fn]=n.current,zl(e),a)for(e=0;e<a.length;e++)s=a[e],l=s._getVersion,l=l(s._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[s,l]:n.mutableSourceEagerHydrationData.push(s,l);return new xi(n)};Ft.render=function(e,n,s){if(!yi(n))throw Error(q(200));return vi(null,e,n,!1,s)};Ft.unmountComponentAtNode=function(e){if(!yi(e))throw Error(q(40));return e._reactRootContainer?(Us(function(){vi(null,null,e,!1,function(){e._reactRootContainer=null,e[Fn]=null})}),!0):!1};Ft.unstable_batchedUpdates=nc;Ft.unstable_renderSubtreeIntoContainer=function(e,n,s,a){if(!yi(s))throw Error(q(200));if(e==null||e._reactInternals===void 0)throw Error(q(38));return vi(e,n,s,!1,a)};Ft.version="18.3.1-next-f1338f8080-20240426";function nh(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(nh)}catch(e){console.error(e)}}nh(),tp.exports=Ft;var ry=tp.exports,sh,Eu=ry;sh=Eu.createRoot,Eu.hydrateRoot;const ue="",P={incidents:"SB Incident",ideas:"SB Idea",orders:"SB Order",organizations:"SB Organization",processes:"SB Process",managements:"Managements",departments:"Department",branches:"Branch",incidentTypes:"Incident Types",ideaTypes:"Idea Types",orderTypes:"Order Types",processTypes:"Process Types",incidentClass:"Incident Class",incidentField:"Incident Field",incidentStatuses:"Incident Statuses",ideaStatuses:"Idea Statuses",orderStatuses:"Order Statuses",processStatuses:"Process Statuses",users:"User",cycles:"SB Cycle",kpiInput:"SB KPI Input",delegations:"SB Delegation",groupCompanies:"SB Group Company",currency:"Currency"},V={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},iy=[{id:"dashboard",icon:"📊",label:"Dashboard"},{id:"inbox",icon:"📥",label:"Inbox"},{id:"incidents",icon:"📋",label:"Incidents"},{id:"ideas",icon:"💡",label:"Ideas"},{id:"orders",icon:"📦",label:"Orders"},{id:"processes",icon:"⚙️",label:"Processes"},{id:"delegations",icon:"🤝",label:"Delegations"},{id:"reports",icon:"📈",label:"Reports"}],ah=[{id:"group-companies",icon:"🌐",label:"Group Companies"},{id:"users",icon:"👤",label:"Users"},{id:"organizations",icon:"🏢",label:"Organizations"},{id:"managements",icon:"🏗️",label:"Managements"},{id:"departments",icon:"🗂️",label:"Departments"},{id:"branches",icon:"🌿",label:"Branches"},{id:"cycles",icon:"🔄",label:"Cycles"},{id:"kpi-input",icon:"📊",label:"KPI Input"},{id:"incident-types",icon:"🚨",label:"Incident Types"},{id:"idea-types",icon:"💡",label:"Idea Types"},{id:"order-types",icon:"📦",label:"Order Types"},{id:"process-types",icon:"⚙️",label:"Process Types"},{id:"incident-statuses",icon:"🔴",label:"Incident Statuses"},{id:"idea-statuses",icon:"🟢",label:"Idea Statuses"},{id:"order-statuses",icon:"🟣",label:"Order Statuses"},{id:"process-statuses",icon:"🔵",label:"Process Statuses"}],oy=new Set(["users","group-companies"]);function dy(e){return e!=="Admin"&&e!=="Auditor"&&e!=="CEO"?[]:ah.filter(({id:n})=>e==="Admin"||e==="CEO"||!oy.has(n))}const Yn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],cy={incidents:{label:"Incidents",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date",label:"Date"},{key:"assigned_to",label:"Assigned To"},{key:"priority",label:"Priority"},{key:"economy_class",label:"Economy Class"},{key:"entity_scope",label:"Entity Scope"},{key:"hses_field",label:"HSES Field"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date","assigned_to"]},ideas:{label:"Ideas",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date",label:"Date"},{key:"assigned_to",label:"Assigned To"},{key:"priority",label:"Priority"},{key:"economy_class",label:"Economy Class"},{key:"current_condition",label:"Current Condition"},{key:"proposed_condition",label:"Proposed Condition"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date","assigned_to"]},orders:{label:"Orders",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"starting_date",label:"Start Date"},{key:"ending_date",label:"End Date"},{key:"assigned_to",label:"Assigned To"},{key:"budget",label:"Budget"},{key:"actual_cost",label:"Actual Cost"},{key:"currency",label:"Currency"},{key:"stage",label:"Stage"},{key:"completion_pct",label:"Completion %"},{key:"priority",label:"Priority"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","starting_date","ending_date","assigned_to","budget"]},processes:{label:"Processes",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date_start",label:"Start Date"},{key:"date_end",label:"End Date"},{key:"actor",label:"Actor"},{key:"cycle_type",label:"Cycle Type"},{key:"kpi_name",label:"KPI Name"},{key:"cost_per_cycle",label:"Cost / Cycle"},{key:"escalation_level",label:"Escalation"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date_start","date_end","actor"]},organizations:{label:"Organizations",columns:[{key:"name",label:"Code"},{key:"organization_name",label:"Organization Name"},{key:"type",label:"Type"},{key:"city",label:"City"},{key:"contact_email",label:"Contact Email"},{key:"is_active",label:"Active"},{key:"creation_date",label:"Created On"}],defaultColumns:["organization_name","type","city","contact_email","is_active"]},managements:{label:"Managements",orgField:"organization",columns:[{key:"name1",label:"Name"},{key:"organization",label:"Organization"},{key:"status",label:"Status"},{key:"creation_date",label:"Created On"}],defaultColumns:["name1","organization","status"]},departments:{label:"Departments",orgField:"custom_organization",columns:[{key:"department_name",label:"Department Name"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_status",label:"Status"},{key:"custom_creation_date",label:"Created On"}],defaultColumns:["department_name","custom_organization","custom_management","custom_status"]},branches:{label:"Branches",orgField:"organization",columns:[{key:"branch",label:"Branch"},{key:"organization",label:"Organization"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"custom_status",label:"Status"},{key:"custom_creation_date",label:"Created On"}],defaultColumns:["branch","organization","management","department","custom_status"]},cycles:{label:"Cycles",orgField:"organization",columns:[{key:"name1",label:"Name"},{key:"organization",label:"Organization"},{key:"frequency",label:"Frequency"},{key:"status",label:"Status"},{key:"start_date",label:"Start Date"},{key:"end_date",label:"End Date"},{key:"update_window_days",label:"Update Window (days)"}],defaultColumns:["name1","organization","frequency","status","start_date","end_date"]},"kpi-input":{label:"KPI Input",orgField:"organization",columns:[{key:"organization",label:"Organization"},{key:"period",label:"Period"},{key:"revenue_growth",label:"Revenue Growth"},{key:"net_profit",label:"Net Profit"},{key:"cash_flow",label:"Cash Flow"},{key:"strategic_goal_pct",label:"Strategic Goal %"},{key:"customer_satisfaction",label:"Customer Satisfaction"},{key:"employee_turnover_pct",label:"Employee Turnover %"},{key:"open_safety_incidents",label:"Open Safety Incidents"},{key:"compliance_score",label:"Compliance Score"}],defaultColumns:["organization","period","revenue_growth","net_profit","cash_flow"]},"incident-types":{label:"Incident Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:Yn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:Yn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},users:{label:"Users",orgField:"custom_organization",columns:[{key:"full_name",label:"Full Name"},{key:"email",label:"Email"},{key:"username",label:"Username"},{key:"mobile_no",label:"Phone"},{key:"custom_category",label:"Category"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_department",label:"Department"},{key:"custom_branch",label:"Branch"},{key:"custom_number",label:"User ID No"},{key:"enabled",label:"Active"},{key:"creation",label:"Created On"}],defaultColumns:["full_name","email","custom_category","custom_organization","enabled"]},delegations:{label:"Delegations",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"auditor",label:"Delegator"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"incident_initial_evaluation",label:"Incident Initial Evaluation"},{key:"idea_initial_evaluation",label:"Idea Initial Evaluation"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","incident_initial_evaluation","idea_initial_evaluation","status","requested_on"]},"group-companies":{label:"Group Companies",columns:[{key:"company_name",label:"Company Name"},{key:"code",label:"Code"},{key:"acronym",label:"Acronym"},{key:"owner_user",label:"Group Co Owner"},{key:"status",label:"Status"}],defaultColumns:["company_name","code","acronym","owner_user","status"]}},uy=()=>t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),py=()=>t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),fy=()=>t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v6M14 11v6"}),t.jsx("path",{d:"M9 6V4h6v2"})]});function ot({onView:e,onEdit:n,onDelete:s}){const a=(l,r,i,d,f,p)=>d?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),d()},title:p,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:l,color:i,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:C=>{C.currentTarget.style.background=r,C.currentTarget.style.transform="scale(1.08)"},onMouseLeave:C=>{C.currentTarget.style.background=l,C.currentTarget.style.transform="scale(1)"},children:f},p):null;return t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a("#f0f9ff","#e0f2fe","#0284c7",e,t.jsx(uy,{}),"View"),a("#f0fdf4","#dcfce7","#16a34a",n,t.jsx(py,{}),"Edit"),s&&a("#fff1f2","#fee2e2","#e11d48",s,t.jsx(fy,{}),"Delete")]})}const D={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},R={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function lh(e){return e?e.custom_is_deleted===1||e.custom_is_deleted==="1"||e.custom_is_deleted===!0||e.is_deleted===1||e.is_deleted==="1"||e.is_deleted===!0||e.status==="Deleted"||e.custom_status==="Deleted":!1}function hy(e){return lh(e)?!1:typeof(e==null?void 0:e.is_active)<"u"?!!e.is_active:typeof(e==null?void 0:e.status)<"u"?e.status!=="Inactive":typeof(e==null?void 0:e.custom_status)<"u"?e.custom_status!=="Inactive":!0}function Se(e,n){return(e||[]).filter(s=>!lh(s)&&(hy(s)||s.name===n))}const gy={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function ts(e,n){return!!n&&gy[e].includes(n)}function en(e,n){return(e||[]).filter(s=>{if(!s)return!1;const a=s,l=a.organization||a.custom_organization;if(n.organization&&l&&l!==n.organization)return!1;const r=a.management||a.custom_management;if(n.management&&r&&r!==n.management)return!1;const i=a.department||a.custom_department;return!(n.department&&i&&i!==n.department)})}function Na(e,n,s,a){return(e||[]).filter(l=>{const r=n[l.name]||[],i=l.custom_category||"",d=s==="SB Manager"&&i==="Manager"||s==="SB Employee"&&i==="Employee"||s==="SB Auditor"&&(i==="Auditor"||i==="X-Auditor")||s==="SB Admin"&&i==="Admin"||(s==="CEO"||s==="SB CEO")&&(i==="CEO"||i==="Chairman");return!((r.includes("SB Admin")||r.includes("System Manager")||i==="Admin")&&s!=="SB Admin"||!r.includes(s)&&!d||a&&l.custom_organization&&l.custom_organization!==a)})}const Ba={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function Ar(e){const n=(e||"").trim().toLowerCase();return n==="new"||n==="initial evaluation"||n==="draft"?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:n.includes("progress")||n.includes("review")||n.includes("proposal")||n.includes("resolution")?{bg:"#fefce8",color:"#a16207",border:"#fef08a"}:n.includes("executed")||n.includes("approved")||n.includes("active")||n.includes("closed")||n.includes("completed")?{bg:"#f0fdf4",color:"#15803d",border:"#bbf7d0"}:n.includes("rejected")||n.includes("overdue")||n.includes("fail")||n.includes("inactive")?{bg:"#fef2f2",color:"#b91c1c",border:"#fecaca"}:n.includes("deleted")?{bg:"#fff1f2",color:"#e11d48",border:"#fecdd3"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}function my(e){const n=(e||"").trim().toLowerCase();return n.includes("incident")?{bg:"#f1f5f9",color:"#334155",border:"#cbd5e1"}:n.includes("complaint")?{bg:"#fff7ed",color:"#c2410c",border:"#fed7aa"}:n.includes("violation")?{bg:"#faf5ff",color:"#7e22ce",border:"#e9d5ff"}:n.includes("process")?{bg:"#f0fdfa",color:"#0f766e",border:"#99f6e4"}:n.includes("asset")?{bg:"#ecfeff",color:"#0e7490",border:"#a5f3fc"}:n.includes("human")?{bg:"#f5f3ff",color:"#6d28d9",border:"#ddd6fe"}:n.includes("idea")?{bg:"#ecfdf5",color:"#047857",border:"#a7f3d0"}:n.includes("study")?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}const Ll=(e,n)=>{let s;return typeof n=="object"&&n!==null?s=n:typeof n=="string"&&n.startsWith("#")?s=Ar(e):typeof n=="string"?s=Ar(n):s=Ar(e),t.jsx("span",{className:"status-badge",style:{background:s.bg,color:s.color,border:`1px solid ${s.border}`,padding:"2px 8px",borderRadius:9999,fontSize:11,fontWeight:600,letterSpacing:"0.2px",display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:1.3,whiteSpace:"nowrap",boxSizing:"border-box",transition:"all 0.15s ease"},children:e})},fs=e=>Ll(e,Ar(e)),cc=e=>Ll(e,my(e));function et({deletedBy:e,deletedOn:n,reason:s,onRestore:a,onPermanentDelete:l,isRestoring:r}){return t.jsxs("div",{style:{background:"#fff1f2",border:"1px solid #fecdd3",borderRadius:8,padding:"7px 14px",marginBottom:12,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,color:"#9f1239",fontSize:12,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsxs("div",{style:{fontWeight:700,fontSize:12,display:"flex",alignItems:"center",gap:5,color:"#be123c",whiteSpace:"nowrap"},children:[t.jsx("span",{style:{fontSize:13},children:"⚠️"}),t.jsx("span",{children:"DELETED RECORD / سجل محذوف"})]}),t.jsxs("div",{style:{fontSize:11,color:"#881337",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e&&t.jsxs("span",{children:[t.jsx("strong",{children:"Deleted By:"})," ",e]}),n&&t.jsxs("span",{children:["| ",t.jsx("strong",{children:"Deleted On:"})," ",n]}),s&&t.jsxs("span",{children:["| ",t.jsx("strong",{children:"Reason:"})," ",s]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a&&t.jsxs("button",{type:"button",onClick:a,disabled:r,style:{background:"#16a34a",color:"white",border:"none",borderRadius:6,padding:"5px 12px",fontSize:11,fontWeight:700,cursor:r?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:5,whiteSpace:"nowrap",transition:"all 0.15s ease"},onMouseEnter:i=>{r||(i.currentTarget.style.background="#15803d")},onMouseLeave:i=>{r||(i.currentTarget.style.background="#16a34a")},children:[t.jsx("span",{children:"↺"}),t.jsx("span",{children:r?"Restoring...":"Restore Record / استعادة"})]}),l&&t.jsxs("button",{type:"button",onClick:l,style:{background:"#dc2626",color:"white",border:"none",borderRadius:6,padding:"5px 12px",fontSize:11,fontWeight:700,cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:5,whiteSpace:"nowrap",transition:"all 0.15s ease"},onMouseEnter:i=>{i.currentTarget.style.background="#b91c1c"},onMouseLeave:i=>{i.currentTarget.style.background="#dc2626"},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:"Permanent Delete / حذف نهائي"})]})]})]})}function ji({onDelete:e,disabled:n,title:s="Delete Request",btnText:a="Delete"}){return t.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #fee2e2",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:s}),t.jsxs("button",{type:"button",onClick:e,disabled:n,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:"#dc2626",color:"#ffffff",fontWeight:700,fontSize:12,cursor:n?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,boxShadow:"0 1px 3px rgba(220, 38, 38, 0.25)",transition:"all 0.15s ease"},onMouseEnter:l=>{n||(l.currentTarget.style.background="#b91c1c")},onMouseLeave:l=>{n||(l.currentTarget.style.background="#dc2626")},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:a})]})]})}function ce({title:e,children:n,style:s}){return t.jsxs("div",{className:"form-card",style:{background:"#ffffff",borderRadius:10,border:"1px solid #e2e8f0",padding:"16px 20px",marginBottom:16,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.03)",...s},children:[t.jsx("div",{className:"form-card-title",style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:t.jsx("span",{children:e})}),n]})}function bi({title:e="Status Summary",priority:n,createdDate:s,modifiedDate:a,assignedTo:l,status:r}){const i=d=>{if(!d)return"—";try{const f=new Date(d);return isNaN(f.getTime())?d:f.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return d}};return t.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:12},children:e}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[n&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Priority"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:n==="High"||n==="Urgent"?"#dc2626":"#1e293b"},children:n})]}),r&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Status"}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#334155"},children:r})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Assigned To"}),t.jsx("div",{style:{fontSize:12,fontWeight:600,color:l?"#334155":"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l||"—"})]}),s&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Created"}),t.jsx("div",{style:{fontSize:11,color:"#64748b"},children:i(s)})]}),a&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Last Modified"}),t.jsx("div",{style:{fontSize:11,color:"#64748b"},children:i(a)})]})]})]})}const xy="modulepreload",yy=function(e){return"/"+e},Tu={},vy=function(n,s,a){let l=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));l=Promise.allSettled(s.map(f=>{if(f=yy(f),f in Tu)return;Tu[f]=!0;const p=f.endsWith(".css"),C=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${C}`))return;const j=document.createElement("link");if(j.rel=p?"stylesheet":xy,p||(j.as="script"),j.crossOrigin="",j.href=f,d&&j.setAttribute("nonce",d),document.head.appendChild(j),p)return new Promise((_,c)=>{j.addEventListener("load",_),j.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${f}`)))})}))}function r(i){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=i,window.dispatchEvent(d),!d.defaultPrevented)throw i}return l.then(i=>{for(const d of i||[])d.status==="rejected"&&r(d.reason);return n().catch(r)})};function rh(e,n){const s=e[n.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function jy(e,n){const s=URL.createObjectURL(e),a=document.createElement("a");a.href=s,a.download=n,a.click(),URL.revokeObjectURL(s)}function by(e,n,s){const a=e.map(i=>`"${i.label.replace(/"/g,'""')}"`).join(","),l=n.map(i=>e.map(d=>`"${rh(i,d).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),r=new Blob([a+`
|
||
`+l],{type:"text/csv;charset=utf-8;"});jy(r,`${s}.csv`)}async function Sy(e,n,s){const a=await vy(()=>import("./xlsx-D_0l8YDs.js"),[]),l=n.map(d=>{const f={};for(const p of e)f[p.label]=rh(d,p);return f}),r=a.utils.json_to_sheet(l,{header:e.map(d=>d.label)}),i=a.utils.book_new();a.utils.book_append_sheet(i,r,"Export"),a.writeFile(i,`${s}.xlsx`)}const _n="#16a34a";function _y({title:e,rows:n,selectedRows:s=[],pageRows:a=[],columns:l,defaultColumnKeys:r,filenameBase:i,onClose:d}){const[f,p]=S.useState(s.length>0?"selected":"all"),[C,j]=S.useState("csv"),[_,c]=S.useState(new Set(r)),[y,z]=S.useState("");S.useEffect(()=>{s&&s.length>0&&p("selected")},[s]);const k=f==="selected"?s:f==="page"?a:n,g=l.filter(b=>_.has(b.key)),o=y?l.filter(b=>b.label.toLowerCase().includes(y.toLowerCase())):l,h=b=>{c(T=>{const E=new Set(T);return E.has(b)?E.delete(b):E.add(b),E})},x=async()=>{g.length===0||k.length===0||(C==="csv"?by(g,k,i):await Sy(g,k,i),d())},v={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},w={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"},u=[{id:"selected",label:"Selected rows",sub:`${s.length} row${s.length!==1?"s":""} selected`,count:s.length,disabled:s.length===0},{id:"page",label:"Current page",sub:`${a.length} row${a.length!==1?"s":""} on this page`,count:a.length},{id:"all",label:"All records (current filters)",sub:`${n.length} total matching records`,count:n.length}];return t.jsx("div",{onClick:d,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:t.jsxs("div",{onClick:b=>b.stopPropagation(),style:{width:580,maxWidth:"92vw",maxHeight:"90vh",background:"white",borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.3)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{background:_n,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[t.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e,t.jsxs("span",{style:{fontSize:12,fontWeight:400,opacity:.8},children:[l.length," fields available · ",_.size," selected"]})]}),t.jsx("button",{onClick:d,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"white",width:28,height:28,borderRadius:8,cursor:"pointer",fontSize:15,lineHeight:1},children:"✕"})]}),t.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{children:[t.jsx("div",{style:v,children:"What to export"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:u.map(b=>t.jsxs("label",{onClick:()=>!b.disabled&&p(b.id),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderRadius:10,cursor:b.disabled?"not-allowed":"pointer",border:`2px solid ${f===b.id?_n:"#e5e7eb"}`,background:f===b.id?"#f0fdf4":b.disabled?"#fafafa":"white",opacity:b.disabled?.5:1,transition:"border-color 0.15s, background 0.15s"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${f===b.id?_n:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:f===b.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:_n}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#111827"},children:b.label}),t.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:1},children:b.sub})]})]}),t.jsx("span",{style:{background:f===b.id?_n:"#e5e7eb",color:f===b.id?"white":"#374151",fontSize:12,fontWeight:700,padding:"2px 10px",borderRadius:9999},children:b.count})]},b.id))})]}),t.jsxs("div",{children:[t.jsx("div",{style:v,children:"File Format"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Universal, works everywhere",icon:"📄"},{id:"xlsx",label:"Excel (.xlsx)",desc:"Native Excel workbook",icon:"📊"}].map(b=>t.jsxs("div",{onClick:()=>j(b.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${C===b.id?_n:"#e5e7eb"}`,background:C===b.id?"#f0fdf4":"white"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${C===b.id?_n:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:C===b.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:_n}})}),t.jsx("span",{style:{fontSize:20},children:b.icon}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:b.label}),t.jsx("div",{style:{fontSize:11,color:"#888"},children:b.desc})]})]},b.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[t.jsx("div",{style:{...v,marginBottom:0},children:"Columns to Export"}),t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsx("button",{onClick:()=>c(new Set(l.map(b=>b.key))),style:w,children:"All"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>c(new Set(r)),style:w,children:"Default"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>c(new Set),style:{...w,color:"#ef4444"},children:"None"})]})]}),t.jsx("div",{style:{marginBottom:8},children:t.jsx("input",{type:"text",placeholder:"Search fields...",value:y,onChange:b=>z(b.target.value),style:{width:"100%",padding:"7px 10px",borderRadius:8,border:"1px solid #e5e7eb",fontSize:12,boxSizing:"border-box",background:"#f9fafb"}})}),t.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:"10px 12px"},children:o.map(b=>t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer",padding:"3px 5px",borderRadius:5,background:_.has(b.key)?"#f0fdf4":"transparent"},children:[t.jsx("input",{type:"checkbox",checked:_.has(b.key),onChange:()=>h(b.key),style:{accentColor:_n,cursor:"pointer"}}),b.label]},b.key))})}),t.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[_.size," of ",l.length," fields selected"]})]})]}),t.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[t.jsxs("span",{style:{fontSize:12,color:"#888"},children:["Exporting ",k.length," ",f==="selected"?"selected":f==="page"?"page":""," row",k.length!==1?"s":""]}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsx("button",{onClick:d,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{onClick:x,disabled:g.length===0||k.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:_n,color:"white",fontWeight:700,fontSize:13,cursor:g.length===0||k.length===0?"not-allowed":"pointer",opacity:g.length===0||k.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const ih="sidrah_rtl",fd="sidrah-lang-change";function wa(){try{return localStorage.getItem(ih)==="1"}catch{return!1}}function oh(){const e=!wa();try{localStorage.setItem(ih,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(fd))}function re(){const[e,n]=S.useState(wa);return S.useEffect(()=>{const s=()=>n(wa());return window.addEventListener(fd,s),document.documentElement.setAttribute("dir",wa()?"rtl":"ltr"),document.documentElement.setAttribute("lang",wa()?"ar":"en-GB"),()=>window.removeEventListener(fd,s)},[]),e?ky:wy}const wy={rtl:!1,nav:{dashboard:"Dashboard",inbox:"Inbox",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",reports:"Reports",users:"Users",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",settings:"Settings"},pages:{dashboard:"Dashboard",inbox:"Inbox",reports:"Reports",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",users:"Users"},new:"+ New",save:"Save",cancel:"Cancel",edit:"Edit",delete:"Delete",deletedBadge:"DELETED",restore:"Restore",restoring:"Restoring...",restoredOk:"Record restored successfully!",deletedBanner:"⚠️ This record has been deleted",deletedBy:"Deleted by",deletedOn:"Deleted on",deletedReason:"Reason",deleteModal:{title:"Confirm Deletion",subtitle:"Are you sure you want to delete this record?",softDeleteTitle:"Delete",softDeleteDesc:"Moves the record to deleted state. It can be restored later by an Administrator.",permanentDeleteTitle:"Permanent Delete",permanentDeleteDesc:"Permanently removes this record from the database. This action cannot be undone.",reasonLabel:"Reason for deletion (optional):",reasonPlaceholder:"Enter deletion reason…",softDeleteBtn:"Delete",permanentDeleteBtn:"Permanent Delete",cancelBtn:"Cancel",deleting:"Deleting…"},view:"View",back:"← Back",clear:"Clear",search:"Search",loading:"Loading...",saving:"Saving...",savedOk:"Saved successfully!",home:"Home",noRecords:"No records found",login:{subtitle:"Sign in to continue",username:"USERNAME",password:"PASSWORD",usernamePlaceholder:"Enter username",passwordPlaceholder:"Enter password",signIn:"Sign In",signingIn:"Signing in...",invalidCreds:"Invalid username or password",emptyFields:"Please enter username and password",connError:"Connection error: "},myProfile:"My Profile",signOut:"Sign Out",switchLang:"العربية (RTL)",filter:{numberTitle:"Number / Title",searchPlaceholder:"Search...",organization:"Organization",department:"Department",branch:"Branch",status:"Status",allOrgs:"All Organizations",allDepts:"All Departments",allBranches:"All Branches",allStatuses:"All Statuses",allTypes:"All Types"},col:{number:"Number",title:"Title",organization:"Organization",type:"Type",status:"Status",actions:"Actions",name:"Name",department:"Department",branch:"Branch",city:"City",email:"Email",management:"Management",organization_type:"Type",frequency:"Frequency",period:"Period",startDate:"Start Date",endDate:"End Date",auditor:"Auditor",manager:"Manager",functions:"Functions",requestedOn:"Requested On"},field:{number:"Number",title:"Title",organization:"Organization",management:"Management",department:"Department",section:"Section",branch:"Branch",type:"Type",date:"Date",time:"Time",status:"Status",description:"Description",assignedTo:"Assigned To",hsesField:"HSES Field",priority:"Priority",economyClass:"Economy Class",entityScope:"Entity Scope",productRelation:"Product Relation",repeatedEvent:"Repeated Event",solution:"Solution / Action Plan",actualCost:"Actual Cost",summary:"Resolution Summary",auditorComment:"Auditor Comment",incidentClass:"Incident Class",incidentField:"Incident Field",currentCondition:"Current Condition",proposedCondition:"Proposed Condition",ideaClass:"Idea Class",startingDate:"Starting Date",endingDate:"Ending Date",budget:"Budget",currency:"Currency",notes:"Notes",cycle:"Cycle",stage:"Stage",completionPct:"Completion %",actor:"Actor",escalationLevel:"Escalation Level",dateStart:"Start Date",dateEnd:"End Date",cycleType:"Cycle Type",progressIndicators:"Progress Indicators",impactLevel:"Impact Level",kpiName:"KPI Name",kpiType:"KPI Type",kpiMeasure:"KPI Measure",costPerCycle:"Cost per Cycle",chainLocation:"Chain Location",notifyManager:"Notify Manager",creationDate:"Creation Date",statusActive:"Active",statusInactive:"Inactive",name1:"Name",fullName:"Full Name",username:"Username",emailAddress:"Email Address",phoneNumber:"Phone Number",category:"Category",since:"Since",active:"Active",inactive:"Inactive",enabled:"Enabled",selectMgr:"-- Select manager --",select:"-- Select --",eventCategory:"Event Category",selectType:"-- Select type --",selectClass:"-- Select class --",selectField:"-- Select field --",selectStatus:"-- Select status --",solutionPlaceholder:"Describe the solution or action taken…",commentPlaceholder:"Optional comment…",high:"High",normal:"Normal",expenses:"Expenses",capital:"Capital",earn:"Earn",payLoss:"Pay/Loss",upstream:"Upstream",onstream:"On-stream",downstream:"Downstream",government:"Government",private:"Private",linkedOrder:"Linked Order",linkedIdea:"Linked Idea",convertedToOrder:"Converted to Order",originatingIdea:"Originating Idea",viewOrder:"View Order",viewIdea:"View Idea",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",cycleActive:"Active",cycleCompleted:"Completed",cyclePaused:"Paused",updateWindowDays:"Update Window (days)",incidentTriageWindowDays:"Triage Window (days)",incidentResolutionWindowDays:"Resolution Window (days)",orgAcronym:"Acronym",contactEmail:"Contact Email",orgCity:"City",orgName:"Organization Name",organizationType:"Organization Type",revenue_growth:"Revenue Growth (%)",net_profit:"Net Profit",cash_flow:"Cash Flow",strategic_goal_pct:"Strategic Goal (%)",customer_satisfaction:"Customer Satisfaction",employee_turnover_pct:"Employee Turnover (%)",open_safety_incidents:"Open Safety Incidents",compliance_score:"Compliance Score"},wf:{workflow:"Workflow",noActions:"No actions available for your role in this state.",applying:"Applying…",submit:"Submit",assignToManager:"Assign to Manager",reject:"Reject",submitSolution:"Submit Solution",resolutionComplete:"Resolution complete",moveToOutsourcing:"Move to Outsourcing",closeIdea:"Close Idea"},steps:{auditorTriage:"Auditor Triage (Step 2)",managerSolution:"Manager Solution (Step 3)",ownerComment:"Owner / Auditor Comment (Step 4)",auditorEval:"Auditor Evaluation (Step 2)",managerReview:"Manager Review (Step 3)"},formTitle:{newIncident:"New Incident",editIncident:"Edit Incident",viewIncident:"Incident: ",newIdea:"New Idea",editIdea:"Edit Idea",viewIdea:"Idea: ",newOrder:"New Order",editOrder:"Edit Order",viewOrder:"Order: ",newProcess:"New Process",editProcess:"Edit Process",viewProcess:"Process: ",newOrg:"New Organization",editOrg:"Edit Organization",newMgmt:"New Management",editMgmt:"Edit Management",newDept:"New Department",editDept:"Edit Department",newBranch:"New Branch",editBranch:"Edit Branch",newUser:"New User",editUser:"Edit User",viewUser:"User Profile",newCycle:"New Cycle",editCycle:"Edit Cycle",newKpi:"New KPI Input",editKpi:"Edit KPI Input",newDelegation:"New Delegation",viewDelegation:"Delegation: "},saveIncident:"Save Incident",saveIdea:"Save Idea",saveOrder:"Save Order",saveProcess:"Save Process",saveOrg:"Save Organization",saveMgmt:"Save Management",saveDept:"Save Department",saveBranch:"Save Branch",saveUser:"Save User",saveCycle:"Save Cycle",saveKpi:"Save KPI Input",saveDelegation:"Send Delegation",saveName:"Save",dash:{allOrgs:"All organizations",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",level2:"Level 2 — Critical Escalation",level1:"Level 1 — Auditor Review Needed",overduePrefix:"Overdue for Triage — ",overdueSuffix:" incident(s) past 3-day window",untriaged:"Untriaged Incidents",recentKpi:"Recent KPI Inputs",manageKpi:"Manage KPI Inputs",escalatedProcesses:"Escalated Processes",escalatedOrders:"Escalated Orders",level:"Level",revenueGrowth:"Revenue Growth",netProfit:"Net Profit",strategicGoal:"Strategic Goal",customerSat:"Customer Sat.",compliance:"Compliance",safetyInc:"Safety Incidents",total:"Total"},noIncidents:"No incidents found",noIdeas:"No ideas found",noOrders:"No orders found",noProcesses:"No processes found",noUsers:"No users found",noData:"No data found",users:{category:"Category",number:"Number",fullName:"Full Name",username:"Username",email:"Email Address",phone:"Phone Number",organization:"Organization",management:"Management",department:"Department",branch:"Branch",since:"Since",status:"Status",tools:"Tools",active:"Active",inactive:"Inactive",setPassword:"Set Password",newPassword:"New password",passwordUpdated:"Password updated!",passwordFailed:"Failed. Please try again.",disableConfirm:"Delete user? They will no longer appear in the list.",password:"Password"},inbox:{title:"Inbox",noMessages:"No messages"},reports:{title:"Reports",selectOrg:"Select Organization",generate:"Generate Report"},comments:{title:"Comments",placeholder:"Write a comment…",post:"Post",noComments:"No comments yet."},activity:{title:"Activity Log",created:"Created",by:"by"}},ky={rtl:!0,nav:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",reports:"التقارير",users:"المستخدمون",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",settings:"الإعدادات"},pages:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",reports:"التقارير",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",users:"المستخدمون"},new:"+ جديد",save:"حفظ",cancel:"إلغاء",edit:"تعديل",delete:"حذف",deletedBadge:"محذوف",restore:"استعادة",restoring:"جارٍ الاستعادة...",restoredOk:"تمت استعادة السجل بنجاح!",deletedBanner:"⚠️ هذا السجل محذوف",deletedBy:"تم الحذف بواسطة",deletedOn:"تاريخ الحذف",deletedReason:"السبب",deleteModal:{title:"تأكيد الحذف",subtitle:"هل أنت متأكد من رغبتك في حذف هذا السجل؟",softDeleteTitle:"حذف",softDeleteDesc:"يتم نقل السجل إلى سلة المحذوفات. يمكن للمسؤول استعادته لاحقاً.",permanentDeleteTitle:"حذف نهائي",permanentDeleteDesc:"حذف السجل نهائياً من قاعدة البيانات. لا يمكن التراجع عن هذا الإجراء.",reasonLabel:"سبب الحذف (اختياري):",reasonPlaceholder:"أدخل سبب الحذف…",softDeleteBtn:"حذف",permanentDeleteBtn:"حذف نهائي",cancelBtn:"إلغاء",deleting:"جارٍ الحذف…"},view:"عرض",back:"رجوع →",clear:"مسح",search:"بحث",loading:"جارٍ التحميل...",saving:"جارٍ الحفظ...",savedOk:"تم الحفظ بنجاح!",home:"الرئيسية",noRecords:"لا توجد سجلات",login:{subtitle:"تسجيل الدخول للمتابعة",username:"اسم المستخدم",password:"كلمة المرور",usernamePlaceholder:"أدخل اسم المستخدم",passwordPlaceholder:"أدخل كلمة المرور",signIn:"تسجيل الدخول",signingIn:"جارٍ تسجيل الدخول...",invalidCreds:"اسم المستخدم أو كلمة المرور غير صحيحة",emptyFields:"الرجاء إدخال اسم المستخدم وكلمة المرور",connError:"خطأ في الاتصال: "},myProfile:"ملفي الشخصي",signOut:"تسجيل الخروج",switchLang:"English (LTR)",filter:{numberTitle:"الرقم / العنوان",searchPlaceholder:"بحث...",organization:"المؤسسة",department:"القسم",branch:"الفرع",status:"الحالة",allOrgs:"جميع المؤسسات",allDepts:"جميع الأقسام",allBranches:"جميع الفروع",allStatuses:"جميع الحالات",allTypes:"جميع الأنواع"},col:{number:"الرقم",title:"العنوان",organization:"المؤسسة",type:"النوع",status:"الحالة",actions:"الإجراءات",name:"الاسم",department:"القسم",branch:"الفرع",city:"المدينة",email:"البريد الإلكتروني",management:"الإدارة",organization_type:"النوع",frequency:"التكرار",period:"الفترة",startDate:"تاريخ البدء",endDate:"تاريخ الانتهاء",auditor:"المدقق",manager:"المدير",functions:"الوظائف",requestedOn:"تاريخ الطلب"},field:{number:"الرقم",title:"العنوان",organization:"المؤسسة",management:"الإدارة",department:"القسم",section:"القطاع",branch:"الفرع",type:"النوع",date:"التاريخ",time:"الوقت",status:"الحالة",description:"الوصف",assignedTo:"مُسند إلى",hsesField:"مجال السلامة والصحة",priority:"الأولوية",economyClass:"التصنيف الاقتصادي",entityScope:"نطاق الكيان",productRelation:"علاقة المنتج",repeatedEvent:"حدث متكرر",solution:"الحل / خطة العمل",actualCost:"التكلفة الفعلية",summary:"ملخص الحل",auditorComment:"تعليق المدقق",incidentClass:"تصنيف الحادث",incidentField:"مجال الحادث",currentCondition:"الوضع الراهن",proposedCondition:"الوضع المقترح",ideaClass:"تصنيف الفكرة",startingDate:"تاريخ البدء",endingDate:"تاريخ الانتهاء",budget:"الميزانية",currency:"العملة",notes:"الملاحظات",cycle:"الدورة",stage:"المرحلة",completionPct:"نسبة الاكتمال",actor:"المنفذ",escalationLevel:"مستوى التصعيد",dateStart:"تاريخ البدء",dateEnd:"تاريخ الانتهاء",cycleType:"نوع الدورة",progressIndicators:"مؤشرات التقدم",impactLevel:"مستوى التأثير",kpiName:"اسم المؤشر",kpiType:"نوع المؤشر",kpiMeasure:"قياس المؤشر",costPerCycle:"التكلفة لكل دورة",chainLocation:"موقع السلسلة",notifyManager:"إشعار المدير",creationDate:"تاريخ الإنشاء",statusActive:"نشط",statusInactive:"غير نشط",name1:"الاسم",fullName:"الاسم الكامل",username:"اسم المستخدم",emailAddress:"البريد الإلكتروني",phoneNumber:"رقم الهاتف",category:"الفئة",since:"منذ",active:"نشط",inactive:"غير نشط",enabled:"مفعّل",selectMgr:"-- اختر المدير --",select:"-- اختر --",eventCategory:"فئة الحدث",selectType:"-- اختر النوع --",selectClass:"-- اختر التصنيف --",selectField:"-- اختر المجال --",selectStatus:"-- اختر الحالة --",solutionPlaceholder:"صف الحل أو الإجراء المتخذ…",commentPlaceholder:"تعليق اختياري…",high:"عالي",normal:"عادي",expenses:"مصروفات",capital:"رأس مال",earn:"إيرادات",payLoss:"دفع/خسارة",upstream:"مرحلة المنبع",onstream:"على الخط",downstream:"مرحلة المصب",government:"حكومي",private:"خاص",linkedOrder:"الأمر المرتبط",linkedIdea:"الفكرة المرتبطة",convertedToOrder:"تم التحويل إلى أمر",originatingIdea:"الفكرة الأصلية",viewOrder:"عرض الأمر",viewIdea:"عرض الفكرة",monthly:"شهري",quarterly:"ربع سنوي",yearly:"سنوي",cycleActive:"نشط",cycleCompleted:"مكتمل",cyclePaused:"موقوف",updateWindowDays:"نافذة التحديث (أيام)",incidentTriageWindowDays:"نافذة الفرز (أيام)",incidentResolutionWindowDays:"نافذة الحل (أيام)",orgAcronym:"الاختصار",contactEmail:"البريد الإلكتروني للتواصل",orgCity:"المدينة",orgName:"اسم المؤسسة",organizationType:"نوع المؤسسة",revenue_growth:"نمو الإيرادات (%)",net_profit:"صافي الربح",cash_flow:"التدفق النقدي",strategic_goal_pct:"الهدف الاستراتيجي (%)",customer_satisfaction:"رضا العملاء",employee_turnover_pct:"معدل دوران الموظفين (%)",open_safety_incidents:"حوادث السلامة المفتوحة",compliance_score:"درجة الامتثال"},wf:{workflow:"سير العمل",noActions:"لا توجد إجراءات متاحة لدورك في هذه الحالة.",applying:"جارٍ التطبيق...",submit:"إرسال",assignToManager:"تعيين للمدير",reject:"رفض",submitSolution:"إرسال الحل",resolutionComplete:"اكتمال الحل",moveToOutsourcing:"نقل للاستعانة بمصادر خارجية",closeIdea:"إغلاق الفكرة"},steps:{auditorTriage:"فرز المدقق (الخطوة 2)",managerSolution:"حل المدير (الخطوة 3)",ownerComment:"تعليق المالك / المدقق (الخطوة 4)",auditorEval:"تقييم المدقق (الخطوة 2)",managerReview:"مراجعة المدير (الخطوة 3)"},formTitle:{newIncident:"حادث جديد",editIncident:"تعديل الحادث",viewIncident:"الحادث: ",newIdea:"فكرة جديدة",editIdea:"تعديل الفكرة",viewIdea:"الفكرة: ",newOrder:"طلب جديد",editOrder:"تعديل الطلب",viewOrder:"الطلب: ",newProcess:"عملية جديدة",editProcess:"تعديل العملية",viewProcess:"العملية: ",newOrg:"مؤسسة جديدة",editOrg:"تعديل المؤسسة",newMgmt:"إدارة جديدة",editMgmt:"تعديل الإدارة",newDept:"قسم جديد",editDept:"تعديل القسم",newBranch:"فرع جديد",editBranch:"تعديل الفرع",newUser:"مستخدم جديد",editUser:"تعديل المستخدم",viewUser:"ملف المستخدم",newCycle:"دورة جديدة",editCycle:"تعديل الدورة",newKpi:"مؤشر أداء جديد",editKpi:"تعديل مؤشر الأداء",newDelegation:"تفويض جديد",viewDelegation:"التفويض: "},saveIncident:"حفظ الحادث",saveIdea:"حفظ الفكرة",saveOrder:"حفظ الطلب",saveProcess:"حفظ العملية",saveOrg:"حفظ المؤسسة",saveMgmt:"حفظ الإدارة",saveDept:"حفظ القسم",saveBranch:"حفظ الفرع",saveUser:"حفظ المستخدم",saveCycle:"حفظ الدورة",saveKpi:"حفظ مؤشر الأداء",saveDelegation:"إرسال التفويض",saveName:"حفظ",dash:{allOrgs:"جميع المؤسسات",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",level2:"المستوى 2 — تصعيد حرج",level1:"المستوى 1 — مراجعة المدقق مطلوبة",overduePrefix:"متأخر للفرز — ",overdueSuffix:" حادث(ة) تجاوز نافذة 3 أيام",untriaged:"حوادث غير مفرزة",recentKpi:"مؤشرات الأداء الأخيرة",manageKpi:"إدارة مؤشرات الأداء",escalatedProcesses:"عمليات متصاعدة",escalatedOrders:"طلبات متصاعدة",level:"المستوى",revenueGrowth:"نمو الإيرادات",netProfit:"صافي الربح",strategicGoal:"الهدف الاستراتيجي",customerSat:"رضا العملاء",compliance:"الامتثال",safetyInc:"حوادث السلامة",total:"الإجمالي"},noIncidents:"لا توجد حوادث",noIdeas:"لا توجد أفكار",noOrders:"لا توجد طلبات",noProcesses:"لا توجد عمليات",noUsers:"لا يوجد مستخدمون",noData:"لا توجد بيانات",users:{category:"الفئة",number:"الرقم",fullName:"الاسم الكامل",username:"اسم المستخدم",email:"البريد الإلكتروني",phone:"رقم الهاتف",organization:"المؤسسة",management:"الإدارة",department:"القسم",branch:"الفرع",since:"منذ",status:"الحالة",tools:"الأدوات",active:"نشط",inactive:"غير نشط",setPassword:"تعيين كلمة المرور",newPassword:"كلمة مرور جديدة",passwordUpdated:"تم تحديث كلمة المرور!",passwordFailed:"فشل. الرجاء المحاولة مرة أخرى.",disableConfirm:"حذف المستخدم؟ لن يظهر في القائمة بعد الآن.",password:"كلمة المرور"},inbox:{title:"البريد الوارد",noMessages:"لا توجد رسائل"},reports:{title:"التقارير",selectOrg:"اختر المؤسسة",generate:"إنشاء التقرير"},comments:{title:"التعليقات",placeholder:"اكتب تعليقاً…",post:"نشر",noComments:"لا توجد تعليقات بعد."},activity:{title:"سجل النشاط",created:"أُنشئ",by:"بواسطة"}};function Au({isOpen:e,doctype:n,docname:s,docTitle:a,isAdmin:l,isDeleting:r,onClose:i,onConfirmSoftDelete:d,onConfirmPermanentDelete:f}){const p=re(),[C,j]=S.useState("");if(S.useEffect(()=>{e&&j("")},[e]),S.useEffect(()=>{const c=y=>{y.key==="Escape"&&e&&!r&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e,r,i]),!e)return null;const _=n.replace(/^SB\s+/,"");return t.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:"rgba(15, 23, 42, 0.6)",backdropFilter:"blur(3px)",animation:"fadeIn 0.15s ease"},onClick:c=>{c.target===c.currentTarget&&!r&&i()},children:t.jsxs("div",{className:"delete-modal-card",style:{background:"white",borderRadius:12,boxShadow:"0 20px 35px -10px rgba(0, 0, 0, 0.22)",maxWidth:390,width:"100%",padding:"16px 18px",boxSizing:"border-box",position:"relative",animation:"scaleIn 0.15s ease",border:"1px solid rgba(226, 232, 240, 0.9)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#ef4444"},children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3 6h18m-2 0v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6m3 0V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),t.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),t.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("h3",{style:{margin:0,fontSize:14,fontWeight:700,color:"#1e293b"},children:p.deleteModal.title}),t.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:p.deleteModal.subtitle})]}),t.jsx("button",{type:"button",onClick:i,disabled:r,style:{background:"transparent",border:"none",color:"#94a3b8",cursor:"pointer",padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"6px 10px",marginBottom:12,display:"flex",alignItems:"center",gap:6},children:[t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.4px",flexShrink:0},children:[_,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?`${a} (${s})`:s})]}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#475569",marginBottom:4},children:p.deleteModal.reasonLabel}),t.jsx("input",{type:"text",value:C,onChange:c=>j(c.target.value),placeholder:p.deleteModal.reasonPlaceholder,disabled:r,style:{width:"100%",height:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,boxSizing:"border-box",outline:"none"},onFocus:c=>{c.target.style.borderColor="#6366f1",c.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:c=>{c.target.style.borderColor="#cbd5e1",c.target.style.boxShadow="none"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",onClick:i,disabled:r,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#475569",fontSize:12,fontWeight:600,cursor:r?"not-allowed":"pointer",transition:"background 0.15s"},children:p.deleteModal.cancelBtn}),t.jsxs("button",{type:"button",onClick:()=>d(C),disabled:r,title:p.deleteModal.softDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #fca5a5",background:"#fff1f2",color:"#b91c1c",fontSize:12,fontWeight:600,cursor:r?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s"},onMouseEnter:c=>{r||(c.currentTarget.style.background="#fee2e2")},onMouseLeave:c=>{r||(c.currentTarget.style.background="#fff1f2")},children:[t.jsx("span",{children:"🗑️"}),r?p.deleteModal.deleting:p.deleteModal.softDeleteBtn]}),l&&t.jsxs("button",{type:"button",onClick:()=>f(C),disabled:r,title:p.deleteModal.permanentDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"none",background:"#ef4444",color:"#ffffff",fontSize:12,fontWeight:600,cursor:r?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,boxShadow:"0 1px 3px rgba(239, 68, 68, 0.25)",transition:"all 0.15s"},onMouseEnter:c=>{r||(c.currentTarget.style.background="#dc2626")},onMouseLeave:c=>{r||(c.currentTarget.style.background="#ef4444")},children:[t.jsx("span",{children:"💥"}),r?p.deleteModal.deleting:p.deleteModal.permanentDeleteBtn]})]})]})})}const dh="/assets/logo-BlYgMyx5.png";function ch({collapsed:e,onToggleCollapsed:n,activePage:s,onNavigate:a,hasDashboard:l,hasReports:r,hasDelegations:i,role:d,hideSettings:f,rtl:p,navLabels:C,settingsLabel:j}){const _=f?[]:dy(d);return t.jsxs("div",{style:{width:e?60:230,background:"linear-gradient(180deg, #0f172a 0%, #1e1b4b 60%, #0b0f19 100%)",color:"white",flexShrink:0,display:"flex",flexDirection:"column",position:"sticky",top:0,height:"100vh",transition:"width 0.22s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.15)",borderRight:"1px solid rgba(255, 255, 255, 0.06)",zIndex:40},children:[t.jsxs("div",{style:{padding:e?"16px 0":"16px 16px 14px",borderBottom:"1px solid rgba(255, 255, 255, 0.08)",display:"flex",alignItems:"center",justifyContent:e?"center":"space-between",gap:8,flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"white",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",padding:3,boxSizing:"border-box",overflow:"hidden"},children:t.jsx("img",{src:dh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:c=>{c.currentTarget.style.display="none"}})}),!e&&t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.jsx("span",{style:{fontSize:14,fontWeight:800,whiteSpace:"nowrap",color:"#ffffff",letterSpacing:"-0.2px"},children:p?"صدرة للأعمال":"Sidrah"})})]}),t.jsx("button",{type:"button",onClick:n,title:e?p?"توسيع":"Expand":p?"طي":"Collapse",style:{background:"rgba(255, 255, 255, 0.06)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:6,color:"rgba(255, 255, 255, 0.75)",cursor:"pointer",fontSize:11,padding:"4px 7px",flexShrink:0,lineHeight:1,transition:"all 0.15s ease"},onMouseEnter:c=>{c.currentTarget.style.background="rgba(255, 255, 255, 0.15)",c.currentTarget.style.color="#ffffff"},onMouseLeave:c=>{c.currentTarget.style.background="rgba(255, 255, 255, 0.06)",c.currentTarget.style.color="rgba(255, 255, 255, 0.75)"},children:e?"▶":"✕"})]}),t.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[iy.filter(({id:c})=>(c!=="dashboard"||l)&&(c!=="reports"||r)&&(c!=="delegations"||i)).map(({id:c,icon:y})=>{const z=C[c]||c,k=c===s;return t.jsxs("div",{onClick:()=>a(c),title:e?z:void 0,className:"sidebar-nav-item",style:{padding:e?"8px 0":"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:10,background:k?"rgba(99, 102, 241, 0.28)":"transparent",border:k?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:k?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:k?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2,position:"relative"},onMouseEnter:g=>{k||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{k||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:y}),!e&&t.jsx("span",{children:z})]},c)}),_.length>0&&t.jsxs(t.Fragment,{children:[!e&&t.jsx("div",{style:{padding:"12px 12px 4px",fontSize:10,color:"rgba(255, 255, 255, 0.45)",fontWeight:700,letterSpacing:"0.8px",textTransform:"uppercase",marginTop:8},children:j}),e&&t.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),_.map(({id:c,icon:y})=>{const z=C[c]||c,k=c===s;return t.jsxs("div",{onClick:()=>a(c),title:e?z:void 0,className:"sidebar-nav-item",style:{padding:e?"8px 0":"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:10,background:k?"rgba(99, 102, 241, 0.28)":"transparent",border:k?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:k?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:k?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2},onMouseEnter:g=>{k||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{k||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:y}),!e&&t.jsx("span",{children:z})]},c)})]})]})]})}const Fa=new Set(["SB Incident","SB Idea","SB Order","SB Process","SB Organization","SB Cycle","SB KPI Input","Managements","Department","Branch","Incident Types","Idea Types","Order Types","Process Types","Incident Class","Incident Field","Incident Statuses","Idea Statuses","Order Statuses","Process Statuses","SB Group Company"]);let Ms="";async function uc(){try{const e=await fetch(`${ue}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const s=(await e.json()).message||"";if(s)return Ms=s,s}}catch(e){console.error("CSRF fetch error:",e)}return Ms}async function sn(){return Ms||await uc(),Ms}function Wl(e,n){try{if(e!=null&&e._server_messages){const a=JSON.parse(e._server_messages);if(a.length){const l=JSON.parse(a[0]);if(l!=null&&l.message)return l.message.replace(/<[^>]+>/g,"").trim()}}}catch{}let s=(e==null?void 0:e.message)||(e==null?void 0:e.exception)||(e==null?void 0:e.exc)||n;if(typeof s=="string"&&s.includes("frappe.exceptions.")){const a=s.split(`
|
||
`).map(r=>r.trim()).filter(r=>r&&!r.startsWith("Traceback")&&!r.startsWith("File "));s=(a[a.length-1]||s).replace(/^frappe\.exceptions\.\w+:\s*/,"").trim()}return s||n}async function Nt(e,n,s=[]){if(Fa.has(e)){const i=`${ue}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(n)}`,d=await fetch(i,{credentials:"include",headers:{Accept:"application/json"}});if(!d.ok)throw new Error(`API Error: ${d.status}`);return(await d.json()).message}const a=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",l=await fetch(`${ue}/api/v1/resource/${e}/${encodeURIComponent(n)}${a}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!l.ok)throw new Error(`API Error: ${l.status}`);return(await l.json()).data}async function hd(e,n,s="",a=!1){const l=await sn();if(Fa.has(e)){const d=new URLSearchParams({doctype:e,name:n});s&&d.append("reason",s),a&&d.append("permanent","1");const f=await fetch(`${ue}/api/method/sidrah_business.api.delete_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:d.toString()});if(!f.ok){const p=await f.json().catch(()=>({}));throw new Error(Wl(p,`Error deleting ${n}`))}return}const r=new URLSearchParams({doctype:e,name:n});s&&r.append("reason",s),a&&r.append("permanent","1");const i=await fetch(`${ue}/api/method/sidrah_business.soft_delete.soft_delete`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(Wl(d,`Error deleting ${n}`))}return await i.json()}async function Cy(e,n){const s=await sn();if(Fa.has(e)){const r=new URLSearchParams({doctype:e,name:n}),i=await fetch(`${ue}/api/method/sidrah_business.api.restore_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!i.ok){const f=await i.json().catch(()=>({}));throw new Error(Wl(f,`Error restoring ${n}`))}return(await i.json()).message||{success:!0}}const a=new URLSearchParams({doctype:e,name:n}),l=await fetch(`${ue}/api/method/sidrah_business.soft_delete.restore_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:a.toString()});if(!l.ok){const r=await l.json().catch(()=>({}));throw new Error(Wl(r,`Error restoring ${n}`))}return await l.json()}async function Oe(e){if(Fa.has(e))try{const a=`${ue}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,l=await fetch(a,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}const n=encodeURIComponent('["*"]'),s=`${ue}/api/v1/resource/${e}?limit_page_length=500&fields=${n}`;try{const a=await fetch(s,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return a.status===401||a.status===403?[]:a.ok?(await a.json()).data||[]:[]}catch(a){return console.error("Get error:",a),[]}}async function ni(e,n){const s=await sn();if(Fa.has(e)){const l=new URLSearchParams({doctype:e,data_json:JSON.stringify(n)}),r=await fetch(`${ue}/api/method/sidrah_business.api.create_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:l.toString()});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await r.json()).message}}const a=`${ue}/api/v1/resource/${e}`;try{const l=await fetch(a,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(n)});if(l.status===401||l.status===403)throw new Error("Permission denied - login required");if(!l.ok){const r=await l.json();throw new Error(r.message||r.exc||`API Error: ${l.status}`)}return await l.json()}catch(l){throw console.error("Post error:",l),l}}async function Ds(e,n,s){const a=await sn();if(Fa.has(e)){const r=new URLSearchParams({doctype:e,name:n,data_json:JSON.stringify(s)}),i=await fetch(`${ue}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":a},body:r.toString()});if(!i.ok){const f=await i.json().catch(()=>({}));throw new Error(f.message||f.exc||`Error updating ${e}`)}return{data:(await i.json()).message}}const l=`${ue}/api/v1/resource/${e}/${encodeURIComponent(n)}`;try{const r=await fetch(l,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":a},body:JSON.stringify(s)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const i=await r.json();throw new Error(i.message||"Update Error")}return await r.json()}catch(r){throw console.error("Update error:",r),r}}async function zy(){const e=`${ue}/api/method/sidrah_business.api.get_users`;try{const n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(n.status===401||n.status===403)return[];if(!n.ok)return[];const s=await n.json();return s.message||s.data||[]}catch(n){return console.error("Get users error:",n),[]}}async function Iy(e,n){const s=new FormData;s.append("usr",e),s.append("pwd",n);const l=await(await fetch(`${ue}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return l.csrf_token?Ms=l.csrf_token:await uc(),l}async function Ey(){const e=await sn();try{await fetch(`${ue}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Ms=""}function Ty(){return Ms}async function uh(){try{const e=await fetch(`${ue}/api/method/frappe.auth.get_logged_user`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return e.ok&&(await e.json()).message||""}catch{return""}}async function Ay(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),n=`${ue}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).data||[]:[]}catch{return[]}}async function Py(){const e=`${ue}/api/method/sidrah_business.api.get_user_role_map`;try{const n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||{}:{}}catch{return{}}}async function si(e,n){const s=await sn();try{const a=new URLSearchParams({user:e,password:n});(await fetch(`${ue}/api/method/sidrah_business.api.set_user_password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:a.toString()})).ok||await Ds("User",e,{new_password:n})}catch{await Ds("User",e,{new_password:n})}}async function Ry(e=20){try{const n=`${ue}/api/method/sidrah_business.api.get_notifications?limit=${e}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Dy(){const e=await sn();try{await fetch(`${ue}/api/method/sidrah_business.api.mark_notifications_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":e}})}catch{}}async function Oy(e){const n=await sn();try{await fetch(`${ue}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":n},body:new URLSearchParams({name:e}).toString()})}catch{}}async function Ly(e){const n=await sn(),s=new URLSearchParams({name:e});await fetch(`${ue}/api/method/sidrah_business.api.disable_user`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":n},body:s.toString()})}async function Wy(e,n){try{const s=`${ue}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,a=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return a.ok?(await a.json()).message||[]:[]}catch{return[]}}async function Ny(e,n,s){const a=await sn(),l=new URLSearchParams({doctype:e,docname:n,content:s}),r=await fetch(`${ue}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":a},body:l.toString()});if(!r.ok)throw new Error("Failed to post comment");return(await r.json()).message}async function By(e,n){try{const s=`${ue}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,a=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return a.ok?(await a.json()).message||[]:[]}catch{return[]}}async function ph(e){try{const n=`${ue}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,s=await fetch(n,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function $y(){try{const e=`${ue}/api/method/sidrah_business.api.get_my_organization`,n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return n.ok&&(await n.json()).message||""}catch{return""}}async function Gs(e,n={}){const s=await sn(),a=new URLSearchParams(n),l=await fetch(`${ue}/api/method/sidrah_business.api.${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:a.toString()});if(!l.ok){const i=await l.json().catch(()=>({}));throw new Error(Wl(i,`Error calling ${e}`))}return(await l.json()).message}async function Uy(e,n,s="",a,l,r){const i={name:e,action:n,comment:s};return a!==void 0&&(i.stage=a),r!==void 0&&(i.cycle_status=r),Gs("apply_order_workflow",i)}async function My(e,n,s=""){return Gs("apply_incident_workflow",{name:e,action:n,fields_json:s})}async function Fy(e,n,s=""){return Gs("apply_idea_workflow",{name:e,action:n,fields_json:s})}async function Hy(e=""){const n=`${ue}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function Gy(e,n={}){return Gs("get_report_data",{report_name:e,filters_json:JSON.stringify(n)})}async function Qy(){try{const e=`${ue}/api/method/sidrah_business.api.get_inbox_items`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Ky(e,n,s="",a="",l="",r=""){return Gs("create_delegation",{manager:e,functions_json:JSON.stringify(n),organization:s,remarks:a,incident_name:l,idea_name:r})}async function Yy(e,n,s=""){return Gs("respond_to_delegation",{name:e,response:n,remarks:s})}async function Xy(e,n=""){return Gs("revoke_delegation",{name:e,remarks:n})}async function qy(){try{const e=`${ue}/api/method/sidrah_business.api.get_delegations`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Jy(e){const n=`${ue}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error("Failed to load delegation");return(await s.json()).message}async function Vy(){try{const e=`${ue}/api/method/sidrah_business.api.get_my_delegated_functions`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Zy(){try{const e=`${ue}/api/method/sidrah_business.api.get_my_delegated_organizations`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||{}:{}}catch{return{}}}async function e0(){try{const e=await sn(),n=await fetch(`${ue}/api/method/sidrah_business.api.get_group_companies`,{method:"GET",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":e}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function t0(){const e=Ty();return e||uc()}async function dl(e){const n=await fetch(`${ue}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!n.ok){const a=await n.json().catch(()=>({}));throw new Error(a.message||`Failed to load process (${n.status})`)}const s=await n.json();return s.message||s.data}async function n0(e,n,s={}){const a=await t0(),l=new URLSearchParams({name:e,action:n});s.actor_status&&l.set("actor_status",String(s.actor_status)),s.actor_comment&&l.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&l.set("progress_indicators",JSON.stringify(s.progress_indicators));const r=await fetch(`${ue}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":a},body:l.toString()});if(!r.ok){const d=await r.json().catch(()=>({})),f=d.message||(d.exception?String(d.exception).split(`
|
||
`).pop():"")||d.exc_type||`Workflow action "${n}" failed (${r.status})`;throw new Error(f)}const i=await r.json();return i.message||i.data}const s0=["dashboard","incidents","incidents-form","ideas","ideas-form","orders","orders-form","processes","processes-form","processes-workflow","organizations","organizations-form","managements","managements-form","departments","departments-form","branches","branches-form","incident-types","incident-types-form","idea-types","idea-types-form","order-types","order-types-form","process-types","process-types-form","incident-statuses","incident-statuses-form","idea-statuses","idea-statuses-form","order-statuses","order-statuses-form","process-statuses","process-statuses-form","users","users-form","cycles","cycles-form","kpi-input","kpi-input-form","delegations","delegations-form","inbox","reports","profile"],Pu=new Set(s0),a0={"incidents-form":"incidents","ideas-form":"ideas","orders-form":"orders","processes-form":"processes","processes-workflow":"processes","organizations-form":"organizations","managements-form":"managements","departments-form":"departments","branches-form":"branches","incident-types-form":"incident-types","idea-types-form":"idea-types","order-types-form":"order-types","process-types-form":"process-types","incident-statuses-form":"incident-statuses","idea-statuses-form":"idea-statuses","order-statuses-form":"order-statuses","process-statuses-form":"process-statuses","users-form":"users","cycles-form":"cycles","kpi-input-form":"kpi-input","delegations-form":"delegations",profile:"dashboard"};function Ru(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return Pu.has(e)?e:null;const n=window.location.pathname.split("/").filter(Boolean).pop()||"";return Pu.has(n)?n:null}function l0(e){return e?a0[e]??e:null}function r0(e){return`#/${e}`}function i0({onLogin:e}){const n=re(),[s,a]=S.useState(""),[l,r]=S.useState(""),[i,d]=S.useState(""),[f,p]=S.useState(!1),[C,j]=S.useState(!1),[_,c]=S.useState(!1),y=async()=>{if(!s||!l){d(n.login.emptyFields);return}p(!0),d("");try{const k=await Iy(s,l);if(k.message==="Logged In"){const o=await uh()||s,h=await ph(o),x=h.some(v=>["CEO","Ceo","SB CEO"].includes(v))?"CEO":h.some(v=>["SB Admin","System Manager"].includes(v))?"Admin":h.includes("SB Auditor")?"Auditor":h.includes("SB Owner")?"Owner":h.includes("SB X-Auditor")?"XAuditor":h.includes("SB Manager")?"Manager":"Employee";e({name:o,full_name:k.full_name||s,role:x})}else d(n.login.invalidCreds)}catch(k){d(n.login.connError+(k instanceof Error?k.message:"Unknown"))}p(!1)},z=k=>({width:"100%",padding:"11px 16px",border:`1.5px solid ${k?"#6366f1":"#e2e8f0"}`,borderRadius:8,fontSize:14,background:k?"#f8faff":"#ffffff",color:"#1e293b",outline:"none",transition:"all 0.18s ease",boxSizing:"border-box",boxShadow:k?"0 0 0 3px rgba(99, 102, 241, 0.15)":"none"});return t.jsx("div",{style:{minHeight:"100vh",background:"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif",padding:"20px"},children:t.jsxs("div",{style:{width:380,maxWidth:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:[t.jsx("div",{style:{width:72,height:72,borderRadius:18,background:"white",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:20,boxShadow:"0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04)",border:"1px solid #f1f5f9",overflow:"hidden",padding:10},children:t.jsx("img",{src:dh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:k=>{k.currentTarget.style.display="none"}})}),t.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[t.jsx("h1",{style:{fontSize:22,fontWeight:800,color:"#0f172a",letterSpacing:"-0.3px",margin:0},children:n.rtl?"صدرة للأعمال":"Sidrah"}),t.jsx("div",{style:{fontSize:13,color:"#6366f1",fontWeight:600,marginTop:4},children:n.rtl?"نظام إدارة العمليات والأعمال":"Asset Management System"}),t.jsx("div",{style:{fontSize:12,color:"#94a3b8",marginTop:6},children:n.login.subtitle})]}),t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:12},children:[t.jsx("div",{children:t.jsx("input",{value:s,onChange:k=>a(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),onFocus:()=>j(!0),onBlur:()=>j(!1),style:z(C),placeholder:n.login.usernamePlaceholder,autoComplete:"username"})}),t.jsx("div",{children:t.jsx("input",{type:"password",value:l,onChange:k=>r(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),onFocus:()=>c(!0),onBlur:()=>c(!1),style:z(_),placeholder:n.login.passwordPlaceholder,autoComplete:"current-password"})}),i&&t.jsx("div",{style:{padding:"9px 12px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:12,textAlign:"center"},children:i}),t.jsx("button",{type:"button",onClick:y,disabled:f,style:{background:f?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:f?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:k=>{f||(k.currentTarget.style.background="#4338ca")},onMouseLeave:k=>{f||(k.currentTarget.style.background="#4f46e5")},children:f?n.login.signingIn:n.login.signIn}),t.jsx("div",{style:{textAlign:"center",marginTop:8},children:t.jsx("button",{type:"button",onClick:oh,style:{fontSize:12,color:"#94a3b8",background:"none",border:"none",cursor:"pointer"},onMouseEnter:k=>k.currentTarget.style.color="#475569",onMouseLeave:k=>k.currentTarget.style.color="#94a3b8",children:n.switchLang})})]})]})})}function o0(e,n){const s=parseInt(e.replace("#",""),16),a=s>>16&255,l=s>>8&255,r=s&255,i=d=>Math.round(d+(255-d)*n);return`rgb(${i(a)}, ${i(l)}, ${i(r)})`}function sl(e,n){const s=parseInt(e.replace("#",""),16),a=s>>16&255,l=s>>8&255,r=s&255;return`rgba(${a}, ${l}, ${r}, ${n})`}function gr({title:e,data:n,color:s,onSelect:a}){const[,l]=n[0]??["Total",0,""],r=n.slice(1),i=r.map((f,p)=>o0(s,Math.min(p*.16,.7))),d=r.map(([f,p,C],j)=>[f,p,C,i[j]]).filter(([,f])=>f>0);return t.jsxs("div",{className:"status-card",style:{borderRadius:18,padding:"16px 18px 18px",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${sl(s,.09)} 0%, transparent 55%)`}}),t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${sl(s,.35)})`}}),t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[t.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),t.jsx("span",{style:{fontSize:14,fontWeight:800,color:"white",background:s,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${sl(s,.35)}`},children:l})]}),l>0&&t.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:sl(s,.1),marginBottom:13},children:d.map(([f,p,C,j],_)=>t.jsx("div",{title:`${f}: ${p}`,onClick:c=>{c.stopPropagation(),a==null||a(C)},style:{flex:`${p} 0 0`,background:j,borderRight:_<d.length-1?"2px solid white":"none",cursor:a?"pointer":"default"}},f))}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:r.map(([f,p,C],j)=>t.jsxs("div",{className:"status-card-row",onClick:p>0?_=>{_.stopPropagation(),a==null||a(C)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:p>0&&a?"pointer":"default",transition:"background 0.12s"},children:[t.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:i[j],flexShrink:0,boxShadow:`0 0 0 3px ${sl(i[j],.18)}`}}),t.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),t.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:p})]},f))})]})}function an({value:e,onChange:n,organizations:s,placeholder:a="Select organization...",disabled:l=!1,small:r=!1,userRole:i,onCreateNew:d,onQuickCreateSuccess:f}){var Y;const[p,C]=S.useState(!1),[j,_]=S.useState(""),[c,y]=S.useState(!1),[z,k]=S.useState(""),[g,o]=S.useState(""),[h,x]=S.useState(!1),[v,w]=S.useState(""),u=S.useRef(null),b=S.useRef(null);S.useEffect(()=>{const $=I=>{u.current&&!u.current.contains(I.target)&&C(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const T=e?((Y=s.find($=>$.organization_name===e||$.name===e))==null?void 0:Y.organization_name)??e:"",F=s.filter($=>{if(!$)return!1;const I=$;return I.custom_is_deleted===1||I.custom_is_deleted==="1"||I.custom_is_deleted===!0||I.is_deleted===1||I.is_deleted==="1"||I.is_deleted===!0||I.status==="Deleted"||I.custom_status==="Deleted"?!1:!!$.is_active||$.organization_name===e||$.name===e}).filter($=>{if(!j.trim())return!0;const I=j.toLowerCase().trim();return($.organization_name||"").toLowerCase().includes(I)||($.name||"").toLowerCase().includes(I)||($.acronym||"").toLowerCase().includes(I)}),te=!(i==="Employee"||i==="SB Employee"),H=async $=>{if($.preventDefault(),!!z.trim()){x(!0),w("");try{const I={organization_name:z.trim(),acronym:g.trim(),is_active:1},A=await ni("SB Organization",I),M=(A==null?void 0:A.data)||A,X=(M==null?void 0:M.organization_name)||z.trim();n(X),f&&f(X),y(!1),k(""),o("")}catch(I){console.error("Quick create org error:",I),w((I==null?void 0:I.message)||"Failed to create organization. Please try again.")}finally{x(!1)}}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:u,className:`custom-select-container ${l?"disabled":""} ${p?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${r?"small":""} ${l?"disabled":""} ${p?"open":""} ${!e&&!j?"is-placeholder":""}`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingRight:8},onClick:()=>{l||(p||(C(!0),_("")),setTimeout(()=>{var $;return($=b.current)==null?void 0:$.focus()},0))},children:[t.jsx("input",{ref:b,type:"text",disabled:l,placeholder:a,value:p?j:T,onChange:$=>{p||C(!0),_($.target.value)},onFocus:()=>{!l&&!p&&(C(!0),_(""))},style:{border:"none",outline:"none",background:"transparent",width:"100%",fontSize:"inherit",fontFamily:"inherit",color:"inherit",cursor:l?"not-allowed":"text",padding:0}}),e&&!l?t.jsx("span",{title:"Clear selection",style:{cursor:"pointer",color:"#94a3b8",fontSize:14,fontWeight:600,padding:"0 4px",lineHeight:1,userSelect:"none",transition:"color 0.15s ease",flexShrink:0},onClick:$=>{$.stopPropagation(),n(""),_(""),C(!1)},onMouseEnter:$=>$.currentTarget.style.color="#475569",onMouseLeave:$=>$.currentTarget.style.color="#94a3b8",children:"✕"}):t.jsx("span",{className:"trigger-arrow",style:{pointerEvents:"none",flexShrink:0},children:"▼"})]}),p&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[F.length===0&&!te&&t.jsx("div",{className:"custom-select-empty",children:"No matching organizations"}),F.map($=>t.jsx(d0,{label:$.organization_name,selected:e===$.organization_name||e===$.name,active:!!$.is_active,isPlaceholder:!1,small:r,onClick:()=>{n($.organization_name),_(""),C(!1)}},$.name)),te&&t.jsxs("div",{style:{borderTop:"1px solid #e2e8f0",color:"#16a34a",fontWeight:700,fontSize:r?12:13,padding:"10px 14px",display:"flex",alignItems:"center",gap:6,cursor:"pointer",background:"#ffffff",transition:"all 0.15s ease"},onClick:()=>{C(!1),d?d():(k(""),o(""),w(""),y(!0))},onMouseEnter:$=>{$.currentTarget.style.background="#f0fdf4"},onMouseLeave:$=>{$.currentTarget.style.background="#ffffff"},children:[t.jsx("span",{style:{fontSize:16,fontWeight:800,color:"#16a34a",lineHeight:1},children:"+"}),t.jsx("span",{children:"Create New Organization"})]})]})})]}),c&&t.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(15, 23, 42, 0.55)",backdropFilter:"blur(3px)",padding:16},onClick:$=>{$.target===$.currentTarget&&!h&&y(!1)},children:t.jsxs("div",{style:{background:"#ffffff",borderRadius:12,boxShadow:"0 20px 40px rgba(0, 0, 0, 0.2)",maxWidth:440,width:"100%",overflow:"hidden",animation:"scaleIn 0.15s ease"},children:[t.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:16,fontWeight:700,color:"#1e293b"},children:[t.jsx("span",{style:{color:"#2563eb",fontSize:18,fontWeight:800},children:"+"}),t.jsx("span",{children:"Create New Organization"})]}),t.jsx("button",{type:"button",onClick:()=>!h&&y(!1),style:{background:"none",border:"none",color:"#94a3b8",fontSize:18,cursor:"pointer",padding:"2px 6px",borderRadius:4},children:"✕"})]}),t.jsxs("form",{onSubmit:H,style:{padding:"20px"},children:[v&&t.jsx("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#dc2626",padding:"8px 12px",borderRadius:6,fontSize:12,marginBottom:14},children:v}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsxs("label",{style:{display:"block",fontSize:12,fontWeight:700,color:"#334155",marginBottom:6},children:["Organization Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"text",value:z,onChange:$=>k($.target.value),placeholder:"Enter organization name",autoFocus:!0,disabled:h,style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,boxSizing:"border-box",outline:"none"}})]}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsx("label",{style:{display:"block",fontSize:12,fontWeight:700,color:"#334155",marginBottom:6},children:"Acronym"}),t.jsx("input",{type:"text",value:g,onChange:$=>o($.target.value),placeholder:"e.g. KAU",disabled:h,style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,boxSizing:"border-box",outline:"none"}})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,marginTop:22},children:[t.jsx("button",{type:"button",onClick:()=>y(!1),disabled:h,style:{padding:"8px 16px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#475569",fontWeight:600,fontSize:13,cursor:h?"not-allowed":"pointer"},children:"Cancel"}),t.jsxs("button",{type:"submit",disabled:h||!z.trim(),style:{padding:"8px 18px",borderRadius:8,border:"none",background:"#2563eb",color:"#ffffff",fontWeight:700,fontSize:13,cursor:h||!z.trim()?"not-allowed":"pointer",opacity:h||!z.trim()?.6:1,display:"flex",alignItems:"center",gap:6,boxShadow:"0 2px 4px rgba(37, 99, 235, 0.25)"},children:[t.jsx("span",{style:{fontSize:15,fontWeight:800},children:"+"}),t.jsx("span",{children:h?"Creating...":"Create"})]})]})]})]})})]})}function d0({label:e,selected:n,active:s,isPlaceholder:a,small:l,onClick:r}){const[i,d]=S.useState(!1);return t.jsx("div",{onClick:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:`custom-select-option ${n?"selected":""} ${i?"hovered":""} ${a?"placeholder-option":""} ${s?"":"inactive-option"} ${l?"small":""}`,children:e})}function pn({label:e,icon:n,onClick:s}){return t.jsxs("button",{onClick:s,className:"hero-quicklink-btn",style:{display:"flex",alignItems:"center",gap:8,padding:"7px 14px",background:"rgba(255, 255, 255, 0.12)",border:"1px solid rgba(255, 255, 255, 0.22)",borderRadius:10,cursor:"pointer",backdropFilter:"blur(8px)",color:"white",fontSize:13,fontWeight:700,boxShadow:"0 2px 6px rgba(0,0,0,0.12)",transition:"all 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[t.jsx("span",{style:{fontSize:15,display:"flex",alignItems:"center"},children:n}),t.jsx("span",{style:{whiteSpace:"nowrap"},children:e})]})}function ns({items:e,type:n,onNavigate:s}){const a=re();if(!e.length)return null;const l=n==="process"?"processes-form":"orders-form",r=n==="process"?a.dash.escalatedProcesses:a.dash.escalatedOrders,i=e.some(d=>d.escalation_level===2||d.escalation_level==="2");return t.jsxs("div",{children:[t.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:i?"#ef4444":"#f59e0b",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{children:i?"🚨":"⚠️"}),t.jsxs("span",{children:[r," (",e.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.map(d=>t.jsxs("div",{onClick:()=>s(l,d.name),className:"dashboard-alert-item",style:{padding:"10px 14px",background:i?"#fef2f2":"#fffbeb",borderRadius:10,border:`1px solid ${i?"#fecaca":"#fed7aa"}`,cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.15s ease"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:i?"#991b1b":"#92400e",whiteSpace:"nowrap"},children:d.number||d.name}),t.jsx("span",{style:{fontSize:12,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.title})]}),t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:i?"#b91c1c":"#b45309",background:i?"#fee2e2":"#fef3c7",border:`1px solid ${i?"#fca5a5":"#fde68a"}`,padding:"2px 8px",borderRadius:9999,flexShrink:0},children:[a.dash.level," ",d.escalation_level]})]},d.name))})]})}function c0({kpi:e}){const n=re();return t.jsxs("div",{className:"dashboard-kpi-card",style:{borderRadius:14,padding:"16px 18px",border:"1px solid #e2e8f0",background:"white",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",transition:"all 0.2s ease",display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("div",{style:{fontWeight:800,fontSize:14,color:"#1e293b"},children:e.organization}),t.jsx("span",{style:{fontSize:11,fontWeight:700,color:"#4f46e5",background:"#eff6ff",border:"1px solid #c7d2fe",padding:"2px 9px",borderRadius:9999},children:e.period})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[{label:n.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—",color:"#10b981"},{label:n.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—",color:"#3b82f6"},{label:n.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—",color:"#8b5cf6"},{label:n.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—",color:"#f59e0b"},{label:n.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—",color:"#06b6d4"},{label:n.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—",color:"#ef4444"}].map(({label:s,val:a,color:l})=>t.jsxs("div",{style:{background:"#f8fafc",padding:"8px 10px",borderRadius:8,border:"1px solid #f1f5f9"},children:[t.jsx("div",{style:{fontSize:10,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px"},children:s}),t.jsxs("div",{style:{fontSize:14,fontWeight:800,color:"#1e293b",marginTop:2,display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:l}}),a]})]},s))})]})}function u0({data:e}){if(!e.length)return t.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"No cycle data available for trend chart."});const n=Math.max(...e.map(s=>s.pass+s.fail+s.unknown),1);return t.jsxs("div",{children:[t.jsx("div",{style:{display:"flex",gap:14,alignItems:"flex-end",overflowX:"auto",paddingBottom:8,paddingTop:10},children:e.map(s=>{const a=s.pass+s.fail+s.unknown||1,l=100;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,minWidth:54},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:2,height:l,width:36,background:"#f1f5f9",borderRadius:6,padding:2,boxSizing:"border-box"},children:[t.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/n*(l-4)),background:"linear-gradient(180deg, #34d399 0%, #10b981 100%)",borderRadius:"4px 4px 0 0",minHeight:s.pass?4:0}}),t.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/n*(l-4)),background:"linear-gradient(180deg, #f87171 0%, #ef4444 100%)",borderRadius:"4px 4px 0 0",minHeight:s.fail?4:0}}),t.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/n*(l-4)),background:"#94a3b8",borderRadius:"4px 4px 0 0",minHeight:s.unknown?4:0}})]}),t.jsx("div",{style:{fontSize:10,fontWeight:600,color:"#64748b",textAlign:"center",lineHeight:1.2},children:s.month.replace(/^(\d{4})-(\d{2})$/,(r,i,d)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+d-1]} '${i.slice(2)}`)}),t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#10b981",textAlign:"center"},children:a>1?Math.round(s.pass/a*100)+"%":"—"})]},s.month)})}),t.jsx("div",{style:{display:"flex",gap:20,marginTop:12,borderTop:"1px solid #f1f5f9",paddingTop:10},children:[["#10b981","Pass (Verified)"],["#ef4444","Fail (Action Required)"],["#94a3b8","Unknown / Unrecorded"]].map(([s,a])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,fontWeight:600},children:[t.jsx("div",{style:{width:10,height:10,background:s,borderRadius:3}}),t.jsx("span",{style:{color:"#64748b"},children:a})]},a))})]})}function p0({dashData:e,fi:n,fid:s,fo:a,fp:l,incidentStatuses:r,ideaStatuses:i,orderStatuses:d,processStatuses:f,onNavigate:p,onNavigateStatus:C}){const j=re(),_=(e==null?void 0:e.escalated_processes)||[],c=(e==null?void 0:e.escalated_orders)||[],y=(e==null?void 0:e.attention_processes)||[],z=(e==null?void 0:e.attention_orders)||[],k=(e==null?void 0:e.untriaged_incidents)||[],g=(e==null?void 0:e.overdue_triage)||[],o=_.length>0||c.length>0,h=y.length>0||z.length>0,x=[["Total",n.length,""],...r.map(b=>[b.name1||b.name,n.filter(T=>T.status===b.name).length,b.name])],v=[["Total",s.length,""],...i.map(b=>[b.name1||b.name,s.filter(T=>T.status===b.name).length,b.name])],w=[["Total",a.length,""],...d.map(b=>[b.name1||b.name,a.filter(T=>T.status===b.name).length,b.name])],u=[["Total",l.length,""],...f.map(b=>[b.name1||b.name,l.filter(T=>T.status===b.name).length,b.name])];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsx("div",{onClick:()=>p("incidents"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.incidents,color:"#ef4444",data:x,onSelect:b=>C("incidents",b)})}),t.jsx("div",{onClick:()=>p("ideas"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.ideas,color:"#10b981",data:v,onSelect:b=>C("ideas",b)})}),t.jsx("div",{onClick:()=>p("orders"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.orders,color:"#8b5cf6",data:w,onSelect:b=>C("orders",b)})}),t.jsx("div",{onClick:()=>p("processes"),style:{cursor:"pointer"},children:t.jsx(gr,{title:j.dash.processes,color:"#3b82f6",data:u,onSelect:b=>C("processes",b)})})]}),(o||h)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[o&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #ef4444"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#ef4444",margin:0},children:j.dash.level2}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fef2f2",color:"#ef4444",padding:"2px 8px",borderRadius:9999},children:[_.length+c.length," Critical"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:_,type:"process",onNavigate:p}),t.jsx(ns,{items:c,type:"order",onNavigate:p})]})]}),h&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fef3c7",borderLeft:"5px solid #f59e0b"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#b45309",margin:0},children:j.dash.level1}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fffbeb",color:"#b45309",padding:"2px 8px",borderRadius:9999},children:[y.length+z.length," Action Needed"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:y,type:"process",onNavigate:p}),t.jsx(ns,{items:z,type:"order",onNavigate:p})]})]})]}),(g.length>0||k.length>0)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[g.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #dc2626"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#dc2626",marginBottom:10},children:[j.dash.overduePrefix,g.length,j.dash.overdueSuffix]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:g.map(b=>t.jsxs("div",{onClick:()=>p("incidents-form",b.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:"#991b1b"},children:b.number||b.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:b.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:b.date})]},b.name))})]}),k.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #ffedd5",borderLeft:"5px solid #f97316"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#ea580c",marginBottom:10},children:[j.dash.untriaged," (",k.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:k.map(b=>t.jsxs("div",{onClick:()=>p("incidents-form",b.name),style:{padding:"8px 12px",background:"#fff7ed",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:"#9a3412"},children:b.number||b.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:b.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:b.date})]},b.name))})]})]})]})}function f0({dashData:e,selectedOrg:n,onNavigate:s}){const a=re(),[l,r]=S.useState([]),[i,d]=S.useState([]),[f,p]=S.useState(!1),C=(e==null?void 0:e.escalated_processes)||[],j=(e==null?void 0:e.escalated_orders)||[],_=(e==null?void 0:e.attention_processes)||[],c=(e==null?void 0:e.attention_orders)||[],y=(e==null?void 0:e.kpi_inputs)||[];S.useEffect(()=>{p(!0);const g=new URLSearchParams({months:"6"});n&&g.append("organization",n),fetch(`/api/method/sidrah_business.api.get_process_trend?${g}`,{credentials:"include",headers:{Accept:"application/json"}}).then(o=>o.json()).then(o=>{const h=o.message||[],x={};for(const v of h)x[v.month]||(x[v.month]={pass:0,fail:0,unknown:0}),v.status==="Pass"?x[v.month].pass=v.count:v.status==="Fail"?x[v.month].fail=v.count:v.status==="Unknown"&&(x[v.month].unknown=v.count);r(Object.entries(x).map(([v,w])=>({month:v,...w})))}).catch(()=>{}).finally(()=>p(!1))},[n]),S.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(g=>g.json()).then(g=>{var o;d((((o=g.message)==null?void 0:o.rows)||[]).slice(0,50))}).catch(()=>{})},[n]);const z=C.length>0||j.length>0,k=_.length>0||c.length>0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[y.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",margin:0},children:a.dash.recentKpi}),t.jsxs("button",{onClick:()=>s("kpi-input"),style:{padding:"6px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#334155",fontWeight:600,fontSize:12,cursor:"pointer"},children:[a.dash.manageKpi," →"]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:14},children:y.map(g=>t.jsx(c0,{kpi:g},g.name))})]}),(z||k)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[z&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #ef4444"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:14,color:"#ef4444",marginBottom:12},children:["Critical Escalations — Level 2 (",C.length+j.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:C,type:"process",onNavigate:s}),t.jsx(ns,{items:j,type:"order",onNavigate:s})]})]}),k&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fef3c7",borderLeft:"5px solid #f59e0b"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:14,color:"#b45309",marginBottom:12},children:["Needs Attention — Level 1 (",_.length+c.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(ns,{items:_,type:"process",onNavigate:s}),t.jsx(ns,{items:c,type:"order",onNavigate:s})]})]})]}),t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",marginBottom:4},children:"Process Execution Trend — Last 6 Months"}),t.jsx("p",{style:{fontSize:12,color:"#64748b",marginBottom:12},children:"Pass / Fail verification metrics across all processes and review cycles."}),f?t.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"Loading trend analytics…"}):t.jsx(u0,{data:l})]}),i.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",margin:0},children:"Audit Log Book — Recent Activity"}),t.jsx("button",{onClick:()=>s("reports"),style:{padding:"6px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#334155",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log →"})]}),t.jsx("div",{style:{overflowX:"auto",borderRadius:10,border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(g=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#64748b",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:g},g))})}),t.jsx("tbody",{children:i.map((g,o)=>t.jsxs("tr",{style:{borderTop:"1px solid #f1f5f9",background:o%2===0?"white":"#fafafa"},children:[t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",whiteSpace:"nowrap"},children:g.timestamp?String(g.timestamp).slice(0,16):"—"}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600,color:"#1e293b"},children:g.user||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#475569"},children:t.jsx("span",{style:{background:"#f1f5f9",padding:"2px 8px",borderRadius:6,fontWeight:600,fontSize:11},children:g.entity_type||"—"})}),t.jsx("td",{style:{padding:"10px 14px",color:"#1e293b",fontWeight:500},children:g.entity_name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",maxWidth:280,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.changes||"—"})]},o))})]})})]})]})}function h0({incidents:e,ideas:n,orders:s,processes:a,organizations:l,incidentStatuses:r,ideaStatuses:i,orderStatuses:d,processStatuses:f,selectedOrg:p,onOrgChange:C,onNavigate:j,onNavigateStatus:_,userRole:c}){const[y,z]=S.useState(null),[k,g]=S.useState(!1),o=()=>{g(!0),Hy(p).then(z).finally(()=>g(!1))};S.useEffect(()=>{o()},[p]);const h=S.useMemo(()=>p?e.filter(Q=>Q.organization===p):e,[e,p]),x=S.useMemo(()=>p?n.filter(Q=>Q.organization===p):n,[n,p]),v=S.useMemo(()=>p?s.filter(Q=>Q.organization===p):s,[s,p]),w=S.useMemo(()=>p?a.filter(Q=>Q.organization===p):a,[a,p]),u=c==="Admin",b=c==="Owner",[T,E]=S.useState("level1"),F=b||u&&T==="level2";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #1e3a8a 100%)",borderRadius:16,padding:"22px 26px",color:"white",boxShadow:"0 8px 30px rgba(30, 27, 75, 0.25)",position:"relative",zIndex:20},children:[t.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:"inherit",overflow:"hidden",pointerEvents:"none"},children:[t.jsx("div",{style:{position:"absolute",top:-50,right:-50,width:220,height:220,borderRadius:"50%",background:"rgba(99, 102, 241, 0.25)",filter:"blur(50px)"}}),t.jsx("div",{style:{position:"absolute",bottom:-40,left:"35%",width:180,height:180,borderRadius:"50%",background:"rgba(59, 130, 246, 0.2)",filter:"blur(45px)"}})]}),t.jsxs("div",{style:{position:"relative",zIndex:1},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:16,marginBottom:20},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[t.jsx("span",{style:{fontSize:24},children:"⚡"}),t.jsx("h2",{style:{fontSize:22,fontWeight:800,color:"white",margin:0,letterSpacing:-.5},children:F?"Executive Performance Dashboard":"Operational Activity Dashboard"})]}),t.jsx("p",{style:{fontSize:13,color:"#c7d2fe",margin:0,opacity:.9},children:p?`Real-time analytics for ${p}`:"Enterprise overview across all organizations & business units"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{style:{minWidth:190,maxWidth:260},children:t.jsx(an,{value:p,onChange:C,organizations:l,placeholder:"All Organizations",small:!0})}),u&&t.jsxs("div",{style:{display:"flex",background:"rgba(255, 255, 255, 0.12)",borderRadius:10,padding:3,gap:3,backdropFilter:"blur(8px)",border:"1px solid rgba(255, 255, 255, 0.15)"},children:[t.jsx("button",{onClick:()=>E("level1"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:T==="level1"?"white":"transparent",color:T==="level1"?"#1e1b4b":"#c7d2fe",boxShadow:T==="level1"?"0 2px 6px rgba(0,0,0,0.15)":"none",transition:"all 0.15s ease"},children:"Level 1 (Ops)"}),t.jsx("button",{onClick:()=>E("level2"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:T==="level2"?"#8b5cf6":"transparent",color:"white",boxShadow:T==="level2"?"0 2px 6px rgba(0,0,0,0.2)":"none",transition:"all 0.15s ease"},children:"Level 2 (Exec)"})]}),!u&&t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:F?"#8b5cf6":"#3b82f6",padding:"5px 14px",borderRadius:9999,border:"1px solid rgba(255, 255, 255, 0.2)",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},children:F?"👑 Owner View":"💼 Operations View"}),t.jsx("button",{onClick:o,disabled:k,title:"Refresh Metrics",style:{width:32,height:32,borderRadius:10,background:"rgba(255, 255, 255, 0.15)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,transition:"all 0.15s"},children:t.jsx("span",{style:{display:"inline-block",transform:k?"rotate(180deg)":"none",transition:"transform 0.4s ease"},children:"🔄"})})]})]}),t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:F?t.jsxs(t.Fragment,{children:[t.jsx(pn,{label:"Manage Users & Roles",icon:"👥",onClick:()=>j("users")}),t.jsx(pn,{label:"Active Review Cycles",icon:"🔄",onClick:()=>j("cycles")}),t.jsx(pn,{label:"Strategic KPI Inputs",icon:"📈",onClick:()=>j("kpi-input")}),t.jsx(pn,{label:"Executive Reports",icon:"📊",onClick:()=>j("reports")}),t.jsx(pn,{label:"Organizations Hierarchy",icon:"🏢",onClick:()=>j("organizations")})]}):t.jsxs(t.Fragment,{children:[t.jsx(pn,{label:"Incidents",icon:"⚠️",onClick:()=>j("incidents")}),t.jsx(pn,{label:"Ideas",icon:"💡",onClick:()=>j("ideas")}),t.jsx(pn,{label:"Orders",icon:"📦",onClick:()=>j("orders")}),t.jsx(pn,{label:"Processes",icon:"⚙️",onClick:()=>j("processes")}),t.jsx(pn,{label:"Inbox",icon:"📥",onClick:()=>j("inbox")}),t.jsx(pn,{label:"Reports",icon:"📊",onClick:()=>j("reports")})]})})]})]}),F?t.jsx(f0,{dashData:y,selectedOrg:p,onNavigate:j}):t.jsx(p0,{dashData:y,fi:h,fid:x,fo:v,fp:w,incidentStatuses:r,ideaStatuses:i,orderStatuses:d,processStatuses:f,onNavigate:j,onNavigateStatus:_})]})}const st={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},at={width:"100%",padding:"6px 10px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,background:"white",color:"#1e293b",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:32,outline:"none"};function Si({children:e}){const[n,s]=S.useState(!1);return t.jsxs("div",{style:{borderRadius:10,overflow:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",flexShrink:0,border:"1px solid #e2e8f0",marginBottom:14},children:[t.jsxs("div",{onClick:()=>s(a=>!a),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",color:"white",padding:"10px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none",fontWeight:600,fontSize:13},children:[t.jsx("span",{style:{fontSize:12,opacity:.9},children:n?"▲":"▼"}),t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{children:"Filters"})]}),n&&t.jsx("div",{style:{background:"#f8fafc",padding:"14px 18px",borderTop:"1px solid #e2e8f0"},children:e})]})}const ie=20;function g0(e,n){if(n<=7)return Array.from({length:n},(a,l)=>l+1);const s=[];if(e<=4){for(let a=1;a<=Math.min(4,n);a++)s.push(a);n>4&&(s.push("ellipsis"),s.push(n))}else if(e>=n-3){s.push(1),s.push("ellipsis");for(let a=n-3;a<=n;a++)s.push(a)}else s.push(1),s.push("ellipsis"),s.push(e-1),s.push(e),s.push(e+1),s.push("ellipsis"),s.push(n);return s}function Ue({page:e,pageSize:n=ie,total:s,onPageChange:a,itemLabel:l="results"}){const[r,i]=S.useState("");if(s===0)return null;const d=Math.max(1,Math.ceil(s/n)),f=s===0?0:(e-1)*n+1,p=Math.min(e*n,s),C=_=>{_&&_.preventDefault();const c=parseInt(r.trim(),10);!isNaN(c)&&c>=1&&c<=d&&(a(c),i(""))},j=g0(e,d);return t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"14px 8px",fontSize:13,color:"#475569",flexWrap:"wrap",gap:12,userSelect:"none"},children:[t.jsxs("div",{style:{color:"#475569",fontWeight:500},children:["Showing ",f," to ",p," of ",s," ",l]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",disabled:e<=1,onClick:()=>a(e-1),style:{padding:"5px 12px",borderRadius:6,border:"1px solid #e2e8f0",background:"#ffffff",color:e<=1?"#94a3b8":"#475569",fontSize:13,fontWeight:500,cursor:e<=1?"not-allowed":"pointer",transition:"all 0.15s ease",fontFamily:"inherit"},children:"Previous"}),j.map((_,c)=>{if(_==="ellipsis")return t.jsx("span",{style:{padding:"0 4px",color:"#94a3b8",fontSize:13,fontWeight:600},children:"..."},`ellipsis-${c}`);const y=_===e;return t.jsx("button",{type:"button",onClick:()=>a(_),style:{minWidth:32,height:32,padding:"0 6px",borderRadius:6,border:y?"1px solid #2563eb":"1px solid #e2e8f0",background:y?"#2563eb":"#ffffff",color:y?"#ffffff":"#334155",fontSize:13,fontWeight:y?600:500,cursor:y?"default":"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s ease",fontFamily:"inherit"},children:_},_)}),t.jsx("button",{type:"button",disabled:e>=d,onClick:()=>a(e+1),style:{padding:"5px 12px",borderRadius:6,border:"1px solid #e2e8f0",background:"#ffffff",color:e>=d?"#94a3b8":"#475569",fontSize:13,fontWeight:500,cursor:e>=d?"not-allowed":"pointer",transition:"all 0.15s ease",fontFamily:"inherit"},children:"Next"}),t.jsxs("form",{onSubmit:C,style:{display:"inline-flex",alignItems:"center",gap:6,marginLeft:8},children:[t.jsx("span",{style:{fontSize:13,color:"#64748b"},children:"Go to page:"}),t.jsx("input",{type:"number",min:1,max:d,value:r,onChange:_=>i(_.target.value),style:{width:52,height:30,padding:"0 6px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:13,textAlign:"center",outline:"none",fontFamily:"inherit"}}),t.jsx("button",{type:"submit",style:{background:"none",border:"none",color:"#2563eb",fontWeight:600,fontSize:13,cursor:"pointer",padding:"4px 6px",fontFamily:"inherit"},children:"Go"})]})]})]})}function m0({incidents:e,organizations:n,departments:s,branches:a,incidentStatuses:l,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:C,onDelete:j,onSelectionChange:_}){const c=re(),[y,z]=S.useState(new Set),[k,g]=S.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(u,b)=>g(T=>({...T,[u]:b})),[h,x]=S.useState(1),v=e.filter(u=>!(k.search&&!`${u.number} ${u.title}`.toLowerCase().includes(k.search.toLowerCase())||k.organization&&u.organization!==k.organization||k.department&&u.department!==k.department||k.branch&&u.branch!==k.branch||k.status&&u.status!==k.status));S.useEffect(()=>{x(1)},[k]);const w=v.slice((h-1)*ie,h*ie);return S.useEffect(()=>{if(_){const u=e.filter(b=>y.has(b.name));_(u,w)}},[y,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.numberTitle}),t.jsx("input",{style:at,value:k.search,onChange:u=>o("search",u.target.value),placeholder:c.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.organization}),t.jsxs("select",{style:at,value:k.organization,onChange:u=>o("organization",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allOrgs}),n.map(u=>t.jsx("option",{value:u.name,children:u.organization_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.department}),t.jsxs("select",{style:at,value:k.department,onChange:u=>o("department",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allDepts}),s.map(u=>t.jsx("option",{value:u.name,children:u.department_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.branch}),t.jsxs("select",{style:at,value:k.branch,onChange:u=>o("branch",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allBranches}),a.map(u=>t.jsx("option",{value:u.name,children:u.branch||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.status}),t.jsxs("select",{style:at,value:k.status,onChange:u=>o("status",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allStatuses}),l.map(u=>t.jsx("option",{value:u.name,children:u.name1||u.name},u.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(u=>y.has(u.name)),onChange:u=>{if(u.target.checked)z(new Set([...y,...w.map(b=>b.name)]));else{const b=new Set(y);w.forEach(T=>b.delete(T.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:c.noIncidents})}):w.map((u,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(u),style:{borderTop:"1px solid #f1f5f9",background:y.has(u.name)?"#eff6ff":u.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:y.has(u.name),onChange:()=>{const T=new Set(y);T.has(u.name)?T.delete(u.name):T.add(u.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:u.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:u.title||u.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:u.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.type?cc(u.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.custom_is_deleted?fs(c.deletedBadge):u.status?fs(u.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(ot,{onView:()=>p==null?void 0:p(u),onEdit:d&&C&&!u.custom_is_deleted&&!ts("incident",u.workflow_state)&&!(f==="Employee"&&u.workflow_state&&u.workflow_state!=="New")?()=>C(u):void 0,onDelete:d&&j&&!u.custom_is_deleted?()=>j(u.name):void 0})})]},u.name))})]})}),t.jsx(Ue,{page:h,total:v.length,onPageChange:x})]})}function x0(e){if(!e)return"";const[n,s,a]=e.split("-");return!n||!s||!a?"":`${a}/${s}/${n}`}function je({value:e,onChange:n,disabled:s,style:a,min:l,max:r}){return t.jsxs("div",{style:{position:"relative",width:"100%"},children:[t.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:x0(e),placeholder:"DD/MM/YYYY",style:{...a,pointerEvents:"none",paddingRight:30}}),t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:s?"#bbb":"#666",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),t.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),t.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),t.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),t.jsx("input",{type:"date",value:e||"",disabled:s,min:l,max:r,onChange:i=>n(i.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:s?"default":"pointer",border:"none",padding:0,margin:0}})]})}const Du={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function y0(e){const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function fh({notifCount:e,darkMode:n,onCountChange:s,onToggleDark:a,onViewProfile:l,onLogout:r,onNavigate:i,userName:d,userRole:f}){const[p,C]=S.useState(!1),[j,_]=S.useState([]),[c,y]=S.useState(!1),z=S.useRef(null);S.useEffect(()=>{const E=F=>{z.current&&!z.current.contains(F.target)&&C(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const k=async()=>{y(!0);const E=await Ry(30);_(E),y(!1)},g=()=>{const E=!p;C(E),E&&k()},o=async()=>{await Dy(),_(E=>E.map(F=>({...F,read:1}))),s(0)},h=E=>{E.read||(Oy(E.name),_(Q=>Q.map(te=>te.name===E.name?{...te,read:1}:te)),s(Math.max(0,e-1)));const F=E.document_type?Du[E.document_type]:void 0;F&&i&&(i(F,E.document_type==="SB Delegation"?void 0:E.document_name),C(!1))},x=j.filter(E=>!E.read).length,v=E=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:n?"#2d3748":"#f3f4f6",color:n?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...E}),w=n,u=w?"#1a202c":"white",b=w?"#2d3748":"#e5e7eb",T=w?"#e2e8f0":"#1a2332";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[d&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginRight:4,lineHeight:1.25},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,color:w?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:d}),f&&t.jsx("span",{style:{fontSize:11,color:w?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:f})]}),t.jsx("button",{style:v({background:"#4f46e5",color:"white"}),onClick:l,title:"My Profile",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),t.jsxs("div",{ref:z,style:{position:"relative"},children:[t.jsxs("button",{style:v(),onClick:g,title:"Notifications",children:[t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&t.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),p&&t.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:u,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${b}`,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${b}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:u},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:T},children:["Notifications",x>0&&t.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[x," new"]})]}),x>0&&t.jsx("button",{onClick:o,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),t.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[c&&t.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!c&&j.length===0&&t.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[t.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),t.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!c&&j.map(E=>{const F=!!(E.document_type&&Du[E.document_type]&&i);return t.jsxs("div",{onClick:()=>h(E),style:{padding:"11px 16px",borderBottom:`1px solid ${w?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:E.read?u:w?"#1e3a5f":"#eff6ff",cursor:F?"pointer":"default",transition:"background 0.12s"},onMouseEnter:Q=>{F&&(Q.currentTarget.style.background=w?"#243244":"#e0ecfd")},onMouseLeave:Q=>{Q.currentTarget.style.background=E.read?u:w?"#1e3a5f":"#eff6ff"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:13,fontWeight:E.read?400:600,color:T,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.subject||`${E.document_type}: ${E.document_name}`}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:E.document_type&&t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:w?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[E.document_type.replace("SB ",""),E.document_name?` · ${E.document_name}`:""]})}),t.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:y0(E.creation)})]}),!E.read&&t.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},E.name)})]})]})]}),t.jsx("button",{style:v(),onClick:oh,title:wa()?"Switch to English":"Switch to Arabic",children:t.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),t.jsx("button",{style:v(),onClick:a,title:n?"Light mode":"Dark mode",children:n?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"5"}),t.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),t.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),t.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),t.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),t.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),t.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),t.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),t.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),t.jsx("button",{style:v({background:w?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:r,title:"Logout",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),t.jsx("polyline",{points:"16,17 21,12 16,7"}),t.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function tt({title:e,activePage:n,user:s,formStatus:a,buttonText:l,viewMode:r,statusBadge:i,onEdit:d,onCancel:f,hideSettings:p,rightPanel:C,darkMode:j,notifCount:_,onToggleDark:c,onCountChange:y,onViewProfile:z,onSubmit:k,onBack:g,onNavigate:o,onLogout:h,children:x}){const v=re(),w=s.role,u=w==="Admin"||w==="Owner"||w==="Auditor"||w==="Manager",b=w==="Admin"||w==="Owner"||w==="Auditor"||w==="Manager",T=w==="Admin"||w==="Auditor"||w==="Manager",[E,F]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),Q=S.useRef(void 0),[te,H]=S.useState(!1);S.useEffect(()=>{if(Q.current===!0&&r===!1){H(!0);const I=setTimeout(()=>{H(!1)},4e3);return()=>clearTimeout(I)}else H(!1);Q.current=r},[r]);const Y=()=>F(I=>{const A=!I;return localStorage.setItem("sb_sidebar",A?"1":"0"),A}),$=f||g;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:j?"#0f172a":"#f8fafc"},children:[t.jsx(ch,{collapsed:E,onToggleCollapsed:Y,activePage:n,onNavigate:o,hasDashboard:u,hasReports:b,hasDelegations:T,role:w,hideSettings:p,rtl:v.rtl,navLabels:v.nav,settingsLabel:v.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:j?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${j?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:j?"none":"0 1px 4px rgba(0,0,0,0.03)"},children:t.jsx(fh,{notifCount:_,darkMode:j,onCountChange:y,onToggleDark:c,onNavigate:o,onViewProfile:z,onLogout:h,userName:s.full_name||s.name,userRole:s.role})}),t.jsxs("div",{style:{background:j?"#1e293b":"#ffffff",padding:"12px 24px",borderBottom:`1px solid ${j?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,position:"relative"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx("button",{onClick:g,title:v.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:`1px solid ${j?"#475569":"#e2e8f0"}`,background:j?"#334155":"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:I=>{I.currentTarget.style.background=j?"#475569":"#eff6ff",I.currentTarget.style.borderColor="#93c5fd"},onMouseLeave:I=>{I.currentTarget.style.background=j?"#334155":"#ffffff",I.currentTarget.style.borderColor=j?"#475569":"#e2e8f0"},children:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{style:{fontSize:17,fontWeight:700,color:j?"#f8fafc":"#0f172a"},children:e}),i&&(typeof i=="string"?t.jsx("span",{style:{padding:"3px 10px",borderRadius:16,fontSize:12,fontWeight:600,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:i}):i)]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r&&d&&t.jsxs("button",{type:"button",onClick:d,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:6,border:"none",background:"#2563eb",color:"#ffffff",cursor:"pointer",fontSize:13,fontWeight:600,boxShadow:"0 1px 3px rgba(37,99,235,0.25)",transition:"all 0.15s ease"},onMouseEnter:I=>I.currentTarget.style.background="#1d4ed8",onMouseLeave:I=>I.currentTarget.style.background="#2563eb",children:[t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),v.edit]}),!r&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button",onClick:$,style:{padding:"7px 16px",borderRadius:6,border:`1px solid ${j?"#475569":"#cbd5e1"}`,background:j?"#334155":"#ffffff",color:j?"#e2e8f0":"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:I=>{I.currentTarget.style.background=j?"#475569":"#f1f5f9"},onMouseLeave:I=>{I.currentTarget.style.background=j?"#334155":"#ffffff"},children:v.cancel}),t.jsxs("button",{type:"button",onClick:k,disabled:a==="loading",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 18px",borderRadius:6,border:"none",background:"#16a34a",color:"#ffffff",fontSize:13,fontWeight:600,cursor:a==="loading"?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(22, 163, 74, 0.3)",opacity:a==="loading"?.7:1,transition:"all 0.15s ease"},onMouseEnter:I=>{a!=="loading"&&(I.currentTarget.style.background="#15803d")},onMouseLeave:I=>{a!=="loading"&&(I.currentTarget.style.background="#16a34a")},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),t.jsx("polyline",{points:"7 3 7 8 15 8"})]}),t.jsx("span",{children:a==="loading"?v.saving:l||"Save Changes"})]})]})]}),!r&&te&&t.jsxs("div",{style:{position:"absolute",top:-34,right:24,background:"#0284c7",color:"#ffffff",padding:"4px 12px",borderRadius:6,fontSize:12,fontWeight:600,display:"flex",alignItems:"center",gap:8,boxShadow:"0 2px 8px rgba(2, 132, 199, 0.3)",zIndex:10},children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit mode enabled"]}),t.jsx("button",{type:"button",onClick:()=>H(!1),title:"Dismiss",style:{background:"transparent",border:"none",color:"white",cursor:"pointer",fontSize:14,padding:0,lineHeight:1,opacity:.85},children:"✕"})]})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:C?"1fr 240px":"1fr",gap:16,alignItems:"start"},children:[t.jsxs("div",{style:{minWidth:0},children:[x,a==="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:v.savedOk}),a!=="idle"&&a!=="loading"&&a!=="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:14},children:a})]}),C&&t.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:C})]})]})]})}function xo(e){return e?e==="Department"?{key:"department_name",label:"Department Name"}:e==="Branch"?{key:"branch",label:"Branch Name"}:e==="SB Organization"||e==="Organization"?{key:"organization_name",label:"Organization Name"}:e==="SB Group Company"||e==="Group Company"?{key:"company_name",label:"Company Name"}:{key:"name1",label:`${e.replace(/^SB\s+/,"")} Name`}:{key:"name1",label:"Name"}}function xe({value:e,onChange:n,items:s,placeholder:a="Select...",disabled:l=!1,onCreateNew:r,createNewText:i,doctypeName:d,userRole:f,onQuickCreateSuccess:p,extraFields:C={}}){var M;const[j,_]=S.useState(!1),[c,y]=S.useState(""),[z,k]=S.useState(""),[g,o]=S.useState(!1),[h,x]=S.useState(""),[v,w]=S.useState(!1),[u,b]=S.useState(""),T=S.useRef(null),E=S.useRef(null);S.useEffect(()=>{const X=L=>{T.current&&!T.current.contains(L.target)&&_(!1)};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[]);const F=(s||[]).filter(X=>{if(!X)return!1;const L=X;return!(L.custom_is_deleted===1||L.custom_is_deleted==="1"||L.custom_is_deleted===!0||L.is_deleted===1||L.is_deleted==="1"||L.is_deleted===!0||L.status==="Deleted"||L.custom_status==="Deleted")}),Q=e?((M=F.find(X=>X.name===e))==null?void 0:M.label)??e:"",te=F.filter(X=>{if(!c.trim())return!0;const L=c.toLowerCase().trim();return(X.label||"").toLowerCase().includes(L)||(X.name||"").toLowerCase().includes(L)}),Y=!(f==="Employee"||f==="SB Employee")&&(!!r||!!d||!!i),$=d?`Create New ${d.replace(/^SB\s+/,"")}`:"Create New",I=i||$,A=async X=>{if(X.preventDefault(),!(!h.trim()||!d)){w(!0),b("");try{const L=xo(d),N={[L.key]:h.trim(),...C};["Incident Types","Idea Types","Order Types","Process Types"].includes(d)&&(N.status="Active");const J=await ni(d,N),se=(J==null?void 0:J.data)||J,oe=(se==null?void 0:se.name)||(se==null?void 0:se[L.key])||h.trim();n(oe),p&&p(oe),o(!1),x("")}catch(L){console.error("Quick create error:",L),b((L==null?void 0:L.message)||"Failed to create item. Please try again.")}finally{w(!1)}}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:T,className:`custom-select-container ${l?"disabled":""} ${j?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${l?"disabled":""} ${j?"open":""} ${!e&&!c?"is-placeholder":""}`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingRight:8},onClick:()=>{l||(j||(_(!0),y("")),setTimeout(()=>{var X;return(X=E.current)==null?void 0:X.focus()},0))},children:[t.jsx("input",{ref:E,type:"text",disabled:l,placeholder:a,value:j?c:Q,onChange:X=>{j||_(!0),y(X.target.value)},onFocus:()=>{!l&&!j&&(_(!0),y(""))},style:{border:"none",outline:"none",background:"transparent",width:"100%",fontSize:"inherit",fontFamily:"inherit",color:"inherit",cursor:l?"not-allowed":"text",padding:0}}),e&&!l?t.jsx("span",{title:"Clear selection",style:{cursor:"pointer",color:"#94a3b8",fontSize:14,fontWeight:600,padding:"0 4px",lineHeight:1,userSelect:"none",transition:"color 0.15s ease",flexShrink:0},onClick:X=>{X.stopPropagation(),n(""),y(""),_(!1)},onMouseEnter:X=>X.currentTarget.style.color="#475569",onMouseLeave:X=>X.currentTarget.style.color="#94a3b8",children:"✕"}):t.jsx("span",{className:"trigger-arrow",style:{pointerEvents:"none",flexShrink:0},children:"▼"})]}),j&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[te.length===0&&!Y&&t.jsx("div",{className:"custom-select-empty",children:"No matching records found"}),te.map(X=>t.jsx("div",{className:`custom-select-option ${e===X.name?"selected":""} ${z===X.name?"hovered":""}`,onClick:()=>{n(X.name),y(""),_(!1)},onMouseEnter:()=>k(X.name),onMouseLeave:()=>k(""),children:X.label},X.name)),Y&&t.jsxs("div",{className:`custom-select-option create-new-option ${z==="__create_new"?"hovered":""}`,style:{borderTop:"1px solid #e2e8f0",color:"#16a34a",fontWeight:700,fontSize:13,padding:"10px 14px",display:"flex",alignItems:"center",gap:6,cursor:"pointer",background:z==="__create_new"?"#f0fdf4":"#ffffff",transition:"all 0.15s ease"},onClick:()=>{_(!1),r?r():(x(""),b(""),o(!0))},onMouseEnter:()=>k("__create_new"),onMouseLeave:()=>k(""),children:[t.jsx("span",{style:{fontSize:16,fontWeight:800,color:"#16a34a",lineHeight:1},children:"+"}),t.jsx("span",{children:I})]})]})})]}),g&&d&&t.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(15, 23, 42, 0.55)",backdropFilter:"blur(3px)",padding:16},onClick:X=>{X.target===X.currentTarget&&!v&&o(!1)},children:t.jsxs("div",{style:{background:"#ffffff",borderRadius:12,boxShadow:"0 20px 40px rgba(0, 0, 0, 0.2)",maxWidth:440,width:"100%",overflow:"hidden",animation:"scaleIn 0.15s ease"},children:[t.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:16,fontWeight:700,color:"#1e293b"},children:[t.jsx("span",{style:{color:"#2563eb",fontSize:18,fontWeight:800},children:"+"}),t.jsx("span",{children:`Create New ${d.replace(/^SB\s+/,"")}`})]}),t.jsx("button",{type:"button",onClick:()=>!v&&o(!1),style:{background:"none",border:"none",color:"#94a3b8",fontSize:18,cursor:"pointer",padding:"2px 6px",borderRadius:4},children:"✕"})]}),t.jsxs("form",{onSubmit:A,style:{padding:"20px"},children:[u&&t.jsx("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#dc2626",padding:"8px 12px",borderRadius:6,fontSize:12,marginBottom:14},children:u}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsxs("label",{style:{display:"block",fontSize:12,fontWeight:700,color:"#334155",marginBottom:6},children:[xo(d).label," ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"text",value:h,onChange:X=>x(X.target.value),placeholder:`Enter ${xo(d).label.toLowerCase()}`,autoFocus:!0,disabled:v,style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:13,boxSizing:"border-box",outline:"none"}})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10,marginTop:22},children:[t.jsx("button",{type:"button",onClick:()=>o(!1),disabled:v,style:{padding:"8px 16px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#475569",fontWeight:600,fontSize:13,cursor:v?"not-allowed":"pointer"},children:"Cancel"}),t.jsxs("button",{type:"submit",disabled:v||!h.trim(),style:{padding:"8px 18px",borderRadius:8,border:"none",background:"#2563eb",color:"#ffffff",fontWeight:700,fontSize:13,cursor:v||!h.trim()?"not-allowed":"pointer",opacity:v||!h.trim()?.6:1,display:"flex",alignItems:"center",gap:6,boxShadow:"0 2px 4px rgba(37, 99, 235, 0.25)"},children:[t.jsx("span",{style:{fontSize:15,fontWeight:800},children:"+"}),t.jsx("span",{children:v?"Creating...":"Create"})]})]})]})]})})]})}function v0(e){const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*7?`${Math.floor(n/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function j0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function _i({doctype:e,docname:n,currentUserName:s}){const a=re(),[l,r]=S.useState([]),[i,d]=S.useState(!1),[f,p]=S.useState(""),[C,j]=S.useState(!1),[_,c]=S.useState(!1),[y,z]=S.useState(!1),[k,g]=S.useState(""),o=5,h=S.useCallback(async()=>{d(!0);const b=await Wy(e,n);r(b),d(!1)},[e,n]);S.useEffect(()=>{h()},[h]);const x=async()=>{const b=f.trim();if(!(!b||C)){j(!0),g("");try{await Ny(e,n,b),p(""),await h()}catch{g("Failed to post comment. Please try again.")}j(!1)}},v=async b=>{if(window.confirm("Delete this comment?"))try{await hd("Comment",b),r(T=>T.filter(E=>E.name!==b))}catch{alert("Failed to delete comment.")}},w=y?l:l.slice(-o),u=Math.max(0,l.length-o);return t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>c(b=>!b),style:{padding:"12px 20px",borderBottom:_?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",a.comments.title,l.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:l.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("button",{onClick:b=>{b.stopPropagation(),h()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),t.jsx("span",{style:{color:"#ccc",fontSize:11},children:_?"▼":"▲"})]})]}),!_&&t.jsxs("div",{style:{padding:"16px 20px"},children:[!y&&u>0&&t.jsxs("button",{onClick:()=>z(!0),style:{width:"100%",padding:"8px",marginBottom:12,border:"none",background:"#f8f9fa",borderRadius:6,cursor:"pointer",fontSize:12,color:"#3498db",fontFamily:"Segoe UI"},children:["Show ",u," older comment",u!==1?"s":""]}),i&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:a.loading}),!i&&l.length===0&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:a.comments.noComments}),!i&&w.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:w.map(b=>{const T=b.comment_by||b.comment_email||b.owner||"Unknown",E=b.owner===s||b.comment_by===s;return t.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[t.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,flexShrink:0},children:j0(T)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:T}),t.jsx("span",{style:{fontSize:11,color:"#aaa"},children:v0(b.creation)})]}),E&&t.jsx("button",{onClick:()=>v(b.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),t.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:b.content||""}})]})]},b.name)})}),t.jsxs("div",{style:{borderTop:l.length>0?"1px solid #f0f0f0":"none",paddingTop:l.length>0?14:0},children:[t.jsx("textarea",{value:f,onChange:b=>p(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.ctrlKey||b.metaKey)&&x()},placeholder:a.comments.placeholder,rows:3,style:{width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:8,fontSize:13,fontFamily:"Segoe UI",resize:"vertical",boxSizing:"border-box",outline:"none",color:"#1a2332"}}),k&&t.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:k}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:t.jsx("button",{onClick:x,disabled:!f.trim()||C,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!f.trim()||C?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!f.trim()||C?.6:1},children:C?a.saving:a.comments.post})})]})]})]})}function Ou(e){if(!e)return"";const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*7?`${Math.floor(n/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function b0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Lu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function gd(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Wu(e){return gd(e).split(" ").filter(Boolean).slice(0,2).map(n=>n[0].toUpperCase()).join("")}function S0(e){let n={};try{n=JSON.parse(e.data||"{}")}catch{}const s=(n.changed||[]).map(a=>({field:a[0]||"",oldVal:Lu(a[1]),newVal:Lu(a[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:s,added:(n.added||[]).length,removed:(n.removed||[]).length,rowChanged:(n.row_changed||[]).length}}function wi({doctype:e,docname:n,docCreation:s,docOwner:a}){const l=re(),[r,i]=S.useState([]),[d,f]=S.useState(!1),[p,C]=S.useState(!0),[j,_]=S.useState(!1),c=5,y=S.useCallback(async()=>{f(!0);const o=await By(e,n);i(o.map(S0)),f(!1)},[e,n]);S.useEffect(()=>{p||y()},[p,y]);const z=j?r:r.slice(0,c),k=r.length-c,g=(o,h=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:o,border:"2px solid white",boxShadow:h?`0 0 0 2px ${o}44`:"none"});return t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>C(o=>!o),style:{padding:"12px 20px",borderBottom:p?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",l.activity.title,!p&&r.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:r.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!p&&t.jsx("button",{onClick:o=>{o.stopPropagation(),y()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),t.jsx("span",{style:{color:"#ccc",fontSize:11},children:p?"▼":"▲"})]})]}),!p&&t.jsxs("div",{style:{padding:"16px 20px"},children:[d&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!d&&t.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[t.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[z.map((o,h)=>t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:g(h===0?"#3498db":"#d1d5db",h===0)}),t.jsxs("div",{style:{background:h===0?"#eff6ff":"#f9fafb",border:`1px solid ${h===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Wu(o.owner)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:gd(o.owner)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Ou(o.creation)})]}),o.changes.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:o.changes.map((x,v)=>t.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[t.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:b0(x.field)}),t.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),t.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:x.oldVal}),t.jsx("span",{style:{color:"#6b7280"},children:" → "}),t.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:x.newVal})]},v))}):t.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",o.added>0&&t.jsxs("span",{children:[" · +",o.added," row(s)"]}),o.removed>0&&t.jsxs("span",{children:[" · -",o.removed," row(s)"]}),o.rowChanged>0&&t.jsxs("span",{children:[" · ~",o.rowChanged," row(s) modified"]})]})]})]},o.name)),s&&a&&t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:g("#22c55e")}),t.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[t.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#22c55e",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Wu(a)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:gd(a)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Ou(s)})]}),t.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",l.activity.created]})]})]}),r.length===0&&!s&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!d&&k>0&&t.jsx("div",{style:{textAlign:"center",marginTop:12},children:t.jsx("button",{onClick:()=>_(o=>!o),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:j?"▲ Show less":`▼ Show all (${r.length})`})})]})]})}const _0={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on resolution":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function w0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,..._0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function k0({incForm:e,setIncForm:n,organizations:s,groupCompanies:a=[],managements:l,departments:r,branches:i,incidentTypes:d,incidentClasses:f,incidentFields:p,incidentStatuses:C,users:j,userRoleMap:_={},formStatus:c,viewMode:y,canModify:z,onEdit:k,onDelete:g,onRestore:o,onPermanentDelete:h,darkMode:x,notifCount:v,onToggleDark:w,onCountChange:u,onViewProfile:b,userRole:T,delegatedFunctions:E=[],delegatedOrgs:F={},onSubmit:Q,onBack:te,onNavigate:H,onLogout:Y,user:$,onRefresh:I}){var wt;const A=re(),M=K=>n({...e,...K}),X=y?{background:"#f9f9f9"}:{},L=Na(j,_,"SB Manager",e.organization),[N,J]=S.useState(""),[se,oe]=S.useState(!1),Ye=e.name?y?`${A.formTitle.viewIncident}${e.number||e.name}`:A.formTitle.editIncident:A.formTitle.newIncident,ze=en(l,{organization:e.organization}),St=en(r,{organization:e.organization,management:e.management}),Gt=en(i,{organization:e.organization,management:e.management,department:e.department}),_t=Se(ze,e.management).map(K=>({name:K.name,label:K.name1||K.name})),Lt=Se(St,e.department).map(K=>({name:K.name,label:K.department_name||K.name})),ln=Se(Gt,e.branch).map(K=>({name:K.name,label:K.branch||K.name})),me=Se(d,e.type).map(K=>({name:K.name,label:K.name1||K.name})),Qt=Se(f,e.incident_class).map(K=>({name:K.name,label:K.name1||K.name})),We=Se(p,e.incident_field).map(K=>({name:K.name,label:K.name1||K.name})),G=e.workflow_state||"New",ne=T==="Employee",fe=T==="Auditor"||T==="Admin",Ee=T==="Manager",rn=Ee&&E.includes("incident_initial_evaluation")&&(!F.incident_initial_evaluation||(F.incident_initial_evaluation||[]).includes(e.organization)),he=fe||rn,U=e.name?G==="New"?[{label:A.wf.submit,action:"Submit",color:"#2563eb"}]:G==="Initial Evaluation"&&he?[{label:A.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:A.wf.reject,action:"Reject",color:"#dc2626"}]:G==="Accept & Under Progress"&&(Ee||fe)?[{label:A.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:G==="working on resolution"&&(Ee||fe)?[{label:A.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function le(K){if(e.name){oe(!0),J("");try{const Me={};K==="Assign to Manager"&&(e.assigned_to&&(Me.assigned_to=e.assigned_to),e.priority&&(Me.priority=e.priority),e.economy_class&&(Me.economy_class=e.economy_class),e.entity_scope&&(Me.entity_scope=e.entity_scope),e.hses_field&&(Me.hses_field=e.hses_field),Me.product_relation=String(e.product_relation??0),Me.repeated=String(e.repeated??0)),K==="Submit Solution"&&(e.solution&&(Me.solution=e.solution),e.summary&&(Me.summary=e.summary),e.cost&&(Me.cost=String(e.cost))),(K==="Resolution complete"||K==="Submit Solution")&&e.auditor_comment&&(Me.auditor_comment=e.auditor_comment),await My(e.name,K,JSON.stringify(Me)),J("Done"),I==null||I()}catch(Me){J(Me.message||"Error")}finally{oe(!1)}}}const O=((wt=L.find(K=>K.name===e.assigned_to))==null?void 0:wt.full_name)||e.assigned_to,be=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:A.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:G})]}),G==="Initial Evaluation"&&he&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:R,children:A.wf.assignToManager}),t.jsxs("select",{style:D,value:e.assigned_to||"",onChange:K=>M({assigned_to:K.target.value}),children:[t.jsx("option",{value:"",children:A.field.selectMgr}),L.map(K=>t.jsx("option",{value:K.name,children:K.full_name||K.name},K.name))]})]}),(G==="Accept & Under Progress"||G==="working on resolution")&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:R,children:A.field.solution}),t.jsx("textarea",{style:{...D,height:75,resize:"vertical"},value:e.solution||"",onChange:K=>M({solution:K.target.value}),placeholder:A.field.solutionPlaceholder}),t.jsx("label",{style:{...R,marginTop:6},children:A.field.actualCost}),t.jsx("input",{type:"number",style:D,value:e.cost||"",onChange:K=>M({cost:parseFloat(K.target.value)||0}),placeholder:"0.00"})]}),G==="working on resolution"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:R,children:A.field.auditorComment}),t.jsx("textarea",{style:{...D,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:K=>M({auditor_comment:K.target.value}),placeholder:A.field.commentPlaceholder})]}),U.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:U.map(K=>t.jsx("button",{onClick:()=>le(K.action),disabled:se,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:K.color,color:"white",fontWeight:600,fontSize:12,cursor:se?"not-allowed":"pointer",opacity:se?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:se?A.wf.applying:K.label})},K.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:A.wf.noActions}),N&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:N==="Done"?V.green:V.red},children:N})]}),t.jsx(bi,{priority:e.priority,status:G,assignedTo:O||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(_i,{doctype:P.incidents,docname:e.name,currentUserName:$.name}),t.jsx(wi,{doctype:P.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),z&&g&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:A.delete,onDelete:()=>g(e.name)})]}):null;return t.jsxs(tt,{title:Ye,activePage:"incidents",user:$,formStatus:c,statusBadge:t.jsx("span",{style:w0(G),children:G}),buttonText:A.saveIncident,buttonColor:"#16a34a",viewMode:y,onEdit:k,darkMode:x,notifCount:v,onToggleDark:w,onCountChange:u,onViewProfile:b,rightPanel:be,onSubmit:Q,onBack:te,onNavigate:H,onLogout:Y,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o?()=>o(e.name):void 0,onPermanentDelete:h?()=>h(e.name):void 0}),t.jsx(ce,{title:"Incident Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.number}),t.jsx("input",{style:{...D,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[A.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:K=>{var Et;const Me=(Et=s.find(xs=>xs.name===K))==null?void 0:Et.group_company;M({organization:K,...$.custom_group_company?{}:{group_company:Me||e.group_company}})},organizations:s,disabled:y||!!$.custom_organization,userRole:T,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.title}),t.jsx("input",{style:{...D,...X},value:e.title,disabled:y,onChange:K=>M({title:K.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.management}),t.jsx(xe,{value:e.management,onChange:K=>M({management:K}),items:_t,placeholder:A.field.select,disabled:y,userRole:T,doctypeName:P.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.department}),t.jsx(xe,{value:e.department,onChange:K=>M({department:K}),items:Lt,placeholder:A.field.select,disabled:y,userRole:T,doctypeName:P.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.section}),t.jsx("input",{style:{...D,...X},value:e.section_field||"",disabled:y,onChange:K=>M({section_field:K.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.branch}),t.jsx(xe,{value:e.branch,onChange:K=>M({branch:K}),items:ln,placeholder:A.field.select,disabled:y,userRole:T,doctypeName:P.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.eventCategory}),t.jsxs("select",{style:{...D,...X},value:e.event_category||"",disabled:y,onChange:K=>M({event_category:K.target.value}),children:[t.jsx("option",{value:"",children:A.field.select}),e.event_category&&!["Complaint","Accident","Violent"].includes(e.event_category)&&t.jsx("option",{value:e.event_category,children:e.event_category}),t.jsx("option",{value:"Complaint",children:"Complaint"}),t.jsx("option",{value:"Accident",children:"Accident"}),t.jsx("option",{value:"Violent",children:"Violent"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.type}),t.jsx(xe,{value:e.type,onChange:K=>M({type:K}),items:me,placeholder:A.field.selectType,disabled:y,userRole:T,doctypeName:P.incidentTypes,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.incidentClass}),t.jsx(xe,{value:e.incident_class,onChange:K=>M({incident_class:K}),items:Qt,placeholder:A.field.selectClass,disabled:y,userRole:T,doctypeName:P.incidentClass,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.incidentField}),t.jsx(xe,{value:e.incident_field,onChange:K=>M({incident_field:K}),items:We,placeholder:A.field.selectField,disabled:y,userRole:T,doctypeName:P.incidentField,onQuickCreateSuccess:I})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.hsesField}),t.jsx("input",{style:{...D,...X},value:e.hses_field||"",disabled:y,onChange:K=>M({hses_field:K.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),t.jsxs(ce,{title:"Incident Details & Timing",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.date}),t.jsx(je,{value:e.date,onChange:K=>M({date:K}),disabled:!0,style:{...D,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.time}),t.jsx("input",{type:"time",style:{...D,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.assignedTo}),y||T==="Employee"?t.jsx("input",{style:{...D,background:"#f8fafc",fontWeight:600,color:"#334155"},value:O||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(xe,{value:e.assigned_to||"",onChange:K=>M({assigned_to:K}),items:L.map(K=>({name:K.name,label:K.full_name||K.name})),placeholder:A.field.select})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.description}),t.jsx("textarea",{style:{...D,...X,height:100,resize:"vertical"},value:e.description,disabled:y,onChange:K=>M({description:K.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!ne&&t.jsxs(ce,{title:A.steps.auditorTriage,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.priority}),t.jsxs("select",{style:{...D,...y||!he?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:y||!he,onChange:K=>M({priority:K.target.value}),children:[t.jsx("option",{value:"",children:A.field.select}),t.jsx("option",{value:"High",children:A.field.high}),t.jsx("option",{value:"Normal",children:A.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.economyClass}),t.jsxs("select",{style:{...D,...y||!he?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:y||!he,onChange:K=>M({economy_class:K.target.value}),children:[t.jsx("option",{value:"",children:A.field.select}),t.jsx("option",{value:"Expenses",children:A.field.expenses}),t.jsx("option",{value:"Capital",children:A.field.capital}),t.jsx("option",{value:"Earn",children:A.field.earn}),t.jsx("option",{value:"Pay/Loss",children:A.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.entityScope}),t.jsxs("select",{style:{...D,...y||!he?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:y||!he,onChange:K=>M({entity_scope:K.target.value}),children:[t.jsx("option",{value:"",children:A.field.select}),t.jsx("option",{value:"Upstream",children:A.field.upstream}),t.jsx("option",{value:"On-stream",children:A.field.onstream}),t.jsx("option",{value:"Downstream",children:A.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:y||!he,onChange:K=>M({product_relation:K.target.checked?1:0})})," ",A.field.productRelation]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:y||!he,onChange:K=>M({repeated:K.target.checked?1:0})})," ",A.field.repeatedEvent]})]})]}),!ne&&t.jsxs(ce,{title:A.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:R,children:A.field.solution}),t.jsx("textarea",{style:{...D,height:90,resize:"vertical",...y&&!Ee&&!fe?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:y&&!Ee&&!fe,onChange:K=>M({solution:K.target.value}),placeholder:A.field.solutionPlaceholder})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.actualCost}),t.jsx("input",{type:"number",style:{...D,...y&&!Ee&&!fe?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:y&&!Ee&&!fe,onChange:K=>M({cost:parseFloat(K.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.summary}),t.jsx("input",{style:{...D,...y&&!Ee&&!fe?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:y&&!Ee&&!fe,onChange:K=>M({summary:K.target.value}),placeholder:"Brief summary"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:A.field.auditorComment}),t.jsx("textarea",{style:{...D,height:70,resize:"vertical",...y&&!fe?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:y&&!fe,onChange:K=>M({auditor_comment:K.target.value}),placeholder:A.field.commentPlaceholder})]})]})]})}function C0({ideas:e,organizations:n,departments:s,branches:a,ideaStatuses:l,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:C,onDelete:j,onSelectionChange:_}){const c=re(),[y,z]=S.useState(new Set),[k,g]=S.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(u,b)=>g(T=>({...T,[u]:b})),[h,x]=S.useState(1),v=e.filter(u=>!(k.search&&!`${u.number} ${u.title}`.toLowerCase().includes(k.search.toLowerCase())||k.organization&&u.organization!==k.organization||k.department&&u.department!==k.department||k.branch&&u.branch!==k.branch||k.status&&u.status!==k.status));S.useEffect(()=>{x(1)},[k]);const w=v.slice((h-1)*ie,h*ie);return S.useEffect(()=>{if(_){const u=e.filter(b=>y.has(b.name));_(u,w)}},[y,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.numberTitle}),t.jsx("input",{style:at,value:k.search,onChange:u=>o("search",u.target.value),placeholder:c.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.organization}),t.jsxs("select",{style:at,value:k.organization,onChange:u=>o("organization",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allOrgs}),n.map(u=>t.jsx("option",{value:u.name,children:u.organization_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.department}),t.jsxs("select",{style:at,value:k.department,onChange:u=>o("department",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allDepts}),s.map(u=>t.jsx("option",{value:u.name,children:u.department_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.branch}),t.jsxs("select",{style:at,value:k.branch,onChange:u=>o("branch",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allBranches}),a.map(u=>t.jsx("option",{value:u.name,children:u.branch||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.status}),t.jsxs("select",{style:at,value:k.status,onChange:u=>o("status",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allStatuses}),l.map(u=>t.jsx("option",{value:u.name,children:u.name1||u.name},u.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(u=>y.has(u.name)),onChange:u=>{if(u.target.checked)z(new Set([...y,...w.map(b=>b.name)]));else{const b=new Set(y);w.forEach(T=>b.delete(T.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:c.noIdeas})}):w.map((u,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(u),style:{borderTop:"1px solid #f1f5f9",background:y.has(u.name)?"#eff6ff":u.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:y.has(u.name),onChange:()=>{const T=new Set(y);T.has(u.name)?T.delete(u.name):T.add(u.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:u.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:u.title||"—"}),u.sb_order&&t.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",u.sb_order]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:u.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.custom_is_deleted?fs(c.deletedBadge):u.status?fs(u.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(ot,{onView:()=>p==null?void 0:p(u),onEdit:d&&C&&!u.custom_is_deleted&&!ts("idea",u.workflow_state)&&!(f==="Employee"&&u.workflow_state&&u.workflow_state!=="New")?()=>C(u):void 0,onDelete:d&&j&&!u.custom_is_deleted?()=>j(u.name):void 0})})]},u.name))})]})}),t.jsx(Ue,{page:h,total:v.length,onPageChange:x})]})}const z0={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on proposal":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function I0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...z0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function E0({ideaForm:e,setIdeaForm:n,organizations:s,groupCompanies:a=[],managements:l,departments:r,branches:i,ideaTypes:d,ideaStatuses:f,users:p=[],userRoleMap:C={},formStatus:j,viewMode:_,canModify:c,onEdit:y,onDelete:z,onRestore:k,onPermanentDelete:g,onNavigateToOrder:o,darkMode:h,notifCount:x,onToggleDark:v,onCountChange:w,onViewProfile:u,userRole:b,delegatedFunctions:T=[],delegatedOrgs:E={},onSubmit:F,onBack:Q,onNavigate:te,onLogout:H,user:Y,onRefresh:$}){var le;const I=re(),A=O=>n({...e,...O}),M=_?{background:"#f9f9f9"}:{},X=Na(p,C,"SB Manager",e.organization),[L,N]=S.useState(""),[J,se]=S.useState(!1),oe=e.name?_?`${I.formTitle.viewIdea}${e.number||e.title||e.name}`:I.formTitle.editIdea:I.formTitle.newIdea,Ye=en(l,{organization:e.organization}),ze=en(r,{organization:e.organization,management:e.management}),St=en(i,{organization:e.organization,management:e.management,department:e.department}),Gt=Se(Ye,e.management).map(O=>({name:O.name,label:O.name1||O.name})),_t=Se(ze,e.department).map(O=>({name:O.name,label:O.department_name||O.name})),Lt=Se(St,e.branch).map(O=>({name:O.name,label:O.branch||O.name})),ln=Se(d,e.type).map(O=>({name:O.name,label:O.name1||O.name})),me=e.workflow_state||"New",Qt=b==="Employee",We=b==="Auditor"||b==="Admin",G=b==="Manager",ne=G&&T.includes("idea_initial_evaluation")&&(!E.idea_initial_evaluation||(E.idea_initial_evaluation||[]).includes(e.organization)),fe=We||ne,Ee=e.name?me==="New"?[{label:I.wf.submit,action:"Submit",color:"#2563eb"}]:me==="Initial Evaluation"&&fe?[{label:I.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:me==="Accept & Under Progress"&&(G||We)?[{label:I.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:me==="working on proposal"&&We?[{label:I.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function rn(O){if(e.name){se(!0),N("");try{const be={};O==="Assign to Manager"&&(e.assigned_to&&(be.assigned_to=e.assigned_to),e.priority&&(be.priority=e.priority),e.economy_class&&(be.economy_class=e.economy_class),e.entity_scope&&(be.entity_scope=e.entity_scope),e.hses_field&&(be.hses_field=e.hses_field),be.product_relation=String(e.product_relation??0),be.repeated=String(e.repeated??0)),O==="Submit Proposal"&&(e.solution&&(be.solution=e.solution),e.proposed_condition&&(be.proposed_condition=e.proposed_condition),e.cost&&(be.cost=String(e.cost))),e.auditor_comment&&(O==="Move to Outsourcing"||O==="Reject")&&(be.auditor_comment=e.auditor_comment);const wt=await Fy(e.name,O,JSON.stringify(be));wt!=null&&wt.created_order&&A({sb_order:wt.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),N("Done"),$==null||$()}catch(be){N(be.message||"Error")}finally{se(!1)}}}const he=((le=X.find(O=>O.name===e.assigned_to))==null?void 0:le.full_name)||e.assigned_to,U=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:I.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:me})]}),me==="Initial Evaluation"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:R,children:I.wf.assignToManager}),t.jsxs("select",{style:D,value:e.assigned_to||"",onChange:O=>A({assigned_to:O.target.value}),children:[t.jsx("option",{value:"",children:I.field.selectMgr}),X.map(O=>t.jsx("option",{value:O.name,children:O.full_name||O.name},O.name))]})]}),me==="Accept & Under Progress"&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:R,children:I.field.solution}),t.jsx("textarea",{style:{...D,height:75,resize:"vertical"},value:e.solution||"",onChange:O=>A({solution:O.target.value}),placeholder:I.field.solutionPlaceholder}),t.jsx("label",{style:{...R,marginTop:6},children:I.field.actualCost}),t.jsx("input",{type:"number",style:D,value:e.cost||"",onChange:O=>A({cost:parseFloat(O.target.value)||0}),placeholder:"0.00"})]}),me==="working on proposal"&&We&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:R,children:I.field.auditorComment}),t.jsx("textarea",{style:{...D,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:O=>A({auditor_comment:O.target.value}),placeholder:I.field.commentPlaceholder})]}),Ee.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Ee.map(O=>t.jsx("button",{onClick:()=>rn(O.action),disabled:J,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:O.color,color:"white",fontWeight:600,fontSize:12,cursor:J?"not-allowed":"pointer",opacity:J?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:J?I.wf.applying:O.label})},O.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions}),L&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:L==="Done"?V.green:V.red},children:L})]}),t.jsx(bi,{priority:e.priority,status:me,assignedTo:he||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(_i,{doctype:P.ideas,docname:e.name,currentUserName:Y.name}),t.jsx(wi,{doctype:P.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),c&&z&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:I.delete,onDelete:()=>z(e.name)})]}):null;return t.jsxs(tt,{title:oe,activePage:"ideas",user:Y,formStatus:j,statusBadge:t.jsx("span",{style:I0(me),children:me}),buttonText:I.saveIdea,buttonColor:"#16a34a",viewMode:_,onEdit:y,darkMode:h,notifCount:x,onToggleDark:v,onCountChange:w,onViewProfile:u,rightPanel:U,onSubmit:F,onBack:Q,onNavigate:te,onLogout:H,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:k?()=>k(e.name):void 0,onPermanentDelete:g?()=>g(e.name):void 0}),e.sb_order&&t.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"8px 14px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:"📦"}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#15803d",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[I.field.convertedToOrder,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),o&&t.jsxs("button",{type:"button",onClick:()=>o(e.sb_order),style:{background:"#16a34a",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:O=>O.currentTarget.style.background="#15803d",onMouseLeave:O=>O.currentTarget.style.background="#16a34a",children:[I.field.viewOrder," →"]})]}),t.jsx(ce,{title:"Idea Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.number}),t.jsx("input",{style:{...D,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[I.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:O=>{var wt;const be=(wt=s.find(K=>K.name===O))==null?void 0:wt.group_company;A({organization:O,...Y.custom_group_company?{}:{group_company:be||e.group_company}})},organizations:s,disabled:_||!!Y.custom_organization,userRole:b,onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.title}),t.jsx("input",{style:{...D,...M},value:e.title,disabled:_,onChange:O=>A({title:O.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.management}),t.jsx(xe,{value:e.management,onChange:O=>A({management:O}),items:Gt,placeholder:I.field.select,disabled:_,userRole:b,doctypeName:P.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.department}),t.jsx(xe,{value:e.department,onChange:O=>A({department:O}),items:_t,placeholder:I.field.select,disabled:_,userRole:b,doctypeName:P.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.section}),t.jsx("input",{style:{...D,...M},value:e.section_field||"",disabled:_,onChange:O=>A({section_field:O.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.branch}),t.jsx(xe,{value:e.branch,onChange:O=>A({branch:O}),items:Lt,placeholder:I.field.select,disabled:_,userRole:b,doctypeName:P.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.type}),t.jsx(xe,{value:e.type,onChange:O=>A({type:O}),items:ln,placeholder:I.field.selectType,disabled:_,userRole:b,doctypeName:P.ideaTypes,onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.ideaClass}),t.jsxs("select",{style:{...D,...M},value:e.idea_class||"",disabled:_,onChange:O=>A({idea_class:O.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Safety",children:"Safety"}),t.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.hsesField}),t.jsx("input",{style:{...D,...M},value:e.hses_field||"",disabled:_,onChange:O=>A({hses_field:O.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.date}),t.jsx(je,{value:e.date||"",onChange:O=>A({date:O}),disabled:!0,style:{...D,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.assignedTo}),_||b==="Employee"?t.jsx("input",{style:{...D,background:"#f8fafc",fontWeight:600,color:"#334155"},value:he||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(xe,{value:e.assigned_to||"",onChange:O=>A({assigned_to:O}),items:X.map(O=>({name:O.name,label:O.full_name||O.name})),placeholder:I.field.select})]})]})}),t.jsx(ce,{title:"Condition Details & Description",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.currentCondition}),t.jsx("textarea",{style:{...D,...M,height:100,resize:"vertical"},value:e.current_condition,disabled:_,onChange:O=>A({current_condition:O.target.value}),placeholder:"Describe the current condition or problem..."})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.proposedCondition}),t.jsx("textarea",{style:{...D,...M,height:100,resize:"vertical"},value:e.proposed_condition,disabled:_,onChange:O=>A({proposed_condition:O.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!Qt&&t.jsxs(ce,{title:I.steps.auditorEval,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.priority}),t.jsxs("select",{style:{...D,..._||!fe?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:_||!fe,onChange:O=>A({priority:O.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"High",children:I.field.high}),t.jsx("option",{value:"Normal",children:I.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.economyClass}),t.jsxs("select",{style:{...D,..._||!fe?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:_||!fe,onChange:O=>A({economy_class:O.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Expenses",children:I.field.expenses}),t.jsx("option",{value:"Capital",children:I.field.capital}),t.jsx("option",{value:"Earn",children:I.field.earn}),t.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.entityScope}),t.jsxs("select",{style:{...D,..._||!fe?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:_||!fe,onChange:O=>A({entity_scope:O.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Upstream",children:I.field.upstream}),t.jsx("option",{value:"On-stream",children:I.field.onstream}),t.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:_||!fe,onChange:O=>A({product_relation:O.target.checked?1:0})})," ",I.field.productRelation]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:_||!fe,onChange:O=>A({repeated:O.target.checked?1:0})})," ",I.field.repeatedEvent]})]})]}),!Qt&&t.jsxs(ce,{title:I.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:R,children:I.field.solution}),t.jsx("textarea",{style:{...D,height:90,resize:"vertical",..._&&!G&&!We?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:_&&!G&&!We,onChange:O=>A({solution:O.target.value}),placeholder:I.field.solutionPlaceholder})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.actualCost}),t.jsx("input",{type:"number",style:{...D,..._&&!G&&!We?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:_&&!G&&!We,onChange:O=>A({cost:parseFloat(O.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.auditorComment}),t.jsx("textarea",{style:{...D,height:60,resize:"vertical",..._&&!We?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:_&&!We,onChange:O=>A({auditor_comment:O.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})]})}function T0({orders:e,organizations:n,departments:s,branches:a,orderStatuses:l,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:C,onDelete:j,onSelectionChange:_}){const c=re(),[y,z]=S.useState(new Set),[k,g]=S.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(u,b)=>g(T=>({...T,[u]:b})),[h,x]=S.useState(1),v=e.filter(u=>!(k.search&&!`${u.number} ${u.title}`.toLowerCase().includes(k.search.toLowerCase())||k.organization&&u.organization!==k.organization||k.department&&u.department!==k.department||k.branch&&u.branch!==k.branch||k.status&&u.status!==k.status));S.useEffect(()=>{x(1)},[k]);const w=v.slice((h-1)*ie,h*ie);return S.useEffect(()=>{if(_){const u=e.filter(b=>y.has(b.name));_(u,w)}},[y,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.numberTitle}),t.jsx("input",{style:at,value:k.search,onChange:u=>o("search",u.target.value),placeholder:c.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.organization}),t.jsxs("select",{style:at,value:k.organization,onChange:u=>o("organization",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allOrgs}),n.map(u=>t.jsx("option",{value:u.name,children:u.organization_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.department}),t.jsxs("select",{style:at,value:k.department,onChange:u=>o("department",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allDepts}),s.map(u=>t.jsx("option",{value:u.name,children:u.department_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.branch}),t.jsxs("select",{style:at,value:k.branch,onChange:u=>o("branch",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allBranches}),a.map(u=>t.jsx("option",{value:u.name,children:u.branch||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.status}),t.jsxs("select",{style:at,value:k.status,onChange:u=>o("status",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allStatuses}),l.map(u=>t.jsx("option",{value:u.name,children:u.name1||u.name},u.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(u=>y.has(u.name)),onChange:u=>{if(u.target.checked)z(new Set([...y,...w.map(b=>b.name)]));else{const b=new Set(y);w.forEach(T=>b.delete(T.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:c.noOrders})}):w.map((u,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(u),style:{borderTop:"1px solid #f1f5f9",background:y.has(u.name)?"#eff6ff":u.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:y.has(u.name),onChange:()=>{const T=new Set(y);T.has(u.name)?T.delete(u.name):T.add(u.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:u.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:u.title||u.name||"—"}),u.sb_idea&&t.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",u.sb_idea]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:u.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.type?cc(u.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.custom_is_deleted?fs(c.deletedBadge):u.status?fs(u.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(ot,{onView:()=>p==null?void 0:p(u),onEdit:d&&C&&!u.custom_is_deleted&&!ts("order",u.workflow_state)&&f!=="Employee"?()=>C(u):void 0,onDelete:d&&j&&!u.custom_is_deleted?()=>j(u.name):void 0})})]},u.name))})]})}),t.jsx(Ue,{page:h,total:v.length,onPageChange:x})]})}const A0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},P0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},Review:{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"In Study":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Closed:{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function R0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...P0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function D0({orderForm:e,setOrderForm:n,organizations:s,groupCompanies:a=[],managements:l,departments:r,branches:i,orderTypes:d,orderStatuses:f,cycles:p=[],users:C=[],userRoleMap:j={},formStatus:_,viewMode:c,canModify:y,onEdit:z,onDelete:k,onRestore:g,onPermanentDelete:o,onNavigateToIdea:h,darkMode:x,notifCount:v,onToggleDark:w,onCountChange:u,onViewProfile:b,currentUser:T,userRole:E,onSubmit:F,onBack:Q,onNavigate:te,onLogout:H,user:Y,onRefresh:$}){var Yl,Ha;const I=re(),A=B=>n({...e,...B}),M=c?{background:"#f9f9f9"}:{},X=Na(C,j,"SB Employee",e.organization),[L,N]=S.useState(""),[J,se]=S.useState(""),[oe,Ye]=S.useState(!1),[ze,St]=S.useState("Agree"),Gt=e.name?c?`${I.formTitle.viewOrder}${e.number||e.title||e.name}`:I.formTitle.editOrder:I.formTitle.newOrder,_t=en(l,{organization:e.organization}),Lt=en(r,{organization:e.organization,management:e.management}),ln=en(i,{organization:e.organization,management:e.management,department:e.department}),me=Se(_t,e.management).map(B=>({name:B.name,label:B.name1||B.name})),Qt=Se(Lt,e.department).map(B=>({name:B.name,label:B.department_name||B.name})),We=Se(ln,e.branch).map(B=>({name:B.name,label:B.branch||B.name})),G=Se(d,e.type).map(B=>({name:B.name,label:B.name1||B.name})),ne=["SAR","USD","EUR","AED","GBP","KWD","BHD","QAR","OMR","EGP"],fe=Array.from(new Set([...ne,e.currency].filter(Boolean))).map(B=>({name:B,label:B})),Ee=Se(p,e.cycle).map(B=>({name:B.name,label:B.name1||B.cycle_name||B.name})),rn=!!e.name,he=e.workflow_state||"Draft",U=Math.min(5,(e.stage||0)+1),[le,O]=S.useState(U);S.useEffect(()=>{O(Math.min(5,(e.stage||0)+1))},[e.stage]);const be=E==="Auditor"||E==="Admin"||E==="Manager",wt=be||E==="Owner",K=!!(T&&(e.actor===T||e.assigned_to===T)),Me=e.stage===5||e.completion_pct===100||e.status==="Completion"||he==="Completed"||he==="Closed",Et=e.order_cycle_log||[],xs=Et.length>0?Et[Et.length-1].status:ze,ys=xs==="Deviate"||xs==="Deviated"||xs==="Unknown",Hl=(()=>{if(!rn)return[];if(he==="Closed"||he==="Completed")return[];if(he==="Draft"&&be)return[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}];if(he==="Pending Actor"&&(K||be))return[{label:"Update Status",action:"Update Status",color:"#d97706"}];if(he==="Review"&&wt){const B=[{label:"Move to Study",action:"Move to Study",color:"#059669"}];return(!Me||ys)&&B.push({label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}),Me&&B.push({label:"Close Order",action:"Close Order",color:"#475569"}),B}if(he==="In Study"&&wt){const B=[];return(!Me||ys)&&B.push({label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}),B.push({label:"Close Order",action:"Close Order",color:"#475569"}),B}return[]})();async function Gl(B){if(e.name){Ye(!0),N("");try{let pt;B==="Update Status"&&(pt=ze);const Tn=await Uy(e.name,B,J,B==="Update Status"?String(le):void 0,void 0,pt);if(se(""),St("Agree"),N("Done"),Tn){const De=Tn;n({...e,...De,stage:De.stage??e.stage,completion_pct:De.completion_pct??e.completion_pct,workflow_state:De.workflow_state??e.workflow_state})}$==null||$()}catch(pt){N(pt.message||"Error")}finally{Ye(!1)}}}const Ql=((Yl=X.find(B=>B.name===(e.actor||e.assigned_to)))==null?void 0:Yl.full_name)||e.actor||e.assigned_to,Kl=rn?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:I.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:he})]}),he==="Pending Actor"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:["Stage (1–5) — ",le*20,"% complete"]}),t.jsx("input",{type:"number",min:1,max:5,style:{...D,width:"100%"},value:le,onChange:B=>O(Math.min(5,Math.max(1,parseInt(B.target.value)||1)))})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Cycle Status"}),t.jsxs("select",{style:D,value:ze,onChange:B=>St(B.target.value),children:[t.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),t.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),t.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsxs("label",{style:R,children:["Comment ",ze==="Deviate"&&he==="Pending Actor"?t.jsx("span",{style:{color:V.red},children:" * required for Deviate"}):"(optional)"]}),t.jsx("textarea",{style:{...D,height:60,resize:"vertical",borderColor:ze==="Deviate"&&!J?"#fca5a5":void 0},value:J,onChange:B=>se(B.target.value),placeholder:"Add a comment…"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Hl.map(B=>{const pt=B.action==="Update Status"&&ze==="Deviate"&&!J.trim();return t.jsx("button",{onClick:()=>Gl(B.action),disabled:oe||pt,title:pt?"Comment required when status is Deviate":void 0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:B.color,color:"white",fontWeight:600,fontSize:12,cursor:oe||pt?"not-allowed":"pointer",opacity:oe||pt?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:oe?I.wf.applying:B.label})},B.action)})}),L&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:L==="Done"?V.green:V.red},children:L}),Hl.length===0&&t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions})]}),t.jsx(bi,{priority:e.priority,status:he,assignedTo:E!=="Employee"?Ql:void 0,createdDate:e.starting_date,modifiedDate:e.modified}),t.jsx(_i,{doctype:P.orders,docname:e.name,currentUserName:Y.name}),t.jsx(wi,{doctype:P.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),y&&k&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:I.delete,onDelete:()=>k(e.name)})]}):null;return t.jsxs(tt,{title:Gt,activePage:"orders",user:Y,formStatus:_,statusBadge:t.jsx("span",{style:R0(he),children:he}),buttonText:I.saveOrder,buttonColor:"#16a34a",viewMode:c,onEdit:z,darkMode:x,notifCount:v,onToggleDark:w,onCountChange:u,onViewProfile:b,rightPanel:Kl,onSubmit:F,onBack:Q,onNavigate:te,onLogout:H,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0,onPermanentDelete:o?()=>o(e.name):void 0}),e.sb_idea&&t.jsxs("div",{style:{background:"#f0f7ff",border:"1px solid #bfdbfe",borderRadius:8,padding:"8px 14px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:"💡"}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#1e40af",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[I.field.originatingIdea,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),h&&t.jsxs("button",{type:"button",onClick:()=>h(e.sb_idea),style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:B=>B.currentTarget.style.background="#1d4ed8",onMouseLeave:B=>B.currentTarget.style.background="#2563eb",children:[I.field.viewIdea," →"]})]}),t.jsx(ce,{title:"Order Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.number}),t.jsx("input",{style:{...D,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[I.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:B=>{var Tn;const pt=(Tn=s.find(De=>De.name===B))==null?void 0:Tn.group_company;A({organization:B,...Y.custom_group_company?{}:{group_company:pt||e.group_company}})},organizations:s,disabled:c||!!Y.custom_organization,userRole:E,onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.title}),t.jsx("input",{style:{...D,...M},value:e.title,disabled:c,onChange:B=>A({title:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.management}),t.jsx(xe,{value:e.management,onChange:B=>A({management:B}),items:me,placeholder:I.field.select,disabled:c,userRole:E,doctypeName:P.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.department}),t.jsx(xe,{value:e.department,onChange:B=>A({department:B}),items:Qt,placeholder:I.field.select,disabled:c,userRole:E,doctypeName:P.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.section}),t.jsx("input",{style:{...D,...M},value:e.section_field||"",disabled:c,onChange:B=>A({section_field:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.branch}),t.jsx(xe,{value:e.branch,onChange:B=>A({branch:B}),items:We,placeholder:I.field.select,disabled:c,userRole:E,doctypeName:P.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.type}),t.jsx(xe,{value:e.type,onChange:B=>A({type:B}),items:G,placeholder:I.field.selectType,disabled:c,userRole:E,doctypeName:P.orderTypes,onQuickCreateSuccess:$})]})]})}),t.jsxs(ce,{title:"Financial & Schedule",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.budget}),t.jsx("input",{type:"number",style:{...D,...M},value:e.budget||"",disabled:c,onChange:B=>A({budget:parseFloat(B.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.actualCost}),t.jsx("input",{type:"number",style:{...D,...M},value:e.actual_cost||"",disabled:c,onChange:B=>A({actual_cost:parseFloat(B.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Variance"}),(()=>{const B=(e.budget||0)-(e.actual_cost||0);return t.jsxs("div",{style:{padding:"7px 12px",borderRadius:6,fontWeight:700,fontSize:13,background:B>=0?"#f0fdf4":"#fef2f2",color:B>=0?"#166534":"#dc2626",border:`1px solid ${B>=0?"#bbf7d0":"#fecaca"}`,display:"inline-block",width:"100%",boxSizing:"border-box"},children:[B>=0?"+":"",B.toFixed(2)]})})()]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.currency}),t.jsx(xe,{value:e.currency||"",onChange:B=>A({currency:B}),items:fe,placeholder:I.field.select,disabled:c,userRole:E,doctypeName:P.currency,onQuickCreateSuccess:$})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.startingDate}),t.jsx(je,{value:e.starting_date,onChange:B=>A({starting_date:B}),disabled:c,style:{...D,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.endingDate}),t.jsx(je,{value:e.ending_date,onChange:B=>A({ending_date:B}),disabled:c,style:{...D,...M}})]}),E!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.actor}),c?t.jsx("input",{style:{...D,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Ql||"—",readOnly:!0,disabled:!0}):t.jsxs("select",{style:{...D,background:"#ffffff"},value:e.actor||e.assigned_to||"",onChange:B=>A({actor:B.target.value,assigned_to:B.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),X.map(B=>t.jsx("option",{value:B.name,children:B.full_name||B.name},B.name))]})]})]})]}),t.jsxs(ce,{title:"Classification",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.priority}),t.jsxs("select",{style:{...D,...M},value:e.priority||"",disabled:c,onChange:B=>A({priority:B.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"High",children:I.field.high}),t.jsx("option",{value:"Normal",children:I.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.economyClass}),t.jsxs("select",{style:{...D,...M},value:e.economy_class||"",disabled:c,onChange:B=>A({economy_class:B.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Expenses",children:I.field.expenses}),t.jsx("option",{value:"Capital",children:I.field.capital}),t.jsx("option",{value:"Earn",children:I.field.earn}),t.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.entityScope}),t.jsxs("select",{style:{...D,...M},value:e.entity_scope||"",disabled:c,onChange:B=>A({entity_scope:B.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Upstream",children:I.field.upstream}),t.jsx("option",{value:"On-stream",children:I.field.onstream}),t.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:c,onChange:B=>A({planned:B.target.checked?1:0})})," Planned"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:c,onChange:B=>A({product_relation:B.target.checked?1:0})})," ",I.field.productRelation]})]}),t.jsxs("div",{style:{marginTop:12},children:[t.jsx("label",{style:R,children:I.field.hsesField}),t.jsx("input",{style:{...D,...M},value:e.hses_field||"",disabled:c,onChange:B=>A({hses_field:B.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),t.jsxs(ce,{title:"Cycle & Progress Tracking",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.cycle}),t.jsx(xe,{value:e.cycle||"",onChange:B=>A({cycle:B}),items:Ee,placeholder:I.field.select,disabled:c,userRole:E,doctypeName:P.cycles,extraFields:{organization:e.organization},onQuickCreateSuccess:$})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.cycleType}),t.jsxs("select",{style:{...D,...M},value:e.cycle_type||"Normal",disabled:c,onChange:B=>A({cycle_type:B.target.value}),children:[t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Long",children:"Long"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.stage}),t.jsx("input",{type:"number",min:1,max:5,style:{...D,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Completion"}),t.jsx("input",{style:{...D,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Stage Description"}),t.jsx("span",{style:{display:"inline-block",padding:"7px 12px",borderRadius:6,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd",width:"100%",boxSizing:"border-box"},children:A0[e.stage||1]||"—"})]})]}),e.cycle_type==="Long"&&t.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginBottom:14},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 1"}),t.jsx(je,{value:e.long_cycle_date_1||"",onChange:B=>A({long_cycle_date_1:B}),disabled:c,style:{...D,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 2"}),t.jsx(je,{value:e.long_cycle_date_2||"",onChange:B=>A({long_cycle_date_2:B}),disabled:c,style:{...D,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 3"}),t.jsx(je,{value:e.long_cycle_date_3||"",onChange:B=>A({long_cycle_date_3:B}),disabled:c,style:{...D,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 4"}),t.jsx(je,{value:e.long_cycle_date_4||"",onChange:B=>A({long_cycle_date_4:B}),disabled:c,style:{...D,...M}})]})]})]}),rn&&((Ha=e.order_cycle_log)==null?void 0:Ha.length)>0&&t.jsxs("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:14,marginTop:10},children:[t.jsx("p",{style:{fontWeight:700,color:"#334155",fontSize:13,marginBottom:10},children:"Cycle History"}),t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(B=>t.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:B},B))})}),t.jsx("tbody",{children:(e.order_cycle_log||[]).map((B,pt)=>{const Tn=B.status==="Agree"?"#166534":B.status==="Deviate"?"#c2410c":"#92400e",De=B.status==="Agree"?"#f0fdf4":B.status==="Deviate"?"#fff7ed":"#fefce8";return t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:B.cycle||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:B.cycle_date||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:B.stage||"—"}),t.jsx("td",{style:{padding:"6px 10px"},children:t.jsx("span",{style:{background:De,color:Tn,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:B.status||"—"})}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:B.actor||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:B.comment?"normal":"italic"},children:B.comment||"—"})]},pt)})})]})})]})]}),t.jsxs(ce,{title:"Description & Notes",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.description}),t.jsx("textarea",{style:{...D,...M,height:90,resize:"vertical"},value:e.description,disabled:c,onChange:B=>A({description:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.notes}),t.jsx("textarea",{style:{...D,...M,height:90,resize:"vertical"},value:e.notes,disabled:c,onChange:B=>A({notes:B.target.value})})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:I.field.auditorComment}),t.jsx("textarea",{style:{...D,height:70,resize:"vertical",...c&&K&&!be?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:c&&K&&!be,onChange:B=>A({auditor_comment:B.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})}function O0({processes:e,organizations:n,departments:s,branches:a,processStatuses:l,initialOrg:r,initialStatus:i,canModify:d,userRole:f,onView:p,onEdit:C,onDelete:j,onSelectionChange:_}){const c=re(),[y,z]=S.useState(new Set),[k,g]=S.useState({search:"",organization:r||"",department:"",branch:"",status:i||""}),o=(u,b)=>g(T=>({...T,[u]:b})),[h,x]=S.useState(1),v=e.filter(u=>!(k.search&&!`${u.number} ${u.title}`.toLowerCase().includes(k.search.toLowerCase())||k.organization&&u.organization!==k.organization||k.department&&u.department!==k.department||k.branch&&u.branch!==k.branch||k.status&&u.status!==k.status));S.useEffect(()=>{x(1)},[k]);const w=v.slice((h-1)*ie,h*ie);return S.useEffect(()=>{if(_){const u=e.filter(b=>y.has(b.name));_(u,w)}},[y,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(Si,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.numberTitle}),t.jsx("input",{style:at,value:k.search,onChange:u=>o("search",u.target.value),placeholder:c.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.organization}),t.jsxs("select",{style:at,value:k.organization,onChange:u=>o("organization",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allOrgs}),n.map(u=>t.jsx("option",{value:u.name,children:u.organization_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.department}),t.jsxs("select",{style:at,value:k.department,onChange:u=>o("department",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allDepts}),s.map(u=>t.jsx("option",{value:u.name,children:u.department_name||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.branch}),t.jsxs("select",{style:at,value:k.branch,onChange:u=>o("branch",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allBranches}),a.map(u=>t.jsx("option",{value:u.name,children:u.branch||u.name},u.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:st,children:c.filter.status}),t.jsxs("select",{style:at,value:k.status,onChange:u=>o("status",u.target.value),children:[t.jsx("option",{value:"",children:c.filter.allStatuses}),l.map(u=>t.jsx("option",{value:u.name,children:u.name1||u.name},u.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(u=>y.has(u.name)),onChange:u=>{if(u.target.checked)z(new Set([...y,...w.map(b=>b.name)]));else{const b=new Set(y);w.forEach(T=>b.delete(T.name)),z(b)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.field.cycleType}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:c.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:c.noProcesses})}):w.map((u,b)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>p==null?void 0:p(u),style:{borderTop:"1px solid #f1f5f9",background:y.has(u.name)?"#eff6ff":u.custom_is_deleted?"#fff1f2":b%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:y.has(u.name),onChange:()=>{const T=new Set(y);T.has(u.name)?T.delete(u.name):T.add(u.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:u.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:u.title||u.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:u.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.cycle_type?cc(u.cycle_type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:u.custom_is_deleted?fs(c.deletedBadge):u.status?fs(u.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(ot,{onView:()=>p==null?void 0:p(u),onEdit:d&&C&&!u.custom_is_deleted&&!ts("process",u.workflow_state)&&f!=="Employee"?()=>C(u):void 0,onDelete:d&&j&&!u.custom_is_deleted?()=>j(u.name):void 0})})]},u.name))})]})}),t.jsx(Ue,{page:h,total:v.length,onPageChange:x})]})}const L0={Draft:[{action:"Submit for Review",next:"Pending Actor",allowedRoles:["Auditor","Manager"]}],"Pending Actor":[{action:"Update Status",next:"Pending Comment",allowedRoles:["Employee","Manager"]}],"Pending Comment":[{action:"Add Comment",next:"Review",allowedRoles:["Auditor","Manager"]}],Review:[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Move to Study",next:"In Study",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},W0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Pending Comment":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Completed:{background:"#ecfdf5",color:"#047857",border:"1px solid #a7f3d0"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function Nu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...W0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const mr={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function N0({processName:e,userRole:n,onRefresh:s,canUpdateStatus:a=!0}){const[l,r]=S.useState(null),[i,d]=S.useState(!0),[f,p]=S.useState(""),[C,j]=S.useState(!1),[_,c]=S.useState(""),[y,z]=S.useState(""),[k,g]=S.useState("Pass"),[o,h]=S.useState(""),[x,v]=S.useState({}),w=S.useCallback(async()=>{if(!e){d(!1);return}d(!0),p("");try{const H=await dl(e);r(H);const Y={};for(const $ of H.progress_indicators||[])Y[$.name]=$.actual_value!=null?String($.actual_value):"";v(Y)}catch(H){p(H instanceof Error?H.message:"Failed to load process")}d(!1)},[e]);if(S.useEffect(()=>{w()},[w]),i)return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:24,color:"#aaa",fontSize:13,textAlign:"center"},children:"Loading…"})});if(f||!l)return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:t.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:f||"Could not load workflow"})})});const u=l.workflow_state||"Draft",b=L0[u]??[],T=n==="Employee"||n==="Manager",E=n!=="Manager"||a,F=l.completion_pct===100||l.stage===5||l.status==="Completion"||l.status==="Completed"||u==="Completed"||u==="Closed",Q=b.filter(H=>H.action==="Start New Cycle"&&F?!1:(n==="Admin"||H.allowedRoles.includes(n))&&(H.action!=="Update Status"||E)),te=async H=>{j(!0),c(""),z("");try{const Y={};if(H==="Update Status"){Y.actor_status=k,Y.actor_comment=o;const I=l.progress_indicators||[];I.length>0&&(Y.progress_indicators=I.map(A=>({name:A.name,actual_value:x[A.name]??""})))}H==="Add Comment"&&o&&(Y.actor_comment=o);const $=await n0(l.name,H,Y);r($),h(""),z(`Done — now: ${$.workflow_state||"updated"}`),s==null||s()}catch(Y){c(Y instanceof Error?Y.message:"Action failed")}j(!1)};return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),t.jsx("div",{style:Nu(u),children:u})]}),u==="Pending Actor"&&T&&E&&t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Update Status"}),Array.isArray(l.progress_indicators)&&l.progress_indicators.length>0&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Actual Value"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:l.progress_indicators.map(H=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:11,color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:H.name1,children:H.name1||H.name}),t.jsx("input",{type:"number",value:x[H.name]??"",onChange:Y=>v($=>({...$,[H.name]:Y.target.value})),style:{...mr,width:70,flexShrink:0},placeholder:"0"})]},H.name))})]}),t.jsxs("div",{style:{marginBottom:8},children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),t.jsxs("select",{value:k,onChange:H=>g(H.target.value),style:mr,children:[t.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),t.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),t.jsx("textarea",{value:o,onChange:H=>h(H.target.value),style:{...mr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(u==="Pending Comment"||u==="Review")&&!T&&t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Auditor Comment"}),Array.isArray(l.cycle_logs)&&l.cycle_logs.length>0&&t.jsxs("div",{style:{marginBottom:8,padding:"6px 10px",background:"#f8fafc",borderRadius:6,border:"1px solid #e2e8f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",marginBottom:3},children:"Latest cycle status:"}),(()=>{const H=l.cycle_logs,Y=H[H.length-1],$=Y.status==="Pass"?"#16a34a":Y.status==="Fail"?"#dc2626":"#9ca3af";return t.jsxs("div",{style:{fontSize:13,fontWeight:700,color:$},children:[Y.status," ",Y.comment?`— ${Y.comment}`:""]})})()]}),t.jsx("textarea",{value:o,onChange:H=>h(H.target.value),style:{...mr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:Q.length>0?"1px solid #f0f0f0":"none"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),Q.length===0&&t.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",t.jsx("strong",{children:n})," in ",t.jsx("strong",{children:u}),"."]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Q.map(H=>t.jsxs("button",{onClick:()=>te(H.action),disabled:C,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:H.action==="Close Process"?"#64748b":H.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:C?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:C?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:C?"Applying…":H.action}),t.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",H.next]})]},H.action))}),_&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:_}),y&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:y})]}),b.length>0&&t.jsxs("div",{style:{padding:"12px 14px"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),b.map(H=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[t.jsx("span",{style:{color:"#555",flex:1},children:H.action}),t.jsx("span",{style:{color:"#bbb"},children:"→"}),t.jsx("span",{style:Nu(H.next),children:H.next})]},H.action))]})]})})}function B0({processForm:e,setProcessForm:n,organizations:s,groupCompanies:a=[],managements:l,departments:r,branches:i,processTypes:d,processStatuses:f,cycles:p=[],users:C=[],userRoleMap:j={},formStatus:_,viewMode:c,canModify:y,onEdit:z,onDelete:k,onRestore:g,onPermanentDelete:o,darkMode:h,notifCount:x,onToggleDark:v,onCountChange:w,onViewProfile:u,userRole:b,onRefreshProcess:T,onSubmit:E,onBack:F,onNavigate:Q,onLogout:te,user:H}){var he;const Y=re(),$=U=>n({...e,...U}),I=c?{background:"#f9f9f9"}:{},A=s,M=!!H.custom_organization,X=en(l,{organization:e.organization}),L=en(r,{organization:e.organization,management:e.management}),N=en(i,{organization:e.organization,management:e.management,department:e.department}),J=Se(X,e.management).map(U=>({name:U.name,label:U.name1||U.name})),se=Se(L,e.department).map(U=>({name:U.name,label:U.department_name||U.name})),oe=Se(N,e.branch).map(U=>({name:U.name,label:U.branch||U.name})),Ye=Se(d,e.type).map(U=>({name:U.name,label:U.name1||U.name})),ze=Se(p,e.cycle).map(U=>({name:U.name,label:U.name1||U.name})),St=Na(C,j,"SB Employee",e.organization).map(U=>({name:U.name,label:U.full_name||U.name})),Gt=Na(C,j,"SB Manager",e.organization).map(U=>({name:U.name,label:U.full_name||U.name})),_t=(U,le)=>{const O=[...e.cycle_logs||[]];O[U]={...O[U],...le},$({cycle_logs:O})},Lt=()=>{$({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},ln=U=>{const le=[...e.cycle_logs||[]];le.splice(U,1),$({cycle_logs:le})},me=(U,le)=>{const O=[...e.progress_indicators||[]];O[U]={...O[U],...le},$({progress_indicators:O})},Qt=()=>{$({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"Pass",cycle_date:"",cycle_comment:"",status:"Active"}]})},We=U=>{const le=[...e.progress_indicators||[]];le.splice(U,1),$({progress_indicators:le})},G=e.name?c?`${Y.formTitle.viewProcess}${e.title||e.name}`:Y.formTitle.editProcess:Y.formTitle.newProcess,ne=b!=="Manager"||e.actor===H.name,fe=((he=St.find(U=>U.name===e.actor))==null?void 0:he.label)||e.actor,Ee=e.workflow_state||"Draft",rn=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsx(N0,{processName:e.name,userRole:b||H.role||"Employee",onRefresh:T,canUpdateStatus:ne}),t.jsx(bi,{priority:e.impact_level,status:Ee,assignedTo:fe,createdDate:e.date_start,modifiedDate:e.modified}),t.jsx(_i,{doctype:P.processes,docname:e.name,currentUserName:H.name}),t.jsx(wi,{doctype:P.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),y&&k&&!e.custom_is_deleted&&t.jsx(ji,{title:"Delete Request",btnText:Y.delete,onDelete:()=>k(e.name)})]}):void 0;return t.jsxs(tt,{title:G,activePage:"processes",user:H,formStatus:_,statusBadge:t.jsx("span",{style:{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},children:Ee}),buttonText:Y.saveProcess,buttonColor:"#16a34a",viewMode:c,onEdit:z,darkMode:h,notifCount:x,onToggleDark:v,onCountChange:w,onViewProfile:u,rightPanel:rn,onSubmit:E,onBack:F,onNavigate:Q,onLogout:te,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0,onPermanentDelete:o?()=>o(e.name):void 0}),t.jsx(ce,{title:"Process Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.number}),t.jsx("input",{style:{...D,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[Y.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:U=>{var O;const le=(O=s.find(be=>be.name===U))==null?void 0:O.group_company;$({organization:U,...H.custom_group_company?{}:{group_company:le||e.group_company}})},organizations:A,disabled:c||M,userRole:b,onQuickCreateSuccess:T})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.title}),t.jsx("input",{style:{...D,...I},value:e.title,disabled:c,onChange:U=>$({title:U.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.type}),t.jsx(xe,{value:e.type,onChange:U=>$({type:U}),items:Ye,placeholder:Y.field.selectType,disabled:c,userRole:b,doctypeName:P.processTypes,onQuickCreateSuccess:T})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.management}),t.jsx(xe,{value:e.management,onChange:U=>$({management:U}),items:J,placeholder:Y.field.select,disabled:c,userRole:b,doctypeName:P.managements,extraFields:{organization:e.organization},onQuickCreateSuccess:T})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.department}),t.jsx(xe,{value:e.department,onChange:U=>$({department:U}),items:se,placeholder:Y.field.select,disabled:c,userRole:b,doctypeName:P.departments,extraFields:{organization:e.organization,management:e.management},onQuickCreateSuccess:T})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.section}),t.jsx("input",{style:{...D,...I},value:e.section_field||"",disabled:c,onChange:U=>$({section_field:U.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.branch}),t.jsx(xe,{value:e.branch,onChange:U=>$({branch:U}),items:oe,placeholder:Y.field.select,disabled:c,userRole:b,doctypeName:P.branches,extraFields:{organization:e.organization,management:e.management,department:e.department},onQuickCreateSuccess:T})]})]})}),t.jsxs(ce,{title:"Classification",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.chainLocation}),t.jsxs("select",{style:{...D,...I},value:e.chain_location||"",disabled:c,onChange:U=>$({chain_location:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),t.jsx("option",{value:"Upstream",children:"Upstream"}),t.jsx("option",{value:"On-stream",children:"On-stream"}),t.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.economyClass}),t.jsxs("select",{style:{...D,...I},value:e.economy_class||"",disabled:c,onChange:U=>$({economy_class:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),t.jsx("option",{value:"Expenses",children:Y.field.expenses}),t.jsx("option",{value:"Capital",children:Y.field.capital}),t.jsx("option",{value:"Earn",children:Y.field.earn}),t.jsx("option",{value:"Pay/Loss",children:Y.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.impactLevel}),t.jsxs("select",{style:{...D,...I},value:e.impact_level||"",disabled:c,onChange:U=>$({impact_level:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),t.jsx("option",{value:"High",children:Y.field.high}),t.jsx("option",{value:"Normal",children:Y.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.entityScope}),t.jsxs("select",{style:{...D,...I},value:e.entity_scope||"",disabled:c,onChange:U=>$({entity_scope:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),t.jsx("option",{value:"Upstream",children:Y.field.upstream}),t.jsx("option",{value:"On-stream",children:Y.field.onstream}),t.jsx("option",{value:"Downstream",children:Y.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.hsesField}),t.jsx("input",{style:{...D,...I},value:e.hses_field||"",disabled:c,onChange:U=>$({hses_field:U.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:18},children:t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:c,onChange:U=>$({product_relation:U.target.checked?1:0})})," ",Y.field.productRelation]})})]})]}),t.jsxs(ce,{title:"KPI & Timeline",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.kpiName}),t.jsx("input",{style:{...D,...I},value:e.kpi_name||"",disabled:c,onChange:U=>$({kpi_name:U.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.kpiType}),t.jsxs("select",{style:{...D,...I},value:e.kpi_type||"",disabled:c,onChange:U=>$({kpi_type:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),t.jsx("option",{value:"Human",children:"Human"}),t.jsx("option",{value:"Substantial",children:"Substantial"}),t.jsx("option",{value:"System",children:"System"}),t.jsx("option",{value:"Value",children:"Value"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.kpiMeasure}),t.jsx("input",{style:{...D,...I},value:e.kpi_measure||"",disabled:c,onChange:U=>$({kpi_measure:U.target.value}),placeholder:"Unit of measure"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.dateStart}),t.jsx(je,{value:e.date_start,onChange:U=>$({date_start:U}),disabled:c,style:{...D,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.dateEnd}),t.jsx(je,{value:e.date_end,onChange:U=>$({date_end:U}),disabled:c,style:{...D,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.cycleType}),t.jsxs("select",{style:{...D,...I},value:e.cycle_type||"",disabled:c,onChange:U=>$({cycle_type:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&t.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginTop:14},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 1"}),t.jsx(je,{value:e.long_cycle_date_1||"",onChange:U=>$({long_cycle_date_1:U}),disabled:c,style:{...D,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 2"}),t.jsx(je,{value:e.long_cycle_date_2||"",onChange:U=>$({long_cycle_date_2:U}),disabled:c,style:{...D,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 3"}),t.jsx(je,{value:e.long_cycle_date_3||"",onChange:U=>$({long_cycle_date_3:U}),disabled:c,style:{...D,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Milestone 4"}),t.jsx(je,{value:e.long_cycle_date_4||"",onChange:U=>$({long_cycle_date_4:U}),disabled:c,style:{...D,...I}})]})]})]})]}),t.jsxs(ce,{title:"Progress Indicators",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!c&&t.jsx("button",{type:"button",onClick:Qt,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),t.jsx("div",{style:{overflowX:"auto",minWidth:0},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Order"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Name"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Type"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Unit"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Target"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Min"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Max"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Manager"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actual Value"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Status"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Date"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Comment"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),!c&&t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),t.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:c?14:15,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((U,le)=>t.jsxs("tr",{style:{background:le%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I,width:60},value:U.order??"",disabled:c,onChange:O=>me(le,{order:O.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I},value:U.name1,disabled:c,onChange:O=>me(le,{name1:O.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I},value:U.type,disabled:c,onChange:O=>me(le,{type:O.target.value}),children:[t.jsx("option",{children:"Nominal"}),t.jsx("option",{children:"Ordinal"}),t.jsx("option",{children:"Interval"}),t.jsx("option",{children:"Ratio"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I,width:70},type:"text",value:U.unit??"",disabled:c,onChange:O=>me(le,{unit:O.target.value}),placeholder:"e.g. °C, kg, %"})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I,minWidth:120},value:U.cycle,disabled:c,onChange:O=>me(le,{cycle:O.target.value}),children:[t.jsx("option",{value:"",children:"--"}),ze.map(O=>t.jsx("option",{value:O.name,children:O.label},O.name)),U.cycle&&!ze.some(O=>O.name===U.cycle)&&t.jsx("option",{value:U.cycle,children:U.cycle})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I,width:80},value:U.target,disabled:c,onChange:O=>me(le,{target:O.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I,width:80},value:U.minimum,disabled:c,onChange:O=>me(le,{minimum:O.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I,width:80},value:U.maximum,disabled:c,onChange:O=>me(le,{maximum:O.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I,minWidth:140},value:U.manager,disabled:c,onChange:O=>me(le,{manager:O.target.value}),children:[t.jsx("option",{value:"",children:"--"}),Gt.map(O=>t.jsx("option",{value:O.name,children:O.label},O.name)),U.manager&&!Gt.some(O=>O.name===U.manager)&&t.jsx("option",{value:U.manager,children:U.manager})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I,width:90},type:"number",value:U.actual_value??"",disabled:c,onChange:O=>me(le,{actual_value:parseFloat(O.target.value)||""})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I},value:U.cycle_status??"",disabled:c,onChange:O=>me(le,{cycle_status:O.target.value}),children:[t.jsx("option",{value:"",children:"--"}),t.jsx("option",{children:"Normal"}),t.jsx("option",{children:"Below Min"}),t.jsx("option",{children:"Above Max"}),t.jsx("option",{children:"At Risk"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(je,{value:U.cycle_date||"",onChange:O=>me(le,{cycle_date:O}),disabled:c,style:{...D,...I,width:110}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I},value:U.cycle_comment??"",disabled:c,onChange:O=>me(le,{cycle_comment:O.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I},value:U.status??"",disabled:c,onChange:O=>me(le,{status:O.target.value}),children:[t.jsx("option",{value:"",children:"--"}),t.jsx("option",{children:"Normal"}),t.jsx("option",{children:"Below Min"}),t.jsx("option",{children:"Above Max"}),t.jsx("option",{children:"At Risk"})]})}),!c&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>We(le),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},le))]})]})})]}),t.jsx(ce,{title:"Cycle & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.cycle}),t.jsx(xe,{value:e.cycle||"",onChange:U=>$({cycle:U}),items:ze,placeholder:Y.field.select,disabled:c,userRole:b,doctypeName:P.cycles,extraFields:{organization:e.organization},onQuickCreateSuccess:T})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.actor}),t.jsxs("select",{style:{...D,...I},value:e.actor||"",disabled:c,onChange:U=>$({actor:U.target.value}),children:[t.jsx("option",{value:"",children:Y.field.select}),St.map(U=>t.jsx("option",{value:U.name,children:U.label},U.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.costPerCycle}),t.jsx("input",{style:{...D,...I},type:"number",value:e.cost_per_cycle||"",disabled:c,onChange:U=>$({cost_per_cycle:parseFloat(U.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:Y.field.escalationLevel}),t.jsx("input",{style:{...D,...I},type:"number",value:e.escalation_level||"",disabled:c,onChange:U=>$({escalation_level:parseInt(U.target.value)||0})})]})]})}),t.jsxs(ce,{title:"Cycle History",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!c&&t.jsx("button",{type:"button",onClick:Lt,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),t.jsx("div",{style:{overflowX:"auto",minWidth:0},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Date"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Comment"}),!c&&t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),t.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:c?5:6,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((U,le)=>t.jsxs("tr",{style:{background:le%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I},value:U.cycle||"",disabled:c,onChange:O=>_t(le,{cycle:O.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),ze.map(O=>t.jsx("option",{value:O.name,children:O.label},O.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(je,{value:U.cycle_date||"",onChange:O=>_t(le,{cycle_date:O}),disabled:c,style:{...D,...I,width:130}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I},value:U.status,disabled:c,onChange:O=>_t(le,{status:O.target.value}),children:[t.jsx("option",{value:"Pass",children:"Pass"}),t.jsx("option",{value:"Fail",children:"Fail"}),t.jsx("option",{value:"Unknown",children:"Unknown"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...D,...I},value:U.actor||"",disabled:c,onChange:O=>_t(le,{actor:O.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),St.map(O=>t.jsx("option",{value:O.name,children:O.label},O.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...D,...I},value:U.comment||"",disabled:c,onChange:O=>_t(le,{comment:O.target.value})})}),!c&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>ln(le),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},le))]})]})})]}),t.jsx(ce,{title:Y.field.auditorComment,children:t.jsx("textarea",{style:{...D,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:Y.field.commentPlaceholder})})]})}const $0={CEO:"#8b5cf6",Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function U0({user:e,profileUser:n,darkMode:s,canModify:a,onBack:l,sbUsers:r=[],organizations:i=[],managements:d=[],departments:f=[],branches:p=[],groupCompanies:C=[]}){const j=n||{},_=!!a&&(e.role==="Admin"||e.role==="CEO"),[c,y]=S.useState({first_name:j.first_name||"",middle_name:j.middle_name||"",last_name:j.last_name||"",mobile_no:j.mobile_no||"",custom_organization:j.custom_organization||"",custom_group_company:j.custom_group_company||"",custom_manager:j.custom_manager||"",custom_management:j.custom_management||"",custom_department:j.custom_department||"",custom_branch:j.custom_branch||"",custom_number:j.custom_number||"",custom_category:j.custom_category||""}),[z,k]=S.useState(""),[g,o]=S.useState(!1),[h,x]=S.useState({new:"",confirm:""}),[v,w]=S.useState(""),u=j.email||j.name||"",b=[c.first_name,c.middle_name,c.last_name].filter(Boolean).join(" ")||j.full_name||"",T=j.username||j.name||"",E=c.custom_category||"",F=j.enabled===0?"Inactive":"Active",Q=$0[e.role]||"#6b7280",te=s,H=te?"#0f172a":"#f0f2f5",Y=te?"#1e293b":"white",$=te?"#2d3748":"#e5e7eb",I=te?"#e2e8f0":"#1a2332",A=te?"#94a3b8":"#6b7280",M=te?"#374151":"white",X=te?"#2d3748":"#f9fafb",L={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${$}`,fontSize:13,background:M,color:I,fontFamily:"inherit",outline:"none"},N={...L,background:X,color:A},J={...L,cursor:"pointer"},se={fontSize:12,fontWeight:600,color:A,marginBottom:5,display:"block"},oe={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},Ye={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},ze=(r||[]).find(G=>G.name===c.custom_manager),St=ze?ze.full_name||ze.email||ze.name:c.custom_manager,Gt=(r||[]).filter(G=>{if(G.name===j.name)return!1;const ne=G.custom_category||"",fe=ne==="CEO"||ne==="Chairman"||G.name==="Administrator";return c.custom_organization&&G.custom_organization&&G.custom_organization!==c.custom_organization&&!fe?!1:c.custom_category==="Admin"?ne==="CEO"||ne==="Chairman"||G.name==="Administrator":c.custom_category==="Manager"?ne==="Admin":c.custom_category==="Auditor"||c.custom_category==="X-Auditor"?ne==="Manager"||ne==="Admin":c.custom_category==="Employee"?ne==="Auditor"||ne==="X-Auditor"||ne==="Manager":!(c.custom_category==="CEO"||c.custom_category==="Chairman")}),_t=c.custom_organization?d.filter(G=>!G.organization||G.organization===c.custom_organization):d,Lt=f.filter(G=>!(c.custom_organization&&G.custom_organization&&G.custom_organization!==c.custom_organization||c.custom_management&&G.custom_management&&G.custom_management!==c.custom_management)),ln=p.filter(G=>!(c.custom_organization&&G.organization&&G.organization!==c.custom_organization||c.custom_management&&G.management&&G.management!==c.custom_management||c.custom_department&&G.department&&G.department!==c.custom_department)),me=async()=>{if(a){if(_){if(!c.custom_group_company){alert("Group Company (Tenant) is required");return}if(!c.custom_organization){alert("Organization is required");return}if(!c.custom_category){alert("Category is required");return}if(c.custom_category!=="CEO"&&c.custom_category!=="Chairman"&&!c.custom_manager){alert("Reports To / Supervisor is mandatory.");return}}k("saving");try{await Ds("User",j.name,{first_name:c.first_name,middle_name:c.middle_name,last_name:c.last_name,mobile_no:c.mobile_no,custom_organization:c.custom_organization,custom_group_company:c.custom_group_company,custom_manager:c.custom_manager,custom_management:c.custom_management,custom_department:c.custom_department,custom_branch:c.custom_branch,custom_number:c.custom_number,custom_category:c.custom_category}),k("saved"),setTimeout(()=>k(""),2e3)}catch{k("error"),setTimeout(()=>k(""),3e3)}}},Qt=async()=>{if(!h.new){w("Enter a new password");return}if(h.new!==h.confirm){w("Passwords do not match");return}w("saving");try{await si(j.name,h.new),w("done"),x({new:"",confirm:""}),setTimeout(()=>{w(""),o(!1)},2e3)}catch{w("error")}},We=({title:G,icon:ne,children:fe})=>t.jsxs("div",{style:{background:Y,borderRadius:12,padding:22,border:`1px solid ${$}`,boxShadow:`0 1px 4px rgba(0,0,0,${te?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${$}`},children:[ne,t.jsx("span",{style:{fontSize:14,fontWeight:700,color:I},children:G})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:fe})]});return t.jsxs("div",{style:{background:H,minHeight:"100%",padding:"0 0 32px"},children:[t.jsxs("div",{style:{background:Y,borderBottom:`1px solid ${$}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:I,fontFamily:"inherit"},children:[t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),a&&t.jsxs("button",{onClick:me,style:{display:"flex",alignItems:"center",gap:8,background:z==="saved"?"#16a34a":z==="error"?"#dc2626":"#16a34a",color:"white",border:"none",borderRadius:8,padding:"9px 22px",fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17,21 17,13 7,13 7,21"}),t.jsx("polyline",{points:"7,3 7,8 15,8"})]}),z==="saving"?"Saving…":z==="saved"?"Saved!":z==="error"?"Error":"Save Changes"]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:22,padding:"0 28px"},children:[t.jsxs("div",{style:{borderRadius:14,overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.12)",alignSelf:"start"},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",padding:"32px 20px 28px",display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[t.jsx("div",{style:{width:78,height:78,borderRadius:"50%",background:"rgba(255,255,255,0.22)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:4,border:"3px solid rgba(255,255,255,0.3)"},children:t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"rgba(255,255,255,0.9)",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]})}),t.jsx("div",{style:{fontSize:17,fontWeight:700,color:"white",textAlign:"center",lineHeight:1.3},children:b||u}),t.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:u})]}),t.jsx("div",{style:{background:Y},children:[{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:Q,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),t.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),t.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),t.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),label:"Username",value:T},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:Q,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:E||"—"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:Q,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("line",{x1:"19",y1:"8",x2:"19",y2:"14"}),t.jsx("line",{x1:"22",y1:"11",x2:"16",y2:"11"})]}),label:"Reports To / Supervisor",value:St||c.custom_manager||"—"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:Q,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),t.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),label:"Group Company",value:c.custom_group_company||"—"},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:F==="Active"?"#16a34a":"#dc2626",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),label:"Status",value:F,valueColor:F==="Active"?"#16a34a":"#dc2626"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:Q,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:u},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:Q,strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.69 13a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.6 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"})}),label:"Phone",value:c.mobile_no||"—"}].map(({icon:G,label:ne,value:fe,valueColor:Ee})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${$}`},children:[t.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:G}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:11,color:A,marginBottom:1},children:ne}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:Ee||I,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:fe})]})]},ne))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[t.jsxs(We,{title:"Basic Information",icon:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]}),children:[t.jsxs("div",{style:oe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Email ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m2 7 10 7 10-7"})]})}),t.jsx("input",{style:{...N,paddingLeft:32},value:u,readOnly:!0})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Full Name ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),t.jsx("input",{style:N,value:b,readOnly:!0})]})]}),t.jsxs("div",{style:Ye,children:[t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["First Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{style:a?L:N,value:c.first_name,readOnly:!a,onChange:G=>y(ne=>({...ne,first_name:G.target.value})),placeholder:"First name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:se,children:"Middle Name"}),t.jsx("input",{style:a?L:N,value:c.middle_name,readOnly:!a,onChange:G=>y(ne=>({...ne,middle_name:G.target.value})),placeholder:"Middle name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:se,children:"Last Name"}),t.jsx("input",{style:a?L:N,value:c.last_name,readOnly:!a,onChange:G=>y(ne=>({...ne,last_name:G.target.value})),placeholder:"Last name"})]})]}),t.jsxs("div",{style:oe,children:[t.jsxs("div",{children:[t.jsx("label",{style:se,children:"Phone Number"}),t.jsx("input",{style:a?L:N,value:c.mobile_no,readOnly:!a,onChange:G=>y(ne=>({...ne,mobile_no:G.target.value})),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsx("label",{style:se,children:"User ID No"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{style:{...N,paddingRight:44},value:c.custom_number||j.name||"",readOnly:!0}),t.jsx("div",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",background:"#ef4444",borderRadius:5,padding:"3px 7px",cursor:"default",display:"flex",alignItems:"center"},children:t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"white",children:[t.jsx("circle",{cx:"5",cy:"12",r:"2"}),t.jsx("circle",{cx:"12",cy:"12",r:"2"}),t.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})]})]}),t.jsxs("div",{style:oe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Category ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})," ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_category,onChange:G=>y(ne=>({...ne,custom_category:G.target.value})),children:[t.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(G=>t.jsx("option",{value:G,children:G},G))]}):t.jsx("input",{style:N,value:E||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Group Company (Tenant) ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})," ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_group_company,onChange:G=>y(ne=>({...ne,custom_group_company:G.target.value})),children:[t.jsx("option",{value:"",children:"Select group company"}),C.map(G=>t.jsx("option",{value:G.name,children:G.company_name||G.name},G.name))]}):t.jsx("input",{style:N,value:c.custom_group_company||"—",readOnly:!0})]})]}),c.custom_category!=="CEO"&&c.custom_category!=="Chairman"&&t.jsxs("div",{style:{marginTop:14},children:[t.jsxs("label",{style:se,children:["Reports To / Supervisor ",c.custom_category&&t.jsx("span",{style:{color:"#ef4444"},children:"*"})," ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_manager,disabled:!c.custom_category,onChange:G=>y(ne=>({...ne,custom_manager:G.target.value})),children:[t.jsx("option",{value:""}),Gt.map(G=>{const ne=G.full_name||G.email||G.name,fe=G.custom_category?` [${G.custom_category}]`:"";return t.jsxs("option",{value:G.name,children:[ne,fe]},G.name)})]}):t.jsx("input",{style:N,value:St||c.custom_manager||"—",readOnly:!0})]})]}),t.jsxs(We,{title:"Organization Information",icon:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#8b5cf6",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),t.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),children:[t.jsxs("div",{style:oe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Organization ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})," ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_organization,onChange:G=>y(ne=>({...ne,custom_organization:G.target.value,custom_management:"",custom_department:"",custom_branch:"",custom_manager:""})),children:[t.jsx("option",{value:"",children:"Select organization"}),Se(i,c.custom_organization).map(G=>t.jsx("option",{value:G.name,children:G.organization_name||G.name},G.name))]}):t.jsx("input",{style:N,value:c.custom_organization||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Management ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_management,onChange:G=>y(ne=>({...ne,custom_management:G.target.value,custom_department:"",custom_branch:""})),children:[t.jsx("option",{value:"",children:"Select management"}),Se(_t,c.custom_management).map(G=>t.jsx("option",{value:G.name,children:G.name1||G.name},G.name))]}):t.jsx("input",{style:N,value:c.custom_management||"—",readOnly:!0})]})]}),t.jsxs("div",{style:oe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Department ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_department,onChange:G=>y(ne=>({...ne,custom_department:G.target.value,custom_branch:""})),children:[t.jsx("option",{value:"",children:"Select department"}),Se(Lt,c.custom_department).map(G=>t.jsx("option",{value:G.name,children:G.department_name||G.name},G.name))]}):t.jsx("input",{style:N,value:c.custom_department||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Branch ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:J,value:c.custom_branch,onChange:G=>y(ne=>({...ne,custom_branch:G.target.value})),children:[t.jsx("option",{value:"",children:"Select branch"}),Se(ln,c.custom_branch).map(G=>t.jsx("option",{value:G.name,children:G.branch||G.name},G.name))]}):t.jsx("input",{style:N,value:c.custom_branch||"—",readOnly:!0})]})]})]}),t.jsxs("div",{style:{background:Y,borderRadius:12,padding:22,border:`1px solid ${$}`,boxShadow:`0 1px 4px rgba(0,0,0,${te?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{style:{fontSize:14,fontWeight:700,color:I},children:"Change Password"})]}),a&&t.jsx("button",{onClick:()=>{o(G=>!G),w("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:g?"Cancel":"Change Password"})]}),g&&t.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:Ye,children:[t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["New Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:L,value:h.new,onChange:G=>x(ne=>({...ne,new:G.target.value})),placeholder:"New password"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:se,children:["Confirm Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:L,value:h.confirm,onChange:G=>x(ne=>({...ne,confirm:G.target.value})),placeholder:"Confirm password"})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:Qt,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:v==="saving"?"Saving…":"Update Password"})})]}),v&&v!=="saving"&&t.jsx("div",{style:{fontSize:13,color:v==="done"?"#16a34a":"#dc2626",fontWeight:500},children:v==="done"?"Password updated successfully":v==="error"?"Failed to update password":v})]})]})]})]})]})}function Re({label:e,val:n,color:s}){return t.jsxs("div",{style:{background:"white",borderRadius:8,padding:"8px 16px",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${s}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[t.jsx("div",{style:{fontSize:18,fontWeight:700,color:s},children:n}),t.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const hh={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},M0={...hh,cursor:"pointer"};function bt({filters:e,defaultOpen:n=!1}){const[s,a]=S.useState(n);return t.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[t.jsxs("div",{onClick:()=>a(l=>!l),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:s?t.jsx("polyline",{points:"18,15 12,9 6,15"}):t.jsx("polyline",{points:"6,9 12,15 18,9"})}),t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),s&&t.jsx("div",{style:{padding:"18px 20px"},children:t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((l,r)=>t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:l.label}),l.type==="search"?t.jsx("input",{style:hh,placeholder:l.placeholder,value:l.value,onChange:i=>l.onChange(i.target.value)}):t.jsx("select",{style:M0,value:l.value,onChange:i=>l.onChange(i.target.value),children:l.options.map(i=>t.jsx("option",{value:i.value,children:i.label},i.value))})]},r))})})]})}function F0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function H0({organizations:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),[c,y]=S.useState("all"),z={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},k=S.useMemo(()=>e.filter(x=>{const v=[x.organization_name,x.city].filter(Boolean).join(" ").toLowerCase();return!(p&&!v.includes(p.toLowerCase())||j!=="all"&&x.type!==j||c!=="all"&&(x.is_active?"Active":"Inactive")!==c)}),[e,p,j,c]),[g,o]=S.useState(1);S.useEffect(()=>{o(1)},[p,j,c]);const h=k.slice((g-1)*ie,g*ie);return S.useEffect(()=>{if(r){const x=e.filter(v=>d.has(v.name));r(x,h)}},[d,h]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Re,{label:"Total",val:k.length,color:"#1a2332"}),t.jsx(Re,{label:"Active",val:k.filter(x=>x.is_active).length,color:V.green}),t.jsx(Re,{label:"Government",val:k.filter(x=>x.type==="Government").length,color:V.blue}),t.jsx(Re,{label:"Private",val:k.filter(x=>x.type==="Private").length,color:V.orange})]}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:c,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:h.length>0&&h.every(x=>d.has(x.name)),onChange:x=>{if(x.target.checked)f(new Set([...d,...h.map(v=>v.name)]));else{const v=new Set(d);h.forEach(w=>v.delete(w.name)),f(v)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:z,children:i.col.name}),t.jsx("th",{style:z,children:i.col.type}),t.jsx("th",{style:z,children:i.col.city}),t.jsx("th",{style:z,children:i.field.creationDate}),t.jsx("th",{style:z,children:i.col.status}),t.jsx("th",{style:z,children:i.col.actions})]})}),t.jsx("tbody",{children:k.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):h.map((x,v)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(x),style:{borderTop:"1px solid #f0f0f0",background:d.has(x.name)?"#eff6ff":x.custom_is_deleted?"#fff1f2":v%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:w=>w.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(x.name),onChange:()=>{const w=new Set(d);w.has(x.name)?w.delete(x.name):w.add(x.name),f(w)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:x.organization_name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:x.type||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:x.city||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:F0(x.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:x.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):Ll(x.is_active?i.field.statusActive:i.field.statusInactive,x.is_active?V.green:V.gray)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:w=>w.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(x),onEdit:n&&a&&!x.custom_is_deleted?()=>a(x):void 0,onDelete:n&&l&&!x.custom_is_deleted?()=>l(x.name):void 0})})]},x.name))})]})}),t.jsx(Ue,{page:g,total:k.length,onPageChange:o})]})}const On=e=>({background:e?"#f9f9f9":void 0});function G0({orgForm:e,setOrgForm:n,groupCompanies:s=[],formStatus:a,viewMode:l,onEdit:r,onRestore:i,onPermanentDelete:d,darkMode:f,notifCount:p,onToggleDark:C,onCountChange:j,onViewProfile:_,onSubmit:c,onBack:y,onNavigate:z,onLogout:k,user:g}){const o=re(),h=e.name?l&&e.organization_name||o.formTitle.editOrg:o.formTitle.newOrg;return t.jsxs(tt,{title:h,activePage:"organizations",user:g,formStatus:a,buttonText:o.saveOrg,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:f,notifCount:p,onToggleDark:C,onCountChange:j,onViewProfile:_,onSubmit:c,onBack:y,onNavigate:z,onLogout:k,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0,onPermanentDelete:d&&e.name?()=>d(e.name):void 0}),t.jsx(ce,{title:"Organization Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[o.field.orgName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...D,...On(l||!!e.name)},value:e.organization_name,disabled:l||!!e.name,required:!0,onChange:x=>n({...e,organization_name:x.target.value})})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[o.field.orgAcronym," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...D,...On(l||!!e.name)},value:e.acronym||"",disabled:l||!!e.name,required:!0,onChange:x=>n({...e,acronym:x.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.organizationType}),t.jsxs("select",{style:{...D,...On(l)},value:e.type,disabled:l,onChange:x=>n({...e,type:x.target.value}),children:[t.jsx("option",{children:"Government"}),t.jsx("option",{children:"Private"}),t.jsx("option",{children:"Non-Profit"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.orgCity}),t.jsx("input",{type:"text",style:{...D,...On(l)},value:e.city,disabled:l,onChange:x=>n({...e,city:x.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.contactEmail}),t.jsx("input",{type:"email",style:{...D,...On(l)},value:e.contact_email,disabled:l,onChange:x=>n({...e,contact_email:x.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:x=>n({...e,creation_date:x}),disabled:l,style:{...D,...On(l)}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.status}),t.jsxs("select",{style:{...D,...On(l)},value:e.is_active?"Active":"Inactive",disabled:l,onChange:x=>n({...e,is_active:x.target.value==="Active"?1:0}),children:[t.jsx("option",{value:"Active",children:o.field.statusActive}),t.jsx("option",{value:"Inactive",children:o.field.statusInactive})]})]})]})}),t.jsx(ce,{title:"Incident SLA Windows",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.incidentTriageWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...D,...On(l)},value:e.incident_triage_window_days??3,disabled:l,onChange:x=>n({...e,incident_triage_window_days:parseInt(x.target.value)||3})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:o.field.incidentResolutionWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...D,...On(l)},value:e.incident_resolution_window_days??5,disabled:l,onChange:x=>n({...e,incident_resolution_window_days:parseInt(x.target.value)||5})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})})]})}function Q0({groupCompanies:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=[o.company_name,o.acronym,o.code,o.owner_user].filter(Boolean).join(" ").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Re,{label:"Total Group Cos",val:y.length,color:"#1a2332"}),t.jsx(Re,{label:"Active",val:y.filter(o=>(o.status||"Active")==="Active").length,color:V.green}),t.jsx(Re,{label:"Inactive",val:y.filter(o=>o.status==="Inactive").length,color:V.orange})]}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Inactive",label:"Inactive"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:"#fafafa"},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:"Company Name"}),t.jsx("th",{style:c,children:"Code / Acronym"}),t.jsx("th",{style:c,children:"Group Co Owner"}),t.jsx("th",{style:c,children:"Status"}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsxs("tbody",{children:[g.map((o,h)=>{const x=o.custom_is_deleted===1;return t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderBottom:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":x?"#fef2f2":h%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:v=>v.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const v=new Set(d);v.has(o.name)?v.delete(o.name):v.add(o.name),f(v)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[o.company_name,x&&t.jsx("span",{style:{marginLeft:8},children:Ll(i.deletedBadge,"#ef4444")})]}),t.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:[o.code,o.acronym].filter(Boolean).join(" / ")||"—"}),t.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:o.owner_user||"—"}),t.jsx("td",{style:{padding:"12px 14px"},children:Ll(o.status||"Active",(o.status||"Active")==="Active"?V.green:V.orange)}),t.jsx("td",{style:{padding:"12px 14px"},onClick:v=>v.stopPropagation(),children:t.jsx(ot,{onView:s?()=>s(o):void 0,onEdit:n&&a?()=>a(o):void 0,onDelete:n&&l?()=>l(o.name):void 0})})]},o.name)}),y.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:24,textAlign:"center",color:"#aaa"},children:"No Group Companies found"})})]})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function K0({form:e,setForm:n,users:s=[],formStatus:a,viewMode:l,onEdit:r,onRestore:i,onPermanentDelete:d,darkMode:f,notifCount:p,onToggleDark:C,onCountChange:j,onViewProfile:_,onSubmit:c,onBack:y,onNavigate:z,onLogout:k,user:g}){const o=w=>n({...e,...w}),h=l?{background:"#f8fafc"}:{};S.useEffect(()=>{if(!e.owner_user&&!l){const w=s.find(u=>u.custom_group_company===e.name&&(u.role==="Admin"||u.custom_category==="Admin"));w?o({owner_user:w.name}):!e.name&&(g.role==="Admin"||g.role==="CEO")&&o({owner_user:g.name})}},[e.name,e.owner_user,l,s,g.name,g.role]);const x=e.name?l?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",v=s.map(w=>({name:w.name,label:w.full_name?`${w.full_name} (${w.name})`:w.name}));return t.jsxs(tt,{title:x,activePage:"group-companies",user:g,formStatus:a,buttonText:"Save Group Company",buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:f,notifCount:p,onToggleDark:C,onCountChange:j,onViewProfile:_,onSubmit:c,onBack:y,onNavigate:z,onLogout:k,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i?()=>i(e.name):void 0,onPermanentDelete:d?()=>d(e.name):void 0}),t.jsxs(ce,{title:"Group Company Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:["Company Name ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.company_name||"",disabled:l||!!e.name,onChange:w=>o({company_name:w.target.value}),placeholder:"e.g. Company A Group"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Company Code"}),t.jsx("input",{style:{...D,...h},value:e.code||"",disabled:l,onChange:w=>o({code:w.target.value}),placeholder:"e.g. CO-A"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Acronym"}),t.jsx("input",{style:{...D,...h},value:e.acronym||"",disabled:l,onChange:w=>o({acronym:w.target.value}),placeholder:"e.g. CAG"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Status"}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:l,onChange:w=>o({status:w.target.value}),children:[t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Group Co Owner / Admin User"}),t.jsx(xe,{value:e.owner_user||"",onChange:w=>o({owner_user:w}),items:v,placeholder:"Select owner user",disabled:l})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:"Notes"}),t.jsx("textarea",{style:{...D,...h,height:75,resize:"vertical"},value:e.notes||"",disabled:l,onChange:w=>o({notes:w.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function Y0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function X0({managements:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.blue})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Y0(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function q0({form:e,setForm:n,organizations:s,groupCompanies:a=[],formStatus:l,viewMode:r,onEdit:i,onRestore:d,onPermanentDelete:f,darkMode:p,notifCount:C,onToggleDark:j,onCountChange:_,onViewProfile:c,onSubmit:y,onBack:z,onNavigate:k,onLogout:g,user:o}){const h=re(),x=u=>n(b=>({...b,...u})),v=r?{background:"#f8fafc"}:{},w=e.name?r?`${h.formTitle.editMgmt}: ${e.name1||e.name}`:h.formTitle.editMgmt:h.formTitle.newMgmt;return t.jsxs(tt,{title:w,activePage:"managements",user:o,formStatus:l,buttonText:h.saveMgmt,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:p,notifCount:C,onToggleDark:j,onCountChange:_,onViewProfile:c,onSubmit:y,onBack:z,onNavigate:k,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0,onPermanentDelete:f&&e.name?()=>f(e.name):void 0}),t.jsx(ce,{title:"Management Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[h.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:u=>{var T;const b=(T=s.find(E=>E.name===u))==null?void 0:T.group_company;x({organization:u,...o.custom_group_company?{}:{group_company:b||e.group_company}})},organizations:s,disabled:r||!!o.custom_organization,userRole:o.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[h.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...v},value:e.name1,disabled:r||!!e.name,onChange:u=>x({name1:u.target.value}),placeholder:"Management name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:u=>x({creation_date:u}),disabled:r,style:{...D,...v}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.status}),t.jsxs("select",{style:{...D,...v},value:e.status||"Active",disabled:r,onChange:u=>x({status:u.target.value}),children:[t.jsx("option",{value:"Active",children:h.field.statusActive}),t.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})})]})}function J0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function V0({departments:e,managements:n,canModify:s,onView:a,onEdit:l,onDelete:r,onSelectionChange:i}){const d=re(),[f,p]=S.useState(new Set),[C,j]=S.useState(""),[_,c]=S.useState(""),[y,z]=S.useState("all"),k=w=>{var u;return((u=n.find(b=>b.name===w))==null?void 0:u.name1)||w||"—"},g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=S.useMemo(()=>e.filter(w=>{const u=(w.department_name||w.name||"").toLowerCase();return!(C&&!u.includes(C.toLowerCase())||_&&w.custom_management!==_||y!=="all"&&(w.custom_status||"Active")!==y)}),[e,C,_,y]),[h,x]=S.useState(1);S.useEffect(()=>{x(1)},[C,_,y]);const v=o.slice((h-1)*ie,h*ie);return S.useEffect(()=>{if(i){const w=e.filter(u=>f.has(u.name));i(w,v)}},[f,v]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:o.length,color:V.teal})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:C,onChange:j,placeholder:"Search by name…"},{type:"select",label:d.col.management,value:_,onChange:c,options:[{value:"",label:"All Managements"},...n.map(w=>({value:w.name,label:w.name1||w.name}))]},{type:"select",label:"Status",value:y,onChange:z,options:[{value:"all",label:"All"},{value:"Active",label:d.field.statusActive},{value:"Inactive",label:d.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:v.length>0&&v.every(w=>f.has(w.name)),onChange:w=>{if(w.target.checked)p(new Set([...f,...v.map(u=>u.name)]));else{const u=new Set(f);v.forEach(b=>u.delete(b.name)),p(u)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:g,children:d.col.name}),t.jsx("th",{style:g,children:d.col.management}),t.jsx("th",{style:g,children:d.field.creationDate}),t.jsx("th",{style:g,children:d.field.status}),t.jsx("th",{style:g,children:d.col.actions})]})}),t.jsx("tbody",{children:o.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):v.map((w,u)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>a==null?void 0:a(w),style:{borderTop:"1px solid #f0f0f0",background:f.has(w.name)?"#eff6ff":w.custom_is_deleted?"#fff1f2":u%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:b=>b.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:f.has(w.name),onChange:()=>{const b=new Set(f);b.has(w.name)?b.delete(w.name):b.add(w.name),p(b)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:w.department_name||w.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:k(w.custom_management)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:J0(w.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:w.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:d.deletedBadge}):t.jsx("span",{style:{color:w.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:w.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:b=>b.stopPropagation(),children:t.jsx(ot,{onView:()=>a==null?void 0:a(w),onEdit:s&&l&&!w.custom_is_deleted?()=>l(w):void 0,onDelete:s&&r&&!w.custom_is_deleted?()=>r(w.name):void 0})})]},w.name))})]})}),t.jsx(Ue,{page:h,total:o.length,onPageChange:x})]})}function Z0({form:e,setForm:n,organizations:s,groupCompanies:a=[],managements:l,formStatus:r,viewMode:i,onEdit:d,onRestore:f,onPermanentDelete:p,darkMode:C,notifCount:j,onToggleDark:_,onCountChange:c,onViewProfile:y,onSubmit:z,onBack:k,onNavigate:g,onLogout:o,user:h}){const x=re(),v=T=>n(E=>({...E,...T})),w=i?{background:"#f8fafc"}:{},u=e.name?i?`${x.formTitle.editDept}: ${e.department_name||e.name}`:x.formTitle.editDept:x.formTitle.newDept,b=Se(l,e.custom_management).map(T=>({name:T.name,label:T.name1||T.name}));return t.jsxs(tt,{title:u,activePage:"departments",user:h,formStatus:r,buttonText:x.saveDept,buttonColor:"#16a34a",viewMode:i,onEdit:d,darkMode:C,notifCount:j,onToggleDark:_,onCountChange:c,onViewProfile:y,onSubmit:z,onBack:k,onNavigate:g,onLogout:o,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:f&&e.name?()=>f(e.name):void 0,onPermanentDelete:p&&e.name?()=>p(e.name):void 0}),t.jsx(ce,{title:"Department Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[x.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.custom_organization,onChange:T=>{var F;const E=(F=s.find(Q=>Q.name===T))==null?void 0:F.group_company;v({custom_organization:T,...h.custom_group_company?{}:{group_company:E||e.group_company}})},organizations:s,disabled:i||!!h.custom_organization,userRole:h.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[x.field.department," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...w},value:e.department_name,disabled:i||!!e.name,onChange:T=>v({department_name:T.target.value}),placeholder:"Department name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:x.field.management}),t.jsx(xe,{value:e.custom_management,onChange:T=>v({custom_management:T}),items:b,placeholder:x.field.select,disabled:i,userRole:h.role,doctypeName:P.managements,extraFields:{organization:e.custom_organization}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:x.field.creationDate}),t.jsx(je,{value:e.custom_creation_date||"",onChange:T=>v({custom_creation_date:T}),disabled:i,style:{...D,...w}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:x.field.status}),t.jsxs("select",{style:{...D,...w},value:e.custom_status||"Active",disabled:i,onChange:T=>v({custom_status:T.target.value}),children:[t.jsx("option",{value:"Active",children:x.field.statusActive}),t.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})})]})}function e1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function t1({branches:e,managements:n,departments:s,canModify:a,onView:l,onEdit:r,onDelete:i,onSelectionChange:d}){const f=re(),[p,C]=S.useState(new Set),[j,_]=S.useState(""),[c,y]=S.useState(""),[z,k]=S.useState(""),[g,o]=S.useState("all"),h=E=>{var F;return((F=n.find(Q=>Q.name===E))==null?void 0:F.name1)||E||"—"},x=E=>{var F;return((F=s.find(Q=>Q.name===E))==null?void 0:F.department_name)||E||"—"},v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},w=S.useMemo(()=>e.filter(E=>{const F=(E.branch||E.name||"").toLowerCase();return!(j&&!F.includes(j.toLowerCase())||c&&E.management!==c||z&&E.department!==z||g!=="all"&&(E.custom_status||"Active")!==g)}),[e,j,c,z,g]),[u,b]=S.useState(1);S.useEffect(()=>{b(1)},[j,c,z,g]);const T=w.slice((u-1)*ie,u*ie);return S.useEffect(()=>{if(d){const E=e.filter(F=>p.has(F.name));d(E,T)}},[p,T]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:w.length,color:V.purple})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:j,onChange:_,placeholder:"Search by name…"},{type:"select",label:f.col.management,value:c,onChange:y,options:[{value:"",label:"All Managements"},...n.map(E=>({value:E.name,label:E.name1||E.name}))]},{type:"select",label:f.col.department,value:z,onChange:k,options:[{value:"",label:"All Departments"},...s.map(E=>({value:E.name,label:E.department_name||E.name}))]},{type:"select",label:"Status",value:g,onChange:o,options:[{value:"all",label:"All"},{value:"Active",label:f.field.statusActive},{value:"Inactive",label:f.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:T.length>0&&T.every(E=>p.has(E.name)),onChange:E=>{if(E.target.checked)C(new Set([...p,...T.map(F=>F.name)]));else{const F=new Set(p);T.forEach(Q=>F.delete(Q.name)),C(F)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:v,children:f.col.branch}),t.jsx("th",{style:v,children:f.col.management}),t.jsx("th",{style:v,children:f.col.department}),t.jsx("th",{style:v,children:f.field.creationDate}),t.jsx("th",{style:v,children:f.field.status}),t.jsx("th",{style:v,children:f.col.actions})]})}),t.jsx("tbody",{children:w.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:f.noData})}):T.map((E,F)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(E),style:{borderTop:"1px solid #f0f0f0",background:p.has(E.name)?"#eff6ff":E.custom_is_deleted?"#fff1f2":F%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:Q=>Q.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:p.has(E.name),onChange:()=>{const Q=new Set(p);Q.has(E.name)?Q.delete(E.name):Q.add(E.name),C(Q)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:E.branch||E.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:h(E.management)}),t.jsx("td",{style:{padding:"10px 14px"},children:x(E.department)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:e1(E.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:E.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:f.deletedBadge}):t.jsx("span",{style:{color:E.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:E.custom_status==="Inactive"?f.field.statusInactive:f.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:Q=>Q.stopPropagation(),children:t.jsx(ot,{onView:()=>l==null?void 0:l(E),onEdit:a&&r&&!E.custom_is_deleted?()=>r(E):void 0,onDelete:a&&i&&!E.custom_is_deleted?()=>i(E.name):void 0})})]},E.name))})]})}),t.jsx(Ue,{page:u,total:w.length,onPageChange:b})]})}function n1({form:e,setForm:n,organizations:s,groupCompanies:a=[],managements:l,departments:r,formStatus:i,viewMode:d,onEdit:f,onRestore:p,onPermanentDelete:C,darkMode:j,notifCount:_,onToggleDark:c,onCountChange:y,onViewProfile:z,onSubmit:k,onBack:g,onNavigate:o,onLogout:h,user:x}){const v=re(),w=F=>n(Q=>({...Q,...F})),u=d?{background:"#f8fafc"}:{},b=Se(l,e.management).map(F=>({name:F.name,label:F.name1||F.name})),T=Se(r,e.department).map(F=>({name:F.name,label:F.department_name||F.name})),E=e.name?d?`${v.formTitle.editBranch}: ${e.branch||e.name}`:v.formTitle.editBranch:v.formTitle.newBranch;return t.jsxs(tt,{title:E,activePage:"branches",user:x,formStatus:i,buttonText:v.saveBranch,buttonColor:"#16a34a",viewMode:d,onEdit:f,darkMode:j,notifCount:_,onToggleDark:c,onCountChange:y,onViewProfile:z,onSubmit:k,onBack:g,onNavigate:o,onLogout:h,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:p&&e.name?()=>p(e.name):void 0,onPermanentDelete:C&&e.name?()=>C(e.name):void 0}),t.jsx(ce,{title:"Branch Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[v.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:F=>{var te;const Q=(te=s.find(H=>H.name===F))==null?void 0:te.group_company;w({organization:F,...x.custom_group_company?{}:{group_company:Q||e.group_company}})},organizations:s,disabled:d||!!x.custom_organization,userRole:x.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[v.field.branch," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...u},value:e.branch,disabled:d||!!e.name,onChange:F=>w({branch:F.target.value}),placeholder:"Branch name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:v.field.management}),t.jsx(xe,{value:e.management,onChange:F=>w({management:F}),items:b,placeholder:v.field.select,disabled:d,userRole:x.role,doctypeName:P.managements,extraFields:{organization:e.organization}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:v.field.department}),t.jsx(xe,{value:e.department,onChange:F=>w({department:F}),items:T,placeholder:v.field.select,disabled:d,userRole:x.role,doctypeName:P.departments,extraFields:{organization:e.organization,management:e.management}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:v.field.creationDate}),t.jsx(je,{value:e.custom_creation_date||"",onChange:F=>w({custom_creation_date:F}),disabled:d,style:{...D,...u}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:v.field.status}),t.jsxs("select",{style:{...D,...u},value:e.custom_status||"Active",disabled:d,onChange:F=>w({custom_status:F.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})})]})}function s1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function a1({incidentTypes:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.red})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:s1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function l1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return t.jsxs(tt,{title:x,activePage:"incident-types",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(ce,{title:"Incident Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Incident type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function r1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function i1({ideaTypes:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.teal})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:r1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function o1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return t.jsxs(tt,{title:x,activePage:"idea-types",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(ce,{title:"Idea Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Idea type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function d1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function c1({orderTypes:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.purple})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:d1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function u1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return t.jsxs(tt,{title:x,activePage:"order-types",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(ce,{title:"Order Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Order type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function p1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function f1({processTypes:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.blue})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:p1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function h1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return t.jsxs(tt,{title:x,activePage:"process-types",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsx(ce,{title:"Process Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Process type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})]})}function g1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function m1({incidentStatuses:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.red})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.notifyManager}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:g1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function x1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return t.jsxs(tt,{title:x,activePage:"incident-statuses",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(ce,{title:"Incident Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Incident status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:a,onChange:v=>o({notify_manager:v.target.checked?1:0}),style:Ba}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:a?"default":"pointer"},children:g.field.notifyManager})]})]})]})}function y1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function v1({ideaStatuses:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.teal})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.notifyManager}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:y1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function j1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return t.jsxs(tt,{title:x,activePage:"idea-statuses",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(ce,{title:"Idea Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Idea status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:a,onChange:v=>o({notify_manager:v.target.checked?1:0}),style:Ba}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:a?"default":"pointer"},children:g.field.notifyManager})]})]})]})}function b1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function S1({orderStatuses:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.purple})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.notifyManager}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:b1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function _1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return t.jsxs(tt,{title:x,activePage:"order-statuses",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(ce,{title:"Order Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Order status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:a,onChange:v=>o({notify_manager:v.target.checked?1:0}),style:Ba}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:a?"default":"pointer"},children:g.field.notifyManager})]})]})]})}function w1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function k1({processStatuses:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=S.useMemo(()=>e.filter(o=>{const h=(o.name1||o.name||"").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j!=="all"&&(o.status||"Active")!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total",val:y.length,color:V.blue})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:j,onChange:_,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:c,children:i.col.name}),t.jsx("th",{style:c,children:i.field.notifyManager}),t.jsx("th",{style:c,children:i.field.creationDate}),t.jsx("th",{style:c,children:i.field.status}),t.jsx("th",{style:c,children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.notify_manager?i.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:w1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{color:o.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function C1({form:e,setForm:n,formStatus:s,viewMode:a,onEdit:l,onRestore:r,onPermanentDelete:i,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,user:k}){const g=re(),o=v=>n(w=>({...w,...v})),h=a?{background:"#f8fafc"}:{},x=e.name?a?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return t.jsxs(tt,{title:x,activePage:"process-statuses",user:k,formStatus:s,buttonText:g.saveName,buttonColor:"#16a34a",viewMode:a,onEdit:l,darkMode:d,notifCount:f,onToggleDark:p,onCountChange:C,onViewProfile:j,onSubmit:_,onBack:c,onNavigate:y,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:r&&e.name?()=>r(e.name):void 0,onPermanentDelete:i&&e.name?()=>i(e.name):void 0}),t.jsxs(ce,{title:"Process Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[g.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...h},value:e.name1,disabled:a||!!e.name,onChange:v=>o({name1:v.target.value}),placeholder:"Process status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.creationDate}),t.jsx(je,{value:e.creation_date||"",onChange:v=>o({creation_date:v}),disabled:a,style:{...D,...h}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:g.field.status}),t.jsxs("select",{style:{...D,...h},value:e.status||"Active",disabled:a,onChange:v=>o({status:v.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:a,onChange:v=>o({notify_manager:v.target.checked?1:0}),style:Ba}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:a?"default":"pointer"},children:g.field.notifyManager})]})]})]})}const z1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function I1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function E1({users:e,canModify:n,onView:s,onEdit:a,onDisable:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(!1),[j,_]=S.useState(""),[c,y]=S.useState(""),[z,k]=S.useState(""),[g,o]=S.useState("active"),[h,x]=S.useState(1),[v,w]=S.useState(null),[u,b]=S.useState(""),[T,E]=S.useState("idle"),[F,Q]=S.useState(null),te=async()=>{if(!(!v||!u.trim())){E("loading");try{await si(v.name,u.trim()),E("success"),setTimeout(()=>{w(null),b(""),E("idle")},1200)}catch{E("error")}}},H=async L=>{if(window.confirm(i.users.disableConfirm)){Q(L);try{await(l==null?void 0:l(L))}finally{Q(null)}}},Y=e.filter(L=>{if(g==="active"&&(L.enabled===0||L.enabled==="0")||g==="inactive"&&L.enabled!==0&&L.enabled!=="0")return!1;const N=L.custom_category||"";if(z&&N!==z)return!1;const J=L.custom_organization||"";if(c&&!J.toLowerCase().includes(c.toLowerCase()))return!1;if(j){const se=j.toLowerCase();if(![L.full_name,L.email,L.name,L.username,L.mobile_no].join(" ").toLowerCase().includes(se))return!1}return!0}),$=[...new Set(e.map(L=>L.custom_organization).filter(Boolean))],I=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];S.useEffect(()=>{x(1)},[j,c,z,g]);const A=Y.slice((h-1)*ie,h*ie);S.useEffect(()=>{if(r){const L=Y.filter(N=>d.has(N.name));r(L,A)}},[d,A]);const M={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},X={...M,cursor:"pointer"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[t.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[t.jsxs("div",{onClick:()=>C(L=>!L),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:p?t.jsx("polyline",{points:"18,15 12,9 6,15"}):t.jsx("polyline",{points:"6,9 12,15 18,9"})}),t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),p&&t.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),t.jsx("input",{style:M,placeholder:"Name, email, username…",value:j,onChange:L=>{_(L.target.value),x(1)}})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),t.jsxs("select",{style:X,value:c,onChange:L=>{y(L.target.value),x(1)},children:[t.jsx("option",{value:"",children:"All Organizations"}),$.map(L=>t.jsx("option",{value:L,children:L},L))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),t.jsxs("select",{style:X,value:z,onChange:L=>{k(L.target.value),x(1)},children:[t.jsx("option",{value:"",children:"All Categories"}),I.map(L=>t.jsx("option",{value:L,children:L},L))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),t.jsxs("select",{style:X,value:g,onChange:L=>{o(L.target.value),x(1)},children:[t.jsx("option",{value:"all",children:"All"}),t.jsx("option",{value:"active",children:"Active"}),t.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),t.jsx("div",{style:{background:"white",borderRadius:10,border:"1px solid #e5e7eb",overflow:"auto",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.05)"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f9fafb",borderBottom:"2px solid #e5e7eb",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"11px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:A.length>0&&A.every(L=>d.has(L.name)),onChange:L=>{if(L.target.checked)f(new Set([...d,...A.map(N=>N.name)]));else{const N=new Set(d);A.forEach(J=>N.delete(J.name)),f(N)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),[{label:"Category",w:110},{label:"Number",w:90},{label:i.col.name,w:160},{label:"Username",w:130},{label:"Email",w:180},{label:"Phone",w:110},{label:i.col.organization,w:140},{label:i.col.management,w:120},{label:i.col.department,w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:L,w:N})=>t.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:N,letterSpacing:.3,textTransform:"uppercase"},children:L},L))]})}),t.jsx("tbody",{children:Y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:14,style:{padding:"48px 20px",textAlign:"center",color:"#aaa",fontSize:14},children:"No users found"})}):A.map((L,N)=>{const J=L.custom_category||"",se=z1[J]||"#6b7280";return t.jsxs("tr",{onClick:()=>s==null?void 0:s(L),style:{borderBottom:"1px solid #f3f4f6",background:d.has(L.name)?"#eff6ff":N%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"11px 14px",textAlign:"center"},onClick:oe=>oe.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(L.name),onChange:()=>{const oe=new Set(d);oe.has(L.name)?oe.delete(L.name):oe.add(L.name),f(oe)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:J?t.jsx("span",{style:{background:se+"18",color:se,border:`1px solid ${se}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:J}):t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_number||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:L.full_name||L.first_name||"—"}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.username||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.email||L.name}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.mobile_no||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.custom_organization||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_management||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_department||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_branch||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:I1(L.creation)}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:t.jsx("span",{style:{color:L.enabled?"#16a34a":"#dc2626",fontWeight:600},children:L.enabled?i.users.active:i.users.inactive})}),t.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:oe=>oe.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{onClick:oe=>{oe.stopPropagation(),s==null||s(L)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),n&&a&&t.jsx("button",{onClick:oe=>{oe.stopPropagation(),a(L)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),n&&t.jsx("button",{onClick:oe=>{oe.stopPropagation(),w({name:L.name,email:L.email||L.name}),b(""),E("idle")},title:"Set Password",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fef3c7",color:"#d97706"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),n&&t.jsx("button",{onClick:oe=>{oe.stopPropagation(),H(L.name)},disabled:F===L.name,title:"Disable",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",opacity:F===L.name?.5:1},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v6M14 11v6"}),t.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},L.name)})})]})}),t.jsx(Ue,{page:h,total:Y.length,onPageChange:x}),v&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[t.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:i.users.setPassword}),t.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",t.jsx("strong",{children:v.email})]}),t.jsx("input",{type:"password",value:u,onChange:L=>b(L.target.value),placeholder:i.users.newPassword,style:{width:"100%",padding:"10px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",marginBottom:16,fontFamily:"Segoe UI",outline:"none"},onKeyDown:L=>L.key==="Enter"&&te(),autoFocus:!0}),T==="success"&&t.jsx("div",{style:{color:"#166534",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Password updated successfully"}),T==="error"&&t.jsx("div",{style:{color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Failed to update password"}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsx("button",{onClick:te,disabled:T==="loading"||!u.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:u.trim()?1:.5},children:T==="loading"?"Saving…":i.users.setPassword}),t.jsx("button",{onClick:()=>{w(null),b(""),E("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}function T1({form:e,setForm:n,groupCompanies:s=[],organizations:a,managements:l,departments:r,branches:i,users:d=[],formStatus:f,viewMode:p,onEdit:C,onRestore:j,onPermanentDelete:_,darkMode:c,notifCount:y,onToggleDark:z,onCountChange:k,onViewProfile:g,isSelfProfile:o,onSubmit:h,onBack:x,onNavigate:v,onLogout:w,user:u}){const b=re(),T=N=>n(J=>({...J,...N})),E=p?{background:"#f8fafc"}:{},F=s.map(N=>({name:N.name,label:N.company_name||N.name})),Q=e.custom_organization?l.filter(N=>!N.organization||N.organization===e.custom_organization):l,te=r.filter(N=>!(e.custom_organization&&N.custom_organization&&N.custom_organization!==e.custom_organization||e.custom_management&&N.custom_management&&N.custom_management!==e.custom_management)),H=i.filter(N=>!(e.custom_organization&&N.organization&&N.organization!==e.custom_organization||e.custom_management&&N.management&&N.management!==e.custom_management||e.custom_department&&N.department&&N.department!==e.custom_department)),Y=Se(Q,e.custom_management).map(N=>({name:N.name,label:N.name1||N.name})),$=Se(te,e.custom_department).map(N=>({name:N.name,label:N.department_name||N.name})),I=Se(H,e.custom_branch).map(N=>({name:N.name,label:N.branch||N.name})),A=d.filter(N=>{if(N.name===e.name)return!1;const J=N.custom_category||"",se=J==="CEO"||J==="Chairman"||N.name==="Administrator";return e.custom_organization&&N.custom_organization&&N.custom_organization!==e.custom_organization&&!se?!1:e.custom_category==="Admin"?J==="CEO"||J==="Chairman"||N.name==="Administrator":e.custom_category==="Manager"?J==="Admin":e.custom_category==="Auditor"||e.custom_category==="X-Auditor"?J==="Manager"||J==="Admin":e.custom_category==="Employee"?J==="Auditor"||J==="X-Auditor"||J==="Manager":!(e.custom_category==="CEO"||e.custom_category==="Chairman")}),M=!e.name||e.name.startsWith("new-user-"),X=o?b.formTitle.viewUser:M?b.formTitle.newUser:b.formTitle.editUser,L=N=>{if(N&&N.preventDefault(),!e.first_name){alert(b.field.fullName+" is required");return}if(M&&!e.email){alert(b.field.emailAddress+" is required");return}const J=e.custom_group_company||u.custom_group_company;if(!J){alert("Group Company (Tenant) is required");return}if(!e.custom_organization){alert(b.field.organization+" is required");return}if(!e.custom_category){alert(b.field.category+" is required");return}if(e.custom_category&&e.custom_category!=="CEO"&&e.custom_category!=="Chairman"&&!e.custom_manager){alert("Reports To / Supervisor is mandatory.");return}!e.custom_group_company&&J&&T({custom_group_company:J}),h()};return t.jsxs(tt,{title:X,activePage:"users",user:u,formStatus:f,buttonText:b.saveUser,buttonColor:"#16a34a",viewMode:p,onEdit:C,darkMode:c,notifCount:y,onToggleDark:z,onCountChange:k,onViewProfile:g,onSubmit:L,onBack:x,onNavigate:v,onLogout:w,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:j&&e.name?()=>j(e.name):void 0,onPermanentDelete:_&&e.name?()=>_(e.name):void 0}),t.jsx(ce,{title:"User Organization & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[(u.role==="Admin"||u.role==="CEO")&&!u.custom_group_company&&t.jsxs("div",{children:[t.jsxs("label",{style:R,children:["Group Company (Tenant) ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(xe,{value:e.custom_group_company||"",onChange:N=>T({custom_group_company:N}),items:F,placeholder:"-- Select Group Company --",disabled:p,userRole:u.role,doctypeName:P.groupCompanies})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[b.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.custom_organization,onChange:N=>T({custom_organization:N,custom_management:"",custom_department:"",custom_branch:"",custom_manager:""}),organizations:a,disabled:p,userRole:u.role})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:b.field.management}),t.jsx(xe,{value:e.custom_management,onChange:N=>T({custom_management:N,custom_department:"",custom_branch:""}),items:Y,placeholder:"-- Select --",disabled:p,userRole:u.role,doctypeName:P.managements,extraFields:{organization:e.custom_organization}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:b.field.department}),t.jsx(xe,{value:e.custom_department,onChange:N=>T({custom_department:N,custom_branch:""}),items:$,placeholder:"-- Select --",disabled:p,userRole:u.role,doctypeName:P.departments,extraFields:{organization:e.custom_organization,management:e.custom_management}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:b.field.branch}),t.jsx(xe,{value:e.custom_branch,onChange:N=>T({custom_branch:N}),items:I,placeholder:"-- Select --",disabled:p,userRole:u.role,doctypeName:P.branches,extraFields:{organization:e.custom_organization,management:e.custom_management,department:e.custom_department}})]})]})}),t.jsx(ce,{title:"User Profile Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:b.field.number}),t.jsx("input",{style:{...D,...E},value:e.custom_number,disabled:p,onChange:N=>T({custom_number:N.target.value}),placeholder:"e.g. 10001"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[b.field.fullName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...E},value:e.first_name,disabled:p,onChange:N=>T({first_name:N.target.value}),placeholder:"Full name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:b.field.username}),t.jsx("input",{style:{...D,...E},value:e.username,disabled:p,onChange:N=>T({username:N.target.value}),placeholder:"Username"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:b.field.phoneNumber}),t.jsx("input",{style:{...D,...E},value:e.mobile_no,disabled:p,onChange:N=>T({mobile_no:N.target.value}),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[b.field.emailAddress," ",M&&t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...p||!M?{background:"#f8fafc"}:{}},value:e.email,disabled:p||!M,onChange:N=>T({email:N.target.value}),placeholder:"user@example.com",type:"email",required:M})]}),M&&t.jsxs("div",{children:[t.jsxs("label",{style:R,children:["Password ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...E},type:"password",value:e.new_password||"",disabled:p,onChange:N=>T({new_password:N.target.value}),placeholder:"Initial password",required:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[b.field.category," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsxs("select",{style:{...D,...E},value:e.custom_category,disabled:p,onChange:N=>{const J=N.target.value;T({custom_category:J,custom_manager:""})},children:[t.jsx("option",{value:"",children:b.field.select}),t.jsx("option",{children:"Admin"}),t.jsx("option",{children:"Chairman"}),t.jsx("option",{children:"Auditor"}),t.jsx("option",{children:"X-Auditor"}),t.jsx("option",{children:"Manager"}),t.jsx("option",{children:"Employee"})]})]}),e.custom_category!=="CEO"&&e.custom_category!=="Chairman"&&t.jsxs("div",{children:[t.jsxs("label",{style:R,children:["Reports To / Supervisor"," ",e.custom_category&&t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsxs("select",{style:{...D,...E,...e.custom_category?{}:{background:"#f1f5f9",cursor:"not-allowed",color:"#94a3b8"}},value:e.custom_manager||"",disabled:p||!e.custom_category,onChange:N=>T({custom_manager:N.target.value}),required:!!e.custom_category,children:[t.jsx("option",{value:""}),A.map(N=>{const J=N.full_name||N.email||N.name,se=N.custom_category?` [${N.custom_category}]`:"";return t.jsxs("option",{value:N.name,children:[J,se]},N.name)})]})]})]})})]})}const Bu={Active:V.green,Closed:V.gray};function A1({cycles:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState(""),[c,y]=S.useState("all"),z=S.useMemo(()=>[...new Set(e.map(w=>w.organization).filter(Boolean))],[e]),k=S.useMemo(()=>e.filter(w=>{const u=(w.name1||w.name||"").toLowerCase();return!(p&&!u.includes(p.toLowerCase())||j&&w.organization!==j||c!=="all"&&w.status!==c)}),[e,p,j,c]),[g,o]=S.useState(1);S.useEffect(()=>{o(1)},[p,j,c]);const h=k.slice((g-1)*ie,g*ie);S.useEffect(()=>{if(r){const w=e.filter(u=>d.has(u.name));r(w,h)}},[d,h]);const x=k.filter(w=>w.status==="Active").length,v=k.filter(w=>w.status==="Closed").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Re,{label:"Total",val:k.length,color:V.teal}),t.jsx(Re,{label:"Active",val:x,color:V.green}),t.jsx(Re,{label:"Closed",val:v,color:V.gray})]}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:j,onChange:_,options:[{value:"",label:"All Organizations"},...z.map(w=>({value:w,label:w}))]},{type:"select",label:"Status",value:c,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:h.length>0&&h.every(w=>d.has(w.name)),onChange:w=>{if(w.target.checked)f(new Set([...d,...h.map(u=>u.name)]));else{const u=new Set(d);h.forEach(b=>u.delete(b.name)),f(u)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.name}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.frequency}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.startDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.endDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.status}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),t.jsx("tbody",{children:k.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):h.map((w,u)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(w),style:{borderTop:"1px solid #f0f0f0",background:d.has(w.name)?"#eff6ff":w.custom_is_deleted?"#fff1f2":u%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:b=>b.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(w.name),onChange:()=>{const b=new Set(d);b.has(w.name)?b.delete(w.name):b.add(w.name),f(b)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:w.name1||w.name}),t.jsx("td",{style:{padding:"10px 14px"},children:w.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.frequency||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.start_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.end_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:Bu[w.status]+"22",color:Bu[w.status]||"#666"},children:w.status})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:b=>b.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(w),onEdit:n&&a&&!w.custom_is_deleted?()=>a(w):void 0,onDelete:n&&l&&!w.custom_is_deleted?()=>l(w.name):void 0})})]},w.name))})]})}),t.jsx(Ue,{page:g,total:k.length,onPageChange:o})]})}const P1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],R1=["Active","Closed"];function D1({form:e,setForm:n,organizations:s,groupCompanies:a=[],formStatus:l,viewMode:r,onEdit:i,onRestore:d,onPermanentDelete:f,darkMode:p,notifCount:C,onToggleDark:j,onCountChange:_,onViewProfile:c,onSubmit:y,onBack:z,onNavigate:k,onLogout:g,user:o}){const h=re(),x=u=>n(b=>({...b,...u})),v=r?{background:"#f8fafc"}:{},w=e.name?r?`${h.formTitle.editCycle}: ${e.name1||e.name}`:h.formTitle.editCycle:h.formTitle.newCycle;return t.jsxs(tt,{title:w,activePage:"cycles",user:o,formStatus:l,buttonText:h.saveCycle,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:p,notifCount:C,onToggleDark:j,onCountChange:_,onViewProfile:c,onSubmit:y,onBack:z,onNavigate:k,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0,onPermanentDelete:f&&e.name?()=>f(e.name):void 0}),t.jsx(ce,{title:"Cycle Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[h.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:u=>{var T;const b=(T=s.find(E=>E.name===u))==null?void 0:T.group_company;x({organization:u,...o.custom_group_company?{}:{group_company:b||e.group_company}})},organizations:s,disabled:r||!!o.custom_organization,userRole:o.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[h.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...v},value:e.name1||"",disabled:r||!!e.name,onChange:u=>x({name1:u.target.value}),placeholder:"e.g. Q1-2026"})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.col.frequency}),t.jsx(xe,{value:e.frequency,onChange:u=>x({frequency:u}),items:P1.map(u=>({name:u,label:u})),placeholder:"-- Select Frequency --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.status}),t.jsx(xe,{value:e.status,onChange:u=>x({status:u}),items:R1.map(u=>({name:u,label:u})),placeholder:"-- Select Status --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.dateStart}),t.jsx(je,{value:e.start_date||"",onChange:u=>x({start_date:u}),disabled:r,style:{...D,...v}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.dateEnd}),t.jsx(je,{value:e.end_date||"",onChange:u=>x({end_date:u}),disabled:r,style:{...D,...v}})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.updateWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...D,...v},value:e.update_window_days??2,disabled:r,onChange:u=>x({update_window_days:parseInt(u.target.value)||2})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})]})}function O1({kpiInputs:e,canModify:n,onView:s,onEdit:a,onDelete:l,onSelectionChange:r}){const i=re(),[d,f]=S.useState(new Set),[p,C]=S.useState(""),[j,_]=S.useState(""),c=S.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),y=S.useMemo(()=>e.filter(o=>{const h=[o.organization,o.period].filter(Boolean).join(" ").toLowerCase();return!(p&&!h.includes(p.toLowerCase())||j&&o.organization!==j)}),[e,p,j]),[z,k]=S.useState(1);S.useEffect(()=>{k(1)},[p,j]);const g=y.slice((z-1)*ie,z*ie);return S.useEffect(()=>{if(r){const o=e.filter(h=>d.has(h.name));r(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Re,{label:"Total Records",val:y.length,color:V.blue})}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:p,onChange:C,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:j,onChange:_,options:[{value:"",label:"All Organizations"},...c.map(o=>({value:o,label:o}))]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(o=>d.has(o.name)),onChange:o=>{if(o.target.checked)f(new Set([...d,...g.map(h=>h.name)]));else{const h=new Set(d);g.forEach(x=>h.delete(x.name)),f(h)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),t.jsx("tbody",{children:y.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,h)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:d.has(o.name)?"#eff6ff":o.custom_is_deleted?"#fff1f2":h%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:x=>x.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const x=new Set(d);x.has(o.name)?x.delete(o.name):x.add(o.name),f(x)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.period||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.revenue_growth!=null?`${o.revenue_growth}%`:"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.net_profit!=null?o.net_profit.toLocaleString():"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:i.deletedBadge}):o.customer_satisfaction!=null?o.customer_satisfaction:"—"}),t.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.stopPropagation(),children:t.jsx(ot,{onView:()=>s==null?void 0:s(o),onEdit:n&&a&&!o.custom_is_deleted?()=>a(o):void 0,onDelete:n&&l&&!o.custom_is_deleted?()=>l(o.name):void 0})})]},o.name))})]})}),t.jsx(Ue,{page:z,total:y.length,onPageChange:k})]})}function L1({form:e,setForm:n,organizations:s,groupCompanies:a=[],formStatus:l,viewMode:r,onEdit:i,onRestore:d,onPermanentDelete:f,darkMode:p,notifCount:C,onToggleDark:j,onCountChange:_,onViewProfile:c,onSubmit:y,onBack:z,onNavigate:k,onLogout:g,user:o}){const h=re(),x=b=>n(T=>({...T,...b})),v=r?{background:"#f8fafc"}:{},w=b=>T=>x({[b]:parseFloat(T.target.value)||0}),u=e.name?r?`${h.formTitle.editKpi}: ${e.period||e.name}`:h.formTitle.editKpi:h.formTitle.newKpi;return t.jsxs(tt,{title:u,activePage:"kpi-input",user:o,formStatus:l,buttonText:h.saveKpi,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:p,notifCount:C,onToggleDark:j,onCountChange:_,onViewProfile:c,onSubmit:y,onBack:z,onNavigate:k,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0,onPermanentDelete:f&&e.name?()=>f(e.name):void 0}),t.jsx(ce,{title:"Period & Organization",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[h.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(an,{value:e.organization,onChange:b=>{var E;const T=(E=s.find(F=>F.name===b))==null?void 0:E.group_company;x({organization:b,...o.custom_group_company?{}:{group_company:T||e.group_company}})},organizations:s,disabled:r||!!o.custom_organization,userRole:o.role})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[h.col.period," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...D,...v},value:e.period||"",disabled:r,onChange:b=>x({period:b.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),t.jsx(ce,{title:"Financial KPIs",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.revenue_growth}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.revenue_growth||"",disabled:r,onChange:w("revenue_growth")})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.net_profit}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.net_profit||"",disabled:r,onChange:w("net_profit")})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.cash_flow}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.cash_flow||"",disabled:r,onChange:w("cash_flow")})]})]})}),t.jsx(ce,{title:"Operational KPIs",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.strategic_goal_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.strategic_goal_pct||"",disabled:r,onChange:w("strategic_goal_pct")})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.customer_satisfaction}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.customer_satisfaction||"",disabled:r,onChange:w("customer_satisfaction")})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.employee_turnover_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.employee_turnover_pct||"",disabled:r,onChange:w("employee_turnover_pct")})]})]})}),t.jsx(ce,{title:"Safety & Compliance",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.open_safety_incidents}),t.jsx("input",{type:"number",min:0,style:{...D,...v},value:e.open_safety_incidents||"",disabled:r,onChange:b=>x({open_safety_incidents:parseInt(b.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:h.field.compliance_score}),t.jsx("input",{type:"number",step:"0.01",style:{...D,...v},value:e.compliance_score||"",disabled:r,onChange:w("compliance_score")})]})]})})]})}const W1={incident_initial_evaluation:"Incident Initial Evaluation",idea_initial_evaluation:"Idea Initial Evaluation"},$u={Pending:V.orange,Accepted:V.green,Rejected:V.red,Revoked:V.gray};function N1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function B1(e){const n=[];return e.incident_initial_evaluation&&n.push("incident_initial_evaluation"),e.idea_initial_evaluation&&n.push("idea_initial_evaluation"),n}function $1({delegations:e,organizations:n,userRole:s,currentUser:a,onView:l,onRevoke:r,onSelectionChange:i}){const d=re(),[f,p]=S.useState(new Set),[C,j]=S.useState(""),[_,c]=S.useState(""),[y,z]=S.useState("all"),k={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},g=S.useMemo(()=>e.filter(u=>{const b=`${u.auditor} ${u.manager}`.toLowerCase();return!(C&&!b.includes(C.toLowerCase())||_&&u.organization!==_||y!=="all"&&u.status!==y)}),[e,C,_,y]),[o,h]=S.useState(1);S.useEffect(()=>{h(1)},[C,_,y]);const x=g.slice((o-1)*ie,o*ie);S.useEffect(()=>{if(i){const u=e.filter(b=>f.has(b.name));i(u,x)}},[f,x]);const v=g.filter(u=>u.status==="Pending").length,w=g.filter(u=>u.status==="Accepted").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Re,{label:"Total",val:g.length,color:V.purple}),t.jsx(Re,{label:"Pending",val:v,color:V.orange}),t.jsx(Re,{label:"Accepted",val:w,color:V.green})]}),t.jsx(bt,{filters:[{type:"search",label:"Search",value:C,onChange:j,placeholder:"Auditor or Manager…"},{type:"select",label:d.col.organization,value:_,onChange:c,options:[{value:"",label:"All Organizations"},...n.map(u=>({value:u.organization_name||u.name,label:u.organization_name||u.name}))]},{type:"select",label:"Status",value:y,onChange:z,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:x.length>0&&x.every(u=>f.has(u.name)),onChange:u=>{if(u.target.checked)p(new Set([...f,...x.map(b=>b.name)]));else{const b=new Set(f);x.forEach(T=>b.delete(T.name)),p(b)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:k,children:d.col.number}),t.jsx("th",{style:k,children:d.col.auditor}),t.jsx("th",{style:k,children:d.col.manager}),t.jsx("th",{style:k,children:d.col.organization}),t.jsx("th",{style:k,children:d.col.functions}),t.jsx("th",{style:k,children:d.col.status}),t.jsx("th",{style:k,children:d.col.requestedOn}),t.jsx("th",{style:k,children:d.col.actions})]})}),t.jsx("tbody",{children:g.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:9,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):x.map((u,b)=>{const T=!!r&&(u.status==="Pending"||u.status==="Accepted")&&(s==="Admin"||u.auditor===a);return t.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(u),style:{borderTop:"1px solid #f0f0f0",background:f.has(u.name)?"#eff6ff":b%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:E=>E.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:f.has(u.name),onChange:()=>{const E=new Set(f);E.has(u.name)?E.delete(u.name):E.add(u.name),p(E)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:u.number||u.name}),t.jsx("td",{style:{padding:"10px 14px"},children:u.auditor}),t.jsx("td",{style:{padding:"10px 14px"},children:u.manager}),t.jsx("td",{style:{padding:"10px 14px"},children:u.organization||"All Organizations"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:B1(u).map(E=>t.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:W1[E]||E},E))})}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{background:($u[u.status]||V.gray)+"22",color:$u[u.status]||V.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:u.status})}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N1(u.requested_on)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:E=>E.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>l==null?void 0:l(u),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),T&&t.jsx("button",{onClick:()=>r==null?void 0:r(u.name),title:"Revoke",style:{padding:"0 12px",height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",fontSize:12,fontWeight:700},children:"Revoke"})]})})]},u.name)})})]})}),t.jsx(Ue,{page:o,total:g.length,onPageChange:h})]})}const yo={Pending:V.orange,Accepted:V.green,Rejected:V.red,Revoked:V.gray};function U1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":n.toLocaleString()}function M1({form:e,setForm:n,organizations:s,users:a,userRoleMap:l,incidents:r=[],ideas:i=[],formStatus:d,viewMode:f,onEdit:p,onRestore:C,onPermanentDelete:j,darkMode:_,notifCount:c,onToggleDark:y,onCountChange:z,onViewProfile:k,onSubmit:g,onBack:o,onNavigate:h,onLogout:x,user:v}){var te;const w=re(),u=H=>n(Y=>({...Y,...H})),b=f?{background:"#f8fafc"}:{},T=Na(a,l,"SB Manager",e.organization).filter(H=>H.name!==v.name).map(H=>({name:H.name,label:H.full_name||H.name})),E=(r||[]).filter(H=>(!e.organization||H.organization===e.organization)&&(H.workflow_state==="Initial Evaluation"||H.status==="Initial Evaluation")).map(H=>({name:H.name,label:`${H.number||H.name} — ${H.title}`})),F=(i||[]).filter(H=>(!e.organization||H.organization===e.organization)&&(H.workflow_state==="Initial Evaluation"||H.status==="Initial Evaluation")).map(H=>({name:H.name,label:`${H.number||H.name} — ${H.title}`})),Q=e.name?`${w.formTitle.viewDelegation}${e.name}`:w.formTitle.newDelegation;return t.jsxs(tt,{title:Q,activePage:"delegations",user:v,formStatus:d,statusBadge:e.status?t.jsx("span",{style:{display:"inline-block",padding:"3px 10px",borderRadius:20,fontSize:12,fontWeight:700,background:`${yo[e.status]||V.gray}18`,color:yo[e.status]||V.gray,border:`1px solid ${yo[e.status]||V.gray}40`},children:e.status}):void 0,buttonText:w.saveDelegation,buttonColor:"#16a34a",viewMode:f,onEdit:p,darkMode:_,notifCount:c,onToggleDark:y,onCountChange:z,onViewProfile:k,onSubmit:g,onBack:o,onNavigate:h,onLogout:x,children:[e.custom_is_deleted===1&&t.jsx(et,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:C&&e.name?()=>C(e.name):void 0,onPermanentDelete:j&&e.name?()=>j(e.name):void 0}),e.status==="Revoked"&&t.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f8fafc",border:"1px solid #cbd5e1",color:"#475569",fontSize:13,fontWeight:600,marginBottom:14,display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:16},children:"🚫"})," This delegation has been Revoked and is closed for further edits or re-delegation."]}),t.jsxs(ce,{title:"Delegation Information",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:R,children:w.col.auditor}),t.jsx("input",{style:{...D,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||v.name,disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[w.col.manager," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(xe,{value:e.manager,onChange:H=>u({manager:H}),items:T,placeholder:"-- Select Manager --",disabled:f})]}),t.jsxs("div",{children:[t.jsx("label",{style:R,children:w.col.organization}),t.jsx(an,{value:e.organization,onChange:H=>u({organization:H,incident_name:"",idea_name:""}),organizations:s,placeholder:"-- All Organizations --",disabled:f,userRole:v.role})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:R,children:[w.col.functions," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:6},children:[t.jsxs("div",{className:`delegation-func-box ${e.incident_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:f?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:Ba,checked:!!e.incident_initial_evaluation,disabled:f,onChange:H=>u({incident_initial_evaluation:H.target.checked?1:0,incident_name:H.target.checked?e.incident_name:""})}),t.jsx("span",{className:"func-title",children:"Initial Evaluation (Incidents)"})]}),!!e.incident_initial_evaluation&&t.jsxs("div",{style:{marginTop:10},children:[t.jsxs("label",{style:{...R,fontSize:11},className:"func-sublabel",children:["Specific Incident ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),f?t.jsx("input",{style:{...D,background:"#f8fafc"},value:e.incident_name||"— All Incidents in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(xe,{value:e.incident_name||"",onChange:H=>u({incident_name:H}),items:E,placeholder:`-- Any Incident in Initial Evaluation (${E.length} available) --`,disabled:f})]})]}),t.jsxs("div",{className:`delegation-func-box ${e.idea_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:f?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:Ba,checked:!!e.idea_initial_evaluation,disabled:f,onChange:H=>u({idea_initial_evaluation:H.target.checked?1:0,idea_name:H.target.checked?e.idea_name:""})}),t.jsx("span",{className:"func-title",children:"Initial Evaluation (Ideas)"})]}),!!e.idea_initial_evaluation&&t.jsxs("div",{style:{marginTop:10},children:[t.jsxs("label",{style:{...R,fontSize:11},className:"func-sublabel",children:["Specific Idea ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),f?t.jsx("input",{style:{...D,background:"#f8fafc"},value:e.idea_name||"— All Ideas in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(xe,{value:e.idea_name||"",onChange:H=>u({idea_name:H}),items:F,placeholder:`-- Any Idea in Initial Evaluation (${F.length} available) --`,disabled:f})]})]})]})]}),!f&&t.jsxs("div",{style:{marginTop:14},children:[t.jsx("label",{style:R,children:"Remarks"}),t.jsx("textarea",{style:{...D,...b,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:H=>u({remarks:H.target.value}),placeholder:"Optional note for the Manager…"})]})]}),f&&(((te=e.delegation_log)==null?void 0:te.length)??0)>0&&t.jsx(ce,{title:"Audit Trail",children:t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Action"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Timestamp"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Remarks"})]})}),t.jsx("tbody",{children:(e.delegation_log||[]).map((H,Y)=>t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:H.action}),t.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:H.actor}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:U1(H.timestamp)}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:H.remarks||"—"})]},H.name||Y))})]})})})]})}const Uu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},F1={process:"#3b82f6",order:"#8b5cf6",incident:"#ef4444",idea:"#10b981",delegation:"#f59e0b"},H1={process:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",order:"linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%)",incident:"linear-gradient(135deg, #ef4444 0%, #b91c1c 100%)",idea:"linear-gradient(135deg, #10b981 0%, #047857 100%)",delegation:"linear-gradient(135deg, #f59e0b 0%, #b45309 100%)"},G1={process:"⚙️",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Q1({onNavigate:e,onRefresh:n}){const[s,a]=S.useState([]),[l,r]=S.useState(!0),[i,d]=S.useState(""),[f,p]=S.useState(""),[C,j]=S.useState(""),[_,c]=S.useState("all"),[y,z]=S.useState(1),k=()=>{r(!0),Qy().then(v=>{a(v||[]),r(!1)}).catch(()=>r(!1))};S.useEffect(()=>{k()},[]);const g=S.useMemo(()=>{const v={all:s.length,action:0,info:0};for(const w of s)w.requires_action?v.action=(v.action||0)+1:v.info=(v.info||0)+1,v[w.type]=(v[w.type]||0)+1;return v},[s]),o=S.useMemo(()=>s.filter(v=>{if(_==="action"&&!v.requires_action||_==="info"&&v.requires_action||_!=="all"&&_!=="action"&&_!=="info"&&v.type!==_)return!1;if(C.trim()){const w=C.toLowerCase();if(![v.number,v.title,v.action,v.organization,v.type].filter(Boolean).join(" ").toLowerCase().includes(w))return!1}return!0}),[s,_,C]);S.useEffect(()=>{z(1)},[_,C]);const h=o.slice((y-1)*ie,y*ie),x=async(v,w)=>{d(v),p("");try{await Yy(v,w),await k(),n==null||n()}catch{p(v)}finally{d("")}};return t.jsxs("div",{style:{maxWidth:1100,margin:"0 auto",display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e293b 100%)",borderRadius:16,padding:"24px 28px",color:"#ffffff",boxShadow:"0 10px 25px -5px rgba(30, 27, 75, 0.25), 0 8px 10px -6px rgba(30, 27, 75, 0.2)",display:"flex",flexDirection:"column",gap:18,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",top:-40,right:-40,width:180,height:180,borderRadius:"50%",background:"radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%)",pointerEvents:"none"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:14},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontSize:24},children:"📬"}),t.jsx("h2",{style:{fontSize:20,fontWeight:800,color:"#ffffff",margin:0,letterSpacing:"-0.3px"},children:"Unified Activity Inbox"})]}),t.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#c7d2fe",opacity:.9},children:"Real-time tasks, approvals, delegations, and workflow actions requiring your attention."})]}),t.jsxs("button",{type:"button",onClick:k,disabled:l,style:{background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(8px)",border:"1px solid rgba(255, 255, 255, 0.25)",color:"white",borderRadius:10,padding:"8px 16px",fontSize:13,fontWeight:600,cursor:l?"wait":"pointer",display:"flex",alignItems:"center",gap:8,transition:"all 0.15s ease"},onMouseEnter:v=>{v.currentTarget.style.background="rgba(255, 255, 255, 0.25)"},onMouseLeave:v=>{v.currentTarget.style.background="rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{transform:l?"rotate(180deg)":"none",transition:"transform 0.5s",display:"inline-block"},children:"🔄"}),l?"Refreshing…":"Refresh"]})]}),t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[t.jsxs("div",{style:{background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{fontSize:12,color:"#e0e7ff",fontWeight:500},children:"Total Items"}),t.jsx("span",{style:{background:"white",color:"#1e1b4b",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:g.all||0})]}),t.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.2)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(239, 68, 68, 0.35)"},children:[t.jsx("span",{style:{fontSize:12,color:"#fecaca",fontWeight:600},children:"Action Required"}),t.jsx("span",{style:{background:"#ef4444",color:"white",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:g.action||0})]}),t.jsxs("div",{style:{background:"rgba(59, 130, 246, 0.2)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(59, 130, 246, 0.35)"},children:[t.jsx("span",{style:{fontSize:12,color:"#bfdbfe",fontWeight:500},children:"Informational"}),t.jsx("span",{style:{background:"#3b82f6",color:"white",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:g.info||0})]})]})]}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:14,background:"white",padding:"12px 16px",borderRadius:12,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},className:"form-card",children:[t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[{id:"all",label:"All",icon:"📋",count:g.all},{id:"action",label:"Needs Action",icon:"🚨",count:g.action,badgeColor:"#ef4444"},{id:"info",label:"Info",icon:"ℹ️",count:g.info},{id:"incident",label:"Incidents",icon:"⚠️",count:g.incident},{id:"idea",label:"Ideas",icon:"💡",count:g.idea},{id:"order",label:"Orders",icon:"📦",count:g.order},{id:"process",label:"Processes",icon:"⚙️",count:g.process},{id:"delegation",label:"Delegations",icon:"🤝",count:g.delegation}].map(v=>{const w=_===v.id;return v.id!=="all"&&v.id!=="action"&&v.id!=="info"&&(!v.count||v.count===0)?null:t.jsxs("button",{type:"button",onClick:()=>c(v.id),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:999,border:w?"1px solid #4f46e5":"1px solid #e2e8f0",background:w?"#4f46e5":"#f8fafc",color:w?"#ffffff":"#475569",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},children:[t.jsx("span",{children:v.icon}),t.jsx("span",{children:v.label}),v.count!=null&&v.count>0&&t.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:999,background:w?"rgba(255,255,255,0.25)":v.badgeColor||"#e2e8f0",color:w?"#ffffff":v.badgeColor?"white":"#475569"},children:v.count})]},v.id)})}),t.jsx("div",{style:{minWidth:200,flex:"1 1 200px",maxWidth:300},children:t.jsx("input",{type:"text",placeholder:"Search items, titles, IDs…",value:C,onChange:v=>j(v.target.value),style:{width:"100%",padding:"7px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:12,boxSizing:"border-box",background:"#f8fafc",color:"#334155"}})})]}),l?t.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",color:"#94a3b8",fontSize:14},children:[t.jsx("div",{style:{fontSize:28,marginBottom:8,animation:"spin 1s linear infinite"},children:"⏳"}),"Loading inbox updates…"]}):o.length===0?t.jsxs("div",{style:{background:"white",borderRadius:16,padding:"60px 24px",textAlign:"center",border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.03)"},className:"form-card",children:[t.jsx("div",{style:{fontSize:44,marginBottom:12},children:"✨"}),t.jsx("h3",{style:{fontSize:16,fontWeight:700,color:"#1e293b",margin:0},children:C||_!=="all"?"No matching inbox items":"You are all caught up!"}),t.jsx("p",{style:{fontSize:13,color:"#64748b",marginTop:6,maxWidth:420,margin:"6px auto 0"},children:C||_!=="all"?"Try changing your filter pills or searching for a different keyword.":"There are no active pending approvals or tasks requiring your action right now."}),(C||_!=="all")&&t.jsx("button",{type:"button",onClick:()=>{j(""),c("all")},style:{marginTop:16,padding:"7px 16px",borderRadius:8,background:"#4f46e5",color:"white",border:"none",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Reset Filters"})]}):t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(330px, 1fr))",gap:14},children:h.map((v,w)=>{const u=F1[v.type]||V.gray,b=H1[v.type]||"linear-gradient(135deg, #64748b 0%, #475569 100%)",T=v.type!=="delegation";return t.jsxs("div",{className:"inbox-card form-card",onClick:T?()=>e(Uu[v.type],v.name):void 0,style:{background:"white",borderRadius:14,padding:"16px 18px",border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)",display:"flex",flexDirection:"column",justifyContent:"space-between",gap:14,cursor:T?"pointer":"default",position:"relative",overflow:"hidden",transition:"transform 0.15s ease, box-shadow 0.15s ease"},onMouseEnter:E=>{T&&(E.currentTarget.style.transform="translateY(-2px)",E.currentTarget.style.boxShadow="0 10px 20px -5px rgba(0,0,0,0.08)")},onMouseLeave:E=>{T&&(E.currentTarget.style.transform="none",E.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.04)")},children:[t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:4,background:b}}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:b,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0,boxShadow:`0 3px 8px -1px ${u}66`},children:G1[v.type]||"📌"}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:u,letterSpacing:"0.3px"},children:v.number||v.name})]}),v.requires_action?t.jsxs("span",{style:{fontSize:10,fontWeight:800,color:"#ef4444",background:"#fef2f2",border:"1px solid #fecaca",padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:"0.4px",display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#ef4444"}}),"Action"]}):t.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",background:"#f1f5f9",padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:"0.3px"},children:v.type})]}),t.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:700,color:"#1e293b",lineHeight:1.35,marginBottom:6,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:v.title||v.action||"Untitled Item"}),t.jsx("div",{style:{fontSize:12,color:"#475569",lineHeight:1.4,marginBottom:8},children:v.action}),t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[v.organization&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6,display:"flex",alignItems:"center",gap:4},children:["🏢 ",v.organization]}),v.date&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6},children:["📅 ",v.date]})]}),f===v.name&&t.jsx("div",{style:{marginTop:8,fontSize:11,color:"#ef4444",fontWeight:600},children:"⚠️ Failed to process response. Please try again."})]}),t.jsx("div",{children:v.type==="delegation"?t.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:()=>x(v.name,"Accepted"),disabled:i===v.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#16a34a",color:"white",fontWeight:700,fontSize:12,cursor:i===v.name?"wait":"pointer",opacity:i===v.name?.6:1,transition:"background 0.15s ease"},children:"✓ Accept"}),t.jsx("button",{type:"button",onClick:()=>x(v.name,"Rejected"),disabled:i===v.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#ef4444",color:"white",fontWeight:700,fontSize:12,cursor:i===v.name?"wait":"pointer",opacity:i===v.name?.6:1,transition:"background 0.15s ease"},children:"✕ Reject"})]}):t.jsxs("button",{type:"button",onClick:E=>{E.stopPropagation(),e(Uu[v.type],v.name)},style:{width:"100%",padding:"7px 12px",borderRadius:8,border:v.requires_action?"none":"1px solid #cbd5e1",background:v.requires_action?b:"#f8fafc",color:v.requires_action?"#ffffff":"#334155",fontWeight:700,fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"all 0.15s ease"},children:[t.jsx("span",{children:v.requires_action?"Review & Act Now":"View Details"}),t.jsx("span",{style:{fontSize:13},children:"→"})]})})]},v.name||w)})}),t.jsx(Ue,{page:y,total:o.length,onPageChange:z})]})}const K1=[{id:"process_status_history",label:"Process Status History",description:"Full cycle-by-cycle status for any process, with actor, date, and escalation level",roles:["Admin","Auditor","Owner"]},{id:"order_tracker",label:"Outsourcing Order Tracker",description:"Stage-by-stage progress for all orders, with cost variance",roles:["Admin","Auditor","Manager","Owner"]},{id:"incident_register",label:"Incident Register",description:"All incidents with type, status, assigned manager, and resolution timeline",roles:["Admin","Auditor","Manager","Owner"]},{id:"ideas_pipeline",label:"Ideas Pipeline",description:"All ideas by status and type, conversion rate to Study",roles:["Admin","Auditor","Manager","Owner"]},{id:"department_performance",label:"Department Performance",description:"Aggregate Pass/Fail/Unknown per department per cycle",roles:["Admin","Auditor","Owner"]},{id:"escalation_report",label:"Escalation Report",description:"All Level 2 escalations with entity type and current status",roles:["Admin","Owner"]},{id:"cost_summary",label:"Cost Summary",description:"Total cost per order, per department — budget vs actual",roles:["Admin","Owner"]},{id:"process_year_end",label:"Process Year-End Summary",description:"Full status history and accumulated cost per process for a given year (Rule 11.1-6)",roles:["Admin","Auditor","Owner"],extraFilter:"year"},{id:"user_activity_log",label:"User Activity Log",description:"All actions by user with timestamp and entity reference — Admin only",roles:["Admin"]}],pc={number:"Number",title:"Title",organization:"Organization",department:"Department",status:"Status",actor:"Actor",cycle:"Cycle",date_start:"Start Date",date_end:"End Date",escalation_level:"Escalation",stage:"Stage",completion_pct:"Completion %",budget:"Budget",starting_date:"Start",ending_date:"End",date:"Date",assigned_to:"Assigned To",type:"Type",entity_type:"Entity",pass_count:"Pass",fail_count:"Fail",unknown_count:"Unknown",total:"Total",cycle_type:"Cycle Type",cost_per_cycle:"Cost/Cycle",total_cycles:"Total Cycles",total_cost:"Total Cost",timestamp:"Timestamp",user:"User",entity_name:"Entity",changes:"Fields Changed"};function Y1(e,n){const s=e.map(l=>pc[l]||l).join(","),a=n.map(l=>e.map(r=>`"${l[r]??""}"`).join(",")).join(`
|
||
`);return s+`
|
||
`+a}function X1(e,n){const s=new Blob([e],{type:"text/csv"}),a=URL.createObjectURL(s),l=document.createElement("a");l.href=a,l.download=n,l.click(),URL.revokeObjectURL(a)}const Mu=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function q1(e,n,s){const a=e.map(p=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Mu(pc[p]||p)}</th>`).join(""),l=n.map(p=>`<tr>${e.map(C=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Mu(p[C])}</td>`).join("")}</tr>`).join(""),r=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>Report</x:Name><x:WorksheetOptions/></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table><thead><tr>${a}</tr></thead><tbody>${l}</tbody></table></body></html>`,i=new Blob(["\uFEFF"+r],{type:"application/vnd.ms-excel"}),d=URL.createObjectURL(i),f=document.createElement("a");f.href=d,f.download=s,f.click(),URL.revokeObjectURL(d)}const gh="report-print-area",vo="report-print-portal";function J1(){const e=document.getElementById(gh);if(!e)return;const n=document.createElement("div");n.id=vo,n.innerHTML=e.innerHTML,document.body.appendChild(n);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
|
||
#${vo} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${vo} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(s);const a=()=>{n.remove(),s.remove(),window.removeEventListener("afterprint",a)};window.addEventListener("afterprint",a),window.print()}const Fu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},jo={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function V1({organizations:e,userRole:n}){const s=re(),a=K1.filter(Q=>Q.roles.includes(n)),[l,r]=S.useState(""),[i,d]=S.useState(""),[f,p]=S.useState(""),[C,j]=S.useState(""),[_,c]=S.useState(String(new Date().getFullYear())),[y,z]=S.useState([]),[k,g]=S.useState([]),[o,h]=S.useState(!1),[x,v]=S.useState(""),[w,u]=S.useState(1);S.useEffect(()=>{u(1)},[l,i,_]);const b=k.slice((w-1)*ie,w*ie),T=a.find(Q=>Q.id===l);async function E(){if(l){h(!0),v(""),g([]),z([]);try{const Q={};i&&(Q.organization=i),f&&(Q.from_date=f),C&&(Q.to_date=C),(T==null?void 0:T.extraFilter)==="year"&&_&&(Q.year=_);const te=await Gy(l,Q);z(te.columns||[]),g(te.rows||[])}catch(Q){v(Q.message||"Error running report")}finally{h(!1)}}}const F=(T==null?void 0:T.label)||l;return t.jsxs("div",{children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:a.map(Q=>t.jsxs("div",{onClick:()=>r(Q.id),style:{background:l===Q.id?"#ebf5fb":"white",border:l===Q.id?`2px solid ${V.accent}`:"2px solid transparent",borderRadius:10,padding:"14px 16px",cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[t.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:Q.label}),t.jsx("div",{style:{fontSize:12,color:"#888"},children:Q.description})]},Q.id))}),t.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),t.jsxs("select",{style:Fu,value:l,onChange:Q=>r(Q.target.value),children:[t.jsx("option",{value:"",children:"-- Select Report --"}),a.map(Q=>t.jsx("option",{value:Q.id,children:Q.label},Q.id))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),t.jsxs("select",{style:Fu,value:i,onChange:Q=>d(Q.target.value),children:[t.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(Q=>t.jsx("option",{value:Q.name,children:Q.organization_name||Q.name},Q.name))]})]}),(T==null?void 0:T.extraFilter)==="year"?t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),t.jsx("input",{type:"number",style:{...jo,width:90},value:_,onChange:Q=>c(Q.target.value),min:2020,max:2099})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),t.jsx(je,{value:f,onChange:p,style:jo})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),t.jsx(je,{value:C,onChange:j,style:jo})]})]}),t.jsx("button",{onClick:E,disabled:!l||o,style:{padding:"9px 20px",borderRadius:8,border:"none",background:V.accent,color:"white",fontWeight:700,fontSize:13,cursor:l?"pointer":"not-allowed",opacity:l?1:.5},children:o?s.loading:s.reports.generate}),k.length>0&&t.jsx("button",{onClick:()=>X1(Y1(y,k),`${l}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),k.length>0&&t.jsx("button",{onClick:()=>q1(y,k,`${l}.xls`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #107c41",background:"white",color:"#107c41",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export Excel"}),k.length>0&&t.jsx("button",{onClick:J1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),x&&t.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:x}),k.length>0&&t.jsxs("div",{id:gh,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[t.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,color:"#333"},children:F}),t.jsxs("span",{style:{fontSize:12,color:"#888"},children:[k.length," rows"]})]}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8f9fa"},children:y.map(Q=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:pc[Q]||Q.replace(/_/g," ").toUpperCase()},Q))})}),t.jsx("tbody",{children:b.map((Q,te)=>t.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:te%2===0?"white":"#fafafa"},children:y.map(H=>t.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:Q[H]!=null?String(Q[H]):"—"},H))},te))})]}),t.jsx(Ue,{page:w,total:k.length,onPageChange:u})]}),!o&&k.length===0&&l&&!x&&t.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),a.length===0&&t.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const Fl=()=>new Date().toISOString().split("T")[0],fc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Z1=()=>new Date().toTimeString().slice(0,5),Ln=()=>({name:"",number:"",title:"",organization:"",group_company:"",event_category:"",type:"",incident_class:"",incident_field:"",date:Fl(),time:Z1(),management:"",department:"",section_field:"",branch:"",assigned_to:"",status:"",description:"",summary:"",workflow_state:"New",hses_field:"",priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),wn=()=>({name:"",number:"",title:"",organization:"",group_company:"",type:"",management:"",department:"",section_field:"",branch:"",current_condition:"",proposed_condition:"",status:"",assigned_to:"",workflow_state:"New",idea_class:"",hses_field:"",date:Fl(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),kn=()=>({name:"",number:"",title:"",organization:"",group_company:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Fl(),ending_date:fc(),assigned_to:"",actor:"",status:"",budget:0,actual_cost:0,currency:"SAR",description:"",notes:"",cycle:"",stage:1,completion_pct:0,escalation_level:0,workflow_state:"Draft",planned:0,priority:"",product_relation:0,entity_scope:"",economy_class:"",hses_field:"",auditor_comment:"",sb_idea:"",cycle_type:"Normal",long_cycle_date_1:"",long_cycle_date_2:"",long_cycle_date_3:"",long_cycle_date_4:""}),xr=()=>({name:"",title:"",date_start:Fl(),date_end:fc(),number:"",status:"",cycle_type:"Normal",organization:"",group_company:"",type:"",management:"",department:"",section_field:"",branch:"",progress_indicators:[],cycle:"",actor:"",escalation_level:0,workflow_state:"",chain_location:"",economy_class:"",impact_level:"",product_relation:0,entity_scope:"",hses_field:"",kpi_name:"",kpi_type:"",kpi_measure:"",cost_per_cycle:0,auditor_comment:""}),sa=()=>({name:"",organization_name:"",group_company:"",type:"Government",city:"",contact_email:"",creation_date:new Date().toISOString().slice(0,10),is_active:1,acronym:"",incident_triage_window_days:3,incident_resolution_window_days:5}),ws=()=>({name:"",organization:"",group_company:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ks=()=>({name:"",custom_organization:"",group_company:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Cs=()=>({name:"",organization:"",group_company:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),aa=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),la=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ra=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ia=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),oa=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),da=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ca=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ua=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),yr=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_group_company:"",custom_manager:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),zs=()=>({name:"",name1:"",organization:"",group_company:"",frequency:"Monthly",status:"Active",start_date:Fl(),end_date:fc(),update_window_days:2}),Is=()=>({name:"",organization:"",group_company:"",period:"",revenue_growth:0,net_profit:0,cash_flow:0,strategic_goal_pct:0,customer_satisfaction:0,employee_turnover_pct:0,open_safety_incidents:0,compliance_score:0}),al=()=>({name:"",number:"",auditor:"",manager:"",organization:"",incident_initial_evaluation:0,idea_initial_evaluation:0,status:"Pending",requested_on:"",remarks:""}),ev=new Set(["incidents","incidents-form","ideas","ideas-form"]),tv=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),nv=new Set(ah.flatMap(({id:e})=>[e,`${e}-form`])),sv=new Set(["Admin","Owner","Auditor","Manager","CEO"]),av=new Set(["Admin","Owner","Auditor","Manager","CEO"]),lv=new Set(["Admin","Auditor","Manager","CEO"]);function rv({user:e,onLogout:n,darkMode:s,onToggleDark:a}){const l=re(),r=e.role,i=sv.has(r),d=av.has(r),f=lv.has(r),p=m=>r==="CEO"?!0:m==="users"||m==="users-form"?r==="Admin":r==="Admin"||r==="Auditor"?!0:r==="Owner"||r==="XAuditor"?!1:r==="Manager"?!!tv.has(m):ev.has(m),C=m=>r==="Employee"&&!!m&&m!=="New",j=i?"dashboard":"inbox",_=m=>r==="CEO"?!0:m==="dashboard"?i:m==="reports"?d:m==="delegations"||m==="delegations-form"?f:m==="users"||m==="users-form"?r==="Admin":nv.has(m)?r==="Admin"||r==="Auditor":!0,[c,y]=S.useState(()=>{const m=l0(Ru());return m&&_(m)?m:j});S.useEffect(()=>{const m=r0(c);window.location.hash!==m&&window.history.pushState(null,"",m)},[c]),S.useEffect(()=>{const m=()=>{const W=Ru();y(W&&_(W)?W:j)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]);const z=e.custom_organization||"",k=e.custom_group_company||"",g=m=>{var W;return((W=F.find(_e=>_e.name===m))==null?void 0:W.group_company)||""},[o,h]=S.useState(""),[x,v]=S.useState("");S.useEffect(()=>{if(!x)return;const m=setTimeout(()=>v(""),0);return()=>clearTimeout(m)},[x]);const w=(m,W)=>{v(W),y(m)},[u,b]=S.useState(0),[T,E]=S.useState([]),[F,Q]=S.useState([]),[te,H]=S.useState([]),[Y,$]=S.useState([]),[I,A]=S.useState([]),[M,X]=S.useState([]),[L,N]=S.useState([]),[J,se]=S.useState([]),[oe,Ye]=S.useState([]),[ze,St]=S.useState([]),[Gt,_t]=S.useState([]),[Lt,ln]=S.useState([]),[me,Qt]=S.useState([]),[We,G]=S.useState([]),[ne,fe]=S.useState([]),[Ee,rn]=S.useState([]),[he,U]=S.useState([]),[le,O]=S.useState([]),[be,wt]=S.useState([]),[K,Me]=S.useState({}),[Et,xs]=S.useState([]),[ys,Hl]=S.useState([]),[Gl,Ql]=S.useState([]),[Kl,Yl]=S.useState([]),[Ha,B]=S.useState([]),[pt,Tn]=S.useState({}),[De,mh]=S.useState([]),Xl=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[ki,Qs]=S.useState(Xl()),[Te,ye]=S.useState(!0),[Xe,pe]=S.useState("idle"),[qe,ae]=S.useState(!1),[hc,gc]=S.useState(!1),[ql,mc]=S.useState(null),[xh,yh]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),vh=()=>yh(m=>{const W=!m;return localStorage.setItem("sb_sidebar",W?"1":"0"),W}),[jh,Ci]=S.useState(!1),[bh,Fe]=S.useState([]),[Sh,He]=S.useState([]);S.useEffect(()=>{Ci(!1),Fe([]),He([])},[c]);const[on,An]=S.useState(Ln()),[dn,vn]=S.useState(wn()),[Pn,jn]=S.useState(kn()),[Rn,bn]=S.useState(xr()),[zi,Ks]=S.useState(sa()),[Ii,vs]=S.useState(ws()),[Ei,js]=S.useState(ks()),[Ti,bs]=S.useState(Cs()),[Ai,Ys]=S.useState(aa()),[Pi,Xs]=S.useState(la()),[Ri,qs]=S.useState(ra()),[Di,Js]=S.useState(ia()),[Oi,Vs]=S.useState(oa()),[Li,Zs]=S.useState(da()),[Wi,ea]=S.useState(ca()),[Ni,ta]=S.useState(ua()),[Tt,Jl]=S.useState(yr()),[Bi,Ss]=S.useState(zs()),[$i,_s]=S.useState(Is()),[Kt,Ga]=S.useState(al()),Yt=async()=>{ye(!0);try{const[m,W,_e,dt,Xt,Ce,Wt,cn,Ya,xg,yg,vg,jg,bg,Sg,_g,wg,kg,Cg,zg,Ig,Eg,Tg,Ag,Pg,Rg,Dg]=await Promise.all([Oe(P.incidents),Oe(P.organizations),Oe(P.ideas),Oe(P.orders),Oe(P.processes),zy(),Oe(P.managements),Oe(P.departments),Oe(P.branches),Oe(P.incidentTypes),Oe(P.incidentClass),Oe(P.incidentField),Oe(P.ideaTypes),Oe(P.orderTypes),Oe(P.processTypes),Oe(P.incidentStatuses),Oe(P.ideaStatuses),Oe(P.orderStatuses),Oe(P.processStatuses),Ay(),Py(),Oe(P.cycles),Oe(P.kpiInput),qy(),Vy(),Zy(),e0()]);E(m||[]),Q(W||[]),H(_e||[]),$(dt||[]),A(Xt||[]),xs(Ce||[]),X(Wt||[]),N(cn||[]),se(Ya||[]),Ye(xg||[]),St(yg||[]),_t(vg||[]),ln(jg||[]),Qt(bg||[]),G(Sg||[]),fe(_g||[]),rn(wg||[]),U(kg||[]),O(Cg||[]),wt(zg||[]),Me(Ig||{}),Hl(Eg||[]),Ql(Tg||[]),Yl(Ag||[]),B(Pg||[]),Tn(Rg||{}),mh(Dg||[])}catch(m){console.error("Error loading data:",m)}ye(!1)},xc=async()=>{try{const m=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(m.ok){const W=await m.json();b(Number(W.message)||0)}}catch{}};S.useEffect(()=>{Yt(),xc();const m=setInterval(xc,6e4);return()=>clearInterval(m)},[e.name]);const[mt,Dn]=S.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),de=(m,W,_e)=>{Dn({isOpen:!0,doctype:m,name:W,title:_e||W,isDeleting:!1})},yc=m=>{const _e={[P.incidents]:"incidents",[P.ideas]:"ideas",[P.orders]:"orders",[P.processes]:"processes",[P.organizations]:"organizations",[P.managements]:"managements",[P.departments]:"departments",[P.branches]:"branches",[P.cycles]:"cycles",[P.kpiInput]:"kpi-input",[P.incidentTypes]:"incident-types",[P.ideaTypes]:"idea-types",[P.orderTypes]:"order-types",[P.processTypes]:"process-types",[P.incidentStatuses]:"incident-statuses",[P.ideaStatuses]:"idea-statuses",[P.orderStatuses]:"order-statuses",[P.processStatuses]:"process-statuses",[P.groupCompanies]:"group-companies"}[m];_e&&y(_e)},vc=async m=>{Dn(W=>({...W,isDeleting:!0}));try{const W=mt.doctype;await hd(mt.doctype,mt.name,m,!1),Dn(_e=>({..._e,isOpen:!1,isDeleting:!1})),alert(l.rtl?"تم نقل السجل إلى المحذوفات بنجاح!":"Record moved to Deleted successfully!"),await Yt(),c.endsWith("-form")&&yc(W)}catch(W){console.error("Delete error:",W),alert((W==null?void 0:W.message)||"Delete failed. Please try again."),Dn(_e=>({..._e,isDeleting:!1}))}},jc=async m=>{Dn(W=>({...W,isDeleting:!0}));try{const W=mt.doctype;await hd(mt.doctype,mt.name,m,!0),Dn(_e=>({..._e,isOpen:!1,isDeleting:!1})),alert(l.rtl?"تم حذف السجل نهائياً بنجاح!":"Record permanently deleted successfully!"),await Yt(),c.endsWith("-form")&&yc(W)}catch(W){console.error("Permanent delete error:",W),alert((W==null?void 0:W.message)||"Permanent delete failed. Please try again."),Dn(_e=>({..._e,isDeleting:!1}))}},Je=async(m,W)=>{if(window.confirm(l.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){ye(!0);try{await Cy(m,W),alert(l.restoredOk||"Record restored successfully!"),await Yt()}catch(_e){console.error("Restore error:",_e),alert((_e==null?void 0:_e.message)||"Restore failed. Please try again.")}ye(!1)}},_h=async m=>{try{await Ly(m),await Yt()}catch(W){console.error("Disable user error:",W)}},wh=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.incidents,m.name);An({...Ln(),...W})}catch{An({...Ln(),...m})}y("incidents-form"),ye(!1)},kh=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.ideas,m.name);vn({...wn(),...W})}catch{vn({...wn(),...m})}y("ideas-form"),ye(!1)},Ch=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.orders,m.name);jn({...kn(),...W})}catch{jn({...kn(),...m})}y("orders-form"),ye(!1)},zh=async m=>{ae(!0),ye(!0);try{const W=await dl(m.name);bn({...W,progress_indicators:W.progress_indicators||[],cycle_logs:W.cycle_logs||[]}),y("processes-form")}catch{bn({...m,progress_indicators:m.progress_indicators||[]}),y("processes-form")}ye(!1)},Ih=m=>ke(P.organizations,m,Ks,sa(),"organizations-form",!0),Eh=m=>{ae(!0),Qs(m),y("group-companies-form")},Th=m=>{ae(!1),Qs(m),y("group-companies-form")},Ah=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.managements,m.name);vs({...ws(),...W})}catch{vs({...ws(),...m})}y("managements-form"),ye(!1)},Ph=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.departments,m.name);js({...ks(),...W})}catch{js({...ks(),...m})}y("departments-form"),ye(!1)},Rh=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.branches,m.name);bs({...Cs(),...W})}catch{bs({...Cs(),...m})}y("branches-form"),ye(!1)},Dh=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.cycles,m.name);Ss({...zs(),...W})}catch{Ss({...zs(),...m})}y("cycles-form"),ye(!1)},Oh=async m=>{ae(!0),ye(!0);try{const W=await Nt(P.kpiInput,m.name);_s({...Is(),...W})}catch{_s({...Is(),...m})}y("kpi-input-form"),ye(!1)},lt=async(m,W,_e,dt,Xt)=>{pe("loading");try{if(W.name)await Ds(m,W.name,W),pe("success"),Yt(),setTimeout(()=>pe("idle"),1500);else{const Ce=await ni(m,W),Wt=(Ce==null?void 0:Ce.data)??Ce;Xt&&Xt(Wt),pe("success"),Yt(),setTimeout(()=>pe("idle"),1500)}}catch(Ce){console.error("Submit error:",Ce),pe(Ce instanceof Error?Ce.message:"Error saving. Please try again.")}},Ge=async()=>{await Ey(),n()},ke=async(m,W,_e,dt,Xt,Ce)=>{ae(Ce),ye(!0);try{const Wt=await Nt(m,W.name);_e({...dt,...Wt})}catch{_e({...dt,...W})}y(Xt),ye(!1)},Lh=m=>ke(P.incidents,m,An,Ln(),"incidents-form",!1),Wh=m=>ke(P.ideas,m,vn,wn(),"ideas-form",!1),Nh=m=>ke(P.orders,m,jn,kn(),"orders-form",!1),Bh=m=>{ae(!1),ye(!0),dl(m.name).then(W=>{bn({...W,progress_indicators:W.progress_indicators||[],cycle_logs:W.cycle_logs||[]})}).catch(()=>{bn({...m,progress_indicators:m.progress_indicators||[]})}).finally(()=>{y("processes-form"),ye(!1)})},$h=m=>ke(P.organizations,m,Ks,sa(),"organizations-form",!1),Uh=m=>ke(P.managements,m,vs,ws(),"managements-form",!1),Mh=m=>ke(P.departments,m,js,ks(),"departments-form",!1),Fh=m=>ke(P.branches,m,bs,Cs(),"branches-form",!1),Hh=m=>ke(P.cycles,m,Ss,zs(),"cycles-form",!1),Gh=m=>ke(P.kpiInput,m,_s,Is(),"kpi-input-form",!1),Qh=async m=>{ae(!0),ye(!0);try{const W=await Jy(m.name);Ga({...al(),...W})}catch{Ga({...al(),...m})}y("delegations-form"),ye(!1)},Kh=async()=>{pe("loading");try{const m=[];Kt.incident_initial_evaluation&&m.push("incident_initial_evaluation"),Kt.idea_initial_evaluation&&m.push("idea_initial_evaluation"),await Ky(Kt.manager,m,Kt.organization,Kt.remarks||"",Kt.incident_name||"",Kt.idea_name||""),Ga(al()),pe("success"),Yt(),setTimeout(()=>{pe("idle"),y("delegations")},1500)}catch(m){console.error("Delegation submit error:",m),pe(m instanceof Error?m.message:"Error saving. Please try again.")}},Yh=async m=>{if(window.confirm(l.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){ye(!0);try{await Xy(m),await Yt()}catch(W){console.error("Revoke delegation error:",W),alert(W instanceof Error?W.message:"Revoke failed. Please try again.")}ye(!1)}},Xh=m=>ke(P.incidentTypes,m,Ys,aa(),"incident-types-form",!0),qh=m=>ke(P.incidentTypes,m,Ys,aa(),"incident-types-form",!1),Jh=m=>ke(P.ideaTypes,m,Xs,la(),"idea-types-form",!0),Vh=m=>ke(P.ideaTypes,m,Xs,la(),"idea-types-form",!1),Zh=m=>ke(P.orderTypes,m,qs,ra(),"order-types-form",!0),eg=m=>ke(P.orderTypes,m,qs,ra(),"order-types-form",!1),tg=m=>ke(P.processTypes,m,Js,ia(),"process-types-form",!0),ng=m=>ke(P.processTypes,m,Js,ia(),"process-types-form",!1),sg=m=>ke(P.incidentStatuses,m,Vs,oa(),"incident-statuses-form",!0),ag=m=>ke(P.incidentStatuses,m,Vs,oa(),"incident-statuses-form",!1),lg=m=>ke(P.ideaStatuses,m,Zs,da(),"idea-statuses-form",!0),rg=m=>ke(P.ideaStatuses,m,Zs,da(),"idea-statuses-form",!1),ig=m=>ke(P.orderStatuses,m,ea,ca(),"order-statuses-form",!0),og=m=>ke(P.orderStatuses,m,ea,ca(),"order-statuses-form",!1),dg=m=>ke(P.processStatuses,m,ta,ua(),"process-statuses-form",!0),cg=m=>ke(P.processStatuses,m,ta,ua(),"process-statuses-form",!1),ug=async m=>{mc(m),y("profile")},pg=m=>{ae(!1),gc(!1),Jl({...yr(),...m}),y("users-form")},fg=async()=>{pe("loading");try{if(!Tt.name){const{new_password:W,..._e}=Tt,dt=await ni("User",{..._e,send_welcome_email:0,user_type:"System User"}),Xt=(dt==null?void 0:dt.data)??dt,Ce=(Xt==null?void 0:Xt.name)||Tt.email;if(W&&Ce)try{await si(Ce,W)}catch(Wt){console.error("Password set error:",Wt)}if(Tt.custom_category==="Admin"&&Tt.custom_group_company){const Wt=De.find(cn=>cn.name===Tt.custom_group_company);if(Wt&&!Wt.owner_user)try{await Ds("SB Group Company",Wt.name,{owner_user:Ce})}catch(cn){console.error("GC owner sync error:",cn)}}Jl({...yr(),...Tt,...(dt==null?void 0:dt.data)??dt}),ae(!0),pe("success"),Yt(),setTimeout(()=>pe("idle"),1500)}else{const{name:W,email:_e,creation:dt,full_name:Xt,new_password:Ce,...Wt}=Tt;if(await Ds("User",W,Wt),Ce)try{await si(W,Ce)}catch(cn){console.error("Password set error:",cn)}if(Tt.custom_category==="Admin"&&Tt.custom_group_company){const cn=De.find(Ya=>Ya.name===Tt.custom_group_company);if(cn&&!cn.owner_user)try{await Ds("SB Group Company",cn.name,{owner_user:W})}catch(Ya){console.error("GC owner sync error:",Ya)}}pe("success"),Yt(),setTimeout(()=>pe("idle"),1500)}}catch(m){console.error("User submit error:",m),pe(m instanceof Error?m.message:"Error saving. Please try again.")}},Qe=()=>{const m=be.find(W=>W.name===e.name||W.username===e.name);mc(m||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),y("profile")},Ui=(m,W)=>{if(W){const dt={"processes-form":P.processes,"orders-form":P.orders,"incidents-form":P.incidents,"ideas-form":P.ideas}[m];if(dt){ae(!0),ye(!0),(m==="processes-form"?dl(W).then(Ce=>({...Ce,progress_indicators:Ce.progress_indicators||[],cycle_logs:Ce.cycle_logs||[]})):Nt(dt,W)).then(Ce=>{m==="processes-form"?bn(Ce):m==="orders-form"?jn({...kn(),...Ce}):m==="incidents-form"?An({...Ln(),...Ce}):m==="ideas-form"&&vn({...wn(),...Ce}),y(m),ye(!1)}).catch(()=>{y(m),ye(!1)});return}}y(m)},Ve=m=>t.jsxs(t.Fragment,{children:[m,t.jsx(Au,{isOpen:mt.isOpen,doctype:mt.doctype,docname:mt.name,docTitle:mt.title,isAdmin:r==="Admin"||e.name==="Administrator",isDeleting:mt.isDeleting,onClose:()=>Dn(W=>({...W,isOpen:!1})),onConfirmSoftDelete:vc,onConfirmPermanentDelete:jc})]});if(c==="incidents-form")return Ve(t.jsx(k0,{incForm:on,setIncForm:An,organizations:F,groupCompanies:De,managements:M,departments:L,branches:J,incidentTypes:oe,incidentClasses:ze,incidentFields:Gt,incidentStatuses:ne,users:Et,userRoleMap:K,formStatus:Xe,viewMode:qe||!p("incidents-form")||C(on.workflow_state),canModify:p("incidents-form"),onEdit:p("incidents-form")&&!C(on.workflow_state)&&!ts("incident",on.workflow_state)?()=>ae(!1):void 0,onDelete:p("incidents-form")?m=>de(P.incidents,m,on.title||on.number):void 0,onRestore:r==="Admin"?m=>Je(P.incidents,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.incidents,m,on.title||on.number):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,userRole:r,delegatedFunctions:Ha,delegatedOrgs:pt,onSubmit:()=>lt(P.incidents,on,()=>An(Ln()),"incidents",m=>An({...Ln(),...m})),onBack:()=>{y("incidents"),pe("idle")},onNavigate:y,onLogout:Ge,user:e,onRefresh:async()=>{if(on.name){const m=await Nt(P.incidents,on.name).catch(()=>null);m&&An({...Ln(),...m})}Oe(P.incidents).then(m=>E(m||[])).catch(()=>{})}}));if(c==="ideas-form")return Ve(t.jsx(E0,{ideaForm:dn,setIdeaForm:vn,organizations:F,groupCompanies:De,managements:M,departments:L,branches:J,ideaTypes:Lt,ideaStatuses:Ee,users:Et,userRoleMap:K,formStatus:Xe,viewMode:qe||!p("ideas-form")||C(dn.workflow_state),canModify:p("ideas-form"),onEdit:p("ideas-form")&&!C(dn.workflow_state)&&!ts("idea",dn.workflow_state)?()=>ae(!1):void 0,onDelete:p("ideas-form")?m=>de(P.ideas,m,dn.title||dn.number):void 0,onRestore:r==="Admin"?m=>Je(P.ideas,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.ideas,m,dn.title||dn.number):void 0,onNavigateToOrder:m=>ke(P.orders,{name:m},jn,kn(),"orders-form",!0),darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,userRole:r,delegatedFunctions:Ha,delegatedOrgs:pt,onSubmit:()=>lt(P.ideas,dn,()=>vn(wn()),"ideas",m=>vn({...wn(),...m})),onBack:()=>{y("ideas"),pe("idle")},onNavigate:y,onLogout:Ge,user:e,onRefresh:async()=>{if(dn.name){const m=await Nt(P.ideas,dn.name).catch(()=>null);m&&vn({...wn(),...m})}Oe(P.ideas).then(m=>H(m||[])).catch(()=>{})}}));if(c==="orders-form")return Ve(t.jsx(D0,{orderForm:Pn,setOrderForm:jn,organizations:F,groupCompanies:De,managements:M,departments:L,branches:J,orderTypes:me,orderStatuses:he,cycles:ys,users:Et,userRoleMap:K,formStatus:Xe,viewMode:qe||!p("orders-form"),canModify:p("orders-form"),onEdit:p("orders-form")&&!ts("order",Pn.workflow_state)?()=>ae(!1):void 0,onDelete:p("orders-form")?m=>de(P.orders,m,Pn.title||Pn.number):void 0,onRestore:r==="Admin"?m=>Je(P.orders,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.orders,m,Pn.title||Pn.number):void 0,onNavigateToIdea:m=>ke(P.ideas,{name:m},vn,wn(),"ideas-form",!0),darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,currentUser:e.name,userRole:r,onSubmit:()=>lt(P.orders,Pn,()=>jn(kn()),"orders",m=>jn({...kn(),...m})),onBack:()=>{y("orders"),pe("idle")},onNavigate:y,onLogout:Ge,user:e,onRefresh:async()=>{if(Pn.name){const m=await Nt(P.orders,Pn.name).catch(()=>null);m&&jn({...kn(),...m})}Oe(P.orders).then(m=>$(m||[])).catch(()=>{})}}));if(c==="processes-form")return Ve(t.jsx(B0,{processForm:Rn,setProcessForm:bn,organizations:F,groupCompanies:De,managements:M,departments:L,branches:J,processTypes:We,processStatuses:le,cycles:ys,users:Et,userRoleMap:K,formStatus:Xe,viewMode:qe||!p("processes-form"),canModify:p("processes-form"),onEdit:p("processes-form")&&!ts("process",Rn.workflow_state)?()=>ae(!1):void 0,onDelete:p("processes-form")?m=>de(P.processes,m,Rn.title||Rn.number):void 0,onRestore:r==="Admin"?m=>Je(P.processes,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.processes,m,Rn.title||Rn.number):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,userRole:e.role,onRefreshProcess:async()=>{if(Rn.name)try{const m=await dl(Rn.name);bn({...m,progress_indicators:m.progress_indicators||[],cycle_logs:m.cycle_logs||[]})}catch{}Oe(P.processes).then(m=>A(m||[])).catch(()=>{})},onSubmit:()=>lt(P.processes,Rn,()=>bn(xr()),"processes",m=>bn({...xr(),...m,progress_indicators:m.progress_indicators||[],cycle_logs:m.cycle_logs||[]})),onBack:()=>{y("processes"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="organizations-form")return Ve(t.jsx(G0,{orgForm:zi,setOrgForm:Ks,groupCompanies:De,formStatus:Xe,viewMode:qe||!p("organizations-form"),onEdit:p("organizations-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.organizations,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.organizations,m,zi.organization_name):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.organizations,zi,()=>Ks(sa()),"organizations",m=>{Ks({...sa(),...m}),ae(!0)}),onBack:()=>{y("organizations"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="managements-form")return Ve(t.jsx(q0,{form:Ii,setForm:vs,organizations:F,groupCompanies:De,formStatus:Xe,viewMode:qe||!p("managements-form"),onEdit:p("managements-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.managements,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.managements,m,Ii.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.managements,Ii,()=>vs(ws()),"managements",m=>{vs({...ws(),...m}),ae(!0)}),onBack:()=>{y("managements"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="departments-form")return Ve(t.jsx(Z0,{form:Ei,setForm:js,organizations:F,groupCompanies:De,managements:M,formStatus:Xe,viewMode:qe||!p("departments-form"),onEdit:p("departments-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.departments,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.departments,m,Ei.department_name):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.departments,Ei,()=>js(ks()),"departments",m=>{js({...ks(),...m}),ae(!0)}),onBack:()=>{y("departments"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="branches-form")return Ve(t.jsx(n1,{form:Ti,setForm:bs,organizations:F,groupCompanies:De,managements:M,departments:L,formStatus:Xe,viewMode:qe||!p("branches-form"),onEdit:p("branches-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.branches,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.branches,m,Ti.branch):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.branches,Ti,()=>bs(Cs()),"branches",m=>{bs({...Cs(),...m}),ae(!0)}),onBack:()=>{y("branches"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="cycles-form")return Ve(t.jsx(D1,{form:Bi,setForm:Ss,organizations:F,groupCompanies:De,formStatus:Xe,viewMode:qe||!p("cycles-form"),onEdit:p("cycles-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.cycles,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.cycles,m,Bi.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.cycles,Bi,()=>Ss(zs()),"cycles",m=>{Ss({...zs(),...m}),ae(!0)}),onBack:()=>{y("cycles"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="kpi-input-form")return Ve(t.jsx(L1,{form:$i,setForm:_s,organizations:F,groupCompanies:De,formStatus:Xe,viewMode:qe||!p("kpi-input-form"),onEdit:p("kpi-input-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.kpiInput,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.kpiInput,m,$i.period):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.kpiInput,$i,()=>_s(Is()),"kpi-input",m=>{_s({...Is(),...m}),ae(!0)}),onBack:()=>{y("kpi-input"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="incident-types-form")return Ve(t.jsx(l1,{form:Ai,setForm:Ys,formStatus:Xe,viewMode:qe||!p("incident-types-form"),onEdit:p("incident-types-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.incidentTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.incidentTypes,m,Ai.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.incidentTypes,Ai,()=>Ys(aa()),"incident-types",m=>{Ys({...aa(),...m}),ae(!0)}),onBack:()=>{y("incident-types"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="idea-types-form")return Ve(t.jsx(o1,{form:Pi,setForm:Xs,formStatus:Xe,viewMode:qe||!p("idea-types-form"),onEdit:p("idea-types-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.ideaTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.ideaTypes,m,Pi.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.ideaTypes,Pi,()=>Xs(la()),"idea-types",m=>{Xs({...la(),...m}),ae(!0)}),onBack:()=>{y("idea-types"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="order-types-form")return Ve(t.jsx(u1,{form:Ri,setForm:qs,formStatus:Xe,viewMode:qe||!p("order-types-form"),onEdit:p("order-types-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.orderTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.orderTypes,m,Ri.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.orderTypes,Ri,()=>qs(ra()),"order-types",m=>{qs({...ra(),...m}),ae(!0)}),onBack:()=>{y("order-types"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="process-types-form")return Ve(t.jsx(h1,{form:Di,setForm:Js,formStatus:Xe,viewMode:qe||!p("process-types-form"),onEdit:p("process-types-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.processTypes,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.processTypes,m,Di.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.processTypes,Di,()=>Js(ia()),"process-types",m=>{Js({...ia(),...m}),ae(!0)}),onBack:()=>{y("process-types"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="incident-statuses-form")return Ve(t.jsx(x1,{form:Oi,setForm:Vs,formStatus:Xe,viewMode:qe||!p("incident-statuses-form"),onEdit:p("incident-statuses-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.incidentStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.incidentStatuses,m,Oi.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.incidentStatuses,Oi,()=>Vs(oa()),"incident-statuses",m=>{Vs({...oa(),...m}),ae(!0)}),onBack:()=>{y("incident-statuses"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="idea-statuses-form")return Ve(t.jsx(j1,{form:Li,setForm:Zs,formStatus:Xe,viewMode:qe||!p("idea-statuses-form"),onEdit:p("idea-statuses-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.ideaStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.ideaStatuses,m,Li.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.ideaStatuses,Li,()=>Zs(da()),"idea-statuses",m=>{Zs({...da(),...m}),ae(!0)}),onBack:()=>{y("idea-statuses"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="order-statuses-form")return Ve(t.jsx(_1,{form:Wi,setForm:ea,formStatus:Xe,viewMode:qe||!p("order-statuses-form"),onEdit:p("order-statuses-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.orderStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.orderStatuses,m,Wi.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.orderStatuses,Wi,()=>ea(ca()),"order-statuses",m=>{ea({...ca(),...m}),ae(!0)}),onBack:()=>{y("order-statuses"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="process-statuses-form")return Ve(t.jsx(C1,{form:Ni,setForm:ta,formStatus:Xe,viewMode:qe||!p("process-statuses-form"),onEdit:p("process-statuses-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.processStatuses,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.processStatuses,m,Ni.name1):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.processStatuses,Ni,()=>ta(ua()),"process-statuses",m=>{ta({...ua(),...m}),ae(!0)}),onBack:()=>{y("process-statuses"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="users-form")return Ve(t.jsx(T1,{form:Tt,setForm:Jl,groupCompanies:De,organizations:F,managements:M,departments:L,branches:J,users:Et,formStatus:Xe,viewMode:qe||!p("users-form"),onEdit:p("users-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.users,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.users,m,Tt.full_name||Tt.email):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,isSelfProfile:hc,onSubmit:fg,onBack:()=>{y(hc?i?"dashboard":"inbox":"users"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));if(c==="delegations-form"){const m=Kt.status==="Revoked"||Kt.status==="Accepted"||Kt.status==="Rejected";return Ve(t.jsx(M1,{form:Kt,setForm:Ga,organizations:F,users:Et,userRoleMap:K,incidents:T,ideas:te,formStatus:Xe,viewMode:qe||!p("delegations-form")||m,onEdit:p("delegations-form")&&!m?()=>ae(!1):void 0,onRestore:r==="Admin"?W=>Je(P.delegations,W):void 0,onPermanentDelete:r==="Admin"?W=>de(P.delegations,W,Kt.name):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:Kh,onBack:()=>{y("delegations"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}))}if(c==="group-companies-form")return Ve(t.jsx(K0,{form:ki,setForm:Qs,users:Et,formStatus:Xe,viewMode:qe||!p("group-companies-form"),onEdit:p("group-companies-form")?()=>ae(!1):void 0,onRestore:r==="Admin"?m=>Je(P.groupCompanies,m):void 0,onPermanentDelete:r==="Admin"?m=>de(P.groupCompanies,m,ki.company_name):void 0,darkMode:s,notifCount:u,onToggleDark:a,onCountChange:b,onViewProfile:Qe,onSubmit:()=>lt(P.groupCompanies,ki,()=>Qs(Xl()),"group-companies",m=>{Qs({...Xl(),...m}),ae(!0)}),onBack:()=>{y("group-companies"),pe("idle")},onNavigate:y,onLogout:Ge,user:e}));const Mi={...l.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},hg={"group-companies":{color:V.purple,formPage:"group-companies-form",reset:()=>Qs(Xl())},incidents:{color:V.accent,formPage:"incidents-form",reset:()=>{const m=z||o;An({...Ln(),organization:m,group_company:k||g(m)})}},ideas:{color:V.teal,formPage:"ideas-form",reset:()=>{const m=z||o;vn({...wn(),organization:m,group_company:k||g(m)})}},orders:{color:V.purple,formPage:"orders-form",reset:()=>{const m=z||o;jn({...kn(),organization:m,group_company:k||g(m)})}},processes:{color:V.blue,formPage:"processes-form",reset:()=>{const m=pt.create_processes,W=z||(r==="Manager"&&m&&m.length===1?m[0]:o);bn({...xr(),organization:W,group_company:k||g(W)})}},organizations:{color:V.accent,formPage:"organizations-form",reset:()=>Ks({...sa(),group_company:k})},managements:{color:V.blue,formPage:"managements-form",reset:()=>{const m=z||o;vs({...ws(),organization:m,group_company:k||g(m)})}},departments:{color:V.teal,formPage:"departments-form",reset:()=>{const m=z||o;js({...ks(),custom_organization:m,group_company:k||g(m)})}},branches:{color:V.purple,formPage:"branches-form",reset:()=>{const m=z||o;bs({...Cs(),organization:m,group_company:k||g(m)})}},cycles:{color:V.teal,formPage:"cycles-form",reset:()=>{const m=z||o;Ss({...zs(),organization:m,group_company:k||g(m)})}},"kpi-input":{color:V.blue,formPage:"kpi-input-form",reset:()=>{const m=z||o;_s({...Is(),organization:m,group_company:k||g(m)})}},"incident-types":{color:V.red,formPage:"incident-types-form",reset:()=>Ys(aa())},"idea-types":{color:V.orange,formPage:"idea-types-form",reset:()=>Xs(la())},"order-types":{color:V.green,formPage:"order-types-form",reset:()=>qs(ra())},"process-types":{color:V.accent,formPage:"process-types-form",reset:()=>Js(ia())},"incident-statuses":{color:V.red,formPage:"incident-statuses-form",reset:()=>Vs(oa())},"idea-statuses":{color:V.teal,formPage:"idea-statuses-form",reset:()=>Zs(da())},"order-statuses":{color:V.purple,formPage:"order-statuses-form",reset:()=>ea(ca())},"process-statuses":{color:V.blue,formPage:"process-statuses-form",reset:()=>ta(ua())},users:{color:V.blue,formPage:"users-form",reset:()=>{Jl({...yr(),custom_group_company:k}),gc(!1)}},delegations:{color:V.purple,formPage:"delegations-form",reset:()=>Ga(al())}},gg={"group-companies":"New Group Company",incidents:l.formTitle.newIncident,ideas:l.formTitle.newIdea,orders:l.formTitle.newOrder,processes:l.formTitle.newProcess,organizations:l.formTitle.newOrg,managements:l.formTitle.newMgmt,departments:l.formTitle.newDept,branches:l.formTitle.newBranch,users:l.formTitle.newUser,cycles:l.formTitle.newCycle,"kpi-input":l.formTitle.newKpi,delegations:l.formTitle.newDelegation,"incident-types":"New Incident Type","idea-types":"New Idea Type","order-types":"New Order Type","process-types":"New Process Type","incident-statuses":"New Incident Status","idea-statuses":"New Idea Status","order-statuses":"New Order Status","process-statuses":"New Process Status"},mg={incidents:T,ideas:te,orders:Y,processes:I,organizations:F,managements:M,departments:L,branches:J,cycles:ys,"kpi-input":Gl,"incident-types":oe,"idea-types":Lt,"order-types":me,"process-types":We,"incident-statuses":ne,"idea-statuses":Ee,"order-statuses":he,"process-statuses":le,users:be,delegations:Kl},Qa=cy[c],Ka=mg[c],ee=p(c),Fi=ee?hg[c]:null;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":V.bg},children:[t.jsx(ch,{collapsed:xh,onToggleCollapsed:vh,activePage:c,onNavigate:m=>y(m),hasDashboard:i,hasReports:d,hasDelegations:f,role:r,rtl:l.rtl,navLabels:l.nav,settingsLabel:l.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:s?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${s?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:s?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:t.jsx(fh,{notifCount:u,darkMode:s,onCountChange:b,onToggleDark:a,onNavigate:Ui,onViewProfile:Qe,onLogout:Ge,userName:e.full_name||e.name,userRole:r})}),c!=="profile"&&t.jsxs("div",{style:{background:s?"#1e293b":"white",padding:"12px 24px",borderBottom:`1px solid ${s?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:18,fontWeight:700,color:s?"#e2e8f0":"#0f172a"},children:Mi[c]||c}),Ka&&t.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Ka.length," ",Mi[c]?Mi[c].toLowerCase():"records"]})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[Qa&&Ka&&t.jsx("button",{onClick:()=>Ci(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:"📊 Export"}),Fi&&t.jsxs("button",{onClick:()=>{Fi.reset(),ae(!1),pe("idle"),y(Fi.formPage)},style:{background:"#2563eb",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:["+ ",gg[c]||l.new]})]})]}),Qa&&Ka&&jh&&t.jsx(_y,{title:Qa.label,rows:Ka,selectedRows:bh,pageRows:Sh,columns:Qa.columns,defaultColumnKeys:Qa.defaultColumns,filenameBase:c,onClose:()=>Ci(!1)}),t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:c==="profile"?0:"20px 24px",gap:c==="profile"?0:16},children:[Te&&t.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:l.loading}),!Te&&c==="dashboard"&&i&&t.jsx(h0,{incidents:T,ideas:te,orders:Y,processes:I,organizations:F,incidentStatuses:ne,ideaStatuses:Ee,orderStatuses:he,processStatuses:le,selectedOrg:o,onOrgChange:h,onNavigate:Ui,onNavigateStatus:w,userRole:r}),!Te&&c==="inbox"&&t.jsx(Q1,{onNavigate:Ui,onRefresh:Yt}),!Te&&c==="reports"&&d&&t.jsx(V1,{organizations:F,userRole:r}),!Te&&c==="incidents"&&t.jsx(m0,{incidents:T,organizations:F,departments:L,branches:J,incidentStatuses:ne,initialOrg:o,initialStatus:x,onView:wh,onEdit:ee?Lh:void 0,onDelete:ee?m=>de(P.incidents,m):void 0,canModify:ee,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="ideas"&&t.jsx(C0,{ideas:te,organizations:F,departments:L,branches:J,ideaStatuses:Ee,initialOrg:o,initialStatus:x,onView:kh,onEdit:ee?Wh:void 0,onDelete:ee?m=>de(P.ideas,m):void 0,canModify:ee,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="orders"&&t.jsx(T0,{orders:Y,organizations:F,departments:L,branches:J,orderStatuses:he,initialOrg:o,initialStatus:x,onView:Ch,onEdit:ee?Nh:void 0,onDelete:ee?m=>de(P.orders,m):void 0,canModify:ee,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="processes"&&t.jsx(O0,{processes:I,organizations:F,departments:L,branches:J,processStatuses:le,initialOrg:o,initialStatus:x,onView:zh,onEdit:ee?Bh:void 0,onDelete:ee?m=>de(P.processes,m):void 0,canModify:ee,userRole:r,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="organizations"&&t.jsx(H0,{organizations:F,onView:Ih,onEdit:ee?$h:void 0,onDelete:ee?m=>de(P.organizations,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="group-companies"&&t.jsx(Q0,{groupCompanies:De,onView:Eh,onEdit:ee?Th:void 0,onDelete:ee?m=>de(P.groupCompanies,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="managements"&&t.jsx(X0,{managements:M,onView:Ah,onEdit:ee?Uh:void 0,onDelete:ee?m=>de(P.managements,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="departments"&&t.jsx(V0,{departments:L,managements:M,onView:Ph,onEdit:ee?Mh:void 0,onDelete:ee?m=>de(P.departments,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="branches"&&t.jsx(t1,{branches:J,managements:M,departments:L,onView:Rh,onEdit:ee?Fh:void 0,onDelete:ee?m=>de(P.branches,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="cycles"&&t.jsx(A1,{cycles:ys,canModify:ee,onView:Dh,onEdit:ee?Hh:void 0,onDelete:ee?m=>de(P.cycles,m):void 0,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="kpi-input"&&t.jsx(O1,{kpiInputs:Gl,canModify:ee,onView:Oh,onEdit:ee?Gh:void 0,onDelete:ee?m=>de(P.kpiInput,m):void 0,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="incident-types"&&t.jsx(a1,{incidentTypes:oe,onView:Xh,onEdit:ee?qh:void 0,onDelete:ee?m=>de(P.incidentTypes,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="idea-types"&&t.jsx(i1,{ideaTypes:Lt,onView:Jh,onEdit:ee?Vh:void 0,onDelete:ee?m=>de(P.ideaTypes,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="order-types"&&t.jsx(c1,{orderTypes:me,onView:Zh,onEdit:ee?eg:void 0,onDelete:ee?m=>de(P.orderTypes,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="process-types"&&t.jsx(f1,{processTypes:We,onView:tg,onEdit:ee?ng:void 0,onDelete:ee?m=>de(P.processTypes,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="incident-statuses"&&t.jsx(m1,{incidentStatuses:ne,onView:sg,onEdit:ee?ag:void 0,onDelete:ee?m=>de(P.incidentStatuses,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="idea-statuses"&&t.jsx(v1,{ideaStatuses:Ee,onView:lg,onEdit:ee?rg:void 0,onDelete:ee?m=>de(P.ideaStatuses,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="order-statuses"&&t.jsx(S1,{orderStatuses:he,onView:ig,onEdit:ee?og:void 0,onDelete:ee?m=>de(P.orderStatuses,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="process-statuses"&&t.jsx(k1,{processStatuses:le,onView:dg,onEdit:ee?cg:void 0,onDelete:ee?m=>de(P.processStatuses,m):void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="users"&&t.jsx(E1,{users:be,roleMap:K,onView:ug,onEdit:ee?pg:void 0,onDelete:ee?m=>de("User",m):void 0,onDisable:ee?_h:void 0,canModify:ee,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),!Te&&c==="delegations"&&f&&t.jsx($1,{delegations:Kl,organizations:F,userRole:r,currentUser:e.name,onView:Qh,onRevoke:ee?Yh:void 0,onSelectionChange:(m,W)=>{Fe(m),He(W)}}),c==="profile"&&(()=>{const m=!!ql&&(ql.name===e.name||ql.email===e.name);return t.jsx(U0,{user:e,profileUser:ql,sbUsers:be,organizations:F,groupCompanies:De,managements:M,departments:L,branches:J,darkMode:s,canModify:ee||m,onBack:()=>y(m?i?"dashboard":"inbox":"users"),onNavigate:y})})()]})]}),t.jsx(Au,{isOpen:mt.isOpen,doctype:mt.doctype,docname:mt.name,docTitle:mt.title,isAdmin:r==="Admin"||e.name==="Administrator",isDeleting:mt.isDeleting,onClose:()=>Dn(m=>({...m,isOpen:!1})),onConfirmSoftDelete:vc,onConfirmPermanentDelete:jc})]})}function iv(e){return e.some(n=>["CEO","Ceo","SB CEO"].includes(n))?"CEO":e.some(n=>["SB Admin","System Manager"].includes(n))?"Admin":e.includes("SB Manager")?"Manager":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":"Employee"}function ov(){const[e,n]=S.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[s,a]=S.useState(()=>localStorage.getItem("sb_dark")==="1"),l=()=>{const d=!s;a(d),localStorage.setItem("sb_dark",d?"1":"0"),document.documentElement.classList.toggle("dark",d)};S.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),S.useEffect(()=>{e&&uh().then(async d=>{const f=d||e.name,p=await ph(f);if(!p.length)return;const C=iv(p),j=await $y();if(C!==e.role||f!==e.name||j!==(e.custom_organization||"")){const c={...e,name:f,role:C,custom_organization:j};n(c),localStorage.setItem("sidrah_user",JSON.stringify(c))}})},[e==null?void 0:e.name]);const r=d=>{n(d),localStorage.setItem("sidrah_user",JSON.stringify(d))},i=()=>{n(null),localStorage.removeItem("sidrah_user")};return e?t.jsx(rv,{user:e,onLogout:i,darkMode:s,onToggleDark:l}):t.jsx(i0,{onLogin:r})}sh(document.getElementById("root")).render(t.jsx(S.StrictMode,{children:t.jsx(ov,{})}));
|