2026-10-09 12:16:48 +05:30

53 lines
562 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&l(i)}).observe(document,{childList:!0,subtree:!0});function s(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function l(r){if(r.ep)return;r.ep=!0;const a=s(r);fetch(r.href,a)}})();var Lu={exports:{}},$a={},Ou={exports:{}},ce={};/**
* @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 kr=Symbol.for("react.element"),Ag=Symbol.for("react.portal"),Rg=Symbol.for("react.fragment"),Dg=Symbol.for("react.strict_mode"),Lg=Symbol.for("react.profiler"),Og=Symbol.for("react.provider"),Ng=Symbol.for("react.context"),Wg=Symbol.for("react.forward_ref"),Bg=Symbol.for("react.suspense"),$g=Symbol.for("react.memo"),Ug=Symbol.for("react.lazy"),dc=Symbol.iterator;function Fg(e){return e===null||typeof e!="object"?null:(e=dc&&e[dc]||e["@@iterator"],typeof e=="function"?e:null)}var Nu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Wu=Object.assign,Bu={};function Cl(e,n,s){this.props=e,this.context=n,this.refs=Bu,this.updater=s||Nu}Cl.prototype.isReactComponent={};Cl.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")};Cl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function $u(){}$u.prototype=Cl.prototype;function $o(e,n,s){this.props=e,this.context=n,this.refs=Bu,this.updater=s||Nu}var Uo=$o.prototype=new $u;Uo.constructor=$o;Wu(Uo,Cl.prototype);Uo.isPureReactComponent=!0;var cc=Array.isArray,Uu=Object.prototype.hasOwnProperty,Fo={current:null},Fu={key:!0,ref:!0,__self:!0,__source:!0};function Mu(e,n,s){var l,r={},a=null,i=null;if(n!=null)for(l in n.ref!==void 0&&(i=n.ref),n.key!==void 0&&(a=""+n.key),n)Uu.call(n,l)&&!Fu.hasOwnProperty(l)&&(r[l]=n[l]);var d=arguments.length-2;if(d===1)r.children=s;else if(1<d){for(var p=Array(d),u=0;u<d;u++)p[u]=arguments[u+2];r.children=p}if(e&&e.defaultProps)for(l in d=e.defaultProps,d)r[l]===void 0&&(r[l]=d[l]);return{$$typeof:kr,type:e,key:a,ref:i,props:r,_owner:Fo.current}}function Mg(e,n){return{$$typeof:kr,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function Mo(e){return typeof e=="object"&&e!==null&&e.$$typeof===kr}function Hg(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return n[s]})}var uc=/\/+/g;function gi(e,n){return typeof e=="object"&&e!==null&&e.key!=null?Hg(""+e.key):n.toString(36)}function na(e,n,s,l,r){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(a){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case kr:case Ag:i=!0}}if(i)return i=e,r=r(i),e=l===""?"."+gi(i,0):l,cc(r)?(s="",e!=null&&(s=e.replace(uc,"$&/")+"/"),na(r,n,s,"",function(u){return u})):r!=null&&(Mo(r)&&(r=Mg(r,s+(!r.key||i&&i.key===r.key?"":(""+r.key).replace(uc,"$&/")+"/")+e)),n.push(r)),1;if(i=0,l=l===""?".":l+":",cc(e))for(var d=0;d<e.length;d++){a=e[d];var p=l+gi(a,d);i+=na(a,n,s,p,r)}else if(p=Fg(e),typeof p=="function")for(e=p.call(e),d=0;!(a=e.next()).done;)a=a.value,p=l+gi(a,d++),i+=na(a,n,s,p,r);else if(a==="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 Lr(e,n,s){if(e==null)return e;var l=[],r=0;return na(e,l,"","",function(a){return n.call(s,a,r++)}),l}function Gg(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 jt={current:null},sa={transition:null},Kg={ReactCurrentDispatcher:jt,ReactCurrentBatchConfig:sa,ReactCurrentOwner:Fo};function Hu(){throw Error("act(...) is not supported in production builds of React.")}ce.Children={map:Lr,forEach:function(e,n,s){Lr(e,function(){n.apply(this,arguments)},s)},count:function(e){var n=0;return Lr(e,function(){n++}),n},toArray:function(e){return Lr(e,function(n){return n})||[]},only:function(e){if(!Mo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ce.Component=Cl;ce.Fragment=Rg;ce.Profiler=Lg;ce.PureComponent=$o;ce.StrictMode=Dg;ce.Suspense=Bg;ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Kg;ce.act=Hu;ce.cloneElement=function(e,n,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var l=Wu({},e.props),r=e.key,a=e.ref,i=e._owner;if(n!=null){if(n.ref!==void 0&&(a=n.ref,i=Fo.current),n.key!==void 0&&(r=""+n.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(p in n)Uu.call(n,p)&&!Fu.hasOwnProperty(p)&&(l[p]=n[p]===void 0&&d!==void 0?d[p]:n[p])}var p=arguments.length-2;if(p===1)l.children=s;else if(1<p){d=Array(p);for(var u=0;u<p;u++)d[u]=arguments[u+2];l.children=d}return{$$typeof:kr,type:e.type,key:r,ref:a,props:l,_owner:i}};ce.createContext=function(e){return e={$$typeof:Ng,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Og,_context:e},e.Consumer=e};ce.createElement=Mu;ce.createFactory=function(e){var n=Mu.bind(null,e);return n.type=e,n};ce.createRef=function(){return{current:null}};ce.forwardRef=function(e){return{$$typeof:Wg,render:e}};ce.isValidElement=Mo;ce.lazy=function(e){return{$$typeof:Ug,_payload:{_status:-1,_result:e},_init:Gg}};ce.memo=function(e,n){return{$$typeof:$g,type:e,compare:n===void 0?null:n}};ce.startTransition=function(e){var n=sa.transition;sa.transition={};try{e()}finally{sa.transition=n}};ce.unstable_act=Hu;ce.useCallback=function(e,n){return jt.current.useCallback(e,n)};ce.useContext=function(e){return jt.current.useContext(e)};ce.useDebugValue=function(){};ce.useDeferredValue=function(e){return jt.current.useDeferredValue(e)};ce.useEffect=function(e,n){return jt.current.useEffect(e,n)};ce.useId=function(){return jt.current.useId()};ce.useImperativeHandle=function(e,n,s){return jt.current.useImperativeHandle(e,n,s)};ce.useInsertionEffect=function(e,n){return jt.current.useInsertionEffect(e,n)};ce.useLayoutEffect=function(e,n){return jt.current.useLayoutEffect(e,n)};ce.useMemo=function(e,n){return jt.current.useMemo(e,n)};ce.useReducer=function(e,n,s){return jt.current.useReducer(e,n,s)};ce.useRef=function(e){return jt.current.useRef(e)};ce.useState=function(e){return jt.current.useState(e)};ce.useSyncExternalStore=function(e,n,s){return jt.current.useSyncExternalStore(e,n,s)};ce.useTransition=function(){return jt.current.useTransition()};ce.version="18.3.1";Ou.exports=ce;var S=Ou.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,Yg=Symbol.for("react.element"),Xg=Symbol.for("react.fragment"),qg=Object.prototype.hasOwnProperty,Jg=Qg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vg={key:!0,ref:!0,__self:!0,__source:!0};function Gu(e,n,s){var l,r={},a=null,i=null;s!==void 0&&(a=""+s),n.key!==void 0&&(a=""+n.key),n.ref!==void 0&&(i=n.ref);for(l in n)qg.call(n,l)&&!Vg.hasOwnProperty(l)&&(r[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)r[l]===void 0&&(r[l]=n[l]);return{$$typeof:Yg,type:e,key:a,ref:i,props:r,_owner:Jg.current}}$a.Fragment=Xg;$a.jsx=Gu;$a.jsxs=Gu;Lu.exports=$a;var t=Lu.exports,Ku={exports:{}},Lt={},Qu={exports:{}},Yu={};/**
* @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(G,X){var J=G.length;G.push(X);e:for(;0<J;){var W=J-1>>>1,Z=G[W];if(0<r(Z,X))G[W]=X,G[J]=Z,J=W;else break e}}function s(G){return G.length===0?null:G[0]}function l(G){if(G.length===0)return null;var X=G[0],J=G.pop();if(J!==X){G[0]=J;e:for(var W=0,Z=G.length,pe=Z>>>1;W<pe;){var be=2*(W+1)-1,ae=G[be],Je=be+1,it=G[Je];if(0>r(ae,J))Je<Z&&0>r(it,ae)?(G[W]=it,G[Je]=J,W=Je):(G[W]=ae,G[be]=J,W=be);else if(Je<Z&&0>r(it,J))G[W]=it,G[Je]=J,W=Je;else break e}}return X}function r(G,X){var J=G.sortIndex-X.sortIndex;return J!==0?J:G.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var i=Date,d=i.now();e.unstable_now=function(){return i.now()-d}}var p=[],u=[],C=1,x=null,m=3,h=!1,b=!1,_=!1,v=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 c(G){for(var X=s(u);X!==null;){if(X.callback===null)l(u);else if(X.startTime<=G)l(u),X.sortIndex=X.expirationTime,n(p,X);else break;X=s(u)}}function y(G){if(_=!1,c(G),!b)if(s(p)!==null)b=!0,D(z);else{var X=s(u);X!==null&&H(y,X.startTime-G)}}function z(G,X){b=!1,_&&(_=!1,g(w),w=-1),h=!0;var J=m;try{for(c(X),x=s(p);x!==null&&(!(x.expirationTime>X)||G&&!Y());){var W=x.callback;if(typeof W=="function"){x.callback=null,m=x.priorityLevel;var Z=W(x.expirationTime<=X);X=e.unstable_now(),typeof Z=="function"?x.callback=Z:x===s(p)&&l(p),c(X)}else l(p);x=s(p)}if(x!==null)var pe=!0;else{var be=s(u);be!==null&&H(y,be.startTime-X),pe=!1}return pe}finally{x=null,m=J,h=!1}}var k=!1,f=null,w=-1,I=5,P=-1;function Y(){return!(e.unstable_now()-P<I)}function F(){if(f!==null){var G=e.unstable_now();P=G;var X=!0;try{X=f(!0,G)}finally{X?$():(k=!1,f=null)}}else k=!1}var $;if(typeof o=="function")$=function(){o(F)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,E=U.port2;U.port1.onmessage=F,$=function(){E.postMessage(null)}}else $=function(){v(F,0)};function D(G){f=G,k||(k=!0,$())}function H(G,X){w=v(function(){G(e.unstable_now())},X)}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(G){G.callback=null},e.unstable_continueExecution=function(){b||h||(b=!0,D(z))},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return s(p)},e.unstable_next=function(G){switch(m){case 1:case 2:case 3:var X=3;break;default:X=m}var J=m;m=X;try{return G()}finally{m=J}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,X){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var J=m;m=G;try{return X()}finally{m=J}},e.unstable_scheduleCallback=function(G,X,J){var W=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?W+J:W):J=W,G){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=J+Z,G={id:C++,callback:X,priorityLevel:G,startTime:J,expirationTime:Z,sortIndex:-1},J>W?(G.sortIndex=J,n(u,G),s(p)===null&&G===s(u)&&(_?(g(w),w=-1):_=!0,H(y,J-W))):(G.sortIndex=Z,n(p,G),b||h||(b=!0,D(z))),G},e.unstable_shouldYield=Y,e.unstable_wrapCallback=function(G){var X=m;return function(){var J=m;m=X;try{return G.apply(this,arguments)}finally{m=J}}}})(Yu);Qu.exports=Yu;var Zg=Qu.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 ex=S,Dt=Zg;function K(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 Xu=new Set,rr={};function Ts(e,n){ml(e,n),ml(e+"Capture",n)}function ml(e,n){for(rr[e]=n,e=0;e<n.length;e++)Xu.add(n[e])}var zn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hi=Object.prototype.hasOwnProperty,tx=/^[: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]*$/,pc={},fc={};function nx(e){return Hi.call(fc,e)?!0:Hi.call(pc,e)?!1:tx.test(e)?fc[e]=!0:(pc[e]=!0,!1)}function sx(e,n,s,l){if(s!==null&&s.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function lx(e,n,s,l){if(n===null||typeof n>"u"||sx(e,n,s,l))return!0;if(l)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 bt(e,n,s,l,r,a,i){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=r,this.mustUseProperty=s,this.propertyName=e,this.type=n,this.sanitizeURL=a,this.removeEmptyString=i}var ct={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ct[e]=new bt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];ct[n]=new bt(n,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ct[e]=new bt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ct[e]=new bt(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){ct[e]=new bt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ct[e]=new bt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ct[e]=new bt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ct[e]=new bt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ct[e]=new bt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ho=/[\-:]([a-z])/g;function Go(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(Ho,Go);ct[n]=new bt(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(Ho,Go);ct[n]=new bt(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(Ho,Go);ct[n]=new bt(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ct[e]=new bt(e,1,!1,e.toLowerCase(),null,!1,!1)});ct.xlinkHref=new bt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ct[e]=new bt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ko(e,n,s,l){var r=ct.hasOwnProperty(n)?ct[n]:null;(r!==null?r.type!==0:l||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(lx(n,s,r,l)&&(s=null),l||r===null?nx(n)&&(s===null?e.removeAttribute(n):e.setAttribute(n,""+s)):r.mustUseProperty?e[r.propertyName]=s===null?r.type===3?!1:"":s:(n=r.attributeName,l=r.attributeNamespace,s===null?e.removeAttribute(n):(r=r.type,s=r===3||r===4&&s===!0?"":""+s,l?e.setAttributeNS(l,n,s):e.setAttribute(n,s))))}var Pn=ex.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Or=Symbol.for("react.element"),Vs=Symbol.for("react.portal"),Zs=Symbol.for("react.fragment"),Qo=Symbol.for("react.strict_mode"),Gi=Symbol.for("react.profiler"),qu=Symbol.for("react.provider"),Ju=Symbol.for("react.context"),Yo=Symbol.for("react.forward_ref"),Ki=Symbol.for("react.suspense"),Qi=Symbol.for("react.suspense_list"),Xo=Symbol.for("react.memo"),On=Symbol.for("react.lazy"),Vu=Symbol.for("react.offscreen"),hc=Symbol.iterator;function Ll(e){return e===null||typeof e!="object"?null:(e=hc&&e[hc]||e["@@iterator"],typeof e=="function"?e:null)}var Le=Object.assign,xi;function Gl(e){if(xi===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);xi=n&&n[1]||""}return`
`+xi+e}var mi=!1;function yi(e,n){if(!e||mi)return"";mi=!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(u){var l=u}Reflect.construct(e,[],n)}else{try{n.call()}catch(u){l=u}e.call(n.prototype)}else{try{throw Error()}catch(u){l=u}e()}}catch(u){if(u&&l&&typeof u.stack=="string"){for(var r=u.stack.split(`
`),a=l.stack.split(`
`),i=r.length-1,d=a.length-1;1<=i&&0<=d&&r[i]!==a[d];)d--;for(;1<=i&&0<=d;i--,d--)if(r[i]!==a[d]){if(i!==1||d!==1)do if(i--,d--,0>d||r[i]!==a[d]){var p=`
`+r[i].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),p}while(1<=i&&0<=d);break}}}finally{mi=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?Gl(e):""}function rx(e){switch(e.tag){case 5:return Gl(e.type);case 16:return Gl("Lazy");case 13:return Gl("Suspense");case 19:return Gl("SuspenseList");case 0:case 2:case 15:return e=yi(e.type,!1),e;case 11:return e=yi(e.type.render,!1),e;case 1:return e=yi(e.type,!0),e;default:return""}}function Yi(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 Zs:return"Fragment";case Vs:return"Portal";case Gi:return"Profiler";case Qo:return"StrictMode";case Ki:return"Suspense";case Qi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ju:return(e.displayName||"Context")+".Consumer";case qu:return(e._context.displayName||"Context")+".Provider";case Yo:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Xo:return n=e.displayName||null,n!==null?n:Yi(e.type)||"Memo";case On:n=e._payload,e=e._init;try{return Yi(e(n))}catch{}}return null}function ax(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 Yi(n);case 8:return n===Qo?"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 Vn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Zu(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function ix(e){var n=Zu(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var r=s.get,a=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return r.call(this)},set:function(i){l=""+i,a.call(this,i)}}),Object.defineProperty(e,n,{enumerable:s.enumerable}),{getValue:function(){return l},setValue:function(i){l=""+i},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Nr(e){e._valueTracker||(e._valueTracker=ix(e))}function ep(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var s=n.getValue(),l="";return e&&(l=Zu(e)?e.checked?"true":"false":e.value),e=l,e!==s?(n.setValue(e),!0):!1}function ga(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 Xi(e,n){var s=n.checked;return Le({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function gc(e,n){var s=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;s=Vn(n.value!=null?n.value:s),e._wrapperState={initialChecked:l,initialValue:s,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function tp(e,n){n=n.checked,n!=null&&Ko(e,"checked",n,!1)}function qi(e,n){tp(e,n);var s=Vn(n.value),l=n.type;if(s!=null)l==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?Ji(e,n.type,s):n.hasOwnProperty("defaultValue")&&Ji(e,n.type,Vn(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function xc(e,n,s){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="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 Ji(e,n,s){(n!=="number"||ga(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Kl=Array.isArray;function ul(e,n,s,l){if(e=e.options,n){n={};for(var r=0;r<s.length;r++)n["$"+s[r]]=!0;for(s=0;s<e.length;s++)r=n.hasOwnProperty("$"+e[s].value),e[s].selected!==r&&(e[s].selected=r),r&&l&&(e[s].defaultSelected=!0)}else{for(s=""+Vn(s),n=null,r=0;r<e.length;r++){if(e[r].value===s){e[r].selected=!0,l&&(e[r].defaultSelected=!0);return}n!==null||e[r].disabled||(n=e[r])}n!==null&&(n.selected=!0)}}function Vi(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(K(91));return Le({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mc(e,n){var s=n.value;if(s==null){if(s=n.children,n=n.defaultValue,s!=null){if(n!=null)throw Error(K(92));if(Kl(s)){if(1<s.length)throw Error(K(93));s=s[0]}n=s}n==null&&(n=""),s=n}e._wrapperState={initialValue:Vn(s)}}function np(e,n){var s=Vn(n.value),l=Vn(n.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),n.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),l!=null&&(e.defaultValue=""+l)}function yc(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function sp(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 Zi(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?sp(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Wr,lp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,s,l,r){MSApp.execUnsafeLocalFunction(function(){return e(n,s,l,r)})}:e}(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(Wr=Wr||document.createElement("div"),Wr.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Wr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function ar(e,n){if(n){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=n;return}}e.textContent=n}var ql={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},ox=["Webkit","ms","Moz","O"];Object.keys(ql).forEach(function(e){ox.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),ql[n]=ql[e]})});function rp(e,n,s){return n==null||typeof n=="boolean"||n===""?"":s||typeof n!="number"||n===0||ql.hasOwnProperty(e)&&ql[e]?(""+n).trim():n+"px"}function ap(e,n){e=e.style;for(var s in n)if(n.hasOwnProperty(s)){var l=s.indexOf("--")===0,r=rp(s,n[s],l);s==="float"&&(s="cssFloat"),l?e.setProperty(s,r):e[s]=r}}var dx=Le({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 eo(e,n){if(n){if(dx[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(K(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(K(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(K(61))}if(n.style!=null&&typeof n.style!="object")throw Error(K(62))}}function to(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 no=null;function qo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var so=null,pl=null,fl=null;function vc(e){if(e=zr(e)){if(typeof so!="function")throw Error(K(280));var n=e.stateNode;n&&(n=Ga(n),so(e.stateNode,e.type,n))}}function ip(e){pl?fl?fl.push(e):fl=[e]:pl=e}function op(){if(pl){var e=pl,n=fl;if(fl=pl=null,vc(e),n)for(e=0;e<n.length;e++)vc(n[e])}}function dp(e,n){return e(n)}function cp(){}var vi=!1;function up(e,n,s){if(vi)return e(n,s);vi=!0;try{return dp(e,n,s)}finally{vi=!1,(pl!==null||fl!==null)&&(cp(),op())}}function ir(e,n){var s=e.stateNode;if(s===null)return null;var l=Ga(s);if(l===null)return null;s=l[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":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(K(231,n,typeof s));return s}var lo=!1;if(zn)try{var Ol={};Object.defineProperty(Ol,"passive",{get:function(){lo=!0}}),window.addEventListener("test",Ol,Ol),window.removeEventListener("test",Ol,Ol)}catch{lo=!1}function cx(e,n,s,l,r,a,i,d,p){var u=Array.prototype.slice.call(arguments,3);try{n.apply(s,u)}catch(C){this.onError(C)}}var Jl=!1,xa=null,ma=!1,ro=null,ux={onError:function(e){Jl=!0,xa=e}};function px(e,n,s,l,r,a,i,d,p){Jl=!1,xa=null,cx.apply(ux,arguments)}function fx(e,n,s,l,r,a,i,d,p){if(px.apply(this,arguments),Jl){if(Jl){var u=xa;Jl=!1,xa=null}else throw Error(K(198));ma||(ma=!0,ro=u)}}function Es(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 pp(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 jc(e){if(Es(e)!==e)throw Error(K(188))}function hx(e){var n=e.alternate;if(!n){if(n=Es(e),n===null)throw Error(K(188));return n!==e?null:e}for(var s=e,l=n;;){var r=s.return;if(r===null)break;var a=r.alternate;if(a===null){if(l=r.return,l!==null){s=l;continue}break}if(r.child===a.child){for(a=r.child;a;){if(a===s)return jc(r),e;if(a===l)return jc(r),n;a=a.sibling}throw Error(K(188))}if(s.return!==l.return)s=r,l=a;else{for(var i=!1,d=r.child;d;){if(d===s){i=!0,s=r,l=a;break}if(d===l){i=!0,l=r,s=a;break}d=d.sibling}if(!i){for(d=a.child;d;){if(d===s){i=!0,s=a,l=r;break}if(d===l){i=!0,l=a,s=r;break}d=d.sibling}if(!i)throw Error(K(189))}}if(s.alternate!==l)throw Error(K(190))}if(s.tag!==3)throw Error(K(188));return s.stateNode.current===s?e:n}function fp(e){return e=hx(e),e!==null?hp(e):null}function hp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=hp(e);if(n!==null)return n;e=e.sibling}return null}var gp=Dt.unstable_scheduleCallback,bc=Dt.unstable_cancelCallback,gx=Dt.unstable_shouldYield,xx=Dt.unstable_requestPaint,Ye=Dt.unstable_now,mx=Dt.unstable_getCurrentPriorityLevel,Jo=Dt.unstable_ImmediatePriority,xp=Dt.unstable_UserBlockingPriority,ya=Dt.unstable_NormalPriority,yx=Dt.unstable_LowPriority,mp=Dt.unstable_IdlePriority,Ua=null,pn=null;function vx(e){if(pn&&typeof pn.onCommitFiberRoot=="function")try{pn.onCommitFiberRoot(Ua,e,void 0,(e.current.flags&128)===128)}catch{}}var Jt=Math.clz32?Math.clz32:Sx,jx=Math.log,bx=Math.LN2;function Sx(e){return e>>>=0,e===0?32:31-(jx(e)/bx|0)|0}var Br=64,$r=4194304;function Ql(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 va(e,n){var s=e.pendingLanes;if(s===0)return 0;var l=0,r=e.suspendedLanes,a=e.pingedLanes,i=s&268435455;if(i!==0){var d=i&~r;d!==0?l=Ql(d):(a&=i,a!==0&&(l=Ql(a)))}else i=s&~r,i!==0?l=Ql(i):a!==0&&(l=Ql(a));if(l===0)return 0;if(n!==0&&n!==l&&!(n&r)&&(r=l&-l,a=n&-n,r>=a||r===16&&(a&4194240)!==0))return n;if(l&4&&(l|=s&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)s=31-Jt(n),r=1<<s,l|=e[s],n&=~r;return l}function wx(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 kx(e,n){for(var s=e.suspendedLanes,l=e.pingedLanes,r=e.expirationTimes,a=e.pendingLanes;0<a;){var i=31-Jt(a),d=1<<i,p=r[i];p===-1?(!(d&s)||d&l)&&(r[i]=wx(d,n)):p<=n&&(e.expiredLanes|=d),a&=~d}}function ao(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function yp(){var e=Br;return Br<<=1,!(Br&4194240)&&(Br=64),e}function ji(e){for(var n=[],s=0;31>s;s++)n.push(e);return n}function _r(e,n,s){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Jt(n),e[n]=s}function _x(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 l=e.eventTimes;for(e=e.expirationTimes;0<s;){var r=31-Jt(s),a=1<<r;n[r]=0,l[r]=-1,e[r]=-1,s&=~a}}function Vo(e,n){var s=e.entangledLanes|=n;for(e=e.entanglements;s;){var l=31-Jt(s),r=1<<l;r&n|e[l]&n&&(e[l]|=n),s&=~r}}var je=0;function vp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var jp,Zo,bp,Sp,wp,io=!1,Ur=[],Hn=null,Gn=null,Kn=null,or=new Map,dr=new Map,Wn=[],Cx="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 Sc(e,n){switch(e){case"focusin":case"focusout":Hn=null;break;case"dragenter":case"dragleave":Gn=null;break;case"mouseover":case"mouseout":Kn=null;break;case"pointerover":case"pointerout":or.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":dr.delete(n.pointerId)}}function Nl(e,n,s,l,r,a){return e===null||e.nativeEvent!==a?(e={blockedOn:n,domEventName:s,eventSystemFlags:l,nativeEvent:a,targetContainers:[r]},n!==null&&(n=zr(n),n!==null&&Zo(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,r!==null&&n.indexOf(r)===-1&&n.push(r),e)}function zx(e,n,s,l,r){switch(n){case"focusin":return Hn=Nl(Hn,e,n,s,l,r),!0;case"dragenter":return Gn=Nl(Gn,e,n,s,l,r),!0;case"mouseover":return Kn=Nl(Kn,e,n,s,l,r),!0;case"pointerover":var a=r.pointerId;return or.set(a,Nl(or.get(a)||null,e,n,s,l,r)),!0;case"gotpointercapture":return a=r.pointerId,dr.set(a,Nl(dr.get(a)||null,e,n,s,l,r)),!0}return!1}function kp(e){var n=ys(e.target);if(n!==null){var s=Es(n);if(s!==null){if(n=s.tag,n===13){if(n=pp(s),n!==null){e.blockedOn=n,wp(e.priority,function(){bp(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 la(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var s=oo(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var l=new s.constructor(s.type,s);no=l,s.target.dispatchEvent(l),no=null}else return n=zr(s),n!==null&&Zo(n),e.blockedOn=s,!1;n.shift()}return!0}function wc(e,n,s){la(e)&&s.delete(n)}function Ix(){io=!1,Hn!==null&&la(Hn)&&(Hn=null),Gn!==null&&la(Gn)&&(Gn=null),Kn!==null&&la(Kn)&&(Kn=null),or.forEach(wc),dr.forEach(wc)}function Wl(e,n){e.blockedOn===n&&(e.blockedOn=null,io||(io=!0,Dt.unstable_scheduleCallback(Dt.unstable_NormalPriority,Ix)))}function cr(e){function n(r){return Wl(r,e)}if(0<Ur.length){Wl(Ur[0],e);for(var s=1;s<Ur.length;s++){var l=Ur[s];l.blockedOn===e&&(l.blockedOn=null)}}for(Hn!==null&&Wl(Hn,e),Gn!==null&&Wl(Gn,e),Kn!==null&&Wl(Kn,e),or.forEach(n),dr.forEach(n),s=0;s<Wn.length;s++)l=Wn[s],l.blockedOn===e&&(l.blockedOn=null);for(;0<Wn.length&&(s=Wn[0],s.blockedOn===null);)kp(s),s.blockedOn===null&&Wn.shift()}var hl=Pn.ReactCurrentBatchConfig,ja=!0;function Tx(e,n,s,l){var r=je,a=hl.transition;hl.transition=null;try{je=1,ed(e,n,s,l)}finally{je=r,hl.transition=a}}function Ex(e,n,s,l){var r=je,a=hl.transition;hl.transition=null;try{je=4,ed(e,n,s,l)}finally{je=r,hl.transition=a}}function ed(e,n,s,l){if(ja){var r=oo(e,n,s,l);if(r===null)Ei(e,n,l,ba,s),Sc(e,l);else if(zx(r,e,n,s,l))l.stopPropagation();else if(Sc(e,l),n&4&&-1<Cx.indexOf(e)){for(;r!==null;){var a=zr(r);if(a!==null&&jp(a),a=oo(e,n,s,l),a===null&&Ei(e,n,l,ba,s),a===r)break;r=a}r!==null&&l.stopPropagation()}else Ei(e,n,l,null,s)}}var ba=null;function oo(e,n,s,l){if(ba=null,e=qo(l),e=ys(e),e!==null)if(n=Es(e),n===null)e=null;else if(s=n.tag,s===13){if(e=pp(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 ba=e,null}function _p(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(mx()){case Jo:return 1;case xp:return 4;case ya:case yx:return 16;case mp:return 536870912;default:return 16}default:return 16}}var $n=null,td=null,ra=null;function Cp(){if(ra)return ra;var e,n=td,s=n.length,l,r="value"in $n?$n.value:$n.textContent,a=r.length;for(e=0;e<s&&n[e]===r[e];e++);var i=s-e;for(l=1;l<=i&&n[s-l]===r[a-l];l++);return ra=r.slice(e,1<l?1-l:void 0)}function aa(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 Fr(){return!0}function kc(){return!1}function Ot(e){function n(s,l,r,a,i){this._reactName=s,this._targetInst=r,this.type=l,this.nativeEvent=a,this.target=i,this.currentTarget=null;for(var d in e)e.hasOwnProperty(d)&&(s=e[d],this[d]=s?s(a):a[d]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?Fr:kc,this.isPropagationStopped=kc,this}return Le(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=Fr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Fr)},persist:function(){},isPersistent:Fr}),n}var zl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nd=Ot(zl),Cr=Le({},zl,{view:0,detail:0}),Px=Ot(Cr),bi,Si,Bl,Fa=Le({},Cr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sd,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!==Bl&&(Bl&&e.type==="mousemove"?(bi=e.screenX-Bl.screenX,Si=e.screenY-Bl.screenY):Si=bi=0,Bl=e),bi)},movementY:function(e){return"movementY"in e?e.movementY:Si}}),_c=Ot(Fa),Ax=Le({},Fa,{dataTransfer:0}),Rx=Ot(Ax),Dx=Le({},Cr,{relatedTarget:0}),wi=Ot(Dx),Lx=Le({},zl,{animationName:0,elapsedTime:0,pseudoElement:0}),Ox=Ot(Lx),Nx=Le({},zl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Wx=Ot(Nx),Bx=Le({},zl,{data:0}),Cc=Ot(Bx),$x={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ux={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"},Fx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Fx[e])?!!n[e]:!1}function sd(){return Mx}var Hx=Le({},Cr,{key:function(e){if(e.key){var n=$x[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=aa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ux[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sd,charCode:function(e){return e.type==="keypress"?aa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?aa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Gx=Ot(Hx),Kx=Le({},Fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zc=Ot(Kx),Qx=Le({},Cr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sd}),Yx=Ot(Qx),Xx=Le({},zl,{propertyName:0,elapsedTime:0,pseudoElement:0}),qx=Ot(Xx),Jx=Le({},Fa,{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}),Vx=Ot(Jx),Zx=[9,13,27,32],ld=zn&&"CompositionEvent"in window,Vl=null;zn&&"documentMode"in document&&(Vl=document.documentMode);var em=zn&&"TextEvent"in window&&!Vl,zp=zn&&(!ld||Vl&&8<Vl&&11>=Vl),Ic=" ",Tc=!1;function Ip(e,n){switch(e){case"keyup":return Zx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var el=!1;function tm(e,n){switch(e){case"compositionend":return Tp(n);case"keypress":return n.which!==32?null:(Tc=!0,Ic);case"textInput":return e=n.data,e===Ic&&Tc?null:e;default:return null}}function nm(e,n){if(el)return e==="compositionend"||!ld&&Ip(e,n)?(e=Cp(),ra=td=$n=null,el=!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 zp&&n.locale!=="ko"?null:n.data;default:return null}}var sm={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 Ec(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!sm[e.type]:n==="textarea"}function Ep(e,n,s,l){ip(l),n=Sa(n,"onChange"),0<n.length&&(s=new nd("onChange","change",null,s,l),e.push({event:s,listeners:n}))}var Zl=null,ur=null;function lm(e){Up(e,0)}function Ma(e){var n=sl(e);if(ep(n))return e}function rm(e,n){if(e==="change")return n}var Pp=!1;if(zn){var ki;if(zn){var _i="oninput"in document;if(!_i){var Pc=document.createElement("div");Pc.setAttribute("oninput","return;"),_i=typeof Pc.oninput=="function"}ki=_i}else ki=!1;Pp=ki&&(!document.documentMode||9<document.documentMode)}function Ac(){Zl&&(Zl.detachEvent("onpropertychange",Ap),ur=Zl=null)}function Ap(e){if(e.propertyName==="value"&&Ma(ur)){var n=[];Ep(n,ur,e,qo(e)),up(lm,n)}}function am(e,n,s){e==="focusin"?(Ac(),Zl=n,ur=s,Zl.attachEvent("onpropertychange",Ap)):e==="focusout"&&Ac()}function im(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ma(ur)}function om(e,n){if(e==="click")return Ma(n)}function dm(e,n){if(e==="input"||e==="change")return Ma(n)}function cm(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Zt=typeof Object.is=="function"?Object.is:cm;function pr(e,n){if(Zt(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var s=Object.keys(e),l=Object.keys(n);if(s.length!==l.length)return!1;for(l=0;l<s.length;l++){var r=s[l];if(!Hi.call(n,r)||!Zt(e[r],n[r]))return!1}return!0}function Rc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Dc(e,n){var s=Rc(e);e=0;for(var l;s;){if(s.nodeType===3){if(l=e+s.textContent.length,e<=n&&l>=n)return{node:s,offset:n-e};e=l}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Rc(s)}}function Rp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Rp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Dp(){for(var e=window,n=ga();n instanceof e.HTMLIFrameElement;){try{var s=typeof n.contentWindow.location.href=="string"}catch{s=!1}if(s)e=n.contentWindow;else break;n=ga(e.document)}return n}function rd(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 um(e){var n=Dp(),s=e.focusedElem,l=e.selectionRange;if(n!==s&&s&&s.ownerDocument&&Rp(s.ownerDocument.documentElement,s)){if(l!==null&&rd(s)){if(n=l.start,e=l.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 r=s.textContent.length,a=Math.min(l.start,r);l=l.end===void 0?a:Math.min(l.end,r),!e.extend&&a>l&&(r=l,l=a,a=r),r=Dc(s,a);var i=Dc(s,l);r&&i&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(n=n.createRange(),n.setStart(r.node,r.offset),e.removeAllRanges(),a>l?(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 pm=zn&&"documentMode"in document&&11>=document.documentMode,tl=null,co=null,er=null,uo=!1;function Lc(e,n,s){var l=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;uo||tl==null||tl!==ga(l)||(l=tl,"selectionStart"in l&&rd(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),er&&pr(er,l)||(er=l,l=Sa(co,"onSelect"),0<l.length&&(n=new nd("onSelect","select",null,n,s),e.push({event:n,listeners:l}),n.target=tl)))}function Mr(e,n){var s={};return s[e.toLowerCase()]=n.toLowerCase(),s["Webkit"+e]="webkit"+n,s["Moz"+e]="moz"+n,s}var nl={animationend:Mr("Animation","AnimationEnd"),animationiteration:Mr("Animation","AnimationIteration"),animationstart:Mr("Animation","AnimationStart"),transitionend:Mr("Transition","TransitionEnd")},Ci={},Lp={};zn&&(Lp=document.createElement("div").style,"AnimationEvent"in window||(delete nl.animationend.animation,delete nl.animationiteration.animation,delete nl.animationstart.animation),"TransitionEvent"in window||delete nl.transitionend.transition);function Ha(e){if(Ci[e])return Ci[e];if(!nl[e])return e;var n=nl[e],s;for(s in n)if(n.hasOwnProperty(s)&&s in Lp)return Ci[e]=n[s];return e}var Op=Ha("animationend"),Np=Ha("animationiteration"),Wp=Ha("animationstart"),Bp=Ha("transitionend"),$p=new Map,Oc="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 ts(e,n){$p.set(e,n),Ts(n,[e])}for(var zi=0;zi<Oc.length;zi++){var Ii=Oc[zi],fm=Ii.toLowerCase(),hm=Ii[0].toUpperCase()+Ii.slice(1);ts(fm,"on"+hm)}ts(Op,"onAnimationEnd");ts(Np,"onAnimationIteration");ts(Wp,"onAnimationStart");ts("dblclick","onDoubleClick");ts("focusin","onFocus");ts("focusout","onBlur");ts(Bp,"onTransitionEnd");ml("onMouseEnter",["mouseout","mouseover"]);ml("onMouseLeave",["mouseout","mouseover"]);ml("onPointerEnter",["pointerout","pointerover"]);ml("onPointerLeave",["pointerout","pointerover"]);Ts("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ts("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ts("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ts("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ts("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ts("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yl="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(" "),gm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Yl));function Nc(e,n,s){var l=e.type||"unknown-event";e.currentTarget=s,fx(l,n,void 0,e),e.currentTarget=null}function Up(e,n){n=(n&4)!==0;for(var s=0;s<e.length;s++){var l=e[s],r=l.event;l=l.listeners;e:{var a=void 0;if(n)for(var i=l.length-1;0<=i;i--){var d=l[i],p=d.instance,u=d.currentTarget;if(d=d.listener,p!==a&&r.isPropagationStopped())break e;Nc(r,d,u),a=p}else for(i=0;i<l.length;i++){if(d=l[i],p=d.instance,u=d.currentTarget,d=d.listener,p!==a&&r.isPropagationStopped())break e;Nc(r,d,u),a=p}}}if(ma)throw e=ro,ma=!1,ro=null,e}function Ce(e,n){var s=n[xo];s===void 0&&(s=n[xo]=new Set);var l=e+"__bubble";s.has(l)||(Fp(n,e,2,!1),s.add(l))}function Ti(e,n,s){var l=0;n&&(l|=4),Fp(s,e,l,n)}var Hr="_reactListening"+Math.random().toString(36).slice(2);function fr(e){if(!e[Hr]){e[Hr]=!0,Xu.forEach(function(s){s!=="selectionchange"&&(gm.has(s)||Ti(s,!1,e),Ti(s,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Hr]||(n[Hr]=!0,Ti("selectionchange",!1,n))}}function Fp(e,n,s,l){switch(_p(n)){case 1:var r=Tx;break;case 4:r=Ex;break;default:r=ed}s=r.bind(null,n,s,e),r=void 0,!lo||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(r=!0),l?r!==void 0?e.addEventListener(n,s,{capture:!0,passive:r}):e.addEventListener(n,s,!0):r!==void 0?e.addEventListener(n,s,{passive:r}):e.addEventListener(n,s,!1)}function Ei(e,n,s,l,r){var a=l;if(!(n&1)&&!(n&2)&&l!==null)e:for(;;){if(l===null)return;var i=l.tag;if(i===3||i===4){var d=l.stateNode.containerInfo;if(d===r||d.nodeType===8&&d.parentNode===r)break;if(i===4)for(i=l.return;i!==null;){var p=i.tag;if((p===3||p===4)&&(p=i.stateNode.containerInfo,p===r||p.nodeType===8&&p.parentNode===r))return;i=i.return}for(;d!==null;){if(i=ys(d),i===null)return;if(p=i.tag,p===5||p===6){l=a=i;continue e}d=d.parentNode}}l=l.return}up(function(){var u=a,C=qo(s),x=[];e:{var m=$p.get(e);if(m!==void 0){var h=nd,b=e;switch(e){case"keypress":if(aa(s)===0)break e;case"keydown":case"keyup":h=Gx;break;case"focusin":b="focus",h=wi;break;case"focusout":b="blur",h=wi;break;case"beforeblur":case"afterblur":h=wi;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":h=_c;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=Rx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=Yx;break;case Op:case Np:case Wp:h=Ox;break;case Bp:h=qx;break;case"scroll":h=Px;break;case"wheel":h=Vx;break;case"copy":case"cut":case"paste":h=Wx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=zc}var _=(n&4)!==0,v=!_&&e==="scroll",g=_?m!==null?m+"Capture":null:m;_=[];for(var o=u,c;o!==null;){c=o;var y=c.stateNode;if(c.tag===5&&y!==null&&(c=y,g!==null&&(y=ir(o,g),y!=null&&_.push(hr(o,y,c)))),v)break;o=o.return}0<_.length&&(m=new h(m,b,null,s,C),x.push({event:m,listeners:_}))}}if(!(n&7)){e:{if(m=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",m&&s!==no&&(b=s.relatedTarget||s.fromElement)&&(ys(b)||b[In]))break e;if((h||m)&&(m=C.window===C?C:(m=C.ownerDocument)?m.defaultView||m.parentWindow:window,h?(b=s.relatedTarget||s.toElement,h=u,b=b?ys(b):null,b!==null&&(v=Es(b),b!==v||b.tag!==5&&b.tag!==6)&&(b=null)):(h=null,b=u),h!==b)){if(_=_c,y="onMouseLeave",g="onMouseEnter",o="mouse",(e==="pointerout"||e==="pointerover")&&(_=zc,y="onPointerLeave",g="onPointerEnter",o="pointer"),v=h==null?m:sl(h),c=b==null?m:sl(b),m=new _(y,o+"leave",h,s,C),m.target=v,m.relatedTarget=c,y=null,ys(C)===u&&(_=new _(g,o+"enter",b,s,C),_.target=c,_.relatedTarget=v,y=_),v=y,h&&b)t:{for(_=h,g=b,o=0,c=_;c;c=Fs(c))o++;for(c=0,y=g;y;y=Fs(y))c++;for(;0<o-c;)_=Fs(_),o--;for(;0<c-o;)g=Fs(g),c--;for(;o--;){if(_===g||g!==null&&_===g.alternate)break t;_=Fs(_),g=Fs(g)}_=null}else _=null;h!==null&&Wc(x,m,h,_,!1),b!==null&&v!==null&&Wc(x,v,b,_,!0)}}e:{if(m=u?sl(u):window,h=m.nodeName&&m.nodeName.toLowerCase(),h==="select"||h==="input"&&m.type==="file")var z=rm;else if(Ec(m))if(Pp)z=dm;else{z=im;var k=am}else(h=m.nodeName)&&h.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(z=om);if(z&&(z=z(e,u))){Ep(x,z,s,C);break e}k&&k(e,m,u),e==="focusout"&&(k=m._wrapperState)&&k.controlled&&m.type==="number"&&Ji(m,"number",m.value)}switch(k=u?sl(u):window,e){case"focusin":(Ec(k)||k.contentEditable==="true")&&(tl=k,co=u,er=null);break;case"focusout":er=co=tl=null;break;case"mousedown":uo=!0;break;case"contextmenu":case"mouseup":case"dragend":uo=!1,Lc(x,s,C);break;case"selectionchange":if(pm)break;case"keydown":case"keyup":Lc(x,s,C)}var f;if(ld)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else el?Ip(e,s)&&(w="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(w="onCompositionStart");w&&(zp&&s.locale!=="ko"&&(el||w!=="onCompositionStart"?w==="onCompositionEnd"&&el&&(f=Cp()):($n=C,td="value"in $n?$n.value:$n.textContent,el=!0)),k=Sa(u,w),0<k.length&&(w=new Cc(w,e,null,s,C),x.push({event:w,listeners:k}),f?w.data=f:(f=Tp(s),f!==null&&(w.data=f)))),(f=em?tm(e,s):nm(e,s))&&(u=Sa(u,"onBeforeInput"),0<u.length&&(C=new Cc("onBeforeInput","beforeinput",null,s,C),x.push({event:C,listeners:u}),C.data=f))}Up(x,n)})}function hr(e,n,s){return{instance:e,listener:n,currentTarget:s}}function Sa(e,n){for(var s=n+"Capture",l=[];e!==null;){var r=e,a=r.stateNode;r.tag===5&&a!==null&&(r=a,a=ir(e,s),a!=null&&l.unshift(hr(e,a,r)),a=ir(e,n),a!=null&&l.push(hr(e,a,r))),e=e.return}return l}function Fs(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Wc(e,n,s,l,r){for(var a=n._reactName,i=[];s!==null&&s!==l;){var d=s,p=d.alternate,u=d.stateNode;if(p!==null&&p===l)break;d.tag===5&&u!==null&&(d=u,r?(p=ir(s,a),p!=null&&i.unshift(hr(s,p,d))):r||(p=ir(s,a),p!=null&&i.push(hr(s,p,d)))),s=s.return}i.length!==0&&e.push({event:n,listeners:i})}var xm=/\r\n?/g,mm=/\u0000|\uFFFD/g;function Bc(e){return(typeof e=="string"?e:""+e).replace(xm,`
`).replace(mm,"")}function Gr(e,n,s){if(n=Bc(n),Bc(e)!==n&&s)throw Error(K(425))}function wa(){}var po=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,ym=typeof clearTimeout=="function"?clearTimeout:void 0,$c=typeof Promise=="function"?Promise:void 0,vm=typeof queueMicrotask=="function"?queueMicrotask:typeof $c<"u"?function(e){return $c.resolve(null).then(e).catch(jm)}:go;function jm(e){setTimeout(function(){throw e})}function Pi(e,n){var s=n,l=0;do{var r=s.nextSibling;if(e.removeChild(s),r&&r.nodeType===8)if(s=r.data,s==="/$"){if(l===0){e.removeChild(r),cr(n);return}l--}else s!=="$"&&s!=="$?"&&s!=="$!"||l++;s=r}while(s);cr(n)}function Qn(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 Uc(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 Il=Math.random().toString(36).slice(2),un="__reactFiber$"+Il,gr="__reactProps$"+Il,In="__reactContainer$"+Il,xo="__reactEvents$"+Il,bm="__reactListeners$"+Il,Sm="__reactHandles$"+Il;function ys(e){var n=e[un];if(n)return n;for(var s=e.parentNode;s;){if(n=s[In]||s[un]){if(s=n.alternate,n.child!==null||s!==null&&s.child!==null)for(e=Uc(e);e!==null;){if(s=e[un])return s;e=Uc(e)}return n}e=s,s=e.parentNode}return null}function zr(e){return e=e[un]||e[In],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function sl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(K(33))}function Ga(e){return e[gr]||null}var mo=[],ll=-1;function ns(e){return{current:e}}function ze(e){0>ll||(e.current=mo[ll],mo[ll]=null,ll--)}function ke(e,n){ll++,mo[ll]=e.current,e.current=n}var Zn={},xt=ns(Zn),kt=ns(!1),ws=Zn;function yl(e,n){var s=e.type.contextTypes;if(!s)return Zn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var r={},a;for(a in s)r[a]=n[a];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=r),r}function _t(e){return e=e.childContextTypes,e!=null}function ka(){ze(kt),ze(xt)}function Fc(e,n,s){if(xt.current!==Zn)throw Error(K(168));ke(xt,n),ke(kt,s)}function Mp(e,n,s){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return s;l=l.getChildContext();for(var r in l)if(!(r in n))throw Error(K(108,ax(e)||"Unknown",r));return Le({},s,l)}function _a(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Zn,ws=xt.current,ke(xt,e),ke(kt,kt.current),!0}function Mc(e,n,s){var l=e.stateNode;if(!l)throw Error(K(169));s?(e=Mp(e,n,ws),l.__reactInternalMemoizedMergedChildContext=e,ze(kt),ze(xt),ke(xt,e)):ze(kt),ke(kt,s)}var wn=null,Ka=!1,Ai=!1;function Hp(e){wn===null?wn=[e]:wn.push(e)}function wm(e){Ka=!0,Hp(e)}function ss(){if(!Ai&&wn!==null){Ai=!0;var e=0,n=je;try{var s=wn;for(je=1;e<s.length;e++){var l=s[e];do l=l(!0);while(l!==null)}wn=null,Ka=!1}catch(r){throw wn!==null&&(wn=wn.slice(e+1)),gp(Jo,ss),r}finally{je=n,Ai=!1}}return null}var rl=[],al=0,Ca=null,za=0,Nt=[],Wt=0,ks=null,kn=1,_n="";function xs(e,n){rl[al++]=za,rl[al++]=Ca,Ca=e,za=n}function Gp(e,n,s){Nt[Wt++]=kn,Nt[Wt++]=_n,Nt[Wt++]=ks,ks=e;var l=kn;e=_n;var r=32-Jt(l)-1;l&=~(1<<r),s+=1;var a=32-Jt(n)+r;if(30<a){var i=r-r%5;a=(l&(1<<i)-1).toString(32),l>>=i,r-=i,kn=1<<32-Jt(n)+r|s<<r|l,_n=a+e}else kn=1<<a|s<<r|l,_n=e}function ad(e){e.return!==null&&(xs(e,1),Gp(e,1,0))}function id(e){for(;e===Ca;)Ca=rl[--al],rl[al]=null,za=rl[--al],rl[al]=null;for(;e===ks;)ks=Nt[--Wt],Nt[Wt]=null,_n=Nt[--Wt],Nt[Wt]=null,kn=Nt[--Wt],Nt[Wt]=null}var Rt=null,At=null,Pe=!1,qt=null;function Kp(e,n){var s=Bt(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 Hc(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,Rt=e,At=Qn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Rt=e,At=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(s=ks!==null?{id:kn,overflow:_n}:null,e.memoizedState={dehydrated:n,treeContext:s,retryLane:1073741824},s=Bt(18,null,null,0),s.stateNode=n,s.return=e,e.child=s,Rt=e,At=null,!0):!1;default:return!1}}function yo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function vo(e){if(Pe){var n=At;if(n){var s=n;if(!Hc(e,n)){if(yo(e))throw Error(K(418));n=Qn(s.nextSibling);var l=Rt;n&&Hc(e,n)?Kp(l,s):(e.flags=e.flags&-4097|2,Pe=!1,Rt=e)}}else{if(yo(e))throw Error(K(418));e.flags=e.flags&-4097|2,Pe=!1,Rt=e}}}function Gc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Rt=e}function Kr(e){if(e!==Rt)return!1;if(!Pe)return Gc(e),Pe=!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=At)){if(yo(e))throw Qp(),Error(K(418));for(;n;)Kp(e,n),n=Qn(n.nextSibling)}if(Gc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(K(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(n===0){At=Qn(e.nextSibling);break e}n--}else s!=="$"&&s!=="$!"&&s!=="$?"||n++}e=e.nextSibling}At=null}}else At=Rt?Qn(e.stateNode.nextSibling):null;return!0}function Qp(){for(var e=At;e;)e=Qn(e.nextSibling)}function vl(){At=Rt=null,Pe=!1}function od(e){qt===null?qt=[e]:qt.push(e)}var km=Pn.ReactCurrentBatchConfig;function $l(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(K(309));var l=s.stateNode}if(!l)throw Error(K(147,e));var r=l,a=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===a?n.ref:(n=function(i){var d=r.refs;i===null?delete d[a]:d[a]=i},n._stringRef=a,n)}if(typeof e!="string")throw Error(K(284));if(!s._owner)throw Error(K(290,e))}return e}function Qr(e,n){throw e=Object.prototype.toString.call(n),Error(K(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function Kc(e){var n=e._init;return n(e._payload)}function Yp(e){function n(g,o){if(e){var c=g.deletions;c===null?(g.deletions=[o],g.flags|=16):c.push(o)}}function s(g,o){if(!e)return null;for(;o!==null;)n(g,o),o=o.sibling;return null}function l(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 r(g,o){return g=Jn(g,o),g.index=0,g.sibling=null,g}function a(g,o,c){return g.index=c,e?(c=g.alternate,c!==null?(c=c.index,c<o?(g.flags|=2,o):c):(g.flags|=2,o)):(g.flags|=1048576,o)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function d(g,o,c,y){return o===null||o.tag!==6?(o=Bi(c,g.mode,y),o.return=g,o):(o=r(o,c),o.return=g,o)}function p(g,o,c,y){var z=c.type;return z===Zs?C(g,o,c.props.children,y,c.key):o!==null&&(o.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===On&&Kc(z)===o.type)?(y=r(o,c.props),y.ref=$l(g,o,c),y.return=g,y):(y=fa(c.type,c.key,c.props,null,g.mode,y),y.ref=$l(g,o,c),y.return=g,y)}function u(g,o,c,y){return o===null||o.tag!==4||o.stateNode.containerInfo!==c.containerInfo||o.stateNode.implementation!==c.implementation?(o=$i(c,g.mode,y),o.return=g,o):(o=r(o,c.children||[]),o.return=g,o)}function C(g,o,c,y,z){return o===null||o.tag!==7?(o=Ss(c,g.mode,y,z),o.return=g,o):(o=r(o,c),o.return=g,o)}function x(g,o,c){if(typeof o=="string"&&o!==""||typeof o=="number")return o=Bi(""+o,g.mode,c),o.return=g,o;if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Or:return c=fa(o.type,o.key,o.props,null,g.mode,c),c.ref=$l(g,null,o),c.return=g,c;case Vs:return o=$i(o,g.mode,c),o.return=g,o;case On:var y=o._init;return x(g,y(o._payload),c)}if(Kl(o)||Ll(o))return o=Ss(o,g.mode,c,null),o.return=g,o;Qr(g,o)}return null}function m(g,o,c,y){var z=o!==null?o.key:null;if(typeof c=="string"&&c!==""||typeof c=="number")return z!==null?null:d(g,o,""+c,y);if(typeof c=="object"&&c!==null){switch(c.$$typeof){case Or:return c.key===z?p(g,o,c,y):null;case Vs:return c.key===z?u(g,o,c,y):null;case On:return z=c._init,m(g,o,z(c._payload),y)}if(Kl(c)||Ll(c))return z!==null?null:C(g,o,c,y,null);Qr(g,c)}return null}function h(g,o,c,y,z){if(typeof y=="string"&&y!==""||typeof y=="number")return g=g.get(c)||null,d(o,g,""+y,z);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Or:return g=g.get(y.key===null?c:y.key)||null,p(o,g,y,z);case Vs:return g=g.get(y.key===null?c:y.key)||null,u(o,g,y,z);case On:var k=y._init;return h(g,o,c,k(y._payload),z)}if(Kl(y)||Ll(y))return g=g.get(c)||null,C(o,g,y,z,null);Qr(o,y)}return null}function b(g,o,c,y){for(var z=null,k=null,f=o,w=o=0,I=null;f!==null&&w<c.length;w++){f.index>w?(I=f,f=null):I=f.sibling;var P=m(g,f,c[w],y);if(P===null){f===null&&(f=I);break}e&&f&&P.alternate===null&&n(g,f),o=a(P,o,w),k===null?z=P:k.sibling=P,k=P,f=I}if(w===c.length)return s(g,f),Pe&&xs(g,w),z;if(f===null){for(;w<c.length;w++)f=x(g,c[w],y),f!==null&&(o=a(f,o,w),k===null?z=f:k.sibling=f,k=f);return Pe&&xs(g,w),z}for(f=l(g,f);w<c.length;w++)I=h(f,g,w,c[w],y),I!==null&&(e&&I.alternate!==null&&f.delete(I.key===null?w:I.key),o=a(I,o,w),k===null?z=I:k.sibling=I,k=I);return e&&f.forEach(function(Y){return n(g,Y)}),Pe&&xs(g,w),z}function _(g,o,c,y){var z=Ll(c);if(typeof z!="function")throw Error(K(150));if(c=z.call(c),c==null)throw Error(K(151));for(var k=z=null,f=o,w=o=0,I=null,P=c.next();f!==null&&!P.done;w++,P=c.next()){f.index>w?(I=f,f=null):I=f.sibling;var Y=m(g,f,P.value,y);if(Y===null){f===null&&(f=I);break}e&&f&&Y.alternate===null&&n(g,f),o=a(Y,o,w),k===null?z=Y:k.sibling=Y,k=Y,f=I}if(P.done)return s(g,f),Pe&&xs(g,w),z;if(f===null){for(;!P.done;w++,P=c.next())P=x(g,P.value,y),P!==null&&(o=a(P,o,w),k===null?z=P:k.sibling=P,k=P);return Pe&&xs(g,w),z}for(f=l(g,f);!P.done;w++,P=c.next())P=h(f,g,w,P.value,y),P!==null&&(e&&P.alternate!==null&&f.delete(P.key===null?w:P.key),o=a(P,o,w),k===null?z=P:k.sibling=P,k=P);return e&&f.forEach(function(F){return n(g,F)}),Pe&&xs(g,w),z}function v(g,o,c,y){if(typeof c=="object"&&c!==null&&c.type===Zs&&c.key===null&&(c=c.props.children),typeof c=="object"&&c!==null){switch(c.$$typeof){case Or:e:{for(var z=c.key,k=o;k!==null;){if(k.key===z){if(z=c.type,z===Zs){if(k.tag===7){s(g,k.sibling),o=r(k,c.props.children),o.return=g,g=o;break e}}else if(k.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===On&&Kc(z)===k.type){s(g,k.sibling),o=r(k,c.props),o.ref=$l(g,k,c),o.return=g,g=o;break e}s(g,k);break}else n(g,k);k=k.sibling}c.type===Zs?(o=Ss(c.props.children,g.mode,y,c.key),o.return=g,g=o):(y=fa(c.type,c.key,c.props,null,g.mode,y),y.ref=$l(g,o,c),y.return=g,g=y)}return i(g);case Vs:e:{for(k=c.key;o!==null;){if(o.key===k)if(o.tag===4&&o.stateNode.containerInfo===c.containerInfo&&o.stateNode.implementation===c.implementation){s(g,o.sibling),o=r(o,c.children||[]),o.return=g,g=o;break e}else{s(g,o);break}else n(g,o);o=o.sibling}o=$i(c,g.mode,y),o.return=g,g=o}return i(g);case On:return k=c._init,v(g,o,k(c._payload),y)}if(Kl(c))return b(g,o,c,y);if(Ll(c))return _(g,o,c,y);Qr(g,c)}return typeof c=="string"&&c!==""||typeof c=="number"?(c=""+c,o!==null&&o.tag===6?(s(g,o.sibling),o=r(o,c),o.return=g,g=o):(s(g,o),o=Bi(c,g.mode,y),o.return=g,g=o),i(g)):s(g,o)}return v}var jl=Yp(!0),Xp=Yp(!1),Ia=ns(null),Ta=null,il=null,dd=null;function cd(){dd=il=Ta=null}function ud(e){var n=Ia.current;ze(Ia),e._currentValue=n}function jo(e,n,s){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===s)break;e=e.return}}function gl(e,n){Ta=e,dd=il=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&n&&(wt=!0),e.firstContext=null)}function Ut(e){var n=e._currentValue;if(dd!==e)if(e={context:e,memoizedValue:n,next:null},il===null){if(Ta===null)throw Error(K(308));il=e,Ta.dependencies={lanes:0,firstContext:e}}else il=il.next=e;return n}var vs=null;function pd(e){vs===null?vs=[e]:vs.push(e)}function qp(e,n,s,l){var r=n.interleaved;return r===null?(s.next=s,pd(n)):(s.next=r.next,r.next=s),n.interleaved=s,Tn(e,l)}function Tn(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 Nn=!1;function fd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Jp(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 Cn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Yn(e,n,s){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,ge&2){var r=l.pending;return r===null?n.next=n:(n.next=r.next,r.next=n),l.pending=n,Tn(e,s)}return r=l.interleaved,r===null?(n.next=n,pd(l)):(n.next=r.next,r.next=n),l.interleaved=n,Tn(e,s)}function ia(e,n,s){if(n=n.updateQueue,n!==null&&(n=n.shared,(s&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,Vo(e,s)}}function Qc(e,n){var s=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,s===l)){var r=null,a=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};a===null?r=a=i:a=a.next=i,s=s.next}while(s!==null);a===null?r=a=n:a=a.next=n}else r=a=n;s={baseState:l.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:l.shared,effects:l.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=n:e.next=n,s.lastBaseUpdate=n}function Ea(e,n,s,l){var r=e.updateQueue;Nn=!1;var a=r.firstBaseUpdate,i=r.lastBaseUpdate,d=r.shared.pending;if(d!==null){r.shared.pending=null;var p=d,u=p.next;p.next=null,i===null?a=u:i.next=u,i=p;var C=e.alternate;C!==null&&(C=C.updateQueue,d=C.lastBaseUpdate,d!==i&&(d===null?C.firstBaseUpdate=u:d.next=u,C.lastBaseUpdate=p))}if(a!==null){var x=r.baseState;i=0,C=u=p=null,d=a;do{var m=d.lane,h=d.eventTime;if((l&m)===m){C!==null&&(C=C.next={eventTime:h,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var b=e,_=d;switch(m=n,h=s,_.tag){case 1:if(b=_.payload,typeof b=="function"){x=b.call(h,x,m);break e}x=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=_.payload,m=typeof b=="function"?b.call(h,x,m):b,m==null)break e;x=Le({},x,m);break e;case 2:Nn=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,m=r.effects,m===null?r.effects=[d]:m.push(d))}else h={eventTime:h,lane:m,tag:d.tag,payload:d.payload,callback:d.callback,next:null},C===null?(u=C=h,p=x):C=C.next=h,i|=m;if(d=d.next,d===null){if(d=r.shared.pending,d===null)break;m=d,d=m.next,m.next=null,r.lastBaseUpdate=m,r.shared.pending=null}}while(!0);if(C===null&&(p=x),r.baseState=p,r.firstBaseUpdate=u,r.lastBaseUpdate=C,n=r.shared.interleaved,n!==null){r=n;do i|=r.lane,r=r.next;while(r!==n)}else a===null&&(r.shared.lanes=0);Cs|=i,e.lanes=i,e.memoizedState=x}}function Yc(e,n,s){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],r=l.callback;if(r!==null){if(l.callback=null,l=s,typeof r!="function")throw Error(K(191,r));r.call(l)}}}var Ir={},fn=ns(Ir),xr=ns(Ir),mr=ns(Ir);function js(e){if(e===Ir)throw Error(K(174));return e}function hd(e,n){switch(ke(mr,n),ke(xr,e),ke(fn,Ir),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:Zi(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=Zi(n,e)}ze(fn),ke(fn,n)}function bl(){ze(fn),ze(xr),ze(mr)}function Vp(e){js(mr.current);var n=js(fn.current),s=Zi(n,e.type);n!==s&&(ke(xr,e),ke(fn,s))}function gd(e){xr.current===e&&(ze(fn),ze(xr))}var Re=ns(0);function Pa(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 Ri=[];function xd(){for(var e=0;e<Ri.length;e++)Ri[e]._workInProgressVersionPrimary=null;Ri.length=0}var oa=Pn.ReactCurrentDispatcher,Di=Pn.ReactCurrentBatchConfig,_s=0,De=null,nt=null,rt=null,Aa=!1,tr=!1,yr=0,_m=0;function ft(){throw Error(K(321))}function md(e,n){if(n===null)return!1;for(var s=0;s<n.length&&s<e.length;s++)if(!Zt(e[s],n[s]))return!1;return!0}function yd(e,n,s,l,r,a){if(_s=a,De=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,oa.current=e===null||e.memoizedState===null?Tm:Em,e=s(l,r),tr){a=0;do{if(tr=!1,yr=0,25<=a)throw Error(K(301));a+=1,rt=nt=null,n.updateQueue=null,oa.current=Pm,e=s(l,r)}while(tr)}if(oa.current=Ra,n=nt!==null&&nt.next!==null,_s=0,rt=nt=De=null,Aa=!1,n)throw Error(K(300));return e}function vd(){var e=yr!==0;return yr=0,e}function cn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rt===null?De.memoizedState=rt=e:rt=rt.next=e,rt}function Ft(){if(nt===null){var e=De.alternate;e=e!==null?e.memoizedState:null}else e=nt.next;var n=rt===null?De.memoizedState:rt.next;if(n!==null)rt=n,nt=e;else{if(e===null)throw Error(K(310));nt=e,e={memoizedState:nt.memoizedState,baseState:nt.baseState,baseQueue:nt.baseQueue,queue:nt.queue,next:null},rt===null?De.memoizedState=rt=e:rt=rt.next=e}return rt}function vr(e,n){return typeof n=="function"?n(e):n}function Li(e){var n=Ft(),s=n.queue;if(s===null)throw Error(K(311));s.lastRenderedReducer=e;var l=nt,r=l.baseQueue,a=s.pending;if(a!==null){if(r!==null){var i=r.next;r.next=a.next,a.next=i}l.baseQueue=r=a,s.pending=null}if(r!==null){a=r.next,l=l.baseState;var d=i=null,p=null,u=a;do{var C=u.lane;if((_s&C)===C)p!==null&&(p=p.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),l=u.hasEagerState?u.eagerState:e(l,u.action);else{var x={lane:C,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};p===null?(d=p=x,i=l):p=p.next=x,De.lanes|=C,Cs|=C}u=u.next}while(u!==null&&u!==a);p===null?i=l:p.next=d,Zt(l,n.memoizedState)||(wt=!0),n.memoizedState=l,n.baseState=i,n.baseQueue=p,s.lastRenderedState=l}if(e=s.interleaved,e!==null){r=e;do a=r.lane,De.lanes|=a,Cs|=a,r=r.next;while(r!==e)}else r===null&&(s.lanes=0);return[n.memoizedState,s.dispatch]}function Oi(e){var n=Ft(),s=n.queue;if(s===null)throw Error(K(311));s.lastRenderedReducer=e;var l=s.dispatch,r=s.pending,a=n.memoizedState;if(r!==null){s.pending=null;var i=r=r.next;do a=e(a,i.action),i=i.next;while(i!==r);Zt(a,n.memoizedState)||(wt=!0),n.memoizedState=a,n.baseQueue===null&&(n.baseState=a),s.lastRenderedState=a}return[a,l]}function Zp(){}function ef(e,n){var s=De,l=Ft(),r=n(),a=!Zt(l.memoizedState,r);if(a&&(l.memoizedState=r,wt=!0),l=l.queue,jd(sf.bind(null,s,l,e),[e]),l.getSnapshot!==n||a||rt!==null&&rt.memoizedState.tag&1){if(s.flags|=2048,jr(9,nf.bind(null,s,l,r,n),void 0,null),at===null)throw Error(K(349));_s&30||tf(s,n,r)}return r}function tf(e,n,s){e.flags|=16384,e={getSnapshot:n,value:s},n=De.updateQueue,n===null?(n={lastEffect:null,stores:null},De.updateQueue=n,n.stores=[e]):(s=n.stores,s===null?n.stores=[e]:s.push(e))}function nf(e,n,s,l){n.value=s,n.getSnapshot=l,lf(n)&&rf(e)}function sf(e,n,s){return s(function(){lf(n)&&rf(e)})}function lf(e){var n=e.getSnapshot;e=e.value;try{var s=n();return!Zt(e,s)}catch{return!0}}function rf(e){var n=Tn(e,1);n!==null&&Vt(n,e,1,-1)}function Xc(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:vr,lastRenderedState:e},n.queue=e,e=e.dispatch=Im.bind(null,De,e),[n.memoizedState,e]}function jr(e,n,s,l){return e={tag:e,create:n,destroy:s,deps:l,next:null},n=De.updateQueue,n===null?(n={lastEffect:null,stores:null},De.updateQueue=n,n.lastEffect=e.next=e):(s=n.lastEffect,s===null?n.lastEffect=e.next=e:(l=s.next,s.next=e,e.next=l,n.lastEffect=e)),e}function af(){return Ft().memoizedState}function da(e,n,s,l){var r=cn();De.flags|=e,r.memoizedState=jr(1|n,s,void 0,l===void 0?null:l)}function Qa(e,n,s,l){var r=Ft();l=l===void 0?null:l;var a=void 0;if(nt!==null){var i=nt.memoizedState;if(a=i.destroy,l!==null&&md(l,i.deps)){r.memoizedState=jr(n,s,a,l);return}}De.flags|=e,r.memoizedState=jr(1|n,s,a,l)}function qc(e,n){return da(8390656,8,e,n)}function jd(e,n){return Qa(2048,8,e,n)}function of(e,n){return Qa(4,2,e,n)}function df(e,n){return Qa(4,4,e,n)}function cf(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 uf(e,n,s){return s=s!=null?s.concat([e]):null,Qa(4,4,cf.bind(null,n,e),s)}function bd(){}function pf(e,n){var s=Ft();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&md(n,l[1])?l[0]:(s.memoizedState=[e,n],e)}function ff(e,n){var s=Ft();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&md(n,l[1])?l[0]:(e=e(),s.memoizedState=[e,n],e)}function hf(e,n,s){return _s&21?(Zt(s,n)||(s=yp(),De.lanes|=s,Cs|=s,e.baseState=!0),n):(e.baseState&&(e.baseState=!1,wt=!0),e.memoizedState=s)}function Cm(e,n){var s=je;je=s!==0&&4>s?s:4,e(!0);var l=Di.transition;Di.transition={};try{e(!1),n()}finally{je=s,Di.transition=l}}function gf(){return Ft().memoizedState}function zm(e,n,s){var l=qn(e);if(s={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null},xf(e))mf(n,s);else if(s=qp(e,n,s,l),s!==null){var r=vt();Vt(s,e,l,r),yf(s,n,l)}}function Im(e,n,s){var l=qn(e),r={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null};if(xf(e))mf(n,r);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=n.lastRenderedReducer,a!==null))try{var i=n.lastRenderedState,d=a(i,s);if(r.hasEagerState=!0,r.eagerState=d,Zt(d,i)){var p=n.interleaved;p===null?(r.next=r,pd(n)):(r.next=p.next,p.next=r),n.interleaved=r;return}}catch{}finally{}s=qp(e,n,r,l),s!==null&&(r=vt(),Vt(s,e,l,r),yf(s,n,l))}}function xf(e){var n=e.alternate;return e===De||n!==null&&n===De}function mf(e,n){tr=Aa=!0;var s=e.pending;s===null?n.next=n:(n.next=s.next,s.next=n),e.pending=n}function yf(e,n,s){if(s&4194240){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,Vo(e,s)}}var Ra={readContext:Ut,useCallback:ft,useContext:ft,useEffect:ft,useImperativeHandle:ft,useInsertionEffect:ft,useLayoutEffect:ft,useMemo:ft,useReducer:ft,useRef:ft,useState:ft,useDebugValue:ft,useDeferredValue:ft,useTransition:ft,useMutableSource:ft,useSyncExternalStore:ft,useId:ft,unstable_isNewReconciler:!1},Tm={readContext:Ut,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:Ut,useEffect:qc,useImperativeHandle:function(e,n,s){return s=s!=null?s.concat([e]):null,da(4194308,4,cf.bind(null,n,e),s)},useLayoutEffect:function(e,n){return da(4194308,4,e,n)},useInsertionEffect:function(e,n){return da(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 l=cn();return n=s!==void 0?s(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=zm.bind(null,De,e),[l.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:Xc,useDebugValue:bd,useDeferredValue:function(e){return cn().memoizedState=e},useTransition:function(){var e=Xc(!1),n=e[0];return e=Cm.bind(null,e[1]),cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,s){var l=De,r=cn();if(Pe){if(s===void 0)throw Error(K(407));s=s()}else{if(s=n(),at===null)throw Error(K(349));_s&30||tf(l,n,s)}r.memoizedState=s;var a={value:s,getSnapshot:n};return r.queue=a,qc(sf.bind(null,l,a,e),[e]),l.flags|=2048,jr(9,nf.bind(null,l,a,s,n),void 0,null),s},useId:function(){var e=cn(),n=at.identifierPrefix;if(Pe){var s=_n,l=kn;s=(l&~(1<<32-Jt(l)-1)).toString(32)+s,n=":"+n+"R"+s,s=yr++,0<s&&(n+="H"+s.toString(32)),n+=":"}else s=_m++,n=":"+n+"r"+s.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Em={readContext:Ut,useCallback:pf,useContext:Ut,useEffect:jd,useImperativeHandle:uf,useInsertionEffect:of,useLayoutEffect:df,useMemo:ff,useReducer:Li,useRef:af,useState:function(){return Li(vr)},useDebugValue:bd,useDeferredValue:function(e){var n=Ft();return hf(n,nt.memoizedState,e)},useTransition:function(){var e=Li(vr)[0],n=Ft().memoizedState;return[e,n]},useMutableSource:Zp,useSyncExternalStore:ef,useId:gf,unstable_isNewReconciler:!1},Pm={readContext:Ut,useCallback:pf,useContext:Ut,useEffect:jd,useImperativeHandle:uf,useInsertionEffect:of,useLayoutEffect:df,useMemo:ff,useReducer:Oi,useRef:af,useState:function(){return Oi(vr)},useDebugValue:bd,useDeferredValue:function(e){var n=Ft();return nt===null?n.memoizedState=e:hf(n,nt.memoizedState,e)},useTransition:function(){var e=Oi(vr)[0],n=Ft().memoizedState;return[e,n]},useMutableSource:Zp,useSyncExternalStore:ef,useId:gf,unstable_isNewReconciler:!1};function Yt(e,n){if(e&&e.defaultProps){n=Le({},n),e=e.defaultProps;for(var s in e)n[s]===void 0&&(n[s]=e[s]);return n}return n}function bo(e,n,s,l){n=e.memoizedState,s=s(l,n),s=s==null?n:Le({},n,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Ya={isMounted:function(e){return(e=e._reactInternals)?Es(e)===e:!1},enqueueSetState:function(e,n,s){e=e._reactInternals;var l=vt(),r=qn(e),a=Cn(l,r);a.payload=n,s!=null&&(a.callback=s),n=Yn(e,a,r),n!==null&&(Vt(n,e,r,l),ia(n,e,r))},enqueueReplaceState:function(e,n,s){e=e._reactInternals;var l=vt(),r=qn(e),a=Cn(l,r);a.tag=1,a.payload=n,s!=null&&(a.callback=s),n=Yn(e,a,r),n!==null&&(Vt(n,e,r,l),ia(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var s=vt(),l=qn(e),r=Cn(s,l);r.tag=2,n!=null&&(r.callback=n),n=Yn(e,r,l),n!==null&&(Vt(n,e,l,s),ia(n,e,l))}};function Jc(e,n,s,l,r,a,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,a,i):n.prototype&&n.prototype.isPureReactComponent?!pr(s,l)||!pr(r,a):!0}function vf(e,n,s){var l=!1,r=Zn,a=n.contextType;return typeof a=="object"&&a!==null?a=Ut(a):(r=_t(n)?ws:xt.current,l=n.contextTypes,a=(l=l!=null)?yl(e,r):Zn),n=new n(s,a),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Ya,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=a),n}function Vc(e,n,s,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(s,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(s,l),n.state!==e&&Ya.enqueueReplaceState(n,n.state,null)}function So(e,n,s,l){var r=e.stateNode;r.props=s,r.state=e.memoizedState,r.refs={},fd(e);var a=n.contextType;typeof a=="object"&&a!==null?r.context=Ut(a):(a=_t(n)?ws:xt.current,r.context=yl(e,a)),r.state=e.memoizedState,a=n.getDerivedStateFromProps,typeof a=="function"&&(bo(e,n,a,s),r.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(n=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),n!==r.state&&Ya.enqueueReplaceState(r,r.state,null),Ea(e,s,r,l),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function Sl(e,n){try{var s="",l=n;do s+=rx(l),l=l.return;while(l);var r=s}catch(a){r=`
Error generating stack: `+a.message+`
`+a.stack}return{value:e,source:n,stack:r,digest:null}}function Ni(e,n,s){return{value:e,source:null,stack:s??null,digest:n??null}}function wo(e,n){try{console.error(n.value)}catch(s){setTimeout(function(){throw s})}}var Am=typeof WeakMap=="function"?WeakMap:Map;function jf(e,n,s){s=Cn(-1,s),s.tag=3,s.payload={element:null};var l=n.value;return s.callback=function(){La||(La=!0,Ro=l),wo(e,n)},s}function bf(e,n,s){s=Cn(-1,s),s.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var r=n.value;s.payload=function(){return l(r)},s.callback=function(){wo(e,n)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){wo(e,n),typeof l!="function"&&(Xn===null?Xn=new Set([this]):Xn.add(this));var i=n.stack;this.componentDidCatch(n.value,{componentStack:i!==null?i:""})}),s}function Zc(e,n,s){var l=e.pingCache;if(l===null){l=e.pingCache=new Am;var r=new Set;l.set(n,r)}else r=l.get(n),r===void 0&&(r=new Set,l.set(n,r));r.has(s)||(r.add(s),e=Km.bind(null,e,n,s),n.then(e,e))}function eu(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 tu(e,n,s,l,r){return e.mode&1?(e.flags|=65536,e.lanes=r,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=Cn(-1,1),n.tag=2,Yn(s,n,1))),s.lanes|=1),e)}var Rm=Pn.ReactCurrentOwner,wt=!1;function yt(e,n,s,l){n.child=e===null?Xp(n,null,s,l):jl(n,e.child,s,l)}function nu(e,n,s,l,r){s=s.render;var a=n.ref;return gl(n,r),l=yd(e,n,s,l,a,r),s=vd(),e!==null&&!wt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r,En(e,n,r)):(Pe&&s&&ad(n),n.flags|=1,yt(e,n,l,r),n.child)}function su(e,n,s,l,r){if(e===null){var a=s.type;return typeof a=="function"&&!Td(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(n.tag=15,n.type=a,Sf(e,n,a,l,r)):(e=fa(s.type,null,l,n,n.mode,r),e.ref=n.ref,e.return=n,n.child=e)}if(a=e.child,!(e.lanes&r)){var i=a.memoizedProps;if(s=s.compare,s=s!==null?s:pr,s(i,l)&&e.ref===n.ref)return En(e,n,r)}return n.flags|=1,e=Jn(a,l),e.ref=n.ref,e.return=n,n.child=e}function Sf(e,n,s,l,r){if(e!==null){var a=e.memoizedProps;if(pr(a,l)&&e.ref===n.ref)if(wt=!1,n.pendingProps=l=a,(e.lanes&r)!==0)e.flags&131072&&(wt=!0);else return n.lanes=e.lanes,En(e,n,r)}return ko(e,n,s,l,r)}function wf(e,n,s){var l=n.pendingProps,r=l.children,a=e!==null?e.memoizedState:null;if(l.mode==="hidden")if(!(n.mode&1))n.memoizedState={baseLanes:0,cachePool:null,transitions:null},ke(dl,Pt),Pt|=s;else{if(!(s&1073741824))return e=a!==null?a.baseLanes|s:s,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,ke(dl,Pt),Pt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=a!==null?a.baseLanes:s,ke(dl,Pt),Pt|=l}else a!==null?(l=a.baseLanes|s,n.memoizedState=null):l=s,ke(dl,Pt),Pt|=l;return yt(e,n,r,s),n.child}function kf(e,n){var s=n.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(n.flags|=512,n.flags|=2097152)}function ko(e,n,s,l,r){var a=_t(s)?ws:xt.current;return a=yl(n,a),gl(n,r),s=yd(e,n,s,l,a,r),l=vd(),e!==null&&!wt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r,En(e,n,r)):(Pe&&l&&ad(n),n.flags|=1,yt(e,n,s,r),n.child)}function lu(e,n,s,l,r){if(_t(s)){var a=!0;_a(n)}else a=!1;if(gl(n,r),n.stateNode===null)ca(e,n),vf(n,s,l),So(n,s,l,r),l=!0;else if(e===null){var i=n.stateNode,d=n.memoizedProps;i.props=d;var p=i.context,u=s.contextType;typeof u=="object"&&u!==null?u=Ut(u):(u=_t(s)?ws:xt.current,u=yl(n,u));var C=s.getDerivedStateFromProps,x=typeof C=="function"||typeof i.getSnapshotBeforeUpdate=="function";x||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==l||p!==u)&&Vc(n,i,l,u),Nn=!1;var m=n.memoizedState;i.state=m,Ea(n,l,i,r),p=n.memoizedState,d!==l||m!==p||kt.current||Nn?(typeof C=="function"&&(bo(n,s,C,l),p=n.memoizedState),(d=Nn||Jc(n,s,d,l,m,p,u))?(x||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=l,n.memoizedState=p),i.props=l,i.state=p,i.context=u,l=d):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{i=n.stateNode,Jp(e,n),d=n.memoizedProps,u=n.type===n.elementType?d:Yt(n.type,d),i.props=u,x=n.pendingProps,m=i.context,p=s.contextType,typeof p=="object"&&p!==null?p=Ut(p):(p=_t(s)?ws:xt.current,p=yl(n,p));var h=s.getDerivedStateFromProps;(C=typeof h=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==x||m!==p)&&Vc(n,i,l,p),Nn=!1,m=n.memoizedState,i.state=m,Ea(n,l,i,r);var b=n.memoizedState;d!==x||m!==b||kt.current||Nn?(typeof h=="function"&&(bo(n,s,h,l),b=n.memoizedState),(u=Nn||Jc(n,s,u,l,m,b,p)||!1)?(C||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(l,b,p),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(l,b,p)),typeof i.componentDidUpdate=="function"&&(n.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&m===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&m===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=b),i.props=l,i.state=b,i.context=p,l=u):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&m===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&m===e.memoizedState||(n.flags|=1024),l=!1)}return _o(e,n,s,l,a,r)}function _o(e,n,s,l,r,a){kf(e,n);var i=(n.flags&128)!==0;if(!l&&!i)return r&&Mc(n,s,!1),En(e,n,a);l=n.stateNode,Rm.current=n;var d=i&&typeof s.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&i?(n.child=jl(n,e.child,null,a),n.child=jl(n,null,d,a)):yt(e,n,d,a),n.memoizedState=l.state,r&&Mc(n,s,!0),n.child}function _f(e){var n=e.stateNode;n.pendingContext?Fc(e,n.pendingContext,n.pendingContext!==n.context):n.context&&Fc(e,n.context,!1),hd(e,n.containerInfo)}function ru(e,n,s,l,r){return vl(),od(r),n.flags|=256,yt(e,n,s,l),n.child}var Co={dehydrated:null,treeContext:null,retryLane:0};function zo(e){return{baseLanes:e,cachePool:null,transitions:null}}function Cf(e,n,s){var l=n.pendingProps,r=Re.current,a=!1,i=(n.flags&128)!==0,d;if((d=i)||(d=e!==null&&e.memoizedState===null?!1:(r&2)!==0),d?(a=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(r|=1),ke(Re,r&1),e===null)return vo(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=l.children,e=l.fallback,a?(l=n.mode,a=n.child,i={mode:"hidden",children:i},!(l&1)&&a!==null?(a.childLanes=0,a.pendingProps=i):a=Ja(i,l,0,null),e=Ss(e,l,s,null),a.return=n,e.return=n,a.sibling=e,n.child=a,n.child.memoizedState=zo(s),n.memoizedState=Co,e):Sd(n,i));if(r=e.memoizedState,r!==null&&(d=r.dehydrated,d!==null))return Dm(e,n,i,l,d,r,s);if(a){a=l.fallback,i=n.mode,r=e.child,d=r.sibling;var p={mode:"hidden",children:l.children};return!(i&1)&&n.child!==r?(l=n.child,l.childLanes=0,l.pendingProps=p,n.deletions=null):(l=Jn(r,p),l.subtreeFlags=r.subtreeFlags&14680064),d!==null?a=Jn(d,a):(a=Ss(a,i,s,null),a.flags|=2),a.return=n,l.return=n,l.sibling=a,n.child=l,l=a,a=n.child,i=e.child.memoizedState,i=i===null?zo(s):{baseLanes:i.baseLanes|s,cachePool:null,transitions:i.transitions},a.memoizedState=i,a.childLanes=e.childLanes&~s,n.memoizedState=Co,l}return a=e.child,e=a.sibling,l=Jn(a,{mode:"visible",children:l.children}),!(n.mode&1)&&(l.lanes=s),l.return=n,l.sibling=null,e!==null&&(s=n.deletions,s===null?(n.deletions=[e],n.flags|=16):s.push(e)),n.child=l,n.memoizedState=null,l}function Sd(e,n){return n=Ja({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Yr(e,n,s,l){return l!==null&&od(l),jl(n,e.child,null,s),e=Sd(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Dm(e,n,s,l,r,a,i){if(s)return n.flags&256?(n.flags&=-257,l=Ni(Error(K(422))),Yr(e,n,i,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(a=l.fallback,r=n.mode,l=Ja({mode:"visible",children:l.children},r,0,null),a=Ss(a,r,i,null),a.flags|=2,l.return=n,a.return=n,l.sibling=a,n.child=l,n.mode&1&&jl(n,e.child,null,i),n.child.memoizedState=zo(i),n.memoizedState=Co,a);if(!(n.mode&1))return Yr(e,n,i,null);if(r.data==="$!"){if(l=r.nextSibling&&r.nextSibling.dataset,l)var d=l.dgst;return l=d,a=Error(K(419)),l=Ni(a,l,void 0),Yr(e,n,i,l)}if(d=(i&e.childLanes)!==0,wt||d){if(l=at,l!==null){switch(i&-i){case 4:r=2;break;case 16:r=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:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(l.suspendedLanes|i)?0:r,r!==0&&r!==a.retryLane&&(a.retryLane=r,Tn(e,r),Vt(l,e,r,-1))}return Id(),l=Ni(Error(K(421))),Yr(e,n,i,l)}return r.data==="$?"?(n.flags|=128,n.child=e.child,n=Qm.bind(null,e),r._reactRetry=n,null):(e=a.treeContext,At=Qn(r.nextSibling),Rt=n,Pe=!0,qt=null,e!==null&&(Nt[Wt++]=kn,Nt[Wt++]=_n,Nt[Wt++]=ks,kn=e.id,_n=e.overflow,ks=n),n=Sd(n,l.children),n.flags|=4096,n)}function au(e,n,s){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),jo(e.return,n,s)}function Wi(e,n,s,l,r){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:s,tailMode:r}:(a.isBackwards=n,a.rendering=null,a.renderingStartTime=0,a.last=l,a.tail=s,a.tailMode=r)}function zf(e,n,s){var l=n.pendingProps,r=l.revealOrder,a=l.tail;if(yt(e,n,l.children,s),l=Re.current,l&2)l=l&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&&au(e,s,n);else if(e.tag===19)au(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}l&=1}if(ke(Re,l),!(n.mode&1))n.memoizedState=null;else switch(r){case"forwards":for(s=n.child,r=null;s!==null;)e=s.alternate,e!==null&&Pa(e)===null&&(r=s),s=s.sibling;s=r,s===null?(r=n.child,n.child=null):(r=s.sibling,s.sibling=null),Wi(n,!1,r,s,a);break;case"backwards":for(s=null,r=n.child,n.child=null;r!==null;){if(e=r.alternate,e!==null&&Pa(e)===null){n.child=r;break}e=r.sibling,r.sibling=s,s=r,r=e}Wi(n,!0,s,null,a);break;case"together":Wi(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function ca(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function En(e,n,s){if(e!==null&&(n.dependencies=e.dependencies),Cs|=n.lanes,!(s&n.childLanes))return null;if(e!==null&&n.child!==e.child)throw Error(K(153));if(n.child!==null){for(e=n.child,s=Jn(e,e.pendingProps),n.child=s,s.return=n;e.sibling!==null;)e=e.sibling,s=s.sibling=Jn(e,e.pendingProps),s.return=n;s.sibling=null}return n.child}function Lm(e,n,s){switch(n.tag){case 3:_f(n),vl();break;case 5:Vp(n);break;case 1:_t(n.type)&&_a(n);break;case 4:hd(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,r=n.memoizedProps.value;ke(Ia,l._currentValue),l._currentValue=r;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(ke(Re,Re.current&1),n.flags|=128,null):s&n.child.childLanes?Cf(e,n,s):(ke(Re,Re.current&1),e=En(e,n,s),e!==null?e.sibling:null);ke(Re,Re.current&1);break;case 19:if(l=(s&n.childLanes)!==0,e.flags&128){if(l)return zf(e,n,s);n.flags|=128}if(r=n.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),ke(Re,Re.current),l)break;return null;case 22:case 23:return n.lanes=0,wf(e,n,s)}return En(e,n,s)}var If,Io,Tf,Ef;If=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}};Io=function(){};Tf=function(e,n,s,l){var r=e.memoizedProps;if(r!==l){e=n.stateNode,js(fn.current);var a=null;switch(s){case"input":r=Xi(e,r),l=Xi(e,l),a=[];break;case"select":r=Le({},r,{value:void 0}),l=Le({},l,{value:void 0}),a=[];break;case"textarea":r=Vi(e,r),l=Vi(e,l),a=[];break;default:typeof r.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=wa)}eo(s,l);var i;s=null;for(u in r)if(!l.hasOwnProperty(u)&&r.hasOwnProperty(u)&&r[u]!=null)if(u==="style"){var d=r[u];for(i in d)d.hasOwnProperty(i)&&(s||(s={}),s[i]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(rr.hasOwnProperty(u)?a||(a=[]):(a=a||[]).push(u,null));for(u in l){var p=l[u];if(d=r!=null?r[u]:void 0,l.hasOwnProperty(u)&&p!==d&&(p!=null||d!=null))if(u==="style")if(d){for(i in d)!d.hasOwnProperty(i)||p&&p.hasOwnProperty(i)||(s||(s={}),s[i]="");for(i in p)p.hasOwnProperty(i)&&d[i]!==p[i]&&(s||(s={}),s[i]=p[i])}else s||(a||(a=[]),a.push(u,s)),s=p;else u==="dangerouslySetInnerHTML"?(p=p?p.__html:void 0,d=d?d.__html:void 0,p!=null&&d!==p&&(a=a||[]).push(u,p)):u==="children"?typeof p!="string"&&typeof p!="number"||(a=a||[]).push(u,""+p):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(rr.hasOwnProperty(u)?(p!=null&&u==="onScroll"&&Ce("scroll",e),a||d===p||(a=[])):(a=a||[]).push(u,p))}s&&(a=a||[]).push("style",s);var u=a;(n.updateQueue=u)&&(n.flags|=4)}};Ef=function(e,n,s,l){s!==l&&(n.flags|=4)};function Ul(e,n){if(!Pe)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 l=null;s!==null;)s.alternate!==null&&(l=s),s=s.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function ht(e){var n=e.alternate!==null&&e.alternate.child===e.child,s=0,l=0;if(n)for(var r=e.child;r!==null;)s|=r.lanes|r.childLanes,l|=r.subtreeFlags&14680064,l|=r.flags&14680064,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)s|=r.lanes|r.childLanes,l|=r.subtreeFlags,l|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=l,e.childLanes=s,n}function Om(e,n,s){var l=n.pendingProps;switch(id(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ht(n),null;case 1:return _t(n.type)&&ka(),ht(n),null;case 3:return l=n.stateNode,bl(),ze(kt),ze(xt),xd(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Kr(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&!(n.flags&256)||(n.flags|=1024,qt!==null&&(Oo(qt),qt=null))),Io(e,n),ht(n),null;case 5:gd(n);var r=js(mr.current);if(s=n.type,e!==null&&n.stateNode!=null)Tf(e,n,s,l,r),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(K(166));return ht(n),null}if(e=js(fn.current),Kr(n)){l=n.stateNode,s=n.type;var a=n.memoizedProps;switch(l[un]=n,l[gr]=a,e=(n.mode&1)!==0,s){case"dialog":Ce("cancel",l),Ce("close",l);break;case"iframe":case"object":case"embed":Ce("load",l);break;case"video":case"audio":for(r=0;r<Yl.length;r++)Ce(Yl[r],l);break;case"source":Ce("error",l);break;case"img":case"image":case"link":Ce("error",l),Ce("load",l);break;case"details":Ce("toggle",l);break;case"input":gc(l,a),Ce("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!a.multiple},Ce("invalid",l);break;case"textarea":mc(l,a),Ce("invalid",l)}eo(s,a),r=null;for(var i in a)if(a.hasOwnProperty(i)){var d=a[i];i==="children"?typeof d=="string"?l.textContent!==d&&(a.suppressHydrationWarning!==!0&&Gr(l.textContent,d,e),r=["children",d]):typeof d=="number"&&l.textContent!==""+d&&(a.suppressHydrationWarning!==!0&&Gr(l.textContent,d,e),r=["children",""+d]):rr.hasOwnProperty(i)&&d!=null&&i==="onScroll"&&Ce("scroll",l)}switch(s){case"input":Nr(l),xc(l,a,!0);break;case"textarea":Nr(l),yc(l);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(l.onclick=wa)}l=r,n.updateQueue=l,l!==null&&(n.flags|=4)}else{i=r.nodeType===9?r:r.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=sp(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=i.createElement(s,{is:l.is}):(e=i.createElement(s),s==="select"&&(i=e,l.multiple?i.multiple=!0:l.size&&(i.size=l.size))):e=i.createElementNS(e,s),e[un]=n,e[gr]=l,If(e,n,!1,!1),n.stateNode=e;e:{switch(i=to(s,l),s){case"dialog":Ce("cancel",e),Ce("close",e),r=l;break;case"iframe":case"object":case"embed":Ce("load",e),r=l;break;case"video":case"audio":for(r=0;r<Yl.length;r++)Ce(Yl[r],e);r=l;break;case"source":Ce("error",e),r=l;break;case"img":case"image":case"link":Ce("error",e),Ce("load",e),r=l;break;case"details":Ce("toggle",e),r=l;break;case"input":gc(e,l),r=Xi(e,l),Ce("invalid",e);break;case"option":r=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},r=Le({},l,{value:void 0}),Ce("invalid",e);break;case"textarea":mc(e,l),r=Vi(e,l),Ce("invalid",e);break;default:r=l}eo(s,r),d=r;for(a in d)if(d.hasOwnProperty(a)){var p=d[a];a==="style"?ap(e,p):a==="dangerouslySetInnerHTML"?(p=p?p.__html:void 0,p!=null&&lp(e,p)):a==="children"?typeof p=="string"?(s!=="textarea"||p!=="")&&ar(e,p):typeof p=="number"&&ar(e,""+p):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(rr.hasOwnProperty(a)?p!=null&&a==="onScroll"&&Ce("scroll",e):p!=null&&Ko(e,a,p,i))}switch(s){case"input":Nr(e),xc(e,l,!1);break;case"textarea":Nr(e),yc(e);break;case"option":l.value!=null&&e.setAttribute("value",""+Vn(l.value));break;case"select":e.multiple=!!l.multiple,a=l.value,a!=null?ul(e,!!l.multiple,a,!1):l.defaultValue!=null&&ul(e,!!l.multiple,l.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=wa)}switch(s){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return ht(n),null;case 6:if(e&&n.stateNode!=null)Ef(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(K(166));if(s=js(mr.current),js(fn.current),Kr(n)){if(l=n.stateNode,s=n.memoizedProps,l[un]=n,(a=l.nodeValue!==s)&&(e=Rt,e!==null))switch(e.tag){case 3:Gr(l.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Gr(l.nodeValue,s,(e.mode&1)!==0)}a&&(n.flags|=4)}else l=(s.nodeType===9?s:s.ownerDocument).createTextNode(l),l[un]=n,n.stateNode=l}return ht(n),null;case 13:if(ze(Re),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Pe&&At!==null&&n.mode&1&&!(n.flags&128))Qp(),vl(),n.flags|=98560,a=!1;else if(a=Kr(n),l!==null&&l.dehydrated!==null){if(e===null){if(!a)throw Error(K(318));if(a=n.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(K(317));a[un]=n}else vl(),!(n.flags&128)&&(n.memoizedState=null),n.flags|=4;ht(n),a=!1}else qt!==null&&(Oo(qt),qt=null),a=!0;if(!a)return n.flags&65536?n:null}return n.flags&128?(n.lanes=s,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,n.mode&1&&(e===null||Re.current&1?st===0&&(st=3):Id())),n.updateQueue!==null&&(n.flags|=4),ht(n),null);case 4:return bl(),Io(e,n),e===null&&fr(n.stateNode.containerInfo),ht(n),null;case 10:return ud(n.type._context),ht(n),null;case 17:return _t(n.type)&&ka(),ht(n),null;case 19:if(ze(Re),a=n.memoizedState,a===null)return ht(n),null;if(l=(n.flags&128)!==0,i=a.rendering,i===null)if(l)Ul(a,!1);else{if(st!==0||e!==null&&e.flags&128)for(e=n.child;e!==null;){if(i=Pa(e),i!==null){for(n.flags|=128,Ul(a,!1),l=i.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=s,s=n.child;s!==null;)a=s,e=l,a.flags&=14680066,i=a.alternate,i===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,a.type=i.type,e=i.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return ke(Re,Re.current&1|2),n.child}e=e.sibling}a.tail!==null&&Ye()>wl&&(n.flags|=128,l=!0,Ul(a,!1),n.lanes=4194304)}else{if(!l)if(e=Pa(i),e!==null){if(n.flags|=128,l=!0,s=e.updateQueue,s!==null&&(n.updateQueue=s,n.flags|=4),Ul(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!Pe)return ht(n),null}else 2*Ye()-a.renderingStartTime>wl&&s!==1073741824&&(n.flags|=128,l=!0,Ul(a,!1),n.lanes=4194304);a.isBackwards?(i.sibling=n.child,n.child=i):(s=a.last,s!==null?s.sibling=i:n.child=i,a.last=i)}return a.tail!==null?(n=a.tail,a.rendering=n,a.tail=n.sibling,a.renderingStartTime=Ye(),n.sibling=null,s=Re.current,ke(Re,l?s&1|2:s&1),n):(ht(n),null);case 22:case 23:return zd(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&n.mode&1?Pt&1073741824&&(ht(n),n.subtreeFlags&6&&(n.flags|=8192)):ht(n),null;case 24:return null;case 25:return null}throw Error(K(156,n.tag))}function Nm(e,n){switch(id(n),n.tag){case 1:return _t(n.type)&&ka(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return bl(),ze(kt),ze(xt),xd(),e=n.flags,e&65536&&!(e&128)?(n.flags=e&-65537|128,n):null;case 5:return gd(n),null;case 13:if(ze(Re),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(K(340));vl()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return ze(Re),null;case 4:return bl(),null;case 10:return ud(n.type._context),null;case 22:case 23:return zd(),null;case 24:return null;default:return null}}var Xr=!1,gt=!1,Wm=typeof WeakSet=="function"?WeakSet:Set,V=null;function ol(e,n){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(l){He(e,n,l)}else s.current=null}function To(e,n,s){try{s()}catch(l){He(e,n,l)}}var iu=!1;function Bm(e,n){if(po=ja,e=Dp(),rd(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var l=s.getSelection&&s.getSelection();if(l&&l.rangeCount!==0){s=l.anchorNode;var r=l.anchorOffset,a=l.focusNode;l=l.focusOffset;try{s.nodeType,a.nodeType}catch{s=null;break e}var i=0,d=-1,p=-1,u=0,C=0,x=e,m=null;t:for(;;){for(var h;x!==s||r!==0&&x.nodeType!==3||(d=i+r),x!==a||l!==0&&x.nodeType!==3||(p=i+l),x.nodeType===3&&(i+=x.nodeValue.length),(h=x.firstChild)!==null;)m=x,x=h;for(;;){if(x===e)break t;if(m===s&&++u===r&&(d=i),m===a&&++C===l&&(p=i),(h=x.nextSibling)!==null)break;x=m,m=x.parentNode}x=h}s=d===-1||p===-1?null:{start:d,end:p}}else s=null}s=s||{start:0,end:0}}else s=null;for(fo={focusedElem:e,selectionRange:s},ja=!1,V=n;V!==null;)if(n=V,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,V=e;else for(;V!==null;){n=V;try{var b=n.alternate;if(n.flags&1024)switch(n.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var _=b.memoizedProps,v=b.memoizedState,g=n.stateNode,o=g.getSnapshotBeforeUpdate(n.elementType===n.type?_:Yt(n.type,_),v);g.__reactInternalSnapshotBeforeUpdate=o}break;case 3:var c=n.stateNode.containerInfo;c.nodeType===1?c.textContent="":c.nodeType===9&&c.documentElement&&c.removeChild(c.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(K(163))}}catch(y){He(n,n.return,y)}if(e=n.sibling,e!==null){e.return=n.return,V=e;break}V=n.return}return b=iu,iu=!1,b}function nr(e,n,s){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var r=l=l.next;do{if((r.tag&e)===e){var a=r.destroy;r.destroy=void 0,a!==void 0&&To(n,s,a)}r=r.next}while(r!==l)}}function Xa(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 l=s.create;s.destroy=l()}s=s.next}while(s!==n)}}function Eo(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 Pf(e){var n=e.alternate;n!==null&&(e.alternate=null,Pf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[un],delete n[gr],delete n[xo],delete n[bm],delete n[Sm])),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 Af(e){return e.tag===5||e.tag===3||e.tag===4}function ou(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Af(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 Po(e,n,s){var l=e.tag;if(l===5||l===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=wa));else if(l!==4&&(e=e.child,e!==null))for(Po(e,n,s),e=e.sibling;e!==null;)Po(e,n,s),e=e.sibling}function Ao(e,n,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?s.insertBefore(e,n):s.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Ao(e,n,s),e=e.sibling;e!==null;)Ao(e,n,s),e=e.sibling}var ot=null,Xt=!1;function Dn(e,n,s){for(s=s.child;s!==null;)Rf(e,n,s),s=s.sibling}function Rf(e,n,s){if(pn&&typeof pn.onCommitFiberUnmount=="function")try{pn.onCommitFiberUnmount(Ua,s)}catch{}switch(s.tag){case 5:gt||ol(s,n);case 6:var l=ot,r=Xt;ot=null,Dn(e,n,s),ot=l,Xt=r,ot!==null&&(Xt?(e=ot,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):ot.removeChild(s.stateNode));break;case 18:ot!==null&&(Xt?(e=ot,s=s.stateNode,e.nodeType===8?Pi(e.parentNode,s):e.nodeType===1&&Pi(e,s),cr(e)):Pi(ot,s.stateNode));break;case 4:l=ot,r=Xt,ot=s.stateNode.containerInfo,Xt=!0,Dn(e,n,s),ot=l,Xt=r;break;case 0:case 11:case 14:case 15:if(!gt&&(l=s.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){r=l=l.next;do{var a=r,i=a.destroy;a=a.tag,i!==void 0&&(a&2||a&4)&&To(s,n,i),r=r.next}while(r!==l)}Dn(e,n,s);break;case 1:if(!gt&&(ol(s,n),l=s.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=s.memoizedProps,l.state=s.memoizedState,l.componentWillUnmount()}catch(d){He(s,n,d)}Dn(e,n,s);break;case 21:Dn(e,n,s);break;case 22:s.mode&1?(gt=(l=gt)||s.memoizedState!==null,Dn(e,n,s),gt=l):Dn(e,n,s);break;default:Dn(e,n,s)}}function du(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Wm),n.forEach(function(l){var r=Ym.bind(null,e,l);s.has(l)||(s.add(l),l.then(r,r))})}}function Kt(e,n){var s=n.deletions;if(s!==null)for(var l=0;l<s.length;l++){var r=s[l];try{var a=e,i=n,d=i;e:for(;d!==null;){switch(d.tag){case 5:ot=d.stateNode,Xt=!1;break e;case 3:ot=d.stateNode.containerInfo,Xt=!0;break e;case 4:ot=d.stateNode.containerInfo,Xt=!0;break e}d=d.return}if(ot===null)throw Error(K(160));Rf(a,i,r),ot=null,Xt=!1;var p=r.alternate;p!==null&&(p.return=null),r.return=null}catch(u){He(r,n,u)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Df(n,e),n=n.sibling}function Df(e,n){var s=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Kt(n,e),rn(e),l&4){try{nr(3,e,e.return),Xa(3,e)}catch(_){He(e,e.return,_)}try{nr(5,e,e.return)}catch(_){He(e,e.return,_)}}break;case 1:Kt(n,e),rn(e),l&512&&s!==null&&ol(s,s.return);break;case 5:if(Kt(n,e),rn(e),l&512&&s!==null&&ol(s,s.return),e.flags&32){var r=e.stateNode;try{ar(r,"")}catch(_){He(e,e.return,_)}}if(l&4&&(r=e.stateNode,r!=null)){var a=e.memoizedProps,i=s!==null?s.memoizedProps:a,d=e.type,p=e.updateQueue;if(e.updateQueue=null,p!==null)try{d==="input"&&a.type==="radio"&&a.name!=null&&tp(r,a),to(d,i);var u=to(d,a);for(i=0;i<p.length;i+=2){var C=p[i],x=p[i+1];C==="style"?ap(r,x):C==="dangerouslySetInnerHTML"?lp(r,x):C==="children"?ar(r,x):Ko(r,C,x,u)}switch(d){case"input":qi(r,a);break;case"textarea":np(r,a);break;case"select":var m=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!a.multiple;var h=a.value;h!=null?ul(r,!!a.multiple,h,!1):m!==!!a.multiple&&(a.defaultValue!=null?ul(r,!!a.multiple,a.defaultValue,!0):ul(r,!!a.multiple,a.multiple?[]:"",!1))}r[gr]=a}catch(_){He(e,e.return,_)}}break;case 6:if(Kt(n,e),rn(e),l&4){if(e.stateNode===null)throw Error(K(162));r=e.stateNode,a=e.memoizedProps;try{r.nodeValue=a}catch(_){He(e,e.return,_)}}break;case 3:if(Kt(n,e),rn(e),l&4&&s!==null&&s.memoizedState.isDehydrated)try{cr(n.containerInfo)}catch(_){He(e,e.return,_)}break;case 4:Kt(n,e),rn(e);break;case 13:Kt(n,e),rn(e),r=e.child,r.flags&8192&&(a=r.memoizedState!==null,r.stateNode.isHidden=a,!a||r.alternate!==null&&r.alternate.memoizedState!==null||(_d=Ye())),l&4&&du(e);break;case 22:if(C=s!==null&&s.memoizedState!==null,e.mode&1?(gt=(u=gt)||C,Kt(n,e),gt=u):Kt(n,e),rn(e),l&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!C&&e.mode&1)for(V=e,C=e.child;C!==null;){for(x=V=C;V!==null;){switch(m=V,h=m.child,m.tag){case 0:case 11:case 14:case 15:nr(4,m,m.return);break;case 1:ol(m,m.return);var b=m.stateNode;if(typeof b.componentWillUnmount=="function"){l=m,s=m.return;try{n=l,b.props=n.memoizedProps,b.state=n.memoizedState,b.componentWillUnmount()}catch(_){He(l,s,_)}}break;case 5:ol(m,m.return);break;case 22:if(m.memoizedState!==null){uu(x);continue}}h!==null?(h.return=m,V=h):uu(x)}C=C.sibling}e:for(C=null,x=e;;){if(x.tag===5){if(C===null){C=x;try{r=x.stateNode,u?(a=r.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(d=x.stateNode,p=x.memoizedProps.style,i=p!=null&&p.hasOwnProperty("display")?p.display:null,d.style.display=rp("display",i))}catch(_){He(e,e.return,_)}}}else if(x.tag===6){if(C===null)try{x.stateNode.nodeValue=u?"":x.memoizedProps}catch(_){He(e,e.return,_)}}else if((x.tag!==22&&x.tag!==23||x.memoizedState===null||x===e)&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===e)break e;for(;x.sibling===null;){if(x.return===null||x.return===e)break e;C===x&&(C=null),x=x.return}C===x&&(C=null),x.sibling.return=x.return,x=x.sibling}}break;case 19:Kt(n,e),rn(e),l&4&&du(e);break;case 21:break;default:Kt(n,e),rn(e)}}function rn(e){var n=e.flags;if(n&2){try{e:{for(var s=e.return;s!==null;){if(Af(s)){var l=s;break e}s=s.return}throw Error(K(160))}switch(l.tag){case 5:var r=l.stateNode;l.flags&32&&(ar(r,""),l.flags&=-33);var a=ou(e);Ao(e,a,r);break;case 3:case 4:var i=l.stateNode.containerInfo,d=ou(e);Po(e,d,i);break;default:throw Error(K(161))}}catch(p){He(e,e.return,p)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function $m(e,n,s){V=e,Lf(e)}function Lf(e,n,s){for(var l=(e.mode&1)!==0;V!==null;){var r=V,a=r.child;if(r.tag===22&&l){var i=r.memoizedState!==null||Xr;if(!i){var d=r.alternate,p=d!==null&&d.memoizedState!==null||gt;d=Xr;var u=gt;if(Xr=i,(gt=p)&&!u)for(V=r;V!==null;)i=V,p=i.child,i.tag===22&&i.memoizedState!==null?pu(r):p!==null?(p.return=i,V=p):pu(r);for(;a!==null;)V=a,Lf(a),a=a.sibling;V=r,Xr=d,gt=u}cu(e)}else r.subtreeFlags&8772&&a!==null?(a.return=r,V=a):cu(e)}}function cu(e){for(;V!==null;){var n=V;if(n.flags&8772){var s=n.alternate;try{if(n.flags&8772)switch(n.tag){case 0:case 11:case 15:gt||Xa(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!gt)if(s===null)l.componentDidMount();else{var r=n.elementType===n.type?s.memoizedProps:Yt(n.type,s.memoizedProps);l.componentDidUpdate(r,s.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var a=n.updateQueue;a!==null&&Yc(n,a,l);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}Yc(n,i,s)}break;case 5:var d=n.stateNode;if(s===null&&n.flags&4){s=d;var p=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":p.autoFocus&&s.focus();break;case"img":p.src&&(s.src=p.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var u=n.alternate;if(u!==null){var C=u.memoizedState;if(C!==null){var x=C.dehydrated;x!==null&&cr(x)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(K(163))}gt||n.flags&512&&Eo(n)}catch(m){He(n,n.return,m)}}if(n===e){V=null;break}if(s=n.sibling,s!==null){s.return=n.return,V=s;break}V=n.return}}function uu(e){for(;V!==null;){var n=V;if(n===e){V=null;break}var s=n.sibling;if(s!==null){s.return=n.return,V=s;break}V=n.return}}function pu(e){for(;V!==null;){var n=V;try{switch(n.tag){case 0:case 11:case 15:var s=n.return;try{Xa(4,n)}catch(p){He(n,s,p)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var r=n.return;try{l.componentDidMount()}catch(p){He(n,r,p)}}var a=n.return;try{Eo(n)}catch(p){He(n,a,p)}break;case 5:var i=n.return;try{Eo(n)}catch(p){He(n,i,p)}}}catch(p){He(n,n.return,p)}if(n===e){V=null;break}var d=n.sibling;if(d!==null){d.return=n.return,V=d;break}V=n.return}}var Um=Math.ceil,Da=Pn.ReactCurrentDispatcher,wd=Pn.ReactCurrentOwner,$t=Pn.ReactCurrentBatchConfig,ge=0,at=null,Ve=null,dt=0,Pt=0,dl=ns(0),st=0,br=null,Cs=0,qa=0,kd=0,sr=null,St=null,_d=0,wl=1/0,Sn=null,La=!1,Ro=null,Xn=null,qr=!1,Un=null,Oa=0,lr=0,Do=null,ua=-1,pa=0;function vt(){return ge&6?Ye():ua!==-1?ua:ua=Ye()}function qn(e){return e.mode&1?ge&2&&dt!==0?dt&-dt:km.transition!==null?(pa===0&&(pa=yp()),pa):(e=je,e!==0||(e=window.event,e=e===void 0?16:_p(e.type)),e):1}function Vt(e,n,s,l){if(50<lr)throw lr=0,Do=null,Error(K(185));_r(e,s,l),(!(ge&2)||e!==at)&&(e===at&&(!(ge&2)&&(qa|=s),st===4&&Bn(e,dt)),Ct(e,l),s===1&&ge===0&&!(n.mode&1)&&(wl=Ye()+500,Ka&&ss()))}function Ct(e,n){var s=e.callbackNode;kx(e,n);var l=va(e,e===at?dt:0);if(l===0)s!==null&&bc(s),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(s!=null&&bc(s),n===1)e.tag===0?wm(fu.bind(null,e)):Hp(fu.bind(null,e)),vm(function(){!(ge&6)&&ss()}),s=null;else{switch(vp(l)){case 1:s=Jo;break;case 4:s=xp;break;case 16:s=ya;break;case 536870912:s=mp;break;default:s=ya}s=Mf(s,Of.bind(null,e))}e.callbackPriority=n,e.callbackNode=s}}function Of(e,n){if(ua=-1,pa=0,ge&6)throw Error(K(327));var s=e.callbackNode;if(xl()&&e.callbackNode!==s)return null;var l=va(e,e===at?dt:0);if(l===0)return null;if(l&30||l&e.expiredLanes||n)n=Na(e,l);else{n=l;var r=ge;ge|=2;var a=Wf();(at!==e||dt!==n)&&(Sn=null,wl=Ye()+500,bs(e,n));do try{Hm();break}catch(d){Nf(e,d)}while(!0);cd(),Da.current=a,ge=r,Ve!==null?n=0:(at=null,dt=0,n=st)}if(n!==0){if(n===2&&(r=ao(e),r!==0&&(l=r,n=Lo(e,r))),n===1)throw s=br,bs(e,0),Bn(e,l),Ct(e,Ye()),s;if(n===6)Bn(e,l);else{if(r=e.current.alternate,!(l&30)&&!Fm(r)&&(n=Na(e,l),n===2&&(a=ao(e),a!==0&&(l=a,n=Lo(e,a))),n===1))throw s=br,bs(e,0),Bn(e,l),Ct(e,Ye()),s;switch(e.finishedWork=r,e.finishedLanes=l,n){case 0:case 1:throw Error(K(345));case 2:ms(e,St,Sn);break;case 3:if(Bn(e,l),(l&130023424)===l&&(n=_d+500-Ye(),10<n)){if(va(e,0)!==0)break;if(r=e.suspendedLanes,(r&l)!==l){vt(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=go(ms.bind(null,e,St,Sn),n);break}ms(e,St,Sn);break;case 4:if(Bn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,r=-1;0<l;){var i=31-Jt(l);a=1<<i,i=n[i],i>r&&(r=i),l&=~a}if(l=r,l=Ye()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Um(l/1960))-l,10<l){e.timeoutHandle=go(ms.bind(null,e,St,Sn),l);break}ms(e,St,Sn);break;case 5:ms(e,St,Sn);break;default:throw Error(K(329))}}}return Ct(e,Ye()),e.callbackNode===s?Of.bind(null,e):null}function Lo(e,n){var s=sr;return e.current.memoizedState.isDehydrated&&(bs(e,n).flags|=256),e=Na(e,n),e!==2&&(n=St,St=s,n!==null&&Oo(n)),e}function Oo(e){St===null?St=e:St.push.apply(St,e)}function Fm(e){for(var n=e;;){if(n.flags&16384){var s=n.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var l=0;l<s.length;l++){var r=s[l],a=r.getSnapshot;r=r.value;try{if(!Zt(a(),r))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 Bn(e,n){for(n&=~kd,n&=~qa,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var s=31-Jt(n),l=1<<s;e[s]=-1,n&=~l}}function fu(e){if(ge&6)throw Error(K(327));xl();var n=va(e,0);if(!(n&1))return Ct(e,Ye()),null;var s=Na(e,n);if(e.tag!==0&&s===2){var l=ao(e);l!==0&&(n=l,s=Lo(e,l))}if(s===1)throw s=br,bs(e,0),Bn(e,n),Ct(e,Ye()),s;if(s===6)throw Error(K(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,ms(e,St,Sn),Ct(e,Ye()),null}function Cd(e,n){var s=ge;ge|=1;try{return e(n)}finally{ge=s,ge===0&&(wl=Ye()+500,Ka&&ss())}}function zs(e){Un!==null&&Un.tag===0&&!(ge&6)&&xl();var n=ge;ge|=1;var s=$t.transition,l=je;try{if($t.transition=null,je=1,e)return e()}finally{je=l,$t.transition=s,ge=n,!(ge&6)&&ss()}}function zd(){Pt=dl.current,ze(dl)}function bs(e,n){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,ym(s)),Ve!==null)for(s=Ve.return;s!==null;){var l=s;switch(id(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&ka();break;case 3:bl(),ze(kt),ze(xt),xd();break;case 5:gd(l);break;case 4:bl();break;case 13:ze(Re);break;case 19:ze(Re);break;case 10:ud(l.type._context);break;case 22:case 23:zd()}s=s.return}if(at=e,Ve=e=Jn(e.current,null),dt=Pt=n,st=0,br=null,kd=qa=Cs=0,St=sr=null,vs!==null){for(n=0;n<vs.length;n++)if(s=vs[n],l=s.interleaved,l!==null){s.interleaved=null;var r=l.next,a=s.pending;if(a!==null){var i=a.next;a.next=r,l.next=i}s.pending=l}vs=null}return e}function Nf(e,n){do{var s=Ve;try{if(cd(),oa.current=Ra,Aa){for(var l=De.memoizedState;l!==null;){var r=l.queue;r!==null&&(r.pending=null),l=l.next}Aa=!1}if(_s=0,rt=nt=De=null,tr=!1,yr=0,wd.current=null,s===null||s.return===null){st=1,br=n,Ve=null;break}e:{var a=e,i=s.return,d=s,p=n;if(n=dt,d.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){var u=p,C=d,x=C.tag;if(!(C.mode&1)&&(x===0||x===11||x===15)){var m=C.alternate;m?(C.updateQueue=m.updateQueue,C.memoizedState=m.memoizedState,C.lanes=m.lanes):(C.updateQueue=null,C.memoizedState=null)}var h=eu(i);if(h!==null){h.flags&=-257,tu(h,i,d,a,n),h.mode&1&&Zc(a,u,n),n=h,p=u;var b=n.updateQueue;if(b===null){var _=new Set;_.add(p),n.updateQueue=_}else b.add(p);break e}else{if(!(n&1)){Zc(a,u,n),Id();break e}p=Error(K(426))}}else if(Pe&&d.mode&1){var v=eu(i);if(v!==null){!(v.flags&65536)&&(v.flags|=256),tu(v,i,d,a,n),od(Sl(p,d));break e}}a=p=Sl(p,d),st!==4&&(st=2),sr===null?sr=[a]:sr.push(a),a=i;do{switch(a.tag){case 3:a.flags|=65536,n&=-n,a.lanes|=n;var g=jf(a,p,n);Qc(a,g);break e;case 1:d=p;var o=a.type,c=a.stateNode;if(!(a.flags&128)&&(typeof o.getDerivedStateFromError=="function"||c!==null&&typeof c.componentDidCatch=="function"&&(Xn===null||!Xn.has(c)))){a.flags|=65536,n&=-n,a.lanes|=n;var y=bf(a,d,n);Qc(a,y);break e}}a=a.return}while(a!==null)}$f(s)}catch(z){n=z,Ve===s&&s!==null&&(Ve=s=s.return);continue}break}while(!0)}function Wf(){var e=Da.current;return Da.current=Ra,e===null?Ra:e}function Id(){(st===0||st===3||st===2)&&(st=4),at===null||!(Cs&268435455)&&!(qa&268435455)||Bn(at,dt)}function Na(e,n){var s=ge;ge|=2;var l=Wf();(at!==e||dt!==n)&&(Sn=null,bs(e,n));do try{Mm();break}catch(r){Nf(e,r)}while(!0);if(cd(),ge=s,Da.current=l,Ve!==null)throw Error(K(261));return at=null,dt=0,st}function Mm(){for(;Ve!==null;)Bf(Ve)}function Hm(){for(;Ve!==null&&!gx();)Bf(Ve)}function Bf(e){var n=Ff(e.alternate,e,Pt);e.memoizedProps=e.pendingProps,n===null?$f(e):Ve=n,wd.current=null}function $f(e){var n=e;do{var s=n.alternate;if(e=n.return,n.flags&32768){if(s=Nm(s,n),s!==null){s.flags&=32767,Ve=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{st=6,Ve=null;return}}else if(s=Om(s,n,Pt),s!==null){Ve=s;return}if(n=n.sibling,n!==null){Ve=n;return}Ve=n=e}while(n!==null);st===0&&(st=5)}function ms(e,n,s){var l=je,r=$t.transition;try{$t.transition=null,je=1,Gm(e,n,s,l)}finally{$t.transition=r,je=l}return null}function Gm(e,n,s,l){do xl();while(Un!==null);if(ge&6)throw Error(K(327));s=e.finishedWork;var r=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(K(177));e.callbackNode=null,e.callbackPriority=0;var a=s.lanes|s.childLanes;if(_x(e,a),e===at&&(Ve=at=null,dt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||qr||(qr=!0,Mf(ya,function(){return xl(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=$t.transition,$t.transition=null;var i=je;je=1;var d=ge;ge|=4,wd.current=null,Bm(e,s),Df(s,e),um(fo),ja=!!po,fo=po=null,e.current=s,$m(s),xx(),ge=d,je=i,$t.transition=a}else e.current=s;if(qr&&(qr=!1,Un=e,Oa=r),a=e.pendingLanes,a===0&&(Xn=null),vx(s.stateNode),Ct(e,Ye()),n!==null)for(l=e.onRecoverableError,s=0;s<n.length;s++)r=n[s],l(r.value,{componentStack:r.stack,digest:r.digest});if(La)throw La=!1,e=Ro,Ro=null,e;return Oa&1&&e.tag!==0&&xl(),a=e.pendingLanes,a&1?e===Do?lr++:(lr=0,Do=e):lr=0,ss(),null}function xl(){if(Un!==null){var e=vp(Oa),n=$t.transition,s=je;try{if($t.transition=null,je=16>e?16:e,Un===null)var l=!1;else{if(e=Un,Un=null,Oa=0,ge&6)throw Error(K(331));var r=ge;for(ge|=4,V=e.current;V!==null;){var a=V,i=a.child;if(V.flags&16){var d=a.deletions;if(d!==null){for(var p=0;p<d.length;p++){var u=d[p];for(V=u;V!==null;){var C=V;switch(C.tag){case 0:case 11:case 15:nr(8,C,a)}var x=C.child;if(x!==null)x.return=C,V=x;else for(;V!==null;){C=V;var m=C.sibling,h=C.return;if(Pf(C),C===u){V=null;break}if(m!==null){m.return=h,V=m;break}V=h}}}var b=a.alternate;if(b!==null){var _=b.child;if(_!==null){b.child=null;do{var v=_.sibling;_.sibling=null,_=v}while(_!==null)}}V=a}}if(a.subtreeFlags&2064&&i!==null)i.return=a,V=i;else e:for(;V!==null;){if(a=V,a.flags&2048)switch(a.tag){case 0:case 11:case 15:nr(9,a,a.return)}var g=a.sibling;if(g!==null){g.return=a.return,V=g;break e}V=a.return}}var o=e.current;for(V=o;V!==null;){i=V;var c=i.child;if(i.subtreeFlags&2064&&c!==null)c.return=i,V=c;else e:for(i=o;V!==null;){if(d=V,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:Xa(9,d)}}catch(z){He(d,d.return,z)}if(d===i){V=null;break e}var y=d.sibling;if(y!==null){y.return=d.return,V=y;break e}V=d.return}}if(ge=r,ss(),pn&&typeof pn.onPostCommitFiberRoot=="function")try{pn.onPostCommitFiberRoot(Ua,e)}catch{}l=!0}return l}finally{je=s,$t.transition=n}}return!1}function hu(e,n,s){n=Sl(s,n),n=jf(e,n,1),e=Yn(e,n,1),n=vt(),e!==null&&(_r(e,1,n),Ct(e,n))}function He(e,n,s){if(e.tag===3)hu(e,e,s);else for(;n!==null;){if(n.tag===3){hu(n,e,s);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Xn===null||!Xn.has(l))){e=Sl(s,e),e=bf(n,e,1),n=Yn(n,e,1),e=vt(),n!==null&&(_r(n,1,e),Ct(n,e));break}}n=n.return}}function Km(e,n,s){var l=e.pingCache;l!==null&&l.delete(n),n=vt(),e.pingedLanes|=e.suspendedLanes&s,at===e&&(dt&s)===s&&(st===4||st===3&&(dt&130023424)===dt&&500>Ye()-_d?bs(e,0):kd|=s),Ct(e,n)}function Uf(e,n){n===0&&(e.mode&1?(n=$r,$r<<=1,!($r&130023424)&&($r=4194304)):n=1);var s=vt();e=Tn(e,n),e!==null&&(_r(e,n,s),Ct(e,s))}function Qm(e){var n=e.memoizedState,s=0;n!==null&&(s=n.retryLane),Uf(e,s)}function Ym(e,n){var s=0;switch(e.tag){case 13:var l=e.stateNode,r=e.memoizedState;r!==null&&(s=r.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(K(314))}l!==null&&l.delete(n),Uf(e,s)}var Ff;Ff=function(e,n,s){if(e!==null)if(e.memoizedProps!==n.pendingProps||kt.current)wt=!0;else{if(!(e.lanes&s)&&!(n.flags&128))return wt=!1,Lm(e,n,s);wt=!!(e.flags&131072)}else wt=!1,Pe&&n.flags&1048576&&Gp(n,za,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;ca(e,n),e=n.pendingProps;var r=yl(n,xt.current);gl(n,s),r=yd(null,n,l,e,r,s);var a=vd();return n.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,_t(l)?(a=!0,_a(n)):a=!1,n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,fd(n),r.updater=Ya,n.stateNode=r,r._reactInternals=n,So(n,l,e,s),n=_o(null,n,l,!0,a,s)):(n.tag=0,Pe&&a&&ad(n),yt(null,n,r,s),n=n.child),n;case 16:l=n.elementType;e:{switch(ca(e,n),e=n.pendingProps,r=l._init,l=r(l._payload),n.type=l,r=n.tag=qm(l),e=Yt(l,e),r){case 0:n=ko(null,n,l,e,s);break e;case 1:n=lu(null,n,l,e,s);break e;case 11:n=nu(null,n,l,e,s);break e;case 14:n=su(null,n,l,Yt(l.type,e),s);break e}throw Error(K(306,l,""))}return n;case 0:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),ko(e,n,l,r,s);case 1:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),lu(e,n,l,r,s);case 3:e:{if(_f(n),e===null)throw Error(K(387));l=n.pendingProps,a=n.memoizedState,r=a.element,Jp(e,n),Ea(n,l,null,s);var i=n.memoizedState;if(l=i.element,a.isDehydrated)if(a={element:l,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},n.updateQueue.baseState=a,n.memoizedState=a,n.flags&256){r=Sl(Error(K(423)),n),n=ru(e,n,l,s,r);break e}else if(l!==r){r=Sl(Error(K(424)),n),n=ru(e,n,l,s,r);break e}else for(At=Qn(n.stateNode.containerInfo.firstChild),Rt=n,Pe=!0,qt=null,s=Xp(n,null,l,s),n.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(vl(),l===r){n=En(e,n,s);break e}yt(e,n,l,s)}n=n.child}return n;case 5:return Vp(n),e===null&&vo(n),l=n.type,r=n.pendingProps,a=e!==null?e.memoizedProps:null,i=r.children,ho(l,r)?i=null:a!==null&&ho(l,a)&&(n.flags|=32),kf(e,n),yt(e,n,i,s),n.child;case 6:return e===null&&vo(n),null;case 13:return Cf(e,n,s);case 4:return hd(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=jl(n,null,l,s):yt(e,n,l,s),n.child;case 11:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),nu(e,n,l,r,s);case 7:return yt(e,n,n.pendingProps,s),n.child;case 8:return yt(e,n,n.pendingProps.children,s),n.child;case 12:return yt(e,n,n.pendingProps.children,s),n.child;case 10:e:{if(l=n.type._context,r=n.pendingProps,a=n.memoizedProps,i=r.value,ke(Ia,l._currentValue),l._currentValue=i,a!==null)if(Zt(a.value,i)){if(a.children===r.children&&!kt.current){n=En(e,n,s);break e}}else for(a=n.child,a!==null&&(a.return=n);a!==null;){var d=a.dependencies;if(d!==null){i=a.child;for(var p=d.firstContext;p!==null;){if(p.context===l){if(a.tag===1){p=Cn(-1,s&-s),p.tag=2;var u=a.updateQueue;if(u!==null){u=u.shared;var C=u.pending;C===null?p.next=p:(p.next=C.next,C.next=p),u.pending=p}}a.lanes|=s,p=a.alternate,p!==null&&(p.lanes|=s),jo(a.return,s,n),d.lanes|=s;break}p=p.next}}else if(a.tag===10)i=a.type===n.type?null:a.child;else if(a.tag===18){if(i=a.return,i===null)throw Error(K(341));i.lanes|=s,d=i.alternate,d!==null&&(d.lanes|=s),jo(i,s,n),i=a.sibling}else i=a.child;if(i!==null)i.return=a;else for(i=a;i!==null;){if(i===n){i=null;break}if(a=i.sibling,a!==null){a.return=i.return,i=a;break}i=i.return}a=i}yt(e,n,r.children,s),n=n.child}return n;case 9:return r=n.type,l=n.pendingProps.children,gl(n,s),r=Ut(r),l=l(r),n.flags|=1,yt(e,n,l,s),n.child;case 14:return l=n.type,r=Yt(l,n.pendingProps),r=Yt(l.type,r),su(e,n,l,r,s);case 15:return Sf(e,n,n.type,n.pendingProps,s);case 17:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Yt(l,r),ca(e,n),n.tag=1,_t(l)?(e=!0,_a(n)):e=!1,gl(n,s),vf(n,l,r),So(n,l,r,s),_o(null,n,l,!0,e,s);case 19:return zf(e,n,s);case 22:return wf(e,n,s)}throw Error(K(156,n.tag))};function Mf(e,n){return gp(e,n)}function Xm(e,n,s,l){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=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bt(e,n,s,l){return new Xm(e,n,s,l)}function Td(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qm(e){if(typeof e=="function")return Td(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Yo)return 11;if(e===Xo)return 14}return 2}function Jn(e,n){var s=e.alternate;return s===null?(s=Bt(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 fa(e,n,s,l,r,a){var i=2;if(l=e,typeof e=="function")Td(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Zs:return Ss(s.children,r,a,n);case Qo:i=8,r|=8;break;case Gi:return e=Bt(12,s,n,r|2),e.elementType=Gi,e.lanes=a,e;case Ki:return e=Bt(13,s,n,r),e.elementType=Ki,e.lanes=a,e;case Qi:return e=Bt(19,s,n,r),e.elementType=Qi,e.lanes=a,e;case Vu:return Ja(s,r,a,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qu:i=10;break e;case Ju:i=9;break e;case Yo:i=11;break e;case Xo:i=14;break e;case On:i=16,l=null;break e}throw Error(K(130,e==null?e:typeof e,""))}return n=Bt(i,s,n,r),n.elementType=e,n.type=l,n.lanes=a,n}function Ss(e,n,s,l){return e=Bt(7,e,l,n),e.lanes=s,e}function Ja(e,n,s,l){return e=Bt(22,e,l,n),e.elementType=Vu,e.lanes=s,e.stateNode={isHidden:!1},e}function Bi(e,n,s){return e=Bt(6,e,null,n),e.lanes=s,e}function $i(e,n,s){return n=Bt(4,e.children!==null?e.children:[],e.key,n),n.lanes=s,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Jm(e,n,s,l,r){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=ji(0),this.expirationTimes=ji(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ji(0),this.identifierPrefix=l,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Ed(e,n,s,l,r,a,i,d,p){return e=new Jm(e,n,s,d,p),n===1?(n=1,a===!0&&(n|=8)):n=0,a=Bt(3,null,null,n),e.current=a,a.stateNode=e,a.memoizedState={element:l,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},fd(a),e}function Vm(e,n,s){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Vs,key:l==null?null:""+l,children:e,containerInfo:n,implementation:s}}function Hf(e){if(!e)return Zn;e=e._reactInternals;e:{if(Es(e)!==e||e.tag!==1)throw Error(K(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(_t(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(K(171))}if(e.tag===1){var s=e.type;if(_t(s))return Mp(e,s,n)}return n}function Gf(e,n,s,l,r,a,i,d,p){return e=Ed(s,l,!0,e,r,a,i,d,p),e.context=Hf(null),s=e.current,l=vt(),r=qn(s),a=Cn(l,r),a.callback=n??null,Yn(s,a,r),e.current.lanes=r,_r(e,r,l),Ct(e,l),e}function Va(e,n,s,l){var r=n.current,a=vt(),i=qn(r);return s=Hf(s),n.context===null?n.context=s:n.pendingContext=s,n=Cn(a,i),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=Yn(r,n,i),e!==null&&(Vt(e,r,i,a),ia(e,r,i)),i}function Wa(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 gu(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<n?s:n}}function Pd(e,n){gu(e,n),(e=e.alternate)&&gu(e,n)}function Zm(){return null}var Kf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ad(e){this._internalRoot=e}Za.prototype.render=Ad.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(K(409));Va(e,n,null,null)};Za.prototype.unmount=Ad.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;zs(function(){Va(null,e,null,null)}),n[In]=null}};function Za(e){this._internalRoot=e}Za.prototype.unstable_scheduleHydration=function(e){if(e){var n=Sp();e={blockedOn:null,target:e,priority:n};for(var s=0;s<Wn.length&&n!==0&&n<Wn[s].priority;s++);Wn.splice(s,0,e),s===0&&kp(e)}};function Rd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ei(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function xu(){}function ey(e,n,s,l,r){if(r){if(typeof l=="function"){var a=l;l=function(){var u=Wa(i);a.call(u)}}var i=Gf(n,l,e,0,null,!1,!1,"",xu);return e._reactRootContainer=i,e[In]=i.current,fr(e.nodeType===8?e.parentNode:e),zs(),i}for(;r=e.lastChild;)e.removeChild(r);if(typeof l=="function"){var d=l;l=function(){var u=Wa(p);d.call(u)}}var p=Ed(e,0,!1,null,null,!1,!1,"",xu);return e._reactRootContainer=p,e[In]=p.current,fr(e.nodeType===8?e.parentNode:e),zs(function(){Va(n,p,s,l)}),p}function ti(e,n,s,l,r){var a=s._reactRootContainer;if(a){var i=a;if(typeof r=="function"){var d=r;r=function(){var p=Wa(i);d.call(p)}}Va(n,i,e,r)}else i=ey(s,n,e,r,l);return Wa(i)}jp=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var s=Ql(n.pendingLanes);s!==0&&(Vo(n,s|1),Ct(n,Ye()),!(ge&6)&&(wl=Ye()+500,ss()))}break;case 13:zs(function(){var l=Tn(e,1);if(l!==null){var r=vt();Vt(l,e,1,r)}}),Pd(e,1)}};Zo=function(e){if(e.tag===13){var n=Tn(e,134217728);if(n!==null){var s=vt();Vt(n,e,134217728,s)}Pd(e,134217728)}};bp=function(e){if(e.tag===13){var n=qn(e),s=Tn(e,n);if(s!==null){var l=vt();Vt(s,e,n,l)}Pd(e,n)}};Sp=function(){return je};wp=function(e,n){var s=je;try{return je=e,n()}finally{je=s}};so=function(e,n,s){switch(n){case"input":if(qi(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 l=s[n];if(l!==e&&l.form===e.form){var r=Ga(l);if(!r)throw Error(K(90));ep(l),qi(l,r)}}}break;case"textarea":np(e,s);break;case"select":n=s.value,n!=null&&ul(e,!!s.multiple,n,!1)}};dp=Cd;cp=zs;var ty={usingClientEntryPoint:!1,Events:[zr,sl,Ga,ip,op,Cd]},Fl={findFiberByHostInstance:ys,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ny={bundleType:Fl.bundleType,version:Fl.version,rendererPackageName:Fl.rendererPackageName,rendererConfig:Fl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Pn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=fp(e),e===null?null:e.stateNode},findFiberByHostInstance:Fl.findFiberByHostInstance||Zm,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 Jr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jr.isDisabled&&Jr.supportsFiber)try{Ua=Jr.inject(ny),pn=Jr}catch{}}Lt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ty;Lt.createPortal=function(e,n){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Rd(n))throw Error(K(200));return Vm(e,n,null,s)};Lt.createRoot=function(e,n){if(!Rd(e))throw Error(K(299));var s=!1,l="",r=Kf;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(r=n.onRecoverableError)),n=Ed(e,1,!1,null,null,s,!1,l,r),e[In]=n.current,fr(e.nodeType===8?e.parentNode:e),new Ad(n)};Lt.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(K(188)):(e=Object.keys(e).join(","),Error(K(268,e)));return e=fp(n),e=e===null?null:e.stateNode,e};Lt.flushSync=function(e){return zs(e)};Lt.hydrate=function(e,n,s){if(!ei(n))throw Error(K(200));return ti(null,e,n,!0,s)};Lt.hydrateRoot=function(e,n,s){if(!Rd(e))throw Error(K(405));var l=s!=null&&s.hydratedSources||null,r=!1,a="",i=Kf;if(s!=null&&(s.unstable_strictMode===!0&&(r=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(i=s.onRecoverableError)),n=Gf(n,null,e,1,s??null,r,!1,a,i),e[In]=n.current,fr(e),l)for(e=0;e<l.length;e++)s=l[e],r=s._getVersion,r=r(s._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[s,r]:n.mutableSourceEagerHydrationData.push(s,r);return new Za(n)};Lt.render=function(e,n,s){if(!ei(n))throw Error(K(200));return ti(null,e,n,!1,s)};Lt.unmountComponentAtNode=function(e){if(!ei(e))throw Error(K(40));return e._reactRootContainer?(zs(function(){ti(null,null,e,!1,function(){e._reactRootContainer=null,e[In]=null})}),!0):!1};Lt.unstable_batchedUpdates=Cd;Lt.unstable_renderSubtreeIntoContainer=function(e,n,s,l){if(!ei(s))throw Error(K(200));if(e==null||e._reactInternals===void 0)throw Error(K(38));return ti(e,n,s,!1,l)};Lt.version="18.3.1-next-f1338f8080-20240426";function Qf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Qf)}catch(e){console.error(e)}}Qf(),Ku.exports=Lt;var sy=Ku.exports,Yf,mu=sy;Yf=mu.createRoot,mu.hydrateRoot;const de="",O={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"},q={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},ly=[{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"}],Xf=[{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"}],ry=new Set(["users","group-companies"]);function ay(e){return e!=="Admin"&&e!=="Auditor"?[]:Xf.filter(({id:n})=>e==="Admin"||!ry.has(n))}const Ln=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],iy={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:Ln(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:Ln(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:Ln(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:Ln(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:Ln([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:Ln([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:Ln([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:Ln([{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"]}},oy=()=>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"})]}),dy=()=>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"})]}),cy=()=>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 lt({onView:e,onEdit:n,onDelete:s}){const l=(r,a,i,d,p,u)=>d?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),d()},title:u,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:r,color:i,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:C=>{C.currentTarget.style.background=a,C.currentTarget.style.transform="scale(1.08)"},onMouseLeave:C=>{C.currentTarget.style.background=r,C.currentTarget.style.transform="scale(1)"},children:p},u):null;return t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l("#f0f9ff","#e0f2fe","#0284c7",e,t.jsx(oy,{}),"View"),l("#f0fdf4","#dcfce7","#16a34a",n,t.jsx(dy,{}),"Edit"),s&&l("#fff1f2","#fee2e2","#e11d48",s,t.jsx(cy,{}),"Delete")]})}const A={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},T={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function uy(e){return 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 me(e,n){return e.filter(s=>uy(s)||s.name===n)}const py={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function Fn(e,n){return!!n&&py[e].includes(n)}function kl(e,n,s,l){return e.filter(r=>{const a=n[r.name]||[];return!(a.includes("SB Admin")||a.includes("System Manager")||!a.includes(s)||l&&r.custom_organization&&r.custom_organization!==l)})}const _l={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function ha(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 fy(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 Sr=(e,n)=>{let s;return typeof n=="object"&&n!==null?s=n:typeof n=="string"&&n.startsWith("#")?s=ha(e):typeof n=="string"?s=ha(n):s=ha(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})},es=e=>Sr(e,ha(e)),Dd=e=>Sr(e,fy(e));function Tr({deletedBy:e,deletedOn:n,reason:s,onRestore: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]})]})]}),l&&t.jsxs("button",{type:"button",onClick:l,disabled:r,style:{background:"#e11d48",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:a=>{r||(a.currentTarget.style.background="#be123c")},onMouseLeave:a=>{r||(a.currentTarget.style.background="#e11d48")},children:[t.jsx("span",{children:"↺"}),t.jsx("span",{children:r?"Restoring...":"Restore Record / استعادة"})]})]})}function ni({onDelete:e,disabled:n,title:s="Delete Request",btnText:l="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:r=>{n||(r.currentTarget.style.background="#b91c1c")},onMouseLeave:r=>{n||(r.currentTarget.style.background="#dc2626")},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:l})]})]})}function le({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 si({title:e="Status Summary",priority:n,createdDate:s,modifiedDate:l,assignedTo:r,status:a}){const i=d=>{if(!d)return"—";try{const p=new Date(d);return isNaN(p.getTime())?d:p.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})]}),a&&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:a})]}),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:r?"#334155":"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r||"—"})]}),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)})]}),l&&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(l)})]})]})]})}const hy="modulepreload",gy=function(e){return"/"+e},yu={},xy=function(n,s,l){let r=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"));r=Promise.allSettled(s.map(p=>{if(p=gy(p),p in yu)return;yu[p]=!0;const u=p.endsWith(".css"),C=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${C}`))return;const x=document.createElement("link");if(x.rel=u?"stylesheet":hy,u||(x.as="script"),x.crossOrigin="",x.href=p,d&&x.setAttribute("nonce",d),document.head.appendChild(x),u)return new Promise((m,h)=>{x.addEventListener("load",m),x.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${p}`)))})}))}function a(i){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=i,window.dispatchEvent(d),!d.defaultPrevented)throw i}return r.then(i=>{for(const d of i||[])d.status==="rejected"&&a(d.reason);return n().catch(a)})};function qf(e,n){const s=e[n.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function my(e,n){const s=URL.createObjectURL(e),l=document.createElement("a");l.href=s,l.download=n,l.click(),URL.revokeObjectURL(s)}function yy(e,n,s){const l=e.map(i=>`"${i.label.replace(/"/g,'""')}"`).join(","),r=n.map(i=>e.map(d=>`"${qf(i,d).replace(/"/g,'""')}"`).join(",")).join(`
`),a=new Blob([l+`
`+r],{type:"text/csv;charset=utf-8;"});my(a,`${s}.csv`)}async function vy(e,n,s){const l=await xy(()=>import("./xlsx-D_0l8YDs.js"),[]),r=n.map(d=>{const p={};for(const u of e)p[u.label]=qf(d,u);return p}),a=l.utils.json_to_sheet(r,{header:e.map(d=>d.label)}),i=l.utils.book_new();l.utils.book_append_sheet(i,a,"Export"),l.writeFile(i,`${s}.xlsx`)}const an="#16a34a";function jy({title:e,rows:n,selectedRows:s=[],pageRows:l=[],columns:r,defaultColumnKeys:a,filenameBase:i,onClose:d}){const[p,u]=S.useState(s.length>0?"selected":"all"),[C,x]=S.useState("csv"),[m,h]=S.useState(new Set(a)),[b,_]=S.useState("");S.useEffect(()=>{s&&s.length>0&&u("selected")},[s]);const v=p==="selected"?s:p==="page"?l:n,g=r.filter(w=>m.has(w.key)),o=b?r.filter(w=>w.label.toLowerCase().includes(b.toLowerCase())):r,c=w=>{h(I=>{const P=new Set(I);return P.has(w)?P.delete(w):P.add(w),P})},y=async()=>{g.length===0||v.length===0||(C==="csv"?yy(g,v,i):await vy(g,v,i),d())},z={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},k={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"},f=[{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:`${l.length} row${l.length!==1?"s":""} on this page`,count:l.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:w=>w.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:an,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:[r.length," fields available · ",m.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:z,children:"What to export"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:f.map(w=>t.jsxs("label",{onClick:()=>!w.disabled&&u(w.id),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderRadius:10,cursor:w.disabled?"not-allowed":"pointer",border:`2px solid ${p===w.id?an:"#e5e7eb"}`,background:p===w.id?"#f0fdf4":w.disabled?"#fafafa":"white",opacity:w.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 ${p===w.id?an:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:p===w.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:an}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#111827"},children:w.label}),t.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:1},children:w.sub})]})]}),t.jsx("span",{style:{background:p===w.id?an:"#e5e7eb",color:p===w.id?"white":"#374151",fontSize:12,fontWeight:700,padding:"2px 10px",borderRadius:9999},children:w.count})]},w.id))})]}),t.jsxs("div",{children:[t.jsx("div",{style:z,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(w=>t.jsxs("div",{onClick:()=>x(w.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${C===w.id?an:"#e5e7eb"}`,background:C===w.id?"#f0fdf4":"white"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${C===w.id?an:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:C===w.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:an}})}),t.jsx("span",{style:{fontSize:20},children:w.icon}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:w.label}),t.jsx("div",{style:{fontSize:11,color:"#888"},children:w.desc})]})]},w.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[t.jsx("div",{style:{...z,marginBottom:0},children:"Columns to Export"}),t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsx("button",{onClick:()=>h(new Set(r.map(w=>w.key))),style:k,children:"All"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>h(new Set(a)),style:k,children:"Default"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>h(new Set),style:{...k,color:"#ef4444"},children:"None"})]})]}),t.jsx("div",{style:{marginBottom:8},children:t.jsx("input",{type:"text",placeholder:"Search fields...",value:b,onChange:w=>_(w.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(w=>t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer",padding:"3px 5px",borderRadius:5,background:m.has(w.key)?"#f0fdf4":"transparent"},children:[t.jsx("input",{type:"checkbox",checked:m.has(w.key),onChange:()=>c(w.key),style:{accentColor:an,cursor:"pointer"}}),w.label]},w.key))})}),t.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[m.size," of ",r.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 ",v.length," ",p==="selected"?"selected":p==="page"?"page":""," row",v.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:y,disabled:g.length===0||v.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:an,color:"white",fontWeight:700,fontSize:13,cursor:g.length===0||v.length===0?"not-allowed":"pointer",opacity:g.length===0||v.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const Jf="sidrah_rtl",No="sidrah-lang-change";function cl(){try{return localStorage.getItem(Jf)==="1"}catch{return!1}}function Vf(){const e=!cl();try{localStorage.setItem(Jf,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(No))}function ne(){const[e,n]=S.useState(cl);return S.useEffect(()=>{const s=()=>n(cl());return window.addEventListener(No,s),document.documentElement.setAttribute("dir",cl()?"rtl":"ltr"),document.documentElement.setAttribute("lang",cl()?"ar":"en-GB"),()=>window.removeEventListener(No,s)},[]),e?Sy:by}const by={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 --",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"}},Sy={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:"-- اختر --",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 vu({isOpen:e,doctype:n,docname:s,docTitle:l,isAdmin:r,isDeleting:a,onClose:i,onConfirmSoftDelete:d,onConfirmPermanentDelete:p}){const u=ne(),[C,x]=S.useState("");if(S.useEffect(()=>{e&&x("")},[e]),S.useEffect(()=>{const h=b=>{b.key==="Escape"&&e&&!a&&i()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,a,i]),!e)return null;const m=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:h=>{h.target===h.currentTarget&&!a&&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:u.deleteModal.title}),t.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:u.deleteModal.subtitle})]}),t.jsx("button",{type:"button",onClick:i,disabled:a,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:[m,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l?`${l} (${s})`:s})]}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#475569",marginBottom:4},children:u.deleteModal.reasonLabel}),t.jsx("input",{type:"text",value:C,onChange:h=>x(h.target.value),placeholder:u.deleteModal.reasonPlaceholder,disabled:a,style:{width:"100%",height:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,boxSizing:"border-box",outline:"none"},onFocus:h=>{h.target.style.borderColor="#6366f1",h.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:h=>{h.target.style.borderColor="#cbd5e1",h.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:a,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#475569",fontSize:12,fontWeight:600,cursor:a?"not-allowed":"pointer",transition:"background 0.15s"},children:u.deleteModal.cancelBtn}),t.jsxs("button",{type:"button",onClick:()=>d(C),disabled:a,title:u.deleteModal.softDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #fca5a5",background:"#fff1f2",color:"#b91c1c",fontSize:12,fontWeight:600,cursor:a?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s"},onMouseEnter:h=>{a||(h.currentTarget.style.background="#fee2e2")},onMouseLeave:h=>{a||(h.currentTarget.style.background="#fff1f2")},children:[t.jsx("span",{children:"🗑️"}),a?u.deleteModal.deleting:u.deleteModal.softDeleteBtn]}),r&&t.jsxs("button",{type:"button",onClick:()=>p(C),disabled:a,title:u.deleteModal.permanentDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"none",background:"#ef4444",color:"#ffffff",fontSize:12,fontWeight:600,cursor:a?"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:h=>{a||(h.currentTarget.style.background="#dc2626")},onMouseLeave:h=>{a||(h.currentTarget.style.background="#ef4444")},children:[t.jsx("span",{children:"💥"}),a?u.deleteModal.deleting:u.deleteModal.permanentDeleteBtn]})]})]})})}const Zf="/assets/logo-BlYgMyx5.png";function eh({collapsed:e,onToggleCollapsed:n,activePage:s,onNavigate:l,hasDashboard:r,hasReports:a,hasDelegations:i,role:d,hideSettings:p,rtl:u,navLabels:C,settingsLabel:x}){const m=p?[]:ay(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:Zf,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:h=>{h.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:u?"صدرة للأعمال":"Sidrah"})})]}),t.jsx("button",{type:"button",onClick:n,title:e?u?"توسيع":"Expand":u?"طي":"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:h=>{h.currentTarget.style.background="rgba(255, 255, 255, 0.15)",h.currentTarget.style.color="#ffffff"},onMouseLeave:h=>{h.currentTarget.style.background="rgba(255, 255, 255, 0.06)",h.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:[ly.filter(({id:h})=>(h!=="dashboard"||r)&&(h!=="reports"||a)&&(h!=="delegations"||i)).map(({id:h,icon:b})=>{const _=C[h]||h,v=h===s;return t.jsxs("div",{onClick:()=>l(h),title:e?_: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:v?"rgba(99, 102, 241, 0.28)":"transparent",border:v?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:v?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:v?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2,position:"relative"},onMouseEnter:g=>{v||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{v||(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:b}),!e&&t.jsx("span",{children:_})]},h)}),m.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:x}),e&&t.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),m.map(({id:h,icon:b})=>{const _=C[h]||h,v=h===s;return t.jsxs("div",{onClick:()=>l(h),title:e?_: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:v?"rgba(99, 102, 241, 0.28)":"transparent",border:v?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:v?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:v?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2},onMouseEnter:g=>{v||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{v||(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:b}),!e&&t.jsx("span",{children:_})]},h)})]})]})]})}const Tl=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 Is="";async function Ld(){try{const e=await fetch(`${de}/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 Is=s,s}}catch(e){console.error("CSRF fetch error:",e)}return Is}async function en(){return Is||await Ld(),Is}function wr(e,n){try{if(e!=null&&e._server_messages){const l=JSON.parse(e._server_messages);if(l.length){const r=JSON.parse(l[0]);if(r!=null&&r.message)return r.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 l=s.split(`
`).map(a=>a.trim()).filter(a=>a&&!a.startsWith("Traceback")&&!a.startsWith("File "));s=(l[l.length-1]||s).replace(/^frappe\.exceptions\.\w+:\s*/,"").trim()}return s||n}async function Et(e,n,s=[]){if(Tl.has(e)){const i=`${de}/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 l=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",r=await fetch(`${de}/api/v1/resource/${e}/${encodeURIComponent(n)}${l}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`API Error: ${r.status}`);return(await r.json()).data}async function Wo(e,n,s="",l=!1){const r=await en();if(Tl.has(e)){const d=new URLSearchParams({doctype:e,name:n});s&&d.append("reason",s),l&&d.append("permanent","1");const p=await fetch(`${de}/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":r},body:d.toString()});if(!p.ok){const u=await p.json().catch(()=>({}));throw new Error(wr(u,`Error deleting ${n}`))}return}const a=new URLSearchParams({doctype:e,name:n});s&&a.append("reason",s),l&&a.append("permanent","1");const i=await fetch(`${de}/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":r},body:a.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(wr(d,`Error deleting ${n}`))}return await i.json()}async function wy(e,n){const s=await en();if(Tl.has(e)){const a=new URLSearchParams({doctype:e,name:n}),i=await fetch(`${de}/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:a.toString()});if(!i.ok){const p=await i.json().catch(()=>({}));throw new Error(wr(p,`Error restoring ${n}`))}return(await i.json()).message||{success:!0}}const l=new URLSearchParams({doctype:e,name:n}),r=await fetch(`${de}/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:l.toString()});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(wr(a,`Error restoring ${n}`))}return await r.json()}async function Ee(e){if(Tl.has(e))try{const l=`${de}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,r=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}const n=encodeURIComponent('["*"]'),s=`${de}/api/v1/resource/${e}?limit_page_length=500&fields=${n}`;try{const l=await fetch(s,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return l.status===401||l.status===403?[]:l.ok?(await l.json()).data||[]:[]}catch(l){return console.error("Get error:",l),[]}}async function Ui(e,n){const s=await en();if(Tl.has(e)){const r=new URLSearchParams({doctype:e,data_json:JSON.stringify(n)}),a=await fetch(`${de}/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:r.toString()});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await a.json()).message}}const l=`${de}/api/v1/resource/${e}`;try{const r=await fetch(l,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(n)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const a=await r.json();throw new Error(a.message||a.exc||`API Error: ${r.status}`)}return await r.json()}catch(r){throw console.error("Post error:",r),r}}async function Ba(e,n,s){const l=await en();if(Tl.has(e)){const a=new URLSearchParams({doctype:e,name:n,data_json:JSON.stringify(s)}),i=await fetch(`${de}/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":l},body:a.toString()});if(!i.ok){const p=await i.json().catch(()=>({}));throw new Error(p.message||p.exc||`Error updating ${e}`)}return{data:(await i.json()).message}}const r=`${de}/api/v1/resource/${e}/${encodeURIComponent(n)}`;try{const a=await fetch(r,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":l},body:JSON.stringify(s)});if(a.status===401||a.status===403)throw new Error("Permission denied - login required");if(!a.ok){const i=await a.json();throw new Error(i.message||"Update Error")}return await a.json()}catch(a){throw console.error("Update error:",a),a}}async function ky(){const e=`${de}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return n.status===401||n.status===403?[]:n.ok?(await n.json()).data||[]:[]}catch(n){return console.error("Get users error:",n),[]}}async function _y(e,n){const s=new FormData;s.append("usr",e),s.append("pwd",n);const r=await(await fetch(`${de}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return r.csrf_token?Is=r.csrf_token:await Ld(),r}async function Cy(){const e=await en();try{await fetch(`${de}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Is=""}function zy(){return Is}async function th(){try{const e=await fetch(`${de}/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 Iy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),n=`${de}/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 Ty(){const e=`${de}/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 nh(e,n){await Ba("User",e,{new_password:n})}async function Ey(e=20){try{const n=`${de}/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 Py(){const e=await en();try{await fetch(`${de}/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 Ay(e){const n=await en();try{await fetch(`${de}/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 Ry(e){const n=await en(),s=new URLSearchParams({name:e});await fetch(`${de}/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 Dy(e,n){try{const s=`${de}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function Ly(e,n,s){const l=await en(),r=new URLSearchParams({doctype:e,docname:n,content:s}),a=await fetch(`${de}/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":l},body:r.toString()});if(!a.ok)throw new Error("Failed to post comment");return(await a.json()).message}async function Oy(e,n){try{const s=`${de}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function sh(e){try{const n=`${de}/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 Ny(){try{const e=`${de}/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 Ps(e,n={}){const s=await en(),l=new URLSearchParams(n),r=await fetch(`${de}/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:l.toString()});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(wr(i,`Error calling ${e}`))}return(await r.json()).message}async function Wy(e,n,s="",l,r,a){const i={name:e,action:n,comment:s};return l!==void 0&&(i.stage=l),a!==void 0&&(i.cycle_status=a),Ps("apply_order_workflow",i)}async function By(e,n,s=""){return Ps("apply_incident_workflow",{name:e,action:n,fields_json:s})}async function $y(e,n,s=""){return Ps("apply_idea_workflow",{name:e,action:n,fields_json:s})}async function Uy(e=""){const n=`${de}/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 Fy(e,n={}){return Ps("get_report_data",{report_name:e,filters_json:JSON.stringify(n)})}async function My(){try{const e=`${de}/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 Hy(e,n,s="",l="",r="",a=""){return Ps("create_delegation",{manager:e,functions_json:JSON.stringify(n),organization:s,remarks:l,incident_name:r,idea_name:a})}async function Gy(e,n,s=""){return Ps("respond_to_delegation",{name:e,response:n,remarks:s})}async function Ky(e,n=""){return Ps("revoke_delegation",{name:e,remarks:n})}async function Qy(){try{const e=`${de}/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 Yy(e){const n=`${de}/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 Xy(){try{const e=`${de}/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 qy(){try{const e=`${de}/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 Jy(){try{const e=await en(),n=await fetch(`${de}/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 Vy(){const e=zy();return e||Ld()}async function Xl(e){const n=await fetch(`${de}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.message||`Failed to load process (${n.status})`)}const s=await n.json();return s.message||s.data}async function Zy(e,n,s={}){const l=await Vy(),r=new URLSearchParams({name:e,action:n});s.actor_status&&r.set("actor_status",String(s.actor_status)),s.actor_comment&&r.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&r.set("progress_indicators",JSON.stringify(s.progress_indicators));const a=await fetch(`${de}/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":l},body:r.toString()});if(!a.ok){const d=await a.json().catch(()=>({})),p=d.message||(d.exception?String(d.exception).split(`
`).pop():"")||d.exc_type||`Workflow action "${n}" failed (${a.status})`;throw new Error(p)}const i=await a.json();return i.message||i.data}const e0=["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"],ju=new Set(e0),t0={"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 bu(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return ju.has(e)?e:null;const n=window.location.pathname.split("/").filter(Boolean).pop()||"";return ju.has(n)?n:null}function n0(e){return e?t0[e]??e:null}function s0(e){return`#/${e}`}function l0({onLogin:e}){const n=ne(),[s,l]=S.useState(""),[r,a]=S.useState(""),[i,d]=S.useState(""),[p,u]=S.useState(!1),[C,x]=S.useState(!1),[m,h]=S.useState(!1),b=async()=>{if(!s||!r){d(n.login.emptyFields);return}u(!0),d("");try{const v=await _y(s,r);if(v.message==="Logged In"){const o=await th()||s,c=await sh(o),y=c.some(z=>["SB Admin","System Manager"].includes(z))?"Admin":c.includes("SB Auditor")?"Auditor":c.includes("SB Owner")?"Owner":c.includes("SB X-Auditor")?"XAuditor":c.includes("SB Manager")?"Manager":"Employee";e({name:o,full_name:v.full_name||s,role:y})}else d(n.login.invalidCreds)}catch(v){d(n.login.connError+(v instanceof Error?v.message:"Unknown"))}u(!1)},_=v=>({width:"100%",padding:"11px 16px",border:`1.5px solid ${v?"#6366f1":"#e2e8f0"}`,borderRadius:8,fontSize:14,background:v?"#f8faff":"#ffffff",color:"#1e293b",outline:"none",transition:"all 0.18s ease",boxSizing:"border-box",boxShadow:v?"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:Zf,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:v=>{v.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:v=>l(v.target.value),onKeyDown:v=>v.key==="Enter"&&b(),onFocus:()=>x(!0),onBlur:()=>x(!1),style:_(C),placeholder:n.login.usernamePlaceholder,autoComplete:"username"})}),t.jsx("div",{children:t.jsx("input",{type:"password",value:r,onChange:v=>a(v.target.value),onKeyDown:v=>v.key==="Enter"&&b(),onFocus:()=>h(!0),onBlur:()=>h(!1),style:_(m),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:b,disabled:p,style:{background:p?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:p?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:v=>{p||(v.currentTarget.style.background="#4338ca")},onMouseLeave:v=>{p||(v.currentTarget.style.background="#4f46e5")},children:p?n.login.signingIn:n.login.signIn}),t.jsx("div",{style:{textAlign:"center",marginTop:8},children:t.jsx("button",{type:"button",onClick:Vf,style:{fontSize:12,color:"#94a3b8",background:"none",border:"none",cursor:"pointer"},onMouseEnter:v=>v.currentTarget.style.color="#475569",onMouseLeave:v=>v.currentTarget.style.color="#94a3b8",children:n.switchLang})})]})]})})}function r0(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,a=s&255,i=d=>Math.round(d+(255-d)*n);return`rgb(${i(l)}, ${i(r)}, ${i(a)})`}function Ml(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,a=s&255;return`rgba(${l}, ${r}, ${a}, ${n})`}function Vr({title:e,data:n,color:s,onSelect:l}){const[,r]=n[0]??["Total",0,""],a=n.slice(1),i=a.map((p,u)=>r0(s,Math.min(u*.16,.7))),d=a.map(([p,u,C],x)=>[p,u,C,i[x]]).filter(([,p])=>p>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, ${Ml(s,.09)} 0%, transparent 55%)`}}),t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${Ml(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 ${Ml(s,.35)}`},children:r})]}),r>0&&t.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:Ml(s,.1),marginBottom:13},children:d.map(([p,u,C,x],m)=>t.jsx("div",{title:`${p}: ${u}`,onClick:h=>{h.stopPropagation(),l==null||l(C)},style:{flex:`${u} 0 0`,background:x,borderRight:m<d.length-1?"2px solid white":"none",cursor:l?"pointer":"default"}},p))}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:a.map(([p,u,C],x)=>t.jsxs("div",{className:"status-card-row",onClick:u>0?m=>{m.stopPropagation(),l==null||l(C)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:u>0&&l?"pointer":"default",transition:"background 0.12s"},children:[t.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:i[x],flexShrink:0,boxShadow:`0 0 0 3px ${Ml(i[x],.18)}`}}),t.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),t.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:u})]},p))})]})}function Mt({value:e,onChange:n,organizations:s,placeholder:l="-- Choose organization --",disabled:r=!1,small:a=!1}){var x;const[i,d]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{const m=h=>{p.current&&!p.current.contains(h.target)&&d(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const u=e?((x=s.find(m=>m.organization_name===e||m.name===e))==null?void 0:x.organization_name)??e:l,C=s.filter(m=>!!m.is_active||m.organization_name===e||m.name===e);return t.jsxs("div",{ref:p,className:`custom-select-container ${r?"disabled":""} ${i?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${a?"small":""} ${r?"disabled":""} ${i?"open":""} ${e?"":"is-placeholder"}`,onClick:()=>!r&&d(m=>!m),children:[t.jsx("span",{className:"trigger-text",children:u}),t.jsx("span",{className:"trigger-arrow",children:"▼"})]}),i&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[t.jsx(Su,{label:l,selected:!e,active:!0,isPlaceholder:!0,small:a,onClick:()=>{n(""),d(!1)}}),C.length===0&&t.jsx("div",{className:"custom-select-empty",children:"No organizations"}),C.map(m=>t.jsx(Su,{label:m.organization_name,selected:e===m.organization_name||e===m.name,active:!!m.is_active,isPlaceholder:!1,small:a,onClick:()=>{n(m.organization_name),d(!1)}},m.name))]})})]})}function Su({label:e,selected:n,active:s,isPlaceholder:l,small:r,onClick:a}){const[i,d]=S.useState(!1);return t.jsx("div",{onClick:a,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:`custom-select-option ${n?"selected":""} ${i?"hovered":""} ${l?"placeholder-option":""} ${s?"":"inactive-option"} ${r?"small":""}`,children:e})}function Qt({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 Mn({items:e,type:n,onNavigate:s}){const l=ne();if(!e.length)return null;const r=n==="process"?"processes-form":"orders-form",a=n==="process"?l.dash.escalatedProcesses:l.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:[a," (",e.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.map(d=>t.jsxs("div",{onClick:()=>s(r,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:[l.dash.level," ",d.escalation_level]})]},d.name))})]})}function a0({kpi:e}){const n=ne();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:l,color:r})=>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:r}}),l]})]},s))})]})}function i0({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 l=s.pass+s.fail+s.unknown||1,r=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:r,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*(r-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*(r-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*(r-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})$/,(a,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:l>1?Math.round(s.pass/l*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,l])=>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:l})]},l))})]})}function o0({dashData:e,fi:n,fid:s,fo:l,fp:r,incidentStatuses:a,ideaStatuses:i,orderStatuses:d,processStatuses:p,onNavigate:u,onNavigateStatus:C}){const x=ne(),m=(e==null?void 0:e.escalated_processes)||[],h=(e==null?void 0:e.escalated_orders)||[],b=(e==null?void 0:e.attention_processes)||[],_=(e==null?void 0:e.attention_orders)||[],v=(e==null?void 0:e.untriaged_incidents)||[],g=(e==null?void 0:e.overdue_triage)||[],o=m.length>0||h.length>0,c=b.length>0||_.length>0,y=[["Total",n.length,""],...a.map(w=>[w.name1||w.name,n.filter(I=>I.status===w.name).length,w.name])],z=[["Total",s.length,""],...i.map(w=>[w.name1||w.name,s.filter(I=>I.status===w.name).length,w.name])],k=[["Total",l.length,""],...d.map(w=>[w.name1||w.name,l.filter(I=>I.status===w.name).length,w.name])],f=[["Total",r.length,""],...p.map(w=>[w.name1||w.name,r.filter(I=>I.status===w.name).length,w.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:()=>u("incidents"),style:{cursor:"pointer"},children:t.jsx(Vr,{title:x.dash.incidents,color:"#ef4444",data:y,onSelect:w=>C("incidents",w)})}),t.jsx("div",{onClick:()=>u("ideas"),style:{cursor:"pointer"},children:t.jsx(Vr,{title:x.dash.ideas,color:"#10b981",data:z,onSelect:w=>C("ideas",w)})}),t.jsx("div",{onClick:()=>u("orders"),style:{cursor:"pointer"},children:t.jsx(Vr,{title:x.dash.orders,color:"#8b5cf6",data:k,onSelect:w=>C("orders",w)})}),t.jsx("div",{onClick:()=>u("processes"),style:{cursor:"pointer"},children:t.jsx(Vr,{title:x.dash.processes,color:"#3b82f6",data:f,onSelect:w=>C("processes",w)})})]}),(o||c)&&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:x.dash.level2}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fef2f2",color:"#ef4444",padding:"2px 8px",borderRadius:9999},children:[m.length+h.length," Critical"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Mn,{items:m,type:"process",onNavigate:u}),t.jsx(Mn,{items:h,type:"order",onNavigate:u})]})]}),c&&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:x.dash.level1}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fffbeb",color:"#b45309",padding:"2px 8px",borderRadius:9999},children:[b.length+_.length," Action Needed"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Mn,{items:b,type:"process",onNavigate:u}),t.jsx(Mn,{items:_,type:"order",onNavigate:u})]})]})]}),(g.length>0||v.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:[x.dash.overduePrefix,g.length,x.dash.overdueSuffix]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:g.map(w=>t.jsxs("div",{onClick:()=>u("incidents-form",w.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:w.number||w.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:w.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:w.date})]},w.name))})]}),v.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:[x.dash.untriaged," (",v.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:v.map(w=>t.jsxs("div",{onClick:()=>u("incidents-form",w.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:w.number||w.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:w.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:w.date})]},w.name))})]})]})]})}function d0({dashData:e,selectedOrg:n,onNavigate:s}){const l=ne(),[r,a]=S.useState([]),[i,d]=S.useState([]),[p,u]=S.useState(!1),C=(e==null?void 0:e.escalated_processes)||[],x=(e==null?void 0:e.escalated_orders)||[],m=(e==null?void 0:e.attention_processes)||[],h=(e==null?void 0:e.attention_orders)||[],b=(e==null?void 0:e.kpi_inputs)||[];S.useEffect(()=>{u(!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 c=o.message||[],y={};for(const z of c)y[z.month]||(y[z.month]={pass:0,fail:0,unknown:0}),z.status==="Pass"?y[z.month].pass=z.count:z.status==="Fail"?y[z.month].fail=z.count:z.status==="Unknown"&&(y[z.month].unknown=z.count);a(Object.entries(y).map(([z,k])=>({month:z,...k})))}).catch(()=>{}).finally(()=>u(!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 _=C.length>0||x.length>0,v=m.length>0||h.length>0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[b.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:l.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:[l.dash.manageKpi," →"]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:14},children:b.map(g=>t.jsx(a0,{kpi:g},g.name))})]}),(_||v)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[_&&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+x.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Mn,{items:C,type:"process",onNavigate:s}),t.jsx(Mn,{items:x,type:"order",onNavigate:s})]})]}),v&&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 (",m.length+h.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Mn,{items:m,type:"process",onNavigate:s}),t.jsx(Mn,{items:h,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."}),p?t.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"Loading trend analytics…"}):t.jsx(i0,{data:r})]}),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 c0({incidents:e,ideas:n,orders:s,processes:l,organizations:r,incidentStatuses:a,ideaStatuses:i,orderStatuses:d,processStatuses:p,selectedOrg:u,onOrgChange:C,onNavigate:x,onNavigateStatus:m,userRole:h}){const[b,_]=S.useState(null),[v,g]=S.useState(!1),o=()=>{g(!0),Uy(u).then(_).finally(()=>g(!1))};S.useEffect(()=>{o()},[u]);const c=S.useMemo(()=>u?e.filter(F=>F.organization===u):e,[e,u]),y=S.useMemo(()=>u?n.filter(F=>F.organization===u):n,[n,u]),z=S.useMemo(()=>u?s.filter(F=>F.organization===u):s,[s,u]),k=S.useMemo(()=>u?l.filter(F=>F.organization===u):l,[l,u]),f=h==="Admin",w=h==="Owner",[I,P]=S.useState("level1"),Y=w||f&&I==="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:Y?"Executive Performance Dashboard":"Operational Activity Dashboard"})]}),t.jsx("p",{style:{fontSize:13,color:"#c7d2fe",margin:0,opacity:.9},children:u?`Real-time analytics for ${u}`:"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(Mt,{value:u,onChange:C,organizations:r,placeholder:"All Organizations",small:!0})}),f&&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:()=>P("level1"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:I==="level1"?"white":"transparent",color:I==="level1"?"#1e1b4b":"#c7d2fe",boxShadow:I==="level1"?"0 2px 6px rgba(0,0,0,0.15)":"none",transition:"all 0.15s ease"},children:"Level 1 (Ops)"}),t.jsx("button",{onClick:()=>P("level2"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:I==="level2"?"#8b5cf6":"transparent",color:"white",boxShadow:I==="level2"?"0 2px 6px rgba(0,0,0,0.2)":"none",transition:"all 0.15s ease"},children:"Level 2 (Exec)"})]}),!f&&t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:Y?"#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:Y?"👑 Owner View":"💼 Operations View"}),t.jsx("button",{onClick:o,disabled:v,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:v?"rotate(180deg)":"none",transition:"transform 0.4s ease"},children:"🔄"})})]})]}),t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:Y?t.jsxs(t.Fragment,{children:[t.jsx(Qt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>x("users")}),t.jsx(Qt,{label:"Active Review Cycles",icon:"🔄",onClick:()=>x("cycles")}),t.jsx(Qt,{label:"Strategic KPI Inputs",icon:"📈",onClick:()=>x("kpi-input")}),t.jsx(Qt,{label:"Executive Reports",icon:"📊",onClick:()=>x("reports")}),t.jsx(Qt,{label:"Organizations Hierarchy",icon:"🏢",onClick:()=>x("organizations")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Qt,{label:"Incidents",icon:"⚠️",onClick:()=>x("incidents")}),t.jsx(Qt,{label:"Ideas",icon:"💡",onClick:()=>x("ideas")}),t.jsx(Qt,{label:"Orders",icon:"📦",onClick:()=>x("orders")}),t.jsx(Qt,{label:"Processes",icon:"⚙️",onClick:()=>x("processes")}),t.jsx(Qt,{label:"Inbox",icon:"📥",onClick:()=>x("inbox")}),t.jsx(Qt,{label:"Reports",icon:"📊",onClick:()=>x("reports")})]})})]})]}),Y?t.jsx(d0,{dashData:b,selectedOrg:u,onNavigate:x}):t.jsx(o0,{dashData:b,fi:c,fid:y,fo:z,fp:k,incidentStatuses:a,ideaStatuses:i,orderStatuses:d,processStatuses:p,onNavigate:x,onNavigateStatus:m})]})}const Ze={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},et={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 li({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(l=>!l),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 re=20,wu=e=>({padding:"6px 16px",borderRadius:6,border:"1px solid #d1d5db",fontSize:12,fontWeight:600,background:e?"#f3f4f6":"white",color:e?"#c1c5cc":"#374151",cursor:e?"not-allowed":"pointer",fontFamily:"inherit"});function Xe({page:e,pageSize:n=re,total:s,onPageChange:l}){if(s===0)return null;const r=Math.max(1,Math.ceil(s/n)),a=(e-1)*n+1,i=Math.min(e*n,s);return t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[t.jsxs("span",{children:["Showing ",a," to ",i," of ",s," results"]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{disabled:e<=1,onClick:()=>l(e-1),style:wu(e<=1),children:"Previous"}),t.jsx("button",{disabled:e>=r,onClick:()=>l(e+1),style:wu(e>=r),children:"Next"})]})]})}function u0({incidents:e,organizations:n,departments:s,branches:l,incidentStatuses:r,initialOrg:a,initialStatus:i,canModify:d,userRole:p,onView:u,onEdit:C,onDelete:x,onSelectionChange:m}){const h=ne(),[b,_]=S.useState(new Set),[v,g]=S.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),o=(f,w)=>g(I=>({...I,[f]:w})),[c,y]=S.useState(1),z=e.filter(f=>!(v.search&&!`${f.number} ${f.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&f.organization!==v.organization||v.department&&f.department!==v.department||v.branch&&f.branch!==v.branch||v.status&&f.status!==v.status));S.useEffect(()=>{y(1)},[v]);const k=z.slice((c-1)*re,c*re);return S.useEffect(()=>{if(m){const f=e.filter(w=>b.has(w.name));m(f,k)}},[b,k,e]),t.jsxs(t.Fragment,{children:[t.jsx(li,{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:Ze,children:h.filter.numberTitle}),t.jsx("input",{style:et,value:v.search,onChange:f=>o("search",f.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.organization}),t.jsxs("select",{style:et,value:v.organization,onChange:f=>o("organization",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(f=>t.jsx("option",{value:f.name,children:f.organization_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.department}),t.jsxs("select",{style:et,value:v.department,onChange:f=>o("department",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(f=>t.jsx("option",{value:f.name,children:f.department_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.branch}),t.jsxs("select",{style:et,value:v.branch,onChange:f=>o("branch",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(f=>t.jsx("option",{value:f.name,children:f.branch||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.status}),t.jsxs("select",{style:et,value:v.status,onChange:f=>o("status",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(f=>t.jsx("option",{value:f.name,children:f.name1||f.name},f.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:k.length>0&&k.every(f=>b.has(f.name)),onChange:f=>{if(f.target.checked)_(new Set([...b,...k.map(w=>w.name)]));else{const w=new Set(b);k.forEach(I=>w.delete(I.name)),_(w)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:z.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noIncidents})}):k.map((f,w)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>u==null?void 0:u(f),style:{borderTop:"1px solid #f1f5f9",background:b.has(f.name)?"#eff6ff":f.custom_is_deleted?"#fff1f2":w%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(f.name),onChange:()=>{const I=new Set(b);I.has(f.name)?I.delete(f.name):I.add(f.name),_(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:f.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:f.title||f.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:f.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.type?Dd(f.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.custom_is_deleted?es(h.deletedBadge):f.status?es(f.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(lt,{onView:()=>u==null?void 0:u(f),onEdit:d&&C&&!f.custom_is_deleted&&!Fn("incident",f.workflow_state)&&!(p==="Employee"&&f.workflow_state&&f.workflow_state!=="New")?()=>C(f):void 0,onDelete:d&&x&&!f.custom_is_deleted?()=>x(f.name):void 0})})]},f.name))})]})}),t.jsx(Xe,{page:c,total:z.length,onPageChange:y})]})}function p0(e){if(!e)return"";const[n,s,l]=e.split("-");return!n||!s||!l?"":`${l}/${s}/${n}`}function xe({value:e,onChange:n,disabled:s,style:l,min:r,max:a}){return t.jsxs("div",{style:{position:"relative",width:"100%"},children:[t.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:p0(e),placeholder:"DD/MM/YYYY",style:{...l,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:r,max:a,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 ku={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function f0(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 lh({notifCount:e,darkMode:n,onCountChange:s,onToggleDark:l,onViewProfile:r,onLogout:a,onNavigate:i,userName:d,userRole:p}){const[u,C]=S.useState(!1),[x,m]=S.useState([]),[h,b]=S.useState(!1),_=S.useRef(null);S.useEffect(()=>{const P=Y=>{_.current&&!_.current.contains(Y.target)&&C(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);const v=async()=>{b(!0);const P=await Ey(30);m(P),b(!1)},g=()=>{const P=!u;C(P),P&&v()},o=async()=>{await Py(),m(P=>P.map(Y=>({...Y,read:1}))),s(0)},c=P=>{P.read||(Ay(P.name),m(F=>F.map($=>$.name===P.name?{...$,read:1}:$)),s(Math.max(0,e-1)));const Y=P.document_type?ku[P.document_type]:void 0;Y&&i&&(i(Y,P.document_type==="SB Delegation"?void 0:P.document_name),C(!1))},y=x.filter(P=>!P.read).length,z=P=>({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,...P}),k=n,f=k?"#1a202c":"white",w=k?"#2d3748":"#e5e7eb",I=k?"#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:k?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:d}),p&&t.jsx("span",{style:{fontSize:11,color:k?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:p})]}),t.jsx("button",{style:z({background:"#4f46e5",color:"white"}),onClick:r,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:_,style:{position:"relative"},children:[t.jsxs("button",{style:z(),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})]}),u&&t.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:f,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${w}`,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${w}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:f},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:I},children:["Notifications",y>0&&t.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[y," new"]})]}),y>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:[h&&t.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!h&&x.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"})]}),!h&&x.map(P=>{const Y=!!(P.document_type&&ku[P.document_type]&&i);return t.jsxs("div",{onClick:()=>c(P),style:{padding:"11px 16px",borderBottom:`1px solid ${k?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:P.read?f:k?"#1e3a5f":"#eff6ff",cursor:Y?"pointer":"default",transition:"background 0.12s"},onMouseEnter:F=>{Y&&(F.currentTarget.style.background=k?"#243244":"#e0ecfd")},onMouseLeave:F=>{F.currentTarget.style.background=P.read?f:k?"#1e3a5f":"#eff6ff"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:13,fontWeight:P.read?400:600,color:I,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.subject||`${P.document_type}: ${P.document_name}`}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:P.document_type&&t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:k?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[P.document_type.replace("SB ",""),P.document_name?` · ${P.document_name}`:""]})}),t.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:f0(P.creation)})]}),!P.read&&t.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},P.name)})]})]})]}),t.jsx("button",{style:z(),onClick:Vf,title:cl()?"Switch to English":"Switch to Arabic",children:t.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),t.jsx("button",{style:z(),onClick:l,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:z({background:k?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:a,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 qe({title:e,activePage:n,user:s,formStatus:l,buttonText:r,viewMode:a,statusBadge:i,onEdit:d,onCancel:p,hideSettings:u,rightPanel:C,darkMode:x,notifCount:m,onToggleDark:h,onCountChange:b,onViewProfile:_,onSubmit:v,onBack:g,onNavigate:o,onLogout:c,children:y}){const z=ne(),k=s.role,f=k==="Admin"||k==="Owner"||k==="Auditor"||k==="Manager",w=k==="Admin"||k==="Owner"||k==="Auditor"||k==="Manager",I=k==="Admin"||k==="Auditor"||k==="Manager",[P,Y]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),F=S.useRef(void 0),[$,U]=S.useState(!1);S.useEffect(()=>{if(F.current===!0&&a===!1){U(!0);const H=setTimeout(()=>{U(!1)},4e3);return()=>clearTimeout(H)}else U(!1);F.current=a},[a]);const E=()=>Y(H=>{const G=!H;return localStorage.setItem("sb_sidebar",G?"1":"0"),G}),D=p||g;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:x?"#0f172a":"#f8fafc"},children:[t.jsx(eh,{collapsed:P,onToggleCollapsed:E,activePage:n,onNavigate:o,hasDashboard:f,hasReports:w,hasDelegations:I,role:k,hideSettings:u,rtl:z.rtl,navLabels:z.nav,settingsLabel:z.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:x?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${x?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:x?"none":"0 1px 4px rgba(0,0,0,0.03)"},children:t.jsx(lh,{notifCount:m,darkMode:x,onCountChange:b,onToggleDark:h,onNavigate:o,onViewProfile:_,onLogout:c,userName:s.full_name||s.name,userRole:s.role})}),t.jsxs("div",{style:{background:x?"#1e293b":"#ffffff",padding:"12px 24px",borderBottom:`1px solid ${x?"#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:z.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:`1px solid ${x?"#475569":"#e2e8f0"}`,background:x?"#334155":"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:H=>{H.currentTarget.style.background=x?"#475569":"#eff6ff",H.currentTarget.style.borderColor="#93c5fd"},onMouseLeave:H=>{H.currentTarget.style.background=x?"#334155":"#ffffff",H.currentTarget.style.borderColor=x?"#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:x?"#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:[a&&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:H=>H.currentTarget.style.background="#1d4ed8",onMouseLeave:H=>H.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"})]}),z.edit]}),!a&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button",onClick:D,style:{padding:"7px 16px",borderRadius:6,border:`1px solid ${x?"#475569":"#cbd5e1"}`,background:x?"#334155":"#ffffff",color:x?"#e2e8f0":"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:H=>{H.currentTarget.style.background=x?"#475569":"#f1f5f9"},onMouseLeave:H=>{H.currentTarget.style.background=x?"#334155":"#ffffff"},children:z.cancel}),t.jsxs("button",{type:"button",onClick:v,disabled:l==="loading",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 18px",borderRadius:6,border:"none",background:"#16a34a",color:"#ffffff",fontSize:13,fontWeight:600,cursor:l==="loading"?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(22, 163, 74, 0.3)",opacity:l==="loading"?.7:1,transition:"all 0.15s ease"},onMouseEnter:H=>{l!=="loading"&&(H.currentTarget.style.background="#15803d")},onMouseLeave:H=>{l!=="loading"&&(H.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:l==="loading"?z.saving:r||"Save Changes"})]})]})]}),!a&&$&&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:()=>U(!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:[y,l==="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:z.savedOk}),l!=="idle"&&l!=="loading"&&l!=="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:14},children:l})]}),C&&t.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:C})]})]})]})}function ue({value:e,onChange:n,items:s,placeholder:l="-- Select --",disabled:r=!1}){var x;const[a,i]=S.useState(!1),[d,p]=S.useState(""),u=S.useRef(null);S.useEffect(()=>{const m=h=>{u.current&&!u.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const C=e?((x=s.find(m=>m.name===e))==null?void 0:x.label)??e:l;return t.jsxs("div",{ref:u,className:`custom-select-container ${r?"disabled":""} ${a?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${r?"disabled":""} ${a?"open":""} ${e?"":"is-placeholder"}`,onClick:()=>!r&&i(m=>!m),children:[t.jsx("span",{className:"trigger-text",children:C}),t.jsx("span",{className:"trigger-arrow",children:"▼"})]}),a&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[t.jsx("div",{className:`custom-select-option placeholder-option ${d==="__placeholder"?"hovered":""}`,onClick:()=>{n(""),i(!1)},onMouseEnter:()=>p("__placeholder"),onMouseLeave:()=>p(""),children:l}),s.length===0&&t.jsx("div",{className:"custom-select-empty",children:"No records found"}),s.map(m=>t.jsx("div",{className:`custom-select-option ${e===m.name?"selected":""} ${d===m.name?"hovered":""}`,onClick:()=>{n(m.name),i(!1)},onMouseEnter:()=>p(m.name),onMouseLeave:()=>p(""),children:m.label},m.name))]})})]})}function h0(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 g0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function ri({doctype:e,docname:n,currentUserName:s}){const l=ne(),[r,a]=S.useState([]),[i,d]=S.useState(!1),[p,u]=S.useState(""),[C,x]=S.useState(!1),[m,h]=S.useState(!1),[b,_]=S.useState(!1),[v,g]=S.useState(""),o=5,c=S.useCallback(async()=>{d(!0);const w=await Dy(e,n);a(w),d(!1)},[e,n]);S.useEffect(()=>{c()},[c]);const y=async()=>{const w=p.trim();if(!(!w||C)){x(!0),g("");try{await Ly(e,n,w),u(""),await c()}catch{g("Failed to post comment. Please try again.")}x(!1)}},z=async w=>{if(window.confirm("Delete this comment?"))try{await Wo("Comment",w),a(I=>I.filter(P=>P.name!==w))}catch{alert("Failed to delete comment.")}},k=b?r:r.slice(-o),f=Math.max(0,r.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:()=>h(w=>!w),style:{padding:"12px 20px",borderBottom:m?"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:["💬 ",l.comments.title,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:[t.jsx("button",{onClick:w=>{w.stopPropagation(),c()},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:m?"▼":"▲"})]})]}),!m&&t.jsxs("div",{style:{padding:"16px 20px"},children:[!b&&f>0&&t.jsxs("button",{onClick:()=>_(!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 ",f," older comment",f!==1?"s":""]}),i&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!i&&r.length===0&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:l.comments.noComments}),!i&&k.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:k.map(w=>{const I=w.comment_by||w.comment_email||w.owner||"Unknown",P=w.owner===s||w.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:g0(I)}),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:I}),t.jsx("span",{style:{fontSize:11,color:"#aaa"},children:h0(w.creation)})]}),P&&t.jsx("button",{onClick:()=>z(w.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:w.content||""}})]})]},w.name)})}),t.jsxs("div",{style:{borderTop:r.length>0?"1px solid #f0f0f0":"none",paddingTop:r.length>0?14:0},children:[t.jsx("textarea",{value:p,onChange:w=>u(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.ctrlKey||w.metaKey)&&y()},placeholder:l.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"}}),v&&t.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:v}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:t.jsx("button",{onClick:y,disabled:!p.trim()||C,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!p.trim()||C?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!p.trim()||C?.6:1},children:C?l.saving:l.comments.post})})]})]})]})}function _u(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 x0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Cu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function Bo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function zu(e){return Bo(e).split(" ").filter(Boolean).slice(0,2).map(n=>n[0].toUpperCase()).join("")}function m0(e){let n={};try{n=JSON.parse(e.data||"{}")}catch{}const s=(n.changed||[]).map(l=>({field:l[0]||"",oldVal:Cu(l[1]),newVal:Cu(l[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 ai({doctype:e,docname:n,docCreation:s,docOwner:l}){const r=ne(),[a,i]=S.useState([]),[d,p]=S.useState(!1),[u,C]=S.useState(!0),[x,m]=S.useState(!1),h=5,b=S.useCallback(async()=>{p(!0);const o=await Oy(e,n);i(o.map(m0)),p(!1)},[e,n]);S.useEffect(()=>{u||b()},[u,b]);const _=x?a:a.slice(0,h),v=a.length-h,g=(o,c=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:o,border:"2px solid white",boxShadow:c?`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:u?"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:["📋 ",r.activity.title,!u&&a.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:a.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!u&&t.jsx("button",{onClick:o=>{o.stopPropagation(),b()},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:u?"▼":"▲"})]})]}),!u&&t.jsxs("div",{style:{padding:"16px 20px"},children:[d&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.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:[_.map((o,c)=>t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:g(c===0?"#3498db":"#d1d5db",c===0)}),t.jsxs("div",{style:{background:c===0?"#eff6ff":"#f9fafb",border:`1px solid ${c===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:zu(o.owner)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Bo(o.owner)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:_u(o.creation)})]}),o.changes.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:o.changes.map((y,z)=>t.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[t.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:x0(y.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:y.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:y.newVal})]},z))}):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&&l&&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:zu(l)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Bo(l)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:_u(s)})]}),t.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",r.activity.created]})]})]}),a.length===0&&!s&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!d&&v>0&&t.jsx("div",{style:{textAlign:"center",marginTop:12},children:t.jsx("button",{onClick:()=>m(o=>!o),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:x?"▲ Show less":`▼ Show all (${a.length})`})})]})]})}const y0={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 v0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...y0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function j0({incForm:e,setIncForm:n,organizations:s,managements:l,departments:r,branches:a,incidentTypes:i,incidentClasses:d,incidentFields:p,incidentStatuses:u,users:C,userRoleMap:x={},formStatus:m,viewMode:h,canModify:b,onEdit:_,onDelete:v,onRestore:g,darkMode:o,notifCount:c,onToggleDark:y,onCountChange:z,onViewProfile:k,userRole:f,delegatedFunctions:w=[],delegatedOrgs:I={},onSubmit:P,onBack:Y,onNavigate:F,onLogout:$,user:U,onRefresh:E}){var ut;const D=ne(),H=M=>n({...e,...M}),G=h?{background:"#f9f9f9"}:{},X=kl(C,x,"SB Manager",e.organization),[J,W]=S.useState(""),[Z,pe]=S.useState(!1),be=e.name?h?`${D.formTitle.viewIncident}${e.number||e.name}`:D.formTitle.editIncident:D.formTitle.newIncident,ae=me(l,e.management).map(M=>({name:M.name,label:M.name1||M.name})),Je=me(r,e.department).map(M=>({name:M.name,label:M.department_name||M.name})),it=me(a,e.branch).map(M=>({name:M.name,label:M.branch||M.name})),Q=me(i,e.type).map(M=>({name:M.name,label:M.name1||M.name})),oe=me(d,e.incident_class).map(M=>({name:M.name,label:M.name1||M.name})),Oe=me(p,e.incident_field).map(M=>({name:M.name,label:M.name1||M.name})),ye=e.workflow_state||"New",tn=f==="Employee",fe=f==="Auditor"||f==="Admin",ve=f==="Manager",zt=ve&&w.includes("incident_initial_evaluation")&&(!I.incident_initial_evaluation||(I.incident_initial_evaluation||[]).includes(e.organization)),Ne=fe||zt,L=e.name?ye==="New"?[{label:D.wf.submit,action:"Submit",color:"#2563eb"}]:ye==="Initial Evaluation"&&Ne?[{label:D.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:ye==="Accept & Under Progress"&&(ve||fe)?[{label:D.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:ye==="working on resolution"&&(ve||fe)?[{label:D.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function se(M){if(e.name){pe(!0),W("");try{const Be={};M==="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)),M==="Submit Solution"&&(e.solution&&(Be.solution=e.solution),e.summary&&(Be.summary=e.summary),e.cost&&(Be.cost=String(e.cost))),(M==="Resolution complete"||M==="Submit Solution")&&e.auditor_comment&&(Be.auditor_comment=e.auditor_comment),await By(e.name,M,JSON.stringify(Be)),W("Done"),E==null||E()}catch(Be){W(Be.message||"Error")}finally{pe(!1)}}}const R=((ut=X.find(M=>M.name===e.assigned_to))==null?void 0:ut.full_name)||e.assigned_to,We=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:D.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:ye})]}),ye==="Initial Evaluation"&&Ne&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:T,children:D.wf.assignToManager}),t.jsxs("select",{style:A,value:e.assigned_to||"",onChange:M=>H({assigned_to:M.target.value}),children:[t.jsx("option",{value:"",children:D.field.selectMgr}),X.map(M=>t.jsx("option",{value:M.name,children:M.full_name||M.name},M.name))]})]}),(ye==="Accept & Under Progress"||ye==="working on resolution")&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:T,children:D.field.solution}),t.jsx("textarea",{style:{...A,height:75,resize:"vertical"},value:e.solution||"",onChange:M=>H({solution:M.target.value}),placeholder:D.field.solutionPlaceholder}),t.jsx("label",{style:{...T,marginTop:6},children:D.field.actualCost}),t.jsx("input",{type:"number",style:A,value:e.cost||"",onChange:M=>H({cost:parseFloat(M.target.value)||0}),placeholder:"0.00"})]}),ye==="working on resolution"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:T,children:D.field.auditorComment}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:M=>H({auditor_comment:M.target.value}),placeholder:D.field.commentPlaceholder})]}),L.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:L.map(M=>t.jsx("button",{onClick:()=>se(M.action),disabled:Z,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:M.color,color:"white",fontWeight:600,fontSize:12,cursor:Z?"not-allowed":"pointer",opacity:Z?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:Z?D.wf.applying:M.label})},M.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:D.wf.noActions}),J&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:J==="Done"?q.green:q.red},children:J})]}),t.jsx(si,{priority:e.priority,status:ye,assignedTo:R||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(ri,{doctype:O.incidents,docname:e.name,currentUserName:U.name}),t.jsx(ai,{doctype:O.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),b&&v&&!e.custom_is_deleted&&t.jsx(ni,{title:"Delete Request",btnText:D.delete,onDelete:()=>v(e.name)})]}):null;return t.jsxs(qe,{title:be,activePage:"incidents",user:U,formStatus:m,statusBadge:t.jsx("span",{style:v0(ye),children:ye}),buttonText:D.saveIncident,buttonColor:"#16a34a",viewMode:h,onEdit:_,darkMode:o,notifCount:c,onToggleDark:y,onCountChange:z,onViewProfile:k,rightPanel:We,onSubmit:P,onBack:Y,onNavigate:F,onLogout:$,children:[e.custom_is_deleted===1&&t.jsx(Tr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0}),t.jsx(le,{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:T,children:D.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[D.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:M=>H({organization:M}),organizations:s,disabled:h||!!U.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.title}),t.jsx("input",{style:{...A,...G},value:e.title,disabled:h,onChange:M=>H({title:M.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.management}),t.jsx(ue,{value:e.management,onChange:M=>H({management:M}),items:ae,placeholder:D.field.select,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.department}),t.jsx(ue,{value:e.department,onChange:M=>H({department:M}),items:Je,placeholder:D.field.select,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.section}),t.jsx("input",{style:{...A,...G},value:e.section_field||"",disabled:h,onChange:M=>H({section_field:M.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.branch}),t.jsx(ue,{value:e.branch,onChange:M=>H({branch:M}),items:it,placeholder:D.field.select,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.type}),t.jsx(ue,{value:e.type,onChange:M=>H({type:M}),items:Q,placeholder:D.field.selectType,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.incidentClass}),t.jsx(ue,{value:e.incident_class,onChange:M=>H({incident_class:M}),items:oe,placeholder:D.field.selectClass,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.incidentField}),t.jsx(ue,{value:e.incident_field,onChange:M=>H({incident_field:M}),items:Oe,placeholder:D.field.selectField,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.hsesField}),t.jsx("input",{style:{...A,...G},value:e.hses_field||"",disabled:h,onChange:M=>H({hses_field:M.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),t.jsxs(le,{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:T,children:D.field.date}),t.jsx(xe,{value:e.date,onChange:M=>H({date:M}),disabled:!0,style:{...A,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.time}),t.jsx("input",{type:"time",style:{...A,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.assignedTo}),h||f==="Employee"?t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:R||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.assigned_to||"",onChange:M=>H({assigned_to:M}),items:X.map(M=>({name:M.name,label:M.full_name||M.name})),placeholder:D.field.select})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.description}),t.jsx("textarea",{style:{...A,...G,height:100,resize:"vertical"},value:e.description,disabled:h,onChange:M=>H({description:M.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!tn&&t.jsxs(le,{title:D.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:T,children:D.field.priority}),t.jsxs("select",{style:{...A,...h||!Ne?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:h||!Ne,onChange:M=>H({priority:M.target.value}),children:[t.jsx("option",{value:"",children:D.field.select}),t.jsx("option",{value:"High",children:D.field.high}),t.jsx("option",{value:"Normal",children:D.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.economyClass}),t.jsxs("select",{style:{...A,...h||!Ne?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:h||!Ne,onChange:M=>H({economy_class:M.target.value}),children:[t.jsx("option",{value:"",children:D.field.select}),t.jsx("option",{value:"Expenses",children:D.field.expenses}),t.jsx("option",{value:"Capital",children:D.field.capital}),t.jsx("option",{value:"Earn",children:D.field.earn}),t.jsx("option",{value:"Pay/Loss",children:D.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.entityScope}),t.jsxs("select",{style:{...A,...h||!Ne?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:h||!Ne,onChange:M=>H({entity_scope:M.target.value}),children:[t.jsx("option",{value:"",children:D.field.select}),t.jsx("option",{value:"Upstream",children:D.field.upstream}),t.jsx("option",{value:"On-stream",children:D.field.onstream}),t.jsx("option",{value:"Downstream",children:D.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:h||!Ne,onChange:M=>H({product_relation:M.target.checked?1:0})})," ",D.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:h||!Ne,onChange:M=>H({repeated:M.target.checked?1:0})})," ",D.field.repeatedEvent]})]})]}),!tn&&t.jsxs(le,{title:D.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:T,children:D.field.solution}),t.jsx("textarea",{style:{...A,height:90,resize:"vertical",...h&&!ve&&!fe?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:h&&!ve&&!fe,onChange:M=>H({solution:M.target.value}),placeholder:D.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:T,children:D.field.actualCost}),t.jsx("input",{type:"number",style:{...A,...h&&!ve&&!fe?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:h&&!ve&&!fe,onChange:M=>H({cost:parseFloat(M.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.summary}),t.jsx("input",{style:{...A,...h&&!ve&&!fe?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:h&&!ve&&!fe,onChange:M=>H({summary:M.target.value}),placeholder:"Brief summary"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:D.field.auditorComment}),t.jsx("textarea",{style:{...A,height:70,resize:"vertical",...h&&!fe?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:h&&!fe,onChange:M=>H({auditor_comment:M.target.value}),placeholder:D.field.commentPlaceholder})]})]})]})}function b0({ideas:e,organizations:n,departments:s,branches:l,ideaStatuses:r,initialOrg:a,initialStatus:i,canModify:d,userRole:p,onView:u,onEdit:C,onDelete:x,onSelectionChange:m}){const h=ne(),[b,_]=S.useState(new Set),[v,g]=S.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),o=(f,w)=>g(I=>({...I,[f]:w})),[c,y]=S.useState(1),z=e.filter(f=>!(v.search&&!`${f.number} ${f.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&f.organization!==v.organization||v.department&&f.department!==v.department||v.branch&&f.branch!==v.branch||v.status&&f.status!==v.status));S.useEffect(()=>{y(1)},[v]);const k=z.slice((c-1)*re,c*re);return S.useEffect(()=>{if(m){const f=e.filter(w=>b.has(w.name));m(f,k)}},[b,k,e]),t.jsxs(t.Fragment,{children:[t.jsx(li,{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:Ze,children:h.filter.numberTitle}),t.jsx("input",{style:et,value:v.search,onChange:f=>o("search",f.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.organization}),t.jsxs("select",{style:et,value:v.organization,onChange:f=>o("organization",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(f=>t.jsx("option",{value:f.name,children:f.organization_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.department}),t.jsxs("select",{style:et,value:v.department,onChange:f=>o("department",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(f=>t.jsx("option",{value:f.name,children:f.department_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.branch}),t.jsxs("select",{style:et,value:v.branch,onChange:f=>o("branch",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(f=>t.jsx("option",{value:f.name,children:f.branch||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.status}),t.jsxs("select",{style:et,value:v.status,onChange:f=>o("status",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(f=>t.jsx("option",{value:f.name,children:f.name1||f.name},f.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:k.length>0&&k.every(f=>b.has(f.name)),onChange:f=>{if(f.target.checked)_(new Set([...b,...k.map(w=>w.name)]));else{const w=new Set(b);k.forEach(I=>w.delete(I.name)),_(w)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:z.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noIdeas})}):k.map((f,w)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>u==null?void 0:u(f),style:{borderTop:"1px solid #f1f5f9",background:b.has(f.name)?"#eff6ff":f.custom_is_deleted?"#fff1f2":w%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(f.name),onChange:()=>{const I=new Set(b);I.has(f.name)?I.delete(f.name):I.add(f.name),_(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:f.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:f.title||"—"}),f.sb_order&&t.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",f.sb_order]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:f.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.custom_is_deleted?es(h.deletedBadge):f.status?es(f.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(lt,{onView:()=>u==null?void 0:u(f),onEdit:d&&C&&!f.custom_is_deleted&&!Fn("idea",f.workflow_state)&&!(p==="Employee"&&f.workflow_state&&f.workflow_state!=="New")?()=>C(f):void 0,onDelete:d&&x&&!f.custom_is_deleted?()=>x(f.name):void 0})})]},f.name))})]})}),t.jsx(Xe,{page:c,total:z.length,onPageChange:y})]})}const S0={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 w0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...S0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function k0({ideaForm:e,setIdeaForm:n,organizations:s,managements:l,departments:r,branches:a,ideaTypes:i,ideaStatuses:d,users:p=[],userRoleMap:u={},formStatus:C,viewMode:x,canModify:m,onEdit:h,onDelete:b,onRestore:_,onNavigateToOrder:v,darkMode:g,notifCount:o,onToggleDark:c,onCountChange:y,onViewProfile:z,userRole:k,delegatedFunctions:f=[],delegatedOrgs:w={},onSubmit:I,onBack:P,onNavigate:Y,onLogout:F,user:$,onRefresh:U}){var se;const E=ne(),D=R=>n({...e,...R}),H=x?{background:"#f9f9f9"}:{},G=kl(p,u,"SB Manager",e.organization),[X,J]=S.useState(""),[W,Z]=S.useState(!1),pe=e.name?x?`${E.formTitle.viewIdea}${e.number||e.title||e.name}`:E.formTitle.editIdea:E.formTitle.newIdea,be=me(l,e.management).map(R=>({name:R.name,label:R.name1||R.name})),ae=me(r,e.department).map(R=>({name:R.name,label:R.department_name||R.name})),Je=me(a,e.branch).map(R=>({name:R.name,label:R.branch||R.name})),it=me(i,e.type).map(R=>({name:R.name,label:R.name1||R.name})),Q=e.workflow_state||"New",oe=k==="Employee",Oe=k==="Auditor"||k==="Admin",ye=k==="Manager",tn=ye&&f.includes("idea_initial_evaluation")&&(!w.idea_initial_evaluation||(w.idea_initial_evaluation||[]).includes(e.organization)),fe=Oe||tn,ve=e.name?Q==="New"?[{label:E.wf.submit,action:"Submit",color:"#2563eb"}]:Q==="Initial Evaluation"&&fe?[{label:E.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:E.wf.reject,action:"Reject",color:"#dc2626"}]:Q==="Accept & Under Progress"&&(ye||Oe)?[{label:E.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:Q==="working on proposal"&&Oe?[{label:E.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:E.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function zt(R){if(e.name){Z(!0),J("");try{const We={};R==="Assign to Manager"&&(e.assigned_to&&(We.assigned_to=e.assigned_to),e.priority&&(We.priority=e.priority),e.economy_class&&(We.economy_class=e.economy_class),e.entity_scope&&(We.entity_scope=e.entity_scope),e.hses_field&&(We.hses_field=e.hses_field),We.product_relation=String(e.product_relation??0),We.repeated=String(e.repeated??0)),R==="Submit Proposal"&&(e.solution&&(We.solution=e.solution),e.proposed_condition&&(We.proposed_condition=e.proposed_condition),e.cost&&(We.cost=String(e.cost))),e.auditor_comment&&(R==="Move to Outsourcing"||R==="Reject")&&(We.auditor_comment=e.auditor_comment);const ut=await $y(e.name,R,JSON.stringify(We));ut!=null&&ut.created_order&&D({sb_order:ut.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),J("Done"),U==null||U()}catch(We){J(We.message||"Error")}finally{Z(!1)}}}const Ne=((se=G.find(R=>R.name===e.assigned_to))==null?void 0:se.full_name)||e.assigned_to,L=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:E.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:Q})]}),Q==="Initial Evaluation"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:T,children:E.wf.assignToManager}),t.jsxs("select",{style:A,value:e.assigned_to||"",onChange:R=>D({assigned_to:R.target.value}),children:[t.jsx("option",{value:"",children:E.field.selectMgr}),G.map(R=>t.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]}),Q==="Accept & Under Progress"&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:T,children:E.field.solution}),t.jsx("textarea",{style:{...A,height:75,resize:"vertical"},value:e.solution||"",onChange:R=>D({solution:R.target.value}),placeholder:E.field.solutionPlaceholder}),t.jsx("label",{style:{...T,marginTop:6},children:E.field.actualCost}),t.jsx("input",{type:"number",style:A,value:e.cost||"",onChange:R=>D({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),Q==="working on proposal"&&Oe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:T,children:E.field.auditorComment}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>D({auditor_comment:R.target.value}),placeholder:E.field.commentPlaceholder})]}),ve.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:ve.map(R=>t.jsx("button",{onClick:()=>zt(R.action),disabled:W,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:R.color,color:"white",fontWeight:600,fontSize:12,cursor:W?"not-allowed":"pointer",opacity:W?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:W?E.wf.applying:R.label})},R.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:E.wf.noActions}),X&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:X==="Done"?q.green:q.red},children:X})]}),t.jsx(si,{priority:e.priority,status:Q,assignedTo:Ne||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(ri,{doctype:O.ideas,docname:e.name,currentUserName:$.name}),t.jsx(ai,{doctype:O.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&b&&!e.custom_is_deleted&&t.jsx(ni,{title:"Delete Request",btnText:E.delete,onDelete:()=>b(e.name)})]}):null;return t.jsxs(qe,{title:pe,activePage:"ideas",user:$,formStatus:C,statusBadge:t.jsx("span",{style:w0(Q),children:Q}),buttonText:E.saveIdea,buttonColor:"#16a34a",viewMode:x,onEdit:h,darkMode:g,notifCount:o,onToggleDark:c,onCountChange:y,onViewProfile:z,rightPanel:L,onSubmit:I,onBack:P,onNavigate:Y,onLogout:F,children:[e.custom_is_deleted===1&&t.jsx(Tr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:_?()=>_(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:[E.field.convertedToOrder,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),v&&t.jsxs("button",{type:"button",onClick:()=>v(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:R=>R.currentTarget.style.background="#15803d",onMouseLeave:R=>R.currentTarget.style.background="#16a34a",children:[E.field.viewOrder," →"]})]}),t.jsx(le,{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:T,children:E.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[E.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:R=>D({organization:R}),organizations:s,disabled:x||!!$.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.title}),t.jsx("input",{style:{...A,...H},value:e.title,disabled:x,onChange:R=>D({title:R.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.management}),t.jsx(ue,{value:e.management,onChange:R=>D({management:R}),items:be,placeholder:E.field.select,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.department}),t.jsx(ue,{value:e.department,onChange:R=>D({department:R}),items:ae,placeholder:E.field.select,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.section}),t.jsx("input",{style:{...A,...H},value:e.section_field||"",disabled:x,onChange:R=>D({section_field:R.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.branch}),t.jsx(ue,{value:e.branch,onChange:R=>D({branch:R}),items:Je,placeholder:E.field.select,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.type}),t.jsx(ue,{value:e.type,onChange:R=>D({type:R}),items:it,placeholder:E.field.selectType,disabled:x})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.ideaClass}),t.jsxs("select",{style:{...A,...H},value:e.idea_class||"",disabled:x,onChange:R=>D({idea_class:R.target.value}),children:[t.jsx("option",{value:"",children:E.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:T,children:E.field.hsesField}),t.jsx("input",{style:{...A,...H},value:e.hses_field||"",disabled:x,onChange:R=>D({hses_field:R.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.date}),t.jsx(xe,{value:e.date||"",onChange:R=>D({date:R}),disabled:!0,style:{...A,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.assignedTo}),x||k==="Employee"?t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Ne||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.assigned_to||"",onChange:R=>D({assigned_to:R}),items:G.map(R=>({name:R.name,label:R.full_name||R.name})),placeholder:E.field.select})]})]})}),t.jsx(le,{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:T,children:E.field.currentCondition}),t.jsx("textarea",{style:{...A,...H,height:100,resize:"vertical"},value:e.current_condition,disabled:x,onChange:R=>D({current_condition:R.target.value}),placeholder:"Describe the current condition or problem..."})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.proposedCondition}),t.jsx("textarea",{style:{...A,...H,height:100,resize:"vertical"},value:e.proposed_condition,disabled:x,onChange:R=>D({proposed_condition:R.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!oe&&t.jsxs(le,{title:E.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:T,children:E.field.priority}),t.jsxs("select",{style:{...A,...x||!fe?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:x||!fe,onChange:R=>D({priority:R.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"High",children:E.field.high}),t.jsx("option",{value:"Normal",children:E.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.economyClass}),t.jsxs("select",{style:{...A,...x||!fe?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:x||!fe,onChange:R=>D({economy_class:R.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"Expenses",children:E.field.expenses}),t.jsx("option",{value:"Capital",children:E.field.capital}),t.jsx("option",{value:"Earn",children:E.field.earn}),t.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.entityScope}),t.jsxs("select",{style:{...A,...x||!fe?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:x||!fe,onChange:R=>D({entity_scope:R.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"Upstream",children:E.field.upstream}),t.jsx("option",{value:"On-stream",children:E.field.onstream}),t.jsx("option",{value:"Downstream",children:E.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:x||!fe,onChange:R=>D({product_relation:R.target.checked?1:0})})," ",E.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:x||!fe,onChange:R=>D({repeated:R.target.checked?1:0})})," ",E.field.repeatedEvent]})]})]}),!oe&&t.jsxs(le,{title:E.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:T,children:E.field.solution}),t.jsx("textarea",{style:{...A,height:90,resize:"vertical",...x&&!ye&&!Oe?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:x&&!ye&&!Oe,onChange:R=>D({solution:R.target.value}),placeholder:E.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:T,children:E.field.actualCost}),t.jsx("input",{type:"number",style:{...A,...x&&!ye&&!Oe?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:x&&!ye&&!Oe,onChange:R=>D({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.auditorComment}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical",...x&&!Oe?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:x&&!Oe,onChange:R=>D({auditor_comment:R.target.value}),placeholder:E.field.commentPlaceholder})]})]})]})]})}function _0({orders:e,organizations:n,departments:s,branches:l,orderStatuses:r,initialOrg:a,initialStatus:i,canModify:d,userRole:p,onView:u,onEdit:C,onDelete:x,onSelectionChange:m}){const h=ne(),[b,_]=S.useState(new Set),[v,g]=S.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),o=(f,w)=>g(I=>({...I,[f]:w})),[c,y]=S.useState(1),z=e.filter(f=>!(v.search&&!`${f.number} ${f.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&f.organization!==v.organization||v.department&&f.department!==v.department||v.branch&&f.branch!==v.branch||v.status&&f.status!==v.status));S.useEffect(()=>{y(1)},[v]);const k=z.slice((c-1)*re,c*re);return S.useEffect(()=>{if(m){const f=e.filter(w=>b.has(w.name));m(f,k)}},[b,k,e]),t.jsxs(t.Fragment,{children:[t.jsx(li,{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:Ze,children:h.filter.numberTitle}),t.jsx("input",{style:et,value:v.search,onChange:f=>o("search",f.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.organization}),t.jsxs("select",{style:et,value:v.organization,onChange:f=>o("organization",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(f=>t.jsx("option",{value:f.name,children:f.organization_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.department}),t.jsxs("select",{style:et,value:v.department,onChange:f=>o("department",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(f=>t.jsx("option",{value:f.name,children:f.department_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.branch}),t.jsxs("select",{style:et,value:v.branch,onChange:f=>o("branch",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(f=>t.jsx("option",{value:f.name,children:f.branch||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.status}),t.jsxs("select",{style:et,value:v.status,onChange:f=>o("status",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(f=>t.jsx("option",{value:f.name,children:f.name1||f.name},f.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:k.length>0&&k.every(f=>b.has(f.name)),onChange:f=>{if(f.target.checked)_(new Set([...b,...k.map(w=>w.name)]));else{const w=new Set(b);k.forEach(I=>w.delete(I.name)),_(w)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:z.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noOrders})}):k.map((f,w)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>u==null?void 0:u(f),style:{borderTop:"1px solid #f1f5f9",background:b.has(f.name)?"#eff6ff":f.custom_is_deleted?"#fff1f2":w%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(f.name),onChange:()=>{const I=new Set(b);I.has(f.name)?I.delete(f.name):I.add(f.name),_(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:f.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:f.title||f.name||"—"}),f.sb_idea&&t.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",f.sb_idea]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:f.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.type?Dd(f.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.custom_is_deleted?es(h.deletedBadge):f.status?es(f.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(lt,{onView:()=>u==null?void 0:u(f),onEdit:d&&C&&!f.custom_is_deleted&&!Fn("order",f.workflow_state)&&p!=="Employee"?()=>C(f):void 0,onDelete:d&&x&&!f.custom_is_deleted?()=>x(f.name):void 0})})]},f.name))})]})}),t.jsx(Xe,{page:c,total:z.length,onPageChange:y})]})}const C0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},z0={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 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 T0({orderForm:e,setOrderForm:n,organizations:s,managements:l,departments:r,branches:a,orderTypes:i,orderStatuses:d,cycles:p=[],users:u=[],userRoleMap:C={},formStatus:x,viewMode:m,canModify:h,onEdit:b,onDelete:_,onRestore:v,onNavigateToIdea:g,darkMode:o,notifCount:c,onToggleDark:y,onCountChange:z,onViewProfile:k,currentUser:f,userRole:w,onSubmit:I,onBack:P,onNavigate:Y,onLogout:F,user:$,onRefresh:U}){var hn,Pr;const E=ne(),D=B=>n({...e,...B}),H=m?{background:"#f9f9f9"}:{},G=kl(u,C,"SB Employee",e.organization),[X,J]=S.useState(""),[W,Z]=S.useState(""),[pe,be]=S.useState(!1),[ae,Je]=S.useState("Agree"),it=e.name?m?`${E.formTitle.viewOrder}${e.number||e.title||e.name}`:E.formTitle.editOrder:E.formTitle.newOrder,Q=me(l,e.management).map(B=>({name:B.name,label:B.name1||B.name})),oe=me(r,e.department).map(B=>({name:B.name,label:B.department_name||B.name})),Oe=me(a,e.branch).map(B=>({name:B.name,label:B.branch||B.name})),ye=me(i,e.type).map(B=>({name:B.name,label:B.name1||B.name})),tn=me(p,e.cycle).map(B=>({name:B.name,label:B.name1||B.cycle_name||B.name})),fe=!!e.name,ve=e.workflow_state||"Draft",zt=Math.min(5,(e.stage||0)+1),[Ne,L]=S.useState(zt);S.useEffect(()=>{L(Math.min(5,(e.stage||0)+1))},[e.stage]);const se=w==="Auditor"||w==="Admin"||w==="Manager",R=se||w==="Owner",We=!!(f&&(e.actor===f||e.assigned_to===f)),ut=fe?ve==="Closed"?[]:ve==="Draft"&&se?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:ve==="Pending Actor"&&(We||se)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:ve==="Review"&&R?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:ve==="In Study"&&R?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function M(B){if(e.name){be(!0),J("");try{let It;B==="Update Status"&&(It=ae);const gn=await Wy(e.name,B,W,B==="Update Status"?String(Ne):void 0,void 0,It);if(Z(""),Je("Agree"),J("Done"),gn){const An=gn;n({...e,...An,stage:An.stage??e.stage,completion_pct:An.completion_pct??e.completion_pct,workflow_state:An.workflow_state??e.workflow_state})}U==null||U()}catch(It){J(It.message||"Error")}finally{be(!1)}}}const Be=((hn=G.find(B=>B.name===(e.actor||e.assigned_to)))==null?void 0:hn.full_name)||e.actor||e.assigned_to,ii=fe?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:E.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:ve})]}),ve==="Pending Actor"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:T,children:["Stage (1–5) — ",Ne*20,"% complete"]}),t.jsx("input",{type:"number",min:1,max:5,style:{...A,width:"100%"},value:Ne,onChange:B=>L(Math.min(5,Math.max(1,parseInt(B.target.value)||1)))})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Cycle Status"}),t.jsxs("select",{style:A,value:ae,onChange:B=>Je(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:T,children:["Comment ",ae==="Deviate"&&ve==="Pending Actor"?t.jsx("span",{style:{color:q.red},children:" * required for Deviate"}):"(optional)"]}),t.jsx("textarea",{style:{...A,height:60,resize:"vertical",borderColor:ae==="Deviate"&&!W?"#fca5a5":void 0},value:W,onChange:B=>Z(B.target.value),placeholder:"Add a comment…"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:ut.map(B=>{const It=B.action==="Update Status"&&ae==="Deviate"&&!W.trim();return t.jsx("button",{onClick:()=>M(B.action),disabled:pe||It,title:It?"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:pe||It?"not-allowed":"pointer",opacity:pe||It?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:pe?E.wf.applying:B.label})},B.action)})}),X&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:X==="Done"?q.green:q.red},children:X}),ut.length===0&&t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:E.wf.noActions})]}),t.jsx(si,{priority:e.priority,status:ve,assignedTo:w!=="Employee"?Be:void 0,createdDate:e.starting_date,modifiedDate:e.modified}),t.jsx(ri,{doctype:O.orders,docname:e.name,currentUserName:$.name}),t.jsx(ai,{doctype:O.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),h&&_&&!e.custom_is_deleted&&t.jsx(ni,{title:"Delete Request",btnText:E.delete,onDelete:()=>_(e.name)})]}):null;return t.jsxs(qe,{title:it,activePage:"orders",user:$,formStatus:x,statusBadge:t.jsx("span",{style:I0(ve),children:ve}),buttonText:E.saveOrder,buttonColor:"#16a34a",viewMode:m,onEdit:b,darkMode:o,notifCount:c,onToggleDark:y,onCountChange:z,onViewProfile:k,rightPanel:ii,onSubmit:I,onBack:P,onNavigate:Y,onLogout:F,children:[e.custom_is_deleted===1&&t.jsx(Tr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:v?()=>v(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:[E.field.originatingIdea,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),g&&t.jsxs("button",{type:"button",onClick:()=>g(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:[E.field.viewIdea," →"]})]}),t.jsx(le,{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:T,children:E.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[E.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:B=>D({organization:B}),organizations:s,disabled:m||!!$.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.title}),t.jsx("input",{style:{...A,...H},value:e.title,disabled:m,onChange:B=>D({title:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.management}),t.jsx(ue,{value:e.management,onChange:B=>D({management:B}),items:Q,placeholder:E.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.department}),t.jsx(ue,{value:e.department,onChange:B=>D({department:B}),items:oe,placeholder:E.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.section}),t.jsx("input",{style:{...A,...H},value:e.section_field||"",disabled:m,onChange:B=>D({section_field:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.branch}),t.jsx(ue,{value:e.branch,onChange:B=>D({branch:B}),items:Oe,placeholder:E.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.type}),t.jsx(ue,{value:e.type,onChange:B=>D({type:B}),items:ye,placeholder:E.field.selectType,disabled:m})]})]})}),t.jsxs(le,{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:T,children:E.field.budget}),t.jsx("input",{type:"number",style:{...A,...H},value:e.budget||"",disabled:m,onChange:B=>D({budget:parseFloat(B.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.actualCost}),t.jsx("input",{type:"number",style:{...A,...H},value:e.actual_cost||"",disabled:m,onChange:B=>D({actual_cost:parseFloat(B.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,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:T,children:E.field.currency}),t.jsxs("select",{style:{...A,...H},value:e.currency||"",disabled:m,onChange:B=>D({currency:B.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"}),t.jsx("option",{value:"AED",children:"AED"}),t.jsx("option",{value:"GBP",children:"GBP"})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.startingDate}),t.jsx(xe,{value:e.starting_date,onChange:B=>D({starting_date:B}),disabled:m,style:{...A,...H}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.endingDate}),t.jsx(xe,{value:e.ending_date,onChange:B=>D({ending_date:B}),disabled:m,style:{...A,...H}})]}),w!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.actor}),m?t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Be||"—",readOnly:!0,disabled:!0}):t.jsxs("select",{style:{...A,background:"#ffffff"},value:e.actor||e.assigned_to||"",onChange:B=>D({actor:B.target.value,assigned_to:B.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),G.map(B=>t.jsx("option",{value:B.name,children:B.full_name||B.name},B.name))]})]})]})]}),t.jsxs(le,{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:T,children:E.field.priority}),t.jsxs("select",{style:{...A,...H},value:e.priority||"",disabled:m,onChange:B=>D({priority:B.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"High",children:E.field.high}),t.jsx("option",{value:"Normal",children:E.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.economyClass}),t.jsxs("select",{style:{...A,...H},value:e.economy_class||"",disabled:m,onChange:B=>D({economy_class:B.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"Expenses",children:E.field.expenses}),t.jsx("option",{value:"Capital",children:E.field.capital}),t.jsx("option",{value:"Earn",children:E.field.earn}),t.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.entityScope}),t.jsxs("select",{style:{...A,...H},value:e.entity_scope||"",disabled:m,onChange:B=>D({entity_scope:B.target.value}),children:[t.jsx("option",{value:"",children:E.field.select}),t.jsx("option",{value:"Upstream",children:E.field.upstream}),t.jsx("option",{value:"On-stream",children:E.field.onstream}),t.jsx("option",{value:"Downstream",children:E.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:m,onChange:B=>D({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:m,onChange:B=>D({product_relation:B.target.checked?1:0})})," ",E.field.productRelation]})]}),t.jsxs("div",{style:{marginTop:12},children:[t.jsx("label",{style:T,children:E.field.hsesField}),t.jsx("input",{style:{...A,...H},value:e.hses_field||"",disabled:m,onChange:B=>D({hses_field:B.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),t.jsxs(le,{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:T,children:E.field.cycle}),t.jsx(ue,{value:e.cycle||"",onChange:B=>D({cycle:B}),items:tn,placeholder:E.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.cycleType}),t.jsxs("select",{style:{...A,...H},value:e.cycle_type||"Normal",disabled:m,onChange:B=>D({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:T,children:E.field.stage}),t.jsx("input",{type:"number",min:1,max:5,style:{...A,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Completion"}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,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:C0[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:T,children:"Milestone 1"}),t.jsx(xe,{value:e.long_cycle_date_1||"",onChange:B=>D({long_cycle_date_1:B}),disabled:m,style:{...A,...H}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Milestone 2"}),t.jsx(xe,{value:e.long_cycle_date_2||"",onChange:B=>D({long_cycle_date_2:B}),disabled:m,style:{...A,...H}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Milestone 3"}),t.jsx(xe,{value:e.long_cycle_date_3||"",onChange:B=>D({long_cycle_date_3:B}),disabled:m,style:{...A,...H}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Milestone 4"}),t.jsx(xe,{value:e.long_cycle_date_4||"",onChange:B=>D({long_cycle_date_4:B}),disabled:m,style:{...A,...H}})]})]})]}),fe&&((Pr=e.order_cycle_log)==null?void 0:Pr.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,It)=>{const gn=B.status==="Agree"?"#166534":B.status==="Deviate"?"#c2410c":"#92400e",An=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:An,color:gn,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||"—"})]},It)})})]})})]})]}),t.jsxs(le,{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:T,children:E.field.description}),t.jsx("textarea",{style:{...A,...H,height:90,resize:"vertical"},value:e.description,disabled:m,onChange:B=>D({description:B.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.notes}),t.jsx("textarea",{style:{...A,...H,height:90,resize:"vertical"},value:e.notes,disabled:m,onChange:B=>D({notes:B.target.value})})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:E.field.auditorComment}),t.jsx("textarea",{style:{...A,height:70,resize:"vertical",...m&&We&&!se?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:m&&We&&!se,onChange:B=>D({auditor_comment:B.target.value}),placeholder:E.field.commentPlaceholder})]})]})]})}function E0({processes:e,organizations:n,departments:s,branches:l,processStatuses:r,initialOrg:a,initialStatus:i,canModify:d,userRole:p,onView:u,onEdit:C,onDelete:x,onSelectionChange:m}){const h=ne(),[b,_]=S.useState(new Set),[v,g]=S.useState({search:"",organization:a||"",department:"",branch:"",status:i||""}),o=(f,w)=>g(I=>({...I,[f]:w})),[c,y]=S.useState(1),z=e.filter(f=>!(v.search&&!`${f.number} ${f.title}`.toLowerCase().includes(v.search.toLowerCase())||v.organization&&f.organization!==v.organization||v.department&&f.department!==v.department||v.branch&&f.branch!==v.branch||v.status&&f.status!==v.status));S.useEffect(()=>{y(1)},[v]);const k=z.slice((c-1)*re,c*re);return S.useEffect(()=>{if(m){const f=e.filter(w=>b.has(w.name));m(f,k)}},[b,k,e]),t.jsxs(t.Fragment,{children:[t.jsx(li,{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:Ze,children:h.filter.numberTitle}),t.jsx("input",{style:et,value:v.search,onChange:f=>o("search",f.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.organization}),t.jsxs("select",{style:et,value:v.organization,onChange:f=>o("organization",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(f=>t.jsx("option",{value:f.name,children:f.organization_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.department}),t.jsxs("select",{style:et,value:v.department,onChange:f=>o("department",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(f=>t.jsx("option",{value:f.name,children:f.department_name||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.branch}),t.jsxs("select",{style:et,value:v.branch,onChange:f=>o("branch",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(f=>t.jsx("option",{value:f.name,children:f.branch||f.name},f.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ze,children:h.filter.status}),t.jsxs("select",{style:et,value:v.status,onChange:f=>o("status",f.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(f=>t.jsx("option",{value:f.name,children:f.name1||f.name},f.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:k.length>0&&k.every(f=>b.has(f.name)),onChange:f=>{if(f.target.checked)_(new Set([...b,...k.map(w=>w.name)]));else{const w=new Set(b);k.forEach(I=>w.delete(I.name)),_(w)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.field.cycleType}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:z.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noProcesses})}):k.map((f,w)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>u==null?void 0:u(f),style:{borderTop:"1px solid #f1f5f9",background:b.has(f.name)?"#eff6ff":f.custom_is_deleted?"#fff1f2":w%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:I=>I.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(f.name),onChange:()=>{const I=new Set(b);I.has(f.name)?I.delete(f.name):I.add(f.name),_(I)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:f.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:f.title||f.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:f.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.cycle_type?Dd(f.cycle_type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:f.custom_is_deleted?es(h.deletedBadge):f.status?es(f.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:I=>I.stopPropagation(),children:t.jsx(lt,{onView:()=>u==null?void 0:u(f),onEdit:d&&C&&!f.custom_is_deleted&&!Fn("process",f.workflow_state)&&p!=="Employee"?()=>C(f):void 0,onDelete:d&&x&&!f.custom_is_deleted?()=>x(f.name):void 0})})]},f.name))})]})}),t.jsx(Xe,{page:c,total:z.length,onPageChange:y})]})}const P0={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"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},A0={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"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function Iu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...A0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Zr={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function R0({processName:e,userRole:n,onRefresh:s,canUpdateStatus:l=!0}){const[r,a]=S.useState(null),[i,d]=S.useState(!0),[p,u]=S.useState(""),[C,x]=S.useState(!1),[m,h]=S.useState(""),[b,_]=S.useState(""),[v,g]=S.useState("Pass"),[o,c]=S.useState(""),[y,z]=S.useState({}),k=S.useCallback(async()=>{if(!e){d(!1);return}d(!0),u("");try{const $=await Xl(e);a($);const U={};for(const E of $.progress_indicators||[])U[E.name]=E.actual_value!=null?String(E.actual_value):"";z(U)}catch($){u($ instanceof Error?$.message:"Failed to load process")}d(!1)},[e]);if(S.useEffect(()=>{k()},[k]),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(p||!r)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:p||"Could not load workflow"})})});const f=r.workflow_state||"Draft",w=P0[f]??[],I=n==="Employee"||n==="Manager",P=n!=="Manager"||l,Y=w.filter($=>(n==="Admin"||$.allowedRoles.includes(n))&&($.action!=="Update Status"||P)),F=async $=>{x(!0),h(""),_("");try{const U={};if($==="Update Status"){U.actor_status=v,U.actor_comment=o;const D=r.progress_indicators||[];D.length>0&&(U.progress_indicators=D.map(H=>({name:H.name,actual_value:y[H.name]??""})))}$==="Add Comment"&&o&&(U.actor_comment=o);const E=await Zy(r.name,$,U);a(E),c(""),_(`Done — now: ${E.workflow_state||"updated"}`),s==null||s()}catch(U){h(U instanceof Error?U.message:"Action failed")}x(!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:Iu(f),children:f})]}),f==="Pending Actor"&&I&&P&&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(r.progress_indicators)&&r.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:r.progress_indicators.map($=>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:$.name1,children:$.name1||$.name}),t.jsx("input",{type:"number",value:y[$.name]??"",onChange:U=>z(E=>({...E,[$.name]:U.target.value})),style:{...Zr,width:70,flexShrink:0},placeholder:"0"})]},$.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:v,onChange:$=>g($.target.value),style:Zr,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:$=>c($.target.value),style:{...Zr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(f==="Pending Comment"||f==="Review")&&!I&&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(r.cycle_logs)&&r.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 $=r.cycle_logs,U=$[$.length-1],E=U.status==="Pass"?"#16a34a":U.status==="Fail"?"#dc2626":"#9ca3af";return t.jsxs("div",{style:{fontSize:13,fontWeight:700,color:E},children:[U.status," ",U.comment?`— ${U.comment}`:""]})})()]}),t.jsx("textarea",{value:o,onChange:$=>c($.target.value),style:{...Zr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:Y.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"}),Y.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:f}),"."]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Y.map($=>t.jsxs("button",{onClick:()=>F($.action),disabled:C,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:$.action==="Close Process"?"#64748b":$.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…":$.action}),t.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",$.next]})]},$.action))}),m&&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:m}),b&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:b})]}),w.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"}),w.map($=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[t.jsx("span",{style:{color:"#555",flex:1},children:$.action}),t.jsx("span",{style:{color:"#bbb"},children:"→"}),t.jsx("span",{style:Iu($.next),children:$.next})]},$.action))]})]})})}function D0({processForm:e,setProcessForm:n,organizations:s,managements:l,departments:r,branches:a,processTypes:i,processStatuses:d,cycles:p=[],users:u=[],userRoleMap:C={},formStatus:x,viewMode:m,canModify:h,onEdit:b,onDelete:_,onRestore:v,darkMode:g,notifCount:o,onToggleDark:c,onCountChange:y,onViewProfile:z,userRole:k,onRefreshProcess:f,onSubmit:w,onBack:I,onNavigate:P,onLogout:Y,user:F}){var Ne;const $=ne(),U=L=>n({...e,...L}),E=m?{background:"#f9f9f9"}:{},D=s,H=!!F.custom_organization,G=me(l,e.management).map(L=>({name:L.name,label:L.name1||L.name})),X=me(r,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),J=me(a,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),W=me(i,e.type).map(L=>({name:L.name,label:L.name1||L.name})),Z=me(p,e.cycle).map(L=>({name:L.name,label:L.name1||L.name})),pe=kl(u,C,"SB Employee",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),be=kl(u,C,"SB Manager",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),ae=(L,se)=>{const R=[...e.cycle_logs||[]];R[L]={...R[L],...se},U({cycle_logs:R})},Je=()=>{U({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},it=L=>{const se=[...e.cycle_logs||[]];se.splice(L,1),U({cycle_logs:se})},Q=(L,se)=>{const R=[...e.progress_indicators||[]];R[L]={...R[L],...se},U({progress_indicators:R})},oe=()=>{U({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"}]})},Oe=L=>{const se=[...e.progress_indicators||[]];se.splice(L,1),U({progress_indicators:se})},ye=e.name?m?`${$.formTitle.viewProcess}${e.title||e.name}`:$.formTitle.editProcess:$.formTitle.newProcess,tn=k!=="Manager"||e.actor===F.name,fe=((Ne=pe.find(L=>L.name===e.actor))==null?void 0:Ne.label)||e.actor,ve=e.workflow_state||"Draft",zt=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsx(R0,{processName:e.name,userRole:k||F.role||"Employee",onRefresh:f,canUpdateStatus:tn}),t.jsx(si,{priority:e.impact_level,status:ve,assignedTo:fe,createdDate:e.date_start,modifiedDate:e.modified}),t.jsx(ri,{doctype:O.processes,docname:e.name,currentUserName:F.name}),t.jsx(ai,{doctype:O.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),h&&_&&!e.custom_is_deleted&&t.jsx(ni,{title:"Delete Request",btnText:$.delete,onDelete:()=>_(e.name)})]}):void 0;return t.jsxs(qe,{title:ye,activePage:"processes",user:F,formStatus:x,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:ve}),buttonText:$.saveProcess,buttonColor:"#16a34a",viewMode:m,onEdit:b,darkMode:g,notifCount:o,onToggleDark:c,onCountChange:y,onViewProfile:z,rightPanel:zt,onSubmit:w,onBack:I,onNavigate:P,onLogout:Y,children:[e.custom_is_deleted===1&&t.jsx(Tr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:v?()=>v(e.name):void 0}),t.jsx(le,{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:T,children:$.field.number}),t.jsx("input",{style:{...A,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[$.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:L=>U({organization:L}),organizations:D,disabled:m||H})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.title}),t.jsx("input",{style:{...A,...E},value:e.title,disabled:m,onChange:L=>U({title:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.type}),t.jsx(ue,{value:e.type,onChange:L=>U({type:L}),items:W,placeholder:$.field.selectType,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.management}),t.jsx(ue,{value:e.management,onChange:L=>U({management:L}),items:G,placeholder:$.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.department}),t.jsx(ue,{value:e.department,onChange:L=>U({department:L}),items:X,placeholder:$.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.section}),t.jsx("input",{style:{...A,...E},value:e.section_field||"",disabled:m,onChange:L=>U({section_field:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.branch}),t.jsx(ue,{value:e.branch,onChange:L=>U({branch:L}),items:J,placeholder:$.field.select,disabled:m})]})]})}),t.jsxs(le,{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:T,children:$.field.chainLocation}),t.jsxs("select",{style:{...A,...E},value:e.chain_location||"",disabled:m,onChange:L=>U({chain_location:L.target.value}),children:[t.jsx("option",{value:"",children:$.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:T,children:$.field.economyClass}),t.jsxs("select",{style:{...A,...E},value:e.economy_class||"",disabled:m,onChange:L=>U({economy_class:L.target.value}),children:[t.jsx("option",{value:"",children:$.field.select}),t.jsx("option",{value:"Expenses",children:$.field.expenses}),t.jsx("option",{value:"Capital",children:$.field.capital}),t.jsx("option",{value:"Earn",children:$.field.earn}),t.jsx("option",{value:"Pay/Loss",children:$.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.impactLevel}),t.jsxs("select",{style:{...A,...E},value:e.impact_level||"",disabled:m,onChange:L=>U({impact_level:L.target.value}),children:[t.jsx("option",{value:"",children:$.field.select}),t.jsx("option",{value:"High",children:$.field.high}),t.jsx("option",{value:"Normal",children:$.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.entityScope}),t.jsxs("select",{style:{...A,...E},value:e.entity_scope||"",disabled:m,onChange:L=>U({entity_scope:L.target.value}),children:[t.jsx("option",{value:"",children:$.field.select}),t.jsx("option",{value:"Upstream",children:$.field.upstream}),t.jsx("option",{value:"On-stream",children:$.field.onstream}),t.jsx("option",{value:"Downstream",children:$.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:T,children:$.field.hsesField}),t.jsx("input",{style:{...A,...E},value:e.hses_field||"",disabled:m,onChange:L=>U({hses_field:L.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:m,onChange:L=>U({product_relation:L.target.checked?1:0})})," ",$.field.productRelation]})})]})]}),t.jsxs(le,{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:T,children:$.field.kpiName}),t.jsx("input",{style:{...A,...E},value:e.kpi_name||"",disabled:m,onChange:L=>U({kpi_name:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.kpiType}),t.jsxs("select",{style:{...A,...E},value:e.kpi_type||"",disabled:m,onChange:L=>U({kpi_type:L.target.value}),children:[t.jsx("option",{value:"",children:$.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:T,children:$.field.kpiMeasure}),t.jsx("input",{style:{...A,...E},value:e.kpi_measure||"",disabled:m,onChange:L=>U({kpi_measure:L.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:T,children:$.field.dateStart}),t.jsx(xe,{value:e.date_start,onChange:L=>U({date_start:L}),disabled:m,style:{...A,...E}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.dateEnd}),t.jsx(xe,{value:e.date_end,onChange:L=>U({date_end:L}),disabled:m,style:{...A,...E}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.cycleType}),t.jsxs("select",{style:{...A,...E},value:e.cycle_type||"",disabled:m,onChange:L=>U({cycle_type:L.target.value}),children:[t.jsx("option",{value:"",children:$.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:T,children:"Milestone 1"}),t.jsx(xe,{value:e.long_cycle_date_1||"",onChange:L=>U({long_cycle_date_1:L}),disabled:m,style:{...A,...E}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Milestone 2"}),t.jsx(xe,{value:e.long_cycle_date_2||"",onChange:L=>U({long_cycle_date_2:L}),disabled:m,style:{...A,...E}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Milestone 3"}),t.jsx(xe,{value:e.long_cycle_date_3||"",onChange:L=>U({long_cycle_date_3:L}),disabled:m,style:{...A,...E}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Milestone 4"}),t.jsx(xe,{value:e.long_cycle_date_4||"",onChange:L=>U({long_cycle_date_4:L}),disabled:m,style:{...A,...E}})]})]})]})]}),t.jsxs(le,{title:"Progress Indicators",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!m&&t.jsx("button",{type:"button",onClick:oe,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"}),!m&&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:m?14:15,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((L,se)=>t.jsxs("tr",{style:{background:se%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E,width:60},value:L.order??"",disabled:m,onChange:R=>Q(se,{order:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E},value:L.name1,disabled:m,onChange:R=>Q(se,{name1:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E},value:L.type,disabled:m,onChange:R=>Q(se,{type:R.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:{...A,...E,width:70},type:"text",value:L.unit??"",disabled:m,onChange:R=>Q(se,{unit:R.target.value}),placeholder:"e.g. °C, kg, %"})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E,minWidth:120},value:L.cycle,disabled:m,onChange:R=>Q(se,{cycle:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),Z.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name)),L.cycle&&!Z.some(R=>R.name===L.cycle)&&t.jsx("option",{value:L.cycle,children:L.cycle})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E,width:80},value:L.target,disabled:m,onChange:R=>Q(se,{target:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E,width:80},value:L.minimum,disabled:m,onChange:R=>Q(se,{minimum:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E,width:80},value:L.maximum,disabled:m,onChange:R=>Q(se,{maximum:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E,minWidth:140},value:L.manager,disabled:m,onChange:R=>Q(se,{manager:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),be.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name)),L.manager&&!be.some(R=>R.name===L.manager)&&t.jsx("option",{value:L.manager,children:L.manager})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E,width:90},type:"number",value:L.actual_value??"",disabled:m,onChange:R=>Q(se,{actual_value:parseFloat(R.target.value)||""})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E},value:L.cycle_status??"",disabled:m,onChange:R=>Q(se,{cycle_status:R.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(xe,{value:L.cycle_date||"",onChange:R=>Q(se,{cycle_date:R}),disabled:m,style:{...A,...E,width:110}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E},value:L.cycle_comment??"",disabled:m,onChange:R=>Q(se,{cycle_comment:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E},value:L.status??"",disabled:m,onChange:R=>Q(se,{status:R.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"})]})}),!m&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>Oe(se),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},se))]})]})})]}),t.jsx(le,{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:T,children:$.field.cycle}),t.jsx(ue,{value:e.cycle||"",onChange:L=>U({cycle:L}),items:Z,placeholder:$.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.actor}),t.jsxs("select",{style:{...A,...E},value:e.actor||"",disabled:m,onChange:L=>U({actor:L.target.value}),children:[t.jsx("option",{value:"",children:$.field.select}),pe.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.costPerCycle}),t.jsx("input",{style:{...A,...E},type:"number",value:e.cost_per_cycle||"",disabled:m,onChange:L=>U({cost_per_cycle:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:$.field.escalationLevel}),t.jsx("input",{style:{...A,...E},type:"number",value:e.escalation_level||"",disabled:m,onChange:L=>U({escalation_level:parseInt(L.target.value)||0})})]})]})}),t.jsxs(le,{title:"Cycle History",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!m&&t.jsx("button",{type:"button",onClick:Je,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"}),!m&&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:m?5:6,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((L,se)=>t.jsxs("tr",{style:{background:se%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E},value:L.cycle||"",disabled:m,onChange:R=>ae(se,{cycle:R.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),Z.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(xe,{value:L.cycle_date||"",onChange:R=>ae(se,{cycle_date:R}),disabled:m,style:{...A,...E,width:130}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...A,...E},value:L.status,disabled:m,onChange:R=>ae(se,{status:R.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:{...A,...E},value:L.actor||"",disabled:m,onChange:R=>ae(se,{actor:R.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),pe.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...A,...E},value:L.comment||"",disabled:m,onChange:R=>ae(se,{comment:R.target.value})})}),!m&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>it(se),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},se))]})]})})]}),t.jsx(le,{title:$.field.auditorComment,children:t.jsx("textarea",{style:{...A,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:$.field.commentPlaceholder})})]})}const L0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function O0({user:e,profileUser:n,darkMode:s,canModify:l,onBack:r,organizations:a=[],managements:i=[],departments:d=[],branches:p=[]}){const u=n||{},C=!!l&&e.role==="Admin",[x,m]=S.useState({first_name:u.first_name||"",middle_name:u.middle_name||"",last_name:u.last_name||"",mobile_no:u.mobile_no||"",custom_organization:u.custom_organization||"",custom_management:u.custom_management||"",custom_department:u.custom_department||"",custom_branch:u.custom_branch||"",custom_number:u.custom_number||"",custom_category:u.custom_category||""}),[h,b]=S.useState(""),[_,v]=S.useState(!1),[g,o]=S.useState({new:"",confirm:""}),[c,y]=S.useState(""),z=u.email||u.name||"",k=[x.first_name,x.middle_name,x.last_name].filter(Boolean).join(" ")||u.full_name||"",f=u.username||u.name||"",w=x.custom_category||"",I=u.enabled===0?"Inactive":"Active",P=L0[e.role]||"#6b7280",Y=s,F=Y?"#0f172a":"#f0f2f5",$=Y?"#1e293b":"white",U=Y?"#2d3748":"#e5e7eb",E=Y?"#e2e8f0":"#1a2332",D=Y?"#94a3b8":"#6b7280",H=Y?"#374151":"white",G=Y?"#2d3748":"#f9fafb",X={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${U}`,fontSize:13,background:H,color:E,fontFamily:"inherit",outline:"none"},J={...X,background:G,color:D},W={...X,cursor:"pointer"},Z={fontSize:12,fontWeight:600,color:D,marginBottom:5,display:"block"},pe={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},be={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},ae=async()=>{if(l){b("saving");try{await Ba("User",u.name,{first_name:x.first_name,middle_name:x.middle_name,last_name:x.last_name,mobile_no:x.mobile_no,custom_organization:x.custom_organization,custom_management:x.custom_management,custom_department:x.custom_department,custom_branch:x.custom_branch,custom_number:x.custom_number,custom_category:x.custom_category}),b("saved"),setTimeout(()=>b(""),2e3)}catch{b("error"),setTimeout(()=>b(""),3e3)}}},Je=async()=>{if(!g.new){y("Enter a new password");return}if(g.new!==g.confirm){y("Passwords do not match");return}y("saving");try{await nh(u.name,g.new),y("done"),o({new:"",confirm:""}),setTimeout(()=>{y(""),v(!1)},2e3)}catch{y("error")}},it=({title:Q,icon:oe,children:Oe})=>t.jsxs("div",{style:{background:$,borderRadius:12,padding:22,border:`1px solid ${U}`,boxShadow:`0 1px 4px rgba(0,0,0,${Y?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${U}`},children:[oe,t.jsx("span",{style:{fontSize:14,fontWeight:700,color:E},children:Q})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:Oe})]});return t.jsxs("div",{style:{background:F,minHeight:"100%",padding:"0 0 32px"},children:[t.jsxs("div",{style:{background:$,borderBottom:`1px solid ${U}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[t.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:E,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"]}),l&&t.jsxs("button",{onClick:ae,style:{display:"flex",alignItems:"center",gap:8,background:h==="saved"?"#16a34a":h==="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"})]}),h==="saving"?"Saving…":h==="saved"?"Saved!":h==="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:k||z}),t.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:z})]}),t.jsx("div",{style:{background:$},children:[{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,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:f},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,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:w||"—"},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:I==="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:I,valueColor:I==="Active"?"#16a34a":"#dc2626"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,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:z},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:P,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:x.mobile_no||"—"}].map(({icon:Q,label:oe,value:Oe,valueColor:ye})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${U}`},children:[t.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:Q}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:11,color:D,marginBottom:1},children:oe}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:ye||E,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Oe})]})]},oe))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[t.jsxs(it,{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:pe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,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:{...J,paddingLeft:32},value:z,readOnly:!0})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Full Name ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),t.jsx("input",{style:J,value:k,readOnly:!0})]})]}),t.jsxs("div",{style:be,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["First Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{style:l?X:J,value:x.first_name,readOnly:!l,onChange:Q=>m(oe=>({...oe,first_name:Q.target.value})),placeholder:"First name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Middle Name"}),t.jsx("input",{style:l?X:J,value:x.middle_name,readOnly:!l,onChange:Q=>m(oe=>({...oe,middle_name:Q.target.value})),placeholder:"Middle name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Last Name"}),t.jsx("input",{style:l?X:J,value:x.last_name,readOnly:!l,onChange:Q=>m(oe=>({...oe,last_name:Q.target.value})),placeholder:"Last name"})]})]}),t.jsxs("div",{style:pe,children:[t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Phone Number"}),t.jsx("input",{style:l?X:J,value:x.mobile_no,readOnly:!l,onChange:Q=>m(oe=>({...oe,mobile_no:Q.target.value})),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"User ID No"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{style:{...J,paddingRight:44},value:x.custom_number||u.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",{children:[t.jsxs("label",{style:Z,children:["Category ",!C&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),C?t.jsxs("select",{style:W,value:x.custom_category,onChange:Q=>m(oe=>({...oe,custom_category:Q.target.value})),children:[t.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(Q=>t.jsx("option",{value:Q,children:Q},Q))]}):t.jsx("input",{style:J,value:w||"—",readOnly:!0})]})]}),t.jsxs(it,{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:pe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Organization ",!C&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),C?t.jsxs("select",{style:W,value:x.custom_organization,onChange:Q=>m(oe=>({...oe,custom_organization:Q.target.value})),children:[t.jsx("option",{value:"",children:"Select organization"}),me(a,x.custom_organization).map(Q=>t.jsx("option",{value:Q.name,children:Q.organization_name||Q.name},Q.name))]}):t.jsx("input",{style:J,value:x.custom_organization||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Management ",!C&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),C?t.jsxs("select",{style:W,value:x.custom_management,onChange:Q=>m(oe=>({...oe,custom_management:Q.target.value})),children:[t.jsx("option",{value:"",children:"Select management"}),me(i,x.custom_management).map(Q=>t.jsx("option",{value:Q.name,children:Q.name1||Q.name},Q.name))]}):t.jsx("input",{style:J,value:x.custom_management||"—",readOnly:!0})]})]}),t.jsxs("div",{style:pe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Department ",!C&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),C?t.jsxs("select",{style:W,value:x.custom_department,onChange:Q=>m(oe=>({...oe,custom_department:Q.target.value})),children:[t.jsx("option",{value:"",children:"Select department"}),me(d,x.custom_department).map(Q=>t.jsx("option",{value:Q.name,children:Q.department_name||Q.name},Q.name))]}):t.jsx("input",{style:J,value:x.custom_department||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Branch ",!C&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),C?t.jsxs("select",{style:W,value:x.custom_branch,onChange:Q=>m(oe=>({...oe,custom_branch:Q.target.value})),children:[t.jsx("option",{value:"",children:"Select branch"}),me(p,x.custom_branch).map(Q=>t.jsx("option",{value:Q.name,children:Q.branch||Q.name},Q.name))]}):t.jsx("input",{style:J,value:x.custom_branch||"—",readOnly:!0})]})]})]}),t.jsxs("div",{style:{background:$,borderRadius:12,padding:22,border:`1px solid ${U}`,boxShadow:`0 1px 4px rgba(0,0,0,${Y?.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:E},children:"Change Password"})]}),l&&t.jsx("button",{onClick:()=>{v(Q=>!Q),y("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:_?"Cancel":"Change Password"})]}),_&&t.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:be,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["New Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:X,value:g.new,onChange:Q=>o(oe=>({...oe,new:Q.target.value})),placeholder:"New password"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Confirm Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:X,value:g.confirm,onChange:Q=>o(oe=>({...oe,confirm:Q.target.value})),placeholder:"Confirm password"})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:Je,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:c==="saving"?"Saving…":"Update Password"})})]}),c&&c!=="saving"&&t.jsx("div",{style:{fontSize:13,color:c==="done"?"#16a34a":"#dc2626",fontWeight:500},children:c==="done"?"Password updated successfully":c==="error"?"Failed to update password":c})]})]})]})]})]})}function Ie({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 rh={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},N0={...rh,cursor:"pointer"};function mt({filters:e,defaultOpen:n=!1}){const[s,l]=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:()=>l(r=>!r),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((r,a)=>t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:r.label}),r.type==="search"?t.jsx("input",{style:rh,placeholder:r.placeholder,value:r.value,onChange:i=>r.onChange(i.target.value)}):t.jsx("select",{style:N0,value:r.value,onChange:i=>r.onChange(i.target.value),children:r.options.map(i=>t.jsx("option",{value:i.value,children:i.label},i.value))})]},a))})})]})}function W0(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 B0({organizations:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),[h,b]=S.useState("all"),_={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=S.useMemo(()=>e.filter(y=>{const z=[y.organization_name,y.city].filter(Boolean).join(" ").toLowerCase();return!(u&&!z.includes(u.toLowerCase())||x!=="all"&&y.type!==x||h!=="all"&&(y.is_active?"Active":"Inactive")!==h)}),[e,u,x,h]),[g,o]=S.useState(1);S.useEffect(()=>{o(1)},[u,x,h]);const c=v.slice((g-1)*re,g*re);return S.useEffect(()=>{if(a){const y=e.filter(z=>d.has(z.name));a(y,c)}},[d,c]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:v.length,color:"#1a2332"}),t.jsx(Ie,{label:"Active",val:v.filter(y=>y.is_active).length,color:q.green}),t.jsx(Ie,{label:"Government",val:v.filter(y=>y.type==="Government").length,color:q.blue}),t.jsx(Ie,{label:"Private",val:v.filter(y=>y.type==="Private").length,color:q.orange})]}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:x,onChange:m,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:h,onChange:b,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:c.length>0&&c.every(y=>d.has(y.name)),onChange:y=>{if(y.target.checked)p(new Set([...d,...c.map(z=>z.name)]));else{const z=new Set(d);c.forEach(k=>z.delete(k.name)),p(z)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:_,children:i.col.name}),t.jsx("th",{style:_,children:i.col.type}),t.jsx("th",{style:_,children:i.col.city}),t.jsx("th",{style:_,children:i.field.creationDate}),t.jsx("th",{style:_,children:i.col.status}),t.jsx("th",{style:_,children:i.col.actions})]})}),t.jsx("tbody",{children:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):c.map((y,z)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(y),style:{borderTop:"1px solid #f0f0f0",background:d.has(y.name)?"#eff6ff":z%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:k=>k.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(y.name),onChange:()=>{const k=new Set(d);k.has(y.name)?k.delete(y.name):k.add(y.name),p(k)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:y.organization_name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:y.type||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:y.city||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:W0(y.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:Sr(y.is_active?i.field.statusActive:i.field.statusInactive,y.is_active?q.green:q.gray)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:k=>k.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(y),onEdit:n&&l?()=>l(y):void 0,onDelete:n&&r?()=>r(y.name):void 0})})]},y.name))})]})}),t.jsx(Xe,{page:g,total:v.length,onPageChange:o})]})}const jn=e=>({background:e?"#f9f9f9":void 0});function $0({orgForm:e,setOrgForm:n,groupCompanies:s=[],formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,user:_}){const v=ne(),g=e.name?r&&e.organization_name||v.formTitle.editOrg:v.formTitle.newOrg,o=s.map(c=>({name:c.name,label:c.company_name?`${c.company_name} (${c.name})`:c.name}));return t.jsxs(qe,{title:g,activePage:"organizations",user:_,formStatus:l,buttonText:v.saveOrg,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,children:[t.jsx(le,{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:T,children:[v.field.orgName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...A,...jn(r||!!e.name)},value:e.organization_name,disabled:r||!!e.name,required:!0,onChange:c=>n({...e,organization_name:c.target.value})})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[v.field.orgAcronym," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...A,...jn(r||!!e.name)},value:e.acronym||"",disabled:r||!!e.name,required:!0,onChange:c=>n({...e,acronym:c.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Group Company (Tenant)"}),t.jsx(ue,{value:e.group_company||"",onChange:c=>n({...e,group_company:c}),items:o,placeholder:"Select Group Company",disabled:r||!!_.custom_group_company})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.organizationType}),t.jsxs("select",{style:{...A,...jn(r)},value:e.type,disabled:r,onChange:c=>n({...e,type:c.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:T,children:v.field.orgCity}),t.jsx("input",{type:"text",style:{...A,...jn(r)},value:e.city,disabled:r,onChange:c=>n({...e,city:c.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.contactEmail}),t.jsx("input",{type:"email",style:{...A,...jn(r)},value:e.contact_email,disabled:r,onChange:c=>n({...e,contact_email:c.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>n({...e,creation_date:c}),disabled:r,style:{...A,...jn(r)}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.status}),t.jsxs("select",{style:{...A,...jn(r)},value:e.is_active?"Active":"Inactive",disabled:r,onChange:c=>n({...e,is_active:c.target.value==="Active"?1:0}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})}),t.jsx(le,{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:T,children:v.field.incidentTriageWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...A,...jn(r)},value:e.incident_triage_window_days??3,disabled:r,onChange:c=>n({...e,incident_triage_window_days:parseInt(c.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:T,children:v.field.incidentResolutionWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...A,...jn(r)},value:e.incident_resolution_window_days??5,disabled:r,onChange:c=>n({...e,incident_resolution_window_days:parseInt(c.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 U0({groupCompanies:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=[o.company_name,o.acronym,o.code,o.owner_user].filter(Boolean).join(" ").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total Group Cos",val:b.length,color:"#1a2332"}),t.jsx(Ie,{label:"Active",val:b.filter(o=>(o.status||"Active")==="Active").length,color:q.green}),t.jsx(Ie,{label:"Inactive",val:b.filter(o=>o.status==="Inactive").length,color:q.orange})]}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:"Company Name"}),t.jsx("th",{style:h,children:"Code / Acronym"}),t.jsx("th",{style:h,children:"Group Co Owner"}),t.jsx("th",{style:h,children:"Status"}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsxs("tbody",{children:[g.map((o,c)=>{const y=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":y?"#fef2f2":c%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:z=>z.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const z=new Set(d);z.has(o.name)?z.delete(o.name):z.add(o.name),p(z)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[o.company_name,y&&t.jsx("span",{style:{marginLeft:8},children:Sr(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:Sr(o.status||"Active",(o.status||"Active")==="Active"?q.green:q.orange)}),t.jsx("td",{style:{padding:"12px 14px"},onClick:z=>z.stopPropagation(),children:t.jsx(lt,{onView:s?()=>s(o):void 0,onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name)}),b.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(Xe,{page:_,total:b.length,onPageChange:v})]})}function F0({form:e,setForm:n,users:s=[],formStatus:l,viewMode:r,onEdit:a,onRestore:i,darkMode:d,notifCount:p,onToggleDark:u,onCountChange:C,onViewProfile:x,onSubmit:m,onBack:h,onNavigate:b,onLogout:_,user:v}){const g=z=>n({...e,...z}),o=r?{background:"#f8fafc"}:{},c=e.name?r?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",y=s.map(z=>({name:z.name,label:z.full_name?`${z.full_name} (${z.name})`:z.name}));return t.jsxs(qe,{title:c,activePage:"group-companies",user:v,formStatus:l,buttonText:"Save Group Company",buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:d,notifCount:p,onToggleDark:u,onCountChange:C,onViewProfile:x,onSubmit:m,onBack:h,onNavigate:b,onLogout:_,children:[e.custom_is_deleted===1&&t.jsx(Tr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i?()=>i(e.name):void 0}),t.jsxs(le,{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:T,children:["Company Name ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.company_name||"",disabled:r||!!e.name,onChange:z=>g({company_name:z.target.value}),placeholder:"e.g. Company A Group"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Company Code"}),t.jsx("input",{style:{...A,...o},value:e.code||"",disabled:r,onChange:z=>g({code:z.target.value}),placeholder:"e.g. CO-A"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Acronym"}),t.jsx("input",{style:{...A,...o},value:e.acronym||"",disabled:r,onChange:z=>g({acronym:z.target.value}),placeholder:"e.g. CAG"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Status"}),t.jsxs("select",{style:{...A,...o},value:e.status||"Active",disabled:r,onChange:z=>g({status:z.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:T,children:"Group Co Owner / Admin User"}),t.jsx(ue,{value:e.owner_user||"",onChange:z=>g({owner_user:z}),items:y,placeholder:"Select owner user",disabled:r})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:"Notes"}),t.jsx("textarea",{style:{...A,...o,height:75,resize:"vertical"},value:e.notes||"",disabled:r,onChange:z=>g({notes:z.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function M0(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({managements:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.blue})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:M0(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function G0({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,user:_}){const v=ne(),g=y=>n(z=>({...z,...y})),o=r?{background:"#f8fafc"}:{},c=e.name?r?`${v.formTitle.editMgmt}: ${e.name1||e.name}`:v.formTitle.editMgmt:v.formTitle.newMgmt;return t.jsx(qe,{title:c,activePage:"managements",user:_,formStatus:l,buttonText:v.saveMgmt,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,children:t.jsx(le,{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:T,children:[v.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:y=>g({organization:y}),organizations:s,disabled:r||!!_.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.name1,disabled:r||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"Management name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:y=>g({creation_date:y}),disabled:r,style:{...A,...o}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.status}),t.jsxs("select",{style:{...A,...o},value:e.status||"Active",disabled:r,onChange:y=>g({status:y.target.value}),children:[t.jsx("option",{value:"Active",children:v.field.statusActive}),t.jsx("option",{value:"Inactive",children:v.field.statusInactive})]})]})]})})})}function K0(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 Q0({departments:e,managements:n,canModify:s,onView:l,onEdit:r,onDelete:a,onSelectionChange:i}){const d=ne(),[p,u]=S.useState(new Set),[C,x]=S.useState(""),[m,h]=S.useState(""),[b,_]=S.useState("all"),v=k=>{var f;return((f=n.find(w=>w.name===k))==null?void 0:f.name1)||k||"—"},g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=S.useMemo(()=>e.filter(k=>{const f=(k.department_name||k.name||"").toLowerCase();return!(C&&!f.includes(C.toLowerCase())||m&&k.custom_management!==m||b!=="all"&&(k.custom_status||"Active")!==b)}),[e,C,m,b]),[c,y]=S.useState(1);S.useEffect(()=>{y(1)},[C,m,b]);const z=o.slice((c-1)*re,c*re);return S.useEffect(()=>{if(i){const k=e.filter(f=>p.has(f.name));i(k,z)}},[p,z]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:o.length,color:q.teal})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:C,onChange:x,placeholder:"Search by name…"},{type:"select",label:d.col.management,value:m,onChange:h,options:[{value:"",label:"All Managements"},...n.map(k=>({value:k.name,label:k.name1||k.name}))]},{type:"select",label:"Status",value:b,onChange:_,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:z.length>0&&z.every(k=>p.has(k.name)),onChange:k=>{if(k.target.checked)u(new Set([...p,...z.map(f=>f.name)]));else{const f=new Set(p);z.forEach(w=>f.delete(w.name)),u(f)}},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})}):z.map((k,f)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(k),style:{borderTop:"1px solid #f0f0f0",background:p.has(k.name)?"#eff6ff":f%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:p.has(k.name),onChange:()=>{const w=new Set(p);w.has(k.name)?w.delete(k.name):w.add(k.name),u(w)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:k.department_name||k.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:v(k.custom_management)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:K0(k.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:k.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:k.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:w=>w.stopPropagation(),children:t.jsx(lt,{onView:()=>l==null?void 0:l(k),onEdit:s&&r?()=>r(k):void 0,onDelete:s&&a?()=>a(k.name):void 0})})]},k.name))})]})}),t.jsx(Xe,{page:c,total:o.length,onPageChange:y})]})}function Y0({form:e,setForm:n,organizations:s,managements:l,formStatus:r,viewMode:a,onEdit:i,darkMode:d,notifCount:p,onToggleDark:u,onCountChange:C,onViewProfile:x,onSubmit:m,onBack:h,onNavigate:b,onLogout:_,user:v}){const g=ne(),o=k=>n(f=>({...f,...k})),c=a?{background:"#f8fafc"}:{},y=e.name?a?`${g.formTitle.editDept}: ${e.department_name||e.name}`:g.formTitle.editDept:g.formTitle.newDept,z=me(l,e.custom_management).map(k=>({name:k.name,label:k.name1||k.name}));return t.jsx(qe,{title:y,activePage:"departments",user:v,formStatus:r,buttonText:g.saveDept,buttonColor:"#16a34a",viewMode:a,onEdit:i,darkMode:d,notifCount:p,onToggleDark:u,onCountChange:C,onViewProfile:x,onSubmit:m,onBack:h,onNavigate:b,onLogout:_,children:t.jsx(le,{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:T,children:[g.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.custom_organization,onChange:k=>o({custom_organization:k}),organizations:s,disabled:a||!!v.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[g.field.department," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...c},value:e.department_name,disabled:a||!!e.name,onChange:k=>o({department_name:k.target.value}),placeholder:"Department name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:g.field.management}),t.jsx(ue,{value:e.custom_management,onChange:k=>o({custom_management:k}),items:z,placeholder:g.field.select,disabled:a})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:g.field.creationDate}),t.jsx(xe,{value:e.custom_creation_date||"",onChange:k=>o({custom_creation_date:k}),disabled:a,style:{...A,...c}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:g.field.status}),t.jsxs("select",{style:{...A,...c},value:e.custom_status||"Active",disabled:a,onChange:k=>o({custom_status:k.target.value}),children:[t.jsx("option",{value:"Active",children:g.field.statusActive}),t.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})})}function X0(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 q0({branches:e,managements:n,departments:s,canModify:l,onView:r,onEdit:a,onDelete:i,onSelectionChange:d}){const p=ne(),[u,C]=S.useState(new Set),[x,m]=S.useState(""),[h,b]=S.useState(""),[_,v]=S.useState(""),[g,o]=S.useState("all"),c=P=>{var Y;return((Y=n.find(F=>F.name===P))==null?void 0:Y.name1)||P||"—"},y=P=>{var Y;return((Y=s.find(F=>F.name===P))==null?void 0:Y.department_name)||P||"—"},z={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},k=S.useMemo(()=>e.filter(P=>{const Y=(P.branch||P.name||"").toLowerCase();return!(x&&!Y.includes(x.toLowerCase())||h&&P.management!==h||_&&P.department!==_||g!=="all"&&(P.custom_status||"Active")!==g)}),[e,x,h,_,g]),[f,w]=S.useState(1);S.useEffect(()=>{w(1)},[x,h,_,g]);const I=k.slice((f-1)*re,f*re);return S.useEffect(()=>{if(d){const P=e.filter(Y=>u.has(Y.name));d(P,I)}},[u,I]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:k.length,color:q.purple})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:x,onChange:m,placeholder:"Search by name…"},{type:"select",label:p.col.management,value:h,onChange:b,options:[{value:"",label:"All Managements"},...n.map(P=>({value:P.name,label:P.name1||P.name}))]},{type:"select",label:p.col.department,value:_,onChange:v,options:[{value:"",label:"All Departments"},...s.map(P=>({value:P.name,label:P.department_name||P.name}))]},{type:"select",label:"Status",value:g,onChange:o,options:[{value:"all",label:"All"},{value:"Active",label:p.field.statusActive},{value:"Inactive",label:p.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:I.length>0&&I.every(P=>u.has(P.name)),onChange:P=>{if(P.target.checked)C(new Set([...u,...I.map(Y=>Y.name)]));else{const Y=new Set(u);I.forEach(F=>Y.delete(F.name)),C(Y)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:z,children:p.col.branch}),t.jsx("th",{style:z,children:p.col.management}),t.jsx("th",{style:z,children:p.col.department}),t.jsx("th",{style:z,children:p.field.creationDate}),t.jsx("th",{style:z,children:p.field.status}),t.jsx("th",{style:z,children:p.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:p.noData})}):I.map((P,Y)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(P),style:{borderTop:"1px solid #f0f0f0",background:u.has(P.name)?"#eff6ff":Y%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:F=>F.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:u.has(P.name),onChange:()=>{const F=new Set(u);F.has(P.name)?F.delete(P.name):F.add(P.name),C(F)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:P.branch||P.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:c(P.management)}),t.jsx("td",{style:{padding:"10px 14px"},children:y(P.department)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:X0(P.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{color:P.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:P.custom_status==="Inactive"?p.field.statusInactive:p.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:F=>F.stopPropagation(),children:t.jsx(lt,{onView:()=>r==null?void 0:r(P),onEdit:l&&a?()=>a(P):void 0,onDelete:l&&i?()=>i(P.name):void 0})})]},P.name))})]})}),t.jsx(Xe,{page:f,total:k.length,onPageChange:w})]})}function J0({form:e,setForm:n,organizations:s,managements:l,departments:r,formStatus:a,viewMode:i,onEdit:d,darkMode:p,notifCount:u,onToggleDark:C,onCountChange:x,onViewProfile:m,onSubmit:h,onBack:b,onNavigate:_,onLogout:v,user:g}){const o=ne(),c=w=>n(I=>({...I,...w})),y=i?{background:"#f8fafc"}:{},z=e.name?i?`${o.formTitle.editBranch}: ${e.branch||e.name}`:o.formTitle.editBranch:o.formTitle.newBranch,k=me(l,e.management).map(w=>({name:w.name,label:w.name1||w.name})),f=me(r,e.department).map(w=>({name:w.name,label:w.department_name||w.name}));return t.jsx(qe,{title:z,activePage:"branches",user:g,formStatus:a,buttonText:o.saveBranch,buttonColor:"#16a34a",viewMode:i,onEdit:d,darkMode:p,notifCount:u,onToggleDark:C,onCountChange:x,onViewProfile:m,onSubmit:h,onBack:b,onNavigate:_,onLogout:v,children:t.jsx(le,{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:T,children:[o.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:w=>c({organization:w}),organizations:s,disabled:i||!!g.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[o.field.branch," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...y},value:e.branch,disabled:i||!!e.name,onChange:w=>c({branch:w.target.value}),placeholder:"Branch name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:o.field.management}),t.jsx(ue,{value:e.management,onChange:w=>c({management:w}),items:k,placeholder:o.field.select,disabled:i})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:o.field.department}),t.jsx(ue,{value:e.department,onChange:w=>c({department:w}),items:f,placeholder:o.field.select,disabled:i})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:o.field.creationDate}),t.jsx(xe,{value:e.custom_creation_date||"",onChange:w=>c({custom_creation_date:w}),disabled:i,style:{...A,...y}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:o.field.status}),t.jsxs("select",{style:{...A,...y},value:e.custom_status||"Active",disabled:i,onChange:w=>c({custom_status:w.target.value}),children:[t.jsx("option",{value:"Active",children:o.field.statusActive}),t.jsx("option",{value:"Inactive",children:o.field.statusInactive})]})]})]})})})}function V0(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 Z0({incidentTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.red})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:V0(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function e1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return t.jsx(qe,{title:o,activePage:"incident-types",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsx(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Incident type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.field.statusInactive})]})]})]})})})}function t1(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 n1({ideaTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.teal})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:t1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function s1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return t.jsx(qe,{title:o,activePage:"idea-types",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsx(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Idea type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.field.statusInactive})]})]})]})})})}function l1(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 r1({orderTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.purple})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:l1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function a1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return t.jsx(qe,{title:o,activePage:"order-types",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsx(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Order type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.field.statusInactive})]})]})]})})})}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 o1({processTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.blue})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:i1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function d1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return t.jsx(qe,{title:o,activePage:"process-types",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsx(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Process type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.field.statusInactive})]})]})]})})})}function c1(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 u1({incidentStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.red})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.notifyManager}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:c1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function p1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return t.jsx(qe,{title:o,activePage:"incident-statuses",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsxs(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Incident status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.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:l,onChange:c=>v({notify_manager:c.target.checked?1:0}),style:_l}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:_.field.notifyManager})]})]})})}function f1(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 h1({ideaStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.teal})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.notifyManager}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:f1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function g1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return t.jsx(qe,{title:o,activePage:"idea-statuses",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsxs(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Idea status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.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:l,onChange:c=>v({notify_manager:c.target.checked?1:0}),style:_l}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:_.field.notifyManager})]})]})})}function x1(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({orderStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.purple})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.notifyManager}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:x1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function y1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return t.jsx(qe,{title:o,activePage:"order-statuses",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsxs(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Order status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.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:l,onChange:c=>v({notify_manager:c.target.checked?1:0}),style:_l}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:_.field.notifyManager})]})]})})}function v1(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 j1({processStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(o=>{const c=(o.name1||o.name||"").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x!=="all"&&(o.status||"Active")!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:q.blue})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:"Status",value:x,onChange:m,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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:i.col.name}),t.jsx("th",{style:h,children:i.field.notifyManager}),t.jsx("th",{style:h,children:i.field.creationDate}),t.jsx("th",{style:h,children:i.field.status}),t.jsx("th",{style:h,children:i.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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:v1(o.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children: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:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function b1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,user:b}){const _=ne(),v=c=>n(y=>({...y,...c})),g=l?{background:"#f8fafc"}:{},o=e.name?l?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return t.jsx(qe,{title:o,activePage:"process-statuses",user:b,formStatus:s,buttonText:_.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:a,notifCount:i,onToggleDark:d,onCountChange:p,onViewProfile:u,onSubmit:C,onBack:x,onNavigate:m,onLogout:h,children:t.jsxs(le,{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:T,children:[_.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...g},value:e.name1,disabled:l||!!e.name,onChange:c=>v({name1:c.target.value}),placeholder:"Process status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.creationDate}),t.jsx(xe,{value:e.creation_date||"",onChange:c=>v({creation_date:c}),disabled:l,style:{...A,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:_.field.status}),t.jsxs("select",{style:{...A,...g},value:e.status||"Active",disabled:l,onChange:c=>v({status:c.target.value}),children:[t.jsx("option",{value:"Active",children:_.field.statusActive}),t.jsx("option",{value:"Inactive",children:_.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:l,onChange:c=>v({notify_manager:c.target.checked?1:0}),style:_l}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:_.field.notifyManager})]})]})})}const S1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};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({users:e,canModify:n,onView:s,onEdit:l,onDisable:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(!1),[x,m]=S.useState(""),[h,b]=S.useState(""),[_,v]=S.useState(""),[g,o]=S.useState("active"),[c,y]=S.useState(1),[z,k]=S.useState(null),[f,w]=S.useState(""),[I,P]=S.useState("idle"),[Y,F]=S.useState(null),$=async()=>{if(!(!z||!f.trim())){P("loading");try{await nh(z.name,f.trim()),P("success"),setTimeout(()=>{k(null),w(""),P("idle")},1200)}catch{P("error")}}},U=async W=>{if(window.confirm(i.users.disableConfirm)){F(W);try{await(r==null?void 0:r(W))}finally{F(null)}}},E=e.filter(W=>{if(g==="active"&&(W.enabled===0||W.enabled==="0")||g==="inactive"&&W.enabled!==0&&W.enabled!=="0")return!1;const Z=W.custom_category||"";if(_&&Z!==_)return!1;const pe=W.custom_organization||"";if(h&&!pe.toLowerCase().includes(h.toLowerCase()))return!1;if(x){const be=x.toLowerCase();if(![W.full_name,W.email,W.name,W.username,W.mobile_no].join(" ").toLowerCase().includes(be))return!1}return!0}),D=[...new Set(e.map(W=>W.custom_organization).filter(Boolean))],H=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];S.useEffect(()=>{y(1)},[x,h,_,g]);const G=E.slice((c-1)*re,c*re);S.useEffect(()=>{if(a){const W=E.filter(Z=>d.has(Z.name));a(W,G)}},[d,G]);const X={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},J={...X,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(W=>!W),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:u?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"})]}),u&&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:X,placeholder:"Name, email, username…",value:x,onChange:W=>{m(W.target.value),y(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:J,value:h,onChange:W=>{b(W.target.value),y(1)},children:[t.jsx("option",{value:"",children:"All Organizations"}),D.map(W=>t.jsx("option",{value:W,children:W},W))]})]}),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:J,value:_,onChange:W=>{v(W.target.value),y(1)},children:[t.jsx("option",{value:"",children:"All Categories"}),H.map(W=>t.jsx("option",{value:W,children:W},W))]})]}),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:J,value:g,onChange:W=>{o(W.target.value),y(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:G.length>0&&G.every(W=>d.has(W.name)),onChange:W=>{if(W.target.checked)p(new Set([...d,...G.map(Z=>Z.name)]));else{const Z=new Set(d);G.forEach(pe=>Z.delete(pe.name)),p(Z)}},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:W,w:Z})=>t.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:Z,letterSpacing:.3,textTransform:"uppercase"},children:W},W))]})}),t.jsx("tbody",{children:E.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"})}):G.map((W,Z)=>{const pe=W.custom_category||"",be=S1[pe]||"#6b7280";return t.jsxs("tr",{onClick:()=>s==null?void 0:s(W),style:{borderBottom:"1px solid #f3f4f6",background:d.has(W.name)?"#eff6ff":Z%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"11px 14px",textAlign:"center"},onClick:ae=>ae.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(W.name),onChange:()=>{const ae=new Set(d);ae.has(W.name)?ae.delete(W.name):ae.add(W.name),p(ae)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:pe?t.jsx("span",{style:{background:be+"18",color:be,border:`1px solid ${be}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:pe}):t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:W.custom_number||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:W.full_name||W.first_name||"—"}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:W.username||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:W.email||W.name}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:W.mobile_no||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:W.custom_organization||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:W.custom_management||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:W.custom_department||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:W.custom_branch||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:w1(W.creation)}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:t.jsx("span",{style:{color:W.enabled?"#16a34a":"#dc2626",fontWeight:600},children:W.enabled?i.users.active:i.users.inactive})}),t.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:ae=>ae.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{onClick:ae=>{ae.stopPropagation(),s==null||s(W)},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&&l&&t.jsx("button",{onClick:ae=>{ae.stopPropagation(),l(W)},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:ae=>{ae.stopPropagation(),k({name:W.name,email:W.email||W.name}),w(""),P("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:ae=>{ae.stopPropagation(),U(W.name)},disabled:Y===W.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:Y===W.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"})]})})]})})]},W.name)})})]})}),t.jsx(Xe,{page:c,total:E.length,onPageChange:y}),z&&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:z.email})]}),t.jsx("input",{type:"password",value:f,onChange:W=>w(W.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:W=>W.key==="Enter"&&$(),autoFocus:!0}),I==="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"}),I==="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:$,disabled:I==="loading"||!f.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:f.trim()?1:.5},children:I==="loading"?"Saving…":i.users.setPassword}),t.jsx("button",{onClick:()=>{k(null),w(""),P("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 _1({form:e,setForm:n,groupCompanies:s=[],organizations:l,managements:r,departments:a,branches:i,formStatus:d,viewMode:p,onEdit:u,darkMode:C,notifCount:x,onToggleDark:m,onCountChange:h,onViewProfile:b,isSelfProfile:_,onSubmit:v,onBack:g,onNavigate:o,onLogout:c,user:y}){const z=ne(),k=U=>n(E=>({...E,...U})),f=p?{background:"#f8fafc"}:{},w=!e.name,I=_?"My Profile":w?"New User":p?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,P=s.map(U=>({name:U.name,label:U.company_name?`${U.company_name} (${U.name})`:U.name})),Y=me(r,e.custom_management).map(U=>({name:U.name,label:U.name1||U.name})),F=me(a,e.custom_department).map(U=>({name:U.name,label:U.department_name||U.name})),$=me(i,e.custom_branch).map(U=>({name:U.name,label:U.branch||U.name}));return t.jsxs(qe,{title:I,activePage:"users",user:y,formStatus:d,buttonText:z.saveUser,buttonColor:"#16a34a",viewMode:p,onEdit:u,darkMode:C,notifCount:x,onToggleDark:m,onCountChange:h,onViewProfile:b,hideSettings:_,onSubmit:v,onBack:g,onNavigate:o,onLogout:c,children:[t.jsx(le,{title:"User Organization & Assignment",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:T,children:"Group Company (Tenant)"}),t.jsx(ue,{value:e.custom_group_company||"",onChange:U=>k({custom_group_company:U}),items:P,placeholder:"-- Select Group Company --",disabled:p||!!y.custom_group_company})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.organization}),t.jsx(Mt,{value:e.custom_organization,onChange:U=>k({custom_organization:U}),organizations:l,disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.management}),t.jsx(ue,{value:e.custom_management,onChange:U=>k({custom_management:U}),items:Y,placeholder:"-- Select --",disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.department}),t.jsx(ue,{value:e.custom_department,onChange:U=>k({custom_department:U}),items:F,placeholder:"-- Select --",disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.branch}),t.jsx(ue,{value:e.custom_branch,onChange:U=>k({custom_branch:U}),items:$,placeholder:"-- Select --",disabled:p})]})]})}),t.jsx(le,{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:T,children:z.field.number}),t.jsx("input",{style:{...A,...f},value:e.custom_number,disabled:p,onChange:U=>k({custom_number:U.target.value}),placeholder:"e.g. 10001"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[z.field.fullName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...f},value:e.first_name,disabled:p,onChange:U=>k({first_name:U.target.value}),placeholder:"Full name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.username}),t.jsx("input",{style:{...A,...f},value:e.username,disabled:p,onChange:U=>k({username:U.target.value}),placeholder:"Username"})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.phoneNumber}),t.jsx("input",{style:{...A,...f},value:e.mobile_no,disabled:p,onChange:U=>k({mobile_no:U.target.value}),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[z.field.emailAddress," ",w&&t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...p||!w?{background:"#f8fafc"}:{}},value:e.email,disabled:p||!w,onChange:U=>k({email:U.target.value}),placeholder:"user@example.com",type:"email",required:w})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:z.field.category}),t.jsxs("select",{style:{...A,...f},value:e.custom_category,disabled:p,onChange:U=>k({custom_category:U.target.value}),children:[t.jsx("option",{value:"",children:z.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"})]})]})]})})]})}const Tu={Active:q.green,Closed:q.gray};function C1({cycles:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState(""),[h,b]=S.useState("all"),_=S.useMemo(()=>[...new Set(e.map(k=>k.organization).filter(Boolean))],[e]),v=S.useMemo(()=>e.filter(k=>{const f=(k.name1||k.name||"").toLowerCase();return!(u&&!f.includes(u.toLowerCase())||x&&k.organization!==x||h!=="all"&&k.status!==h)}),[e,u,x,h]),[g,o]=S.useState(1);S.useEffect(()=>{o(1)},[u,x,h]);const c=v.slice((g-1)*re,g*re);S.useEffect(()=>{if(a){const k=e.filter(f=>d.has(f.name));a(k,c)}},[d,c]);const y=v.filter(k=>k.status==="Active").length,z=v.filter(k=>k.status==="Closed").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:v.length,color:q.teal}),t.jsx(Ie,{label:"Active",val:y,color:q.green}),t.jsx(Ie,{label:"Closed",val:z,color:q.gray})]}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:x,onChange:m,options:[{value:"",label:"All Organizations"},..._.map(k=>({value:k,label:k}))]},{type:"select",label:"Status",value:h,onChange:b,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:c.length>0&&c.every(k=>d.has(k.name)),onChange:k=>{if(k.target.checked)p(new Set([...d,...c.map(f=>f.name)]));else{const f=new Set(d);c.forEach(w=>f.delete(w.name)),p(f)}},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:v.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):c.map((k,f)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(k),style:{borderTop:"1px solid #f0f0f0",background:d.has(k.name)?"#eff6ff":f%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(k.name),onChange:()=>{const w=new Set(d);w.has(k.name)?w.delete(k.name):w.add(k.name),p(w)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:k.name1||k.name}),t.jsx("td",{style:{padding:"10px 14px"},children:k.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:k.frequency||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:k.start_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:k.end_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:Tu[k.status]+"22",color:Tu[k.status]||"#666"},children:k.status})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:w=>w.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(k),onEdit:n&&l?()=>l(k):void 0,onDelete:n&&r?()=>r(k.name):void 0})})]},k.name))})]})}),t.jsx(Xe,{page:g,total:v.length,onPageChange:o})]})}const z1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],I1=["Active","Closed"];function T1({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,user:_}){const v=ne(),g=y=>n(z=>({...z,...y})),o=r?{background:"#f8fafc"}:{},c=e.name?r?`${v.formTitle.editCycle}: ${e.name1||e.name}`:v.formTitle.editCycle:v.formTitle.newCycle;return t.jsx(qe,{title:c,activePage:"cycles",user:_,formStatus:l,buttonText:v.saveCycle,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,children:t.jsx(le,{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:T,children:[v.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.name1||"",disabled:r||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"e.g. Q1-2026"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[v.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:y=>g({organization:y}),organizations:s,disabled:r||!!_.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.col.frequency}),t.jsx(ue,{value:e.frequency,onChange:y=>g({frequency:y}),items:z1.map(y=>({name:y,label:y})),placeholder:"-- Select Frequency --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.status}),t.jsx(ue,{value:e.status,onChange:y=>g({status:y}),items:I1.map(y=>({name:y,label:y})),placeholder:"-- Select Status --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.dateStart}),t.jsx(xe,{value:e.start_date||"",onChange:y=>g({start_date:y}),disabled:r,style:{...A,...o}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.dateEnd}),t.jsx(xe,{value:e.end_date||"",onChange:y=>g({end_date:y}),disabled:r,style:{...A,...o}})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.updateWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...A,...o},value:e.update_window_days??2,disabled:r,onChange:y=>g({update_window_days:parseInt(y.target.value)||2})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})})}function E1({kpiInputs:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:a}){const i=ne(),[d,p]=S.useState(new Set),[u,C]=S.useState(""),[x,m]=S.useState(""),h=S.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),b=S.useMemo(()=>e.filter(o=>{const c=[o.organization,o.period].filter(Boolean).join(" ").toLowerCase();return!(u&&!c.includes(u.toLowerCase())||x&&o.organization!==x)}),[e,u,x]),[_,v]=S.useState(1);S.useEffect(()=>{v(1)},[u,x]);const g=b.slice((_-1)*re,_*re);return S.useEffect(()=>{if(a){const o=e.filter(c=>d.has(c.name));a(o,g)}},[d,g]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total Records",val:b.length,color:q.blue})}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:u,onChange:C,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:x,onChange:m,options:[{value:"",label:"All Organizations"},...h.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)p(new Set([...d,...g.map(c=>c.name)]));else{const c=new Set(d);g.forEach(y=>c.delete(y.name)),p(c)}},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:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):g.map((o,c)=>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":c%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:y=>y.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(o.name),onChange:()=>{const y=new Set(d);y.has(o.name)?y.delete(o.name):y.add(o.name),p(y)},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.customer_satisfaction!=null?o.customer_satisfaction:"—"}),t.jsx("td",{style:{padding:"8px 14px"},onClick:y=>y.stopPropagation(),children:t.jsx(lt,{onView:()=>s==null?void 0:s(o),onEdit:n&&l?()=>l(o):void 0,onDelete:n&&r?()=>r(o.name):void 0})})]},o.name))})]})}),t.jsx(Xe,{page:_,total:b.length,onPageChange:v})]})}function P1({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,user:_}){const v=ne(),g=z=>n(k=>({...k,...z})),o=r?{background:"#f8fafc"}:{},c=z=>k=>g({[z]:parseFloat(k.target.value)||0}),y=e.name?r?`${v.formTitle.editKpi}: ${e.period||e.name}`:v.formTitle.editKpi:v.formTitle.newKpi;return t.jsxs(qe,{title:y,activePage:"kpi-input",user:_,formStatus:l,buttonText:v.saveKpi,buttonColor:"#16a34a",viewMode:r,onEdit:a,darkMode:i,notifCount:d,onToggleDark:p,onCountChange:u,onViewProfile:C,onSubmit:x,onBack:m,onNavigate:h,onLogout:b,children:[t.jsx(le,{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:T,children:[v.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Mt,{value:e.organization,onChange:z=>g({organization:z}),organizations:s,disabled:r||!!_.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[v.col.period," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...A,...o},value:e.period||"",disabled:r,onChange:z=>g({period:z.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),t.jsx(le,{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:T,children:v.field.revenue_growth}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.revenue_growth||"",disabled:r,onChange:c("revenue_growth")})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.net_profit}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.net_profit||"",disabled:r,onChange:c("net_profit")})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.cash_flow}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.cash_flow||"",disabled:r,onChange:c("cash_flow")})]})]})}),t.jsx(le,{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:T,children:v.field.strategic_goal_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.strategic_goal_pct||"",disabled:r,onChange:c("strategic_goal_pct")})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.customer_satisfaction}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.customer_satisfaction||"",disabled:r,onChange:c("customer_satisfaction")})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.employee_turnover_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.employee_turnover_pct||"",disabled:r,onChange:c("employee_turnover_pct")})]})]})}),t.jsx(le,{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:T,children:v.field.open_safety_incidents}),t.jsx("input",{type:"number",min:0,style:{...A,...o},value:e.open_safety_incidents||"",disabled:r,onChange:z=>g({open_safety_incidents:parseInt(z.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:v.field.compliance_score}),t.jsx("input",{type:"number",step:"0.01",style:{...A,...o},value:e.compliance_score||"",disabled:r,onChange:c("compliance_score")})]})]})})]})}const A1={incident_initial_evaluation:"Incident Initial Evaluation",idea_initial_evaluation:"Idea Initial Evaluation"},Eu={Pending:q.orange,Accepted:q.green,Rejected:q.red,Revoked:q.gray};function R1(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 D1(e){const n=[];return e.incident_initial_evaluation&&n.push("incident_initial_evaluation"),e.idea_initial_evaluation&&n.push("idea_initial_evaluation"),n}function L1({delegations:e,organizations:n,userRole:s,currentUser:l,onView:r,onRevoke:a,onSelectionChange:i}){const d=ne(),[p,u]=S.useState(new Set),[C,x]=S.useState(""),[m,h]=S.useState(""),[b,_]=S.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},g=S.useMemo(()=>e.filter(f=>{const w=`${f.auditor} ${f.manager}`.toLowerCase();return!(C&&!w.includes(C.toLowerCase())||m&&f.organization!==m||b!=="all"&&f.status!==b)}),[e,C,m,b]),[o,c]=S.useState(1);S.useEffect(()=>{c(1)},[C,m,b]);const y=g.slice((o-1)*re,o*re);S.useEffect(()=>{if(i){const f=e.filter(w=>p.has(w.name));i(f,y)}},[p,y]);const z=g.filter(f=>f.status==="Pending").length,k=g.filter(f=>f.status==="Accepted").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:g.length,color:q.purple}),t.jsx(Ie,{label:"Pending",val:z,color:q.orange}),t.jsx(Ie,{label:"Accepted",val:k,color:q.green})]}),t.jsx(mt,{filters:[{type:"search",label:"Search",value:C,onChange:x,placeholder:"Auditor or Manager…"},{type:"select",label:d.col.organization,value:m,onChange:h,options:[{value:"",label:"All Organizations"},...n.map(f=>({value:f.organization_name||f.name,label:f.organization_name||f.name}))]},{type:"select",label:"Status",value:b,onChange:_,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:y.length>0&&y.every(f=>p.has(f.name)),onChange:f=>{if(f.target.checked)u(new Set([...p,...y.map(w=>w.name)]));else{const w=new Set(p);y.forEach(I=>w.delete(I.name)),u(w)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:v,children:d.col.number}),t.jsx("th",{style:v,children:d.col.auditor}),t.jsx("th",{style:v,children:d.col.manager}),t.jsx("th",{style:v,children:d.col.organization}),t.jsx("th",{style:v,children:d.col.functions}),t.jsx("th",{style:v,children:d.col.status}),t.jsx("th",{style:v,children:d.col.requestedOn}),t.jsx("th",{style:v,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})}):y.map((f,w)=>{const I=!!a&&(f.status==="Pending"||f.status==="Accepted")&&(s==="Admin"||f.auditor===l);return t.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(f),style:{borderTop:"1px solid #f0f0f0",background:p.has(f.name)?"#eff6ff":w%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:P=>P.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:p.has(f.name),onChange:()=>{const P=new Set(p);P.has(f.name)?P.delete(f.name):P.add(f.name),u(P)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.number||f.name}),t.jsx("td",{style:{padding:"10px 14px"},children:f.auditor}),t.jsx("td",{style:{padding:"10px 14px"},children:f.manager}),t.jsx("td",{style:{padding:"10px 14px"},children:f.organization||"All Organizations"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:D1(f).map(P=>t.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:A1[P]||P},P))})}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{background:(Eu[f.status]||q.gray)+"22",color:Eu[f.status]||q.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:f.status})}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:R1(f.requested_on)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:P=>P.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>r==null?void 0:r(f),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"})]})}),I&&t.jsx("button",{onClick:()=>a==null?void 0:a(f.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"})]})})]},f.name)})})]})}),t.jsx(Xe,{page:o,total:g.length,onPageChange:c})]})}const Pu={Pending:q.orange,Accepted:q.green,Rejected:q.red,Revoked:q.gray};function O1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":n.toLocaleString()}function N1({form:e,setForm:n,organizations:s,users:l,userRoleMap:r,incidents:a=[],ideas:i=[],formStatus:d,viewMode:p,onEdit:u,darkMode:C,notifCount:x,onToggleDark:m,onCountChange:h,onViewProfile:b,onSubmit:_,onBack:v,onNavigate:g,onLogout:o,user:c}){var Y;const y=ne(),z=F=>n($=>({...$,...F})),k=p?{background:"#f8fafc"}:{},f=kl(l,r,"SB Manager",e.organization).filter(F=>F.name!==(e.auditor||c.name)).map(F=>({name:F.name,label:F.full_name||F.name})),w=a.filter(F=>(F.workflow_state==="Initial Evaluation"||F.status==="Initial Evaluation")&&(!e.organization||F.organization===e.organization)).map(F=>({name:F.name,label:`${F.number||F.name} — ${F.title||""}`.trim()})),I=i.filter(F=>(F.workflow_state==="Initial Evaluation"||F.status==="Initial Evaluation")&&(!e.organization||F.organization===e.organization)).map(F=>({name:F.name,label:`${F.number||F.name} — ${F.title||""}`.trim()})),P=e.name?`${y.formTitle.viewDelegation}${e.number||e.name}`:y.formTitle.newDelegation;return t.jsxs(qe,{title:P,activePage:"delegations",user:c,formStatus:d,statusBadge:e.status?t.jsx("span",{style:{background:(Pu[e.status]||q.gray)+"22",color:Pu[e.status]||q.gray,padding:"4px 12px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status}):void 0,buttonText:y.saveDelegation,buttonColor:"#16a34a",viewMode:p,onEdit:u,darkMode:C,notifCount:x,onToggleDark:m,onCountChange:h,onViewProfile:b,onSubmit:_,onBack:v,onNavigate:g,onLogout:o,children:[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(le,{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:T,children:y.col.auditor}),t.jsx("input",{style:{...A,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||c.name,disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[y.col.manager," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(ue,{value:e.manager,onChange:F=>z({manager:F}),items:f,placeholder:"-- Select Manager --",disabled:p})]}),t.jsxs("div",{children:[t.jsx("label",{style:T,children:y.col.organization}),t.jsx(Mt,{value:e.organization,onChange:F=>z({organization:F,incident_name:"",idea_name:""}),organizations:s,placeholder:"-- All Organizations --",disabled:p})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:T,children:[y.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:p?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:_l,checked:!!e.incident_initial_evaluation,disabled:p,onChange:F=>z({incident_initial_evaluation:F.target.checked?1:0,incident_name:F.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:{...T,fontSize:11},className:"func-sublabel",children:["Specific Incident ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),p?t.jsx("input",{style:{...A,background:"#f8fafc"},value:e.incident_name||"— All Incidents in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.incident_name||"",onChange:F=>z({incident_name:F}),items:w,placeholder:`-- Any Incident in Initial Evaluation (${w.length} available) --`,disabled:p})]})]}),t.jsxs("div",{className:`delegation-func-box ${e.idea_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:p?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:_l,checked:!!e.idea_initial_evaluation,disabled:p,onChange:F=>z({idea_initial_evaluation:F.target.checked?1:0,idea_name:F.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:{...T,fontSize:11},className:"func-sublabel",children:["Specific Idea ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),p?t.jsx("input",{style:{...A,background:"#f8fafc"},value:e.idea_name||"— All Ideas in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.idea_name||"",onChange:F=>z({idea_name:F}),items:I,placeholder:`-- Any Idea in Initial Evaluation (${I.length} available) --`,disabled:p})]})]})]})]}),!p&&t.jsxs("div",{style:{marginTop:14},children:[t.jsx("label",{style:T,children:"Remarks"}),t.jsx("textarea",{style:{...A,...k,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:F=>z({remarks:F.target.value}),placeholder:"Optional note for the Manager…"})]})]}),p&&(((Y=e.delegation_log)==null?void 0:Y.length)??0)>0&&t.jsx(le,{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((F,$)=>t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:F.action}),t.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:F.actor}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:O1(F.timestamp)}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:F.remarks||"—"})]},F.name||$))})]})})})]})}const Au={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},W1={process:"#3b82f6",order:"#8b5cf6",incident:"#ef4444",idea:"#10b981",delegation:"#f59e0b"},B1={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%)"},$1={process:"⚙️",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function U1({onNavigate:e,onRefresh:n}){const[s,l]=S.useState([]),[r,a]=S.useState(!0),[i,d]=S.useState(""),[p,u]=S.useState(""),[C,x]=S.useState(""),[m,h]=S.useState("all"),b=()=>{a(!0),My().then(o=>{l(o||[]),a(!1)}).catch(()=>a(!1))};S.useEffect(()=>{b()},[]);const _=S.useMemo(()=>{const o={all:s.length,action:0,info:0};for(const c of s)c.requires_action?o.action=(o.action||0)+1:o.info=(o.info||0)+1,o[c.type]=(o[c.type]||0)+1;return o},[s]),v=S.useMemo(()=>s.filter(o=>{if(m==="action"&&!o.requires_action||m==="info"&&o.requires_action||m!=="all"&&m!=="action"&&m!=="info"&&o.type!==m)return!1;if(C.trim()){const c=C.toLowerCase();if(![o.number,o.title,o.action,o.organization,o.type].filter(Boolean).join(" ").toLowerCase().includes(c))return!1}return!0}),[s,m,C]),g=async(o,c)=>{d(o),u("");try{await Gy(o,c),await b(),n==null||n()}catch{u(o)}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:b,disabled:r,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:r?"wait":"pointer",display:"flex",alignItems:"center",gap:8,transition:"all 0.15s ease"},onMouseEnter:o=>{o.currentTarget.style.background="rgba(255, 255, 255, 0.25)"},onMouseLeave:o=>{o.currentTarget.style.background="rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{transform:r?"rotate(180deg)":"none",transition:"transform 0.5s",display:"inline-block"},children:"🔄"}),r?"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:_.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:_.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:_.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:_.all},{id:"action",label:"Needs Action",icon:"🚨",count:_.action,badgeColor:"#ef4444"},{id:"info",label:"Info",icon:"ℹ️",count:_.info},{id:"incident",label:"Incidents",icon:"⚠️",count:_.incident},{id:"idea",label:"Ideas",icon:"💡",count:_.idea},{id:"order",label:"Orders",icon:"📦",count:_.order},{id:"process",label:"Processes",icon:"⚙️",count:_.process},{id:"delegation",label:"Delegations",icon:"🤝",count:_.delegation}].map(o=>{const c=m===o.id;return o.id!=="all"&&o.id!=="action"&&o.id!=="info"&&(!o.count||o.count===0)?null:t.jsxs("button",{type:"button",onClick:()=>h(o.id),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:999,border:c?"1px solid #4f46e5":"1px solid #e2e8f0",background:c?"#4f46e5":"#f8fafc",color:c?"#ffffff":"#475569",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},children:[t.jsx("span",{children:o.icon}),t.jsx("span",{children:o.label}),o.count!=null&&o.count>0&&t.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:999,background:c?"rgba(255,255,255,0.25)":o.badgeColor||"#e2e8f0",color:c?"#ffffff":o.badgeColor?"white":"#475569"},children:o.count})]},o.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:o=>x(o.target.value),style:{width:"100%",padding:"7px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:12,boxSizing:"border-box",background:"#f8fafc",color:"#334155"}})})]}),r?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…"]}):v.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||m!=="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||m!=="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||m!=="all")&&t.jsx("button",{type:"button",onClick:()=>{x(""),h("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:v.map((o,c)=>{const y=W1[o.type]||q.gray,z=B1[o.type]||"linear-gradient(135deg, #64748b 0%, #475569 100%)",k=o.type!=="delegation";return t.jsxs("div",{className:"inbox-card form-card",onClick:k?()=>e(Au[o.type],o.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:k?"pointer":"default",position:"relative",overflow:"hidden",transition:"transform 0.15s ease, box-shadow 0.15s ease"},onMouseEnter:f=>{k&&(f.currentTarget.style.transform="translateY(-2px)",f.currentTarget.style.boxShadow="0 10px 20px -5px rgba(0,0,0,0.08)")},onMouseLeave:f=>{k&&(f.currentTarget.style.transform="none",f.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:z}}),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:z,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0,boxShadow:`0 3px 8px -1px ${y}66`},children:$1[o.type]||"📌"}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:y,letterSpacing:"0.3px"},children:o.number||o.name})]}),o.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:o.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:o.title||o.action||"Untitled Item"}),t.jsx("div",{style:{fontSize:12,color:"#475569",lineHeight:1.4,marginBottom:8},children:o.action}),t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[o.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:["🏢 ",o.organization]}),o.date&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6},children:["📅 ",o.date]})]}),p===o.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:o.type==="delegation"?t.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:()=>g(o.name,"Accepted"),disabled:i===o.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#16a34a",color:"white",fontWeight:700,fontSize:12,cursor:i===o.name?"wait":"pointer",opacity:i===o.name?.6:1,transition:"background 0.15s ease"},children:"✓ Accept"}),t.jsx("button",{type:"button",onClick:()=>g(o.name,"Rejected"),disabled:i===o.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#ef4444",color:"white",fontWeight:700,fontSize:12,cursor:i===o.name?"wait":"pointer",opacity:i===o.name?.6:1,transition:"background 0.15s ease"},children:"✕ Reject"})]}):t.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),e(Au[o.type],o.name)},style:{width:"100%",padding:"7px 12px",borderRadius:8,border:o.requires_action?"none":"1px solid #cbd5e1",background:o.requires_action?z:"#f8fafc",color:o.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:o.requires_action?"Review & Act Now":"View Details"}),t.jsx("span",{style:{fontSize:13},children:"→"})]})})]},o.name||c)})})]})}const F1=[{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"]}],Od={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 M1(e,n){const s=e.map(r=>Od[r]||r).join(","),l=n.map(r=>e.map(a=>`"${r[a]??""}"`).join(",")).join(`
`);return s+`
`+l}function H1(e,n){const s=new Blob([e],{type:"text/csv"}),l=URL.createObjectURL(s),r=document.createElement("a");r.href=l,r.download=n,r.click(),URL.revokeObjectURL(l)}const Ru=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function G1(e,n,s){const l=e.map(u=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Ru(Od[u]||u)}</th>`).join(""),r=n.map(u=>`<tr>${e.map(C=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Ru(u[C])}</td>`).join("")}</tr>`).join(""),a=`<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>${l}</tr></thead><tbody>${r}</tbody></table></body></html>`,i=new Blob(["\uFEFF"+a],{type:"application/vnd.ms-excel"}),d=URL.createObjectURL(i),p=document.createElement("a");p.href=d,p.download=s,p.click(),URL.revokeObjectURL(d)}const ah="report-print-area",Fi="report-print-portal";function K1(){const e=document.getElementById(ah);if(!e)return;const n=document.createElement("div");n.id=Fi,n.innerHTML=e.innerHTML,document.body.appendChild(n);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
#${Fi} { display: none; }
@media print {
#root { display: none !important; }
#${Fi} { display: block !important; }
}
`,document.head.appendChild(s);const l=()=>{n.remove(),s.remove(),window.removeEventListener("afterprint",l)};window.addEventListener("afterprint",l),window.print()}const Du={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Mi={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function Q1({organizations:e,userRole:n}){const s=ne(),l=F1.filter(I=>I.roles.includes(n)),[r,a]=S.useState(""),[i,d]=S.useState(""),[p,u]=S.useState(""),[C,x]=S.useState(""),[m,h]=S.useState(String(new Date().getFullYear())),[b,_]=S.useState([]),[v,g]=S.useState([]),[o,c]=S.useState(!1),[y,z]=S.useState(""),k=l.find(I=>I.id===r);async function f(){if(r){c(!0),z(""),g([]),_([]);try{const I={};i&&(I.organization=i),p&&(I.from_date=p),C&&(I.to_date=C),(k==null?void 0:k.extraFilter)==="year"&&m&&(I.year=m);const P=await Fy(r,I);_(P.columns||[]),g(P.rows||[])}catch(I){z(I.message||"Error running report")}finally{c(!1)}}}const w=(k==null?void 0:k.label)||r;return t.jsxs("div",{children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:l.map(I=>t.jsxs("div",{onClick:()=>a(I.id),style:{background:r===I.id?"#ebf5fb":"white",border:r===I.id?`2px solid ${q.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:I.label}),t.jsx("div",{style:{fontSize:12,color:"#888"},children:I.description})]},I.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:Du,value:r,onChange:I=>a(I.target.value),children:[t.jsx("option",{value:"",children:"-- Select Report --"}),l.map(I=>t.jsx("option",{value:I.id,children:I.label},I.id))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),t.jsxs("select",{style:Du,value:i,onChange:I=>d(I.target.value),children:[t.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(I=>t.jsx("option",{value:I.name,children:I.organization_name||I.name},I.name))]})]}),(k==null?void 0:k.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:{...Mi,width:90},value:m,onChange:I=>h(I.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(xe,{value:p,onChange:u,style:Mi})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),t.jsx(xe,{value:C,onChange:x,style:Mi})]})]}),t.jsx("button",{onClick:f,disabled:!r||o,style:{padding:"9px 20px",borderRadius:8,border:"none",background:q.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:o?s.loading:s.reports.generate}),v.length>0&&t.jsx("button",{onClick:()=>H1(M1(b,v),`${r}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),v.length>0&&t.jsx("button",{onClick:()=>G1(b,v,`${r}.xls`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #107c41",background:"white",color:"#107c41",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export Excel"}),v.length>0&&t.jsx("button",{onClick:K1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),y&&t.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:y}),v.length>0&&t.jsxs("div",{id:ah,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:w}),t.jsxs("span",{style:{fontSize:12,color:"#888"},children:[v.length," rows"]})]}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8f9fa"},children:b.map(I=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Od[I]||I.replace(/_/g," ").toUpperCase()},I))})}),t.jsx("tbody",{children:v.map((I,P)=>t.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:P%2===0?"white":"#fafafa"},children:b.map(Y=>t.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:I[Y]!=null?String(I[Y]):"—"},Y))},P))})]})]}),!o&&v.length===0&&r&&!y&&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."}),l.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 Er=()=>new Date().toISOString().split("T")[0],Nd=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Y1=()=>new Date().toTimeString().slice(0,5),bn=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:Er(),time:Y1(),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:""}),on=()=>({name:"",number:"",title:"",organization:"",type:"",management:"",department:"",section_field:"",branch:"",current_condition:"",proposed_condition:"",status:"",assigned_to:"",workflow_state:"New",idea_class:"",hses_field:"",date:Er(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),dn=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Er(),ending_date:Nd(),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:""}),ea=()=>({name:"",title:"",date_start:Er(),date_end:Nd(),number:"",status:"",cycle_type:"Normal",organization:"",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:""}),Ms=()=>({name:"",organization_name:"",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}),us=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ps=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),fs=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Hs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Gs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ks=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Qs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ys=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Xs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),qs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Js=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ta=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),hs=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:Er(),end_date:Nd(),update_window_days:2}),gs=()=>({name:"",organization:"",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}),Hl=()=>({name:"",number:"",auditor:"",manager:"",organization:"",incident_initial_evaluation:0,idea_initial_evaluation:0,status:"Pending",requested_on:"",remarks:""}),X1=new Set(["incidents","incidents-form","ideas","ideas-form"]),q1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),J1=new Set(Xf.flatMap(({id:e})=>[e,`${e}-form`])),V1=new Set(["Admin","Owner","Auditor","Manager"]),Z1=new Set(["Admin","Owner","Auditor","Manager"]),ev=new Set(["Admin","Auditor","Manager"]);function tv({user:e,onLogout:n,darkMode:s,onToggleDark:l}){const r=ne(),a=e.role,i=V1.has(a),d=Z1.has(a),p=ev.has(a),u=j=>j==="users"||j==="users-form"?a==="Admin":a==="Admin"||a==="Auditor"?!0:a==="Owner"||a==="XAuditor"?!1:a==="Manager"?!!q1.has(j):X1.has(j),C=j=>a==="Employee"&&!!j&&j!=="New",x=i?"dashboard":"inbox",m=j=>j==="dashboard"?i:j==="reports"?d:j==="delegations"||j==="delegations-form"?p:j==="users"||j==="users-form"?a==="Admin":J1.has(j)?a==="Admin"||a==="Auditor":!0,[h,b]=S.useState(()=>{const j=n0(bu());return j&&m(j)?j:x});S.useEffect(()=>{const j=s0(h);window.location.hash!==j&&window.history.pushState(null,"",j)},[h]),S.useEffect(()=>{const j=()=>{const N=bu();b(N&&m(N)?N:x)};return window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)},[]);const _=e.custom_organization||"",[v,g]=S.useState(""),[o,c]=S.useState("");S.useEffect(()=>{if(!o)return;const j=setTimeout(()=>c(""),0);return()=>clearTimeout(j)},[o]);const y=(j,N)=>{c(N),b(j)},[z,k]=S.useState(0),[f,w]=S.useState([]),[I,P]=S.useState([]),[Y,F]=S.useState([]),[$,U]=S.useState([]),[E,D]=S.useState([]),[H,G]=S.useState([]),[X,J]=S.useState([]),[W,Z]=S.useState([]),[pe,be]=S.useState([]),[ae,Je]=S.useState([]),[it,Q]=S.useState([]),[oe,Oe]=S.useState([]),[ye,tn]=S.useState([]),[fe,ve]=S.useState([]),[zt,Ne]=S.useState([]),[L,se]=S.useState([]),[R,We]=S.useState([]),[ut,M]=S.useState([]),[Be,ii]=S.useState([]),[hn,Pr]=S.useState({}),[B,It]=S.useState([]),[gn,An]=S.useState([]),[Wd,ih]=S.useState([]),[Bd,oh]=S.useState([]),[$d,dh]=S.useState([]),[oi,ch]=S.useState({}),[di,uh]=S.useState([]),Ar=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[Ud,As]=S.useState(Ar()),[_e,he]=S.useState(!0),[Ge,ie]=S.useState("idle"),[Ke,te]=S.useState(!1),[Fd,Md]=S.useState(!1),[Rr,Hd]=S.useState(null),[ph,fh]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),hh=()=>fh(j=>{const N=!j;return localStorage.setItem("sb_sidebar",N?"1":"0"),N}),[gh,ci]=S.useState(!1),[xh,$e]=S.useState([]),[mh,Ue]=S.useState([]);S.useEffect(()=>{ci(!1),$e([]),Ue([])},[h]);const[xn,mn]=S.useState(bn()),[yn,nn]=S.useState(on()),[ls,sn]=S.useState(dn()),[rs,ln]=S.useState(ea()),[Gd,Rs]=S.useState(Ms()),[Kd,as]=S.useState(us()),[Qd,is]=S.useState(ps()),[Yd,os]=S.useState(fs()),[Xd,Ds]=S.useState(Hs()),[qd,Ls]=S.useState(Gs()),[Jd,Os]=S.useState(Ks()),[Vd,Ns]=S.useState(Qs()),[Zd,Ws]=S.useState(Ys()),[ec,Bs]=S.useState(Xs()),[tc,$s]=S.useState(qs()),[nc,Us]=S.useState(Js()),[El,Dr]=S.useState(ta()),[sc,ds]=S.useState(hs()),[lc,cs]=S.useState(gs()),[Ht,Pl]=S.useState(Hl()),Tt=async()=>{he(!0);try{const[j,N,we,Gt,Rn,Ae,hi,pg,fg,hg,gg,xg,mg,yg,vg,jg,bg,Sg,wg,kg,_g,Cg,zg,Ig,Tg,Eg,Pg]=await Promise.all([Ee(O.incidents),Ee(O.organizations),Ee(O.ideas),Ee(O.orders),Ee(O.processes),ky(),Ee(O.managements),Ee(O.departments),Ee(O.branches),Ee(O.incidentTypes),Ee(O.incidentClass),Ee(O.incidentField),Ee(O.ideaTypes),Ee(O.orderTypes),Ee(O.processTypes),Ee(O.incidentStatuses),Ee(O.ideaStatuses),Ee(O.orderStatuses),Ee(O.processStatuses),Iy(),Ty(),Ee(O.cycles),Ee(O.kpiInput),Qy(),Xy(),qy(),Jy()]);w(j||[]),P(N||[]),F(we||[]),U(Gt||[]),D(Rn||[]),It(Ae||[]),G(hi||[]),J(pg||[]),Z(fg||[]),be(hg||[]),Je(gg||[]),Q(xg||[]),Oe(mg||[]),tn(yg||[]),ve(vg||[]),Ne(jg||[]),se(bg||[]),We(Sg||[]),M(wg||[]),ii(kg||[]),Pr(_g||{}),An(Cg||[]),ih(zg||[]),oh(Ig||[]),dh(Tg||[]),ch(Eg||{}),uh(Pg||[])}catch(j){console.error("Error loading data:",j)}he(!1)},rc=async()=>{try{const j=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(j.ok){const N=await j.json();k(Number(N.message)||0)}}catch{}};S.useEffect(()=>{Tt(),rc();const j=setInterval(rc,6e4);return()=>clearInterval(j)},[e.name]);const[pt,vn]=S.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),Te=(j,N,we)=>{vn({isOpen:!0,doctype:j,name:N,title:we||N,isDeleting:!1})},ac=j=>{const we={[O.incidents]:"incidents",[O.ideas]:"ideas",[O.orders]:"orders",[O.processes]:"processes",[O.organizations]:"organizations",[O.managements]:"managements",[O.departments]:"departments",[O.branches]:"branches",[O.cycles]:"cycles",[O.kpiInput]:"kpi-input",[O.incidentTypes]:"incident-types",[O.ideaTypes]:"idea-types",[O.orderTypes]:"order-types",[O.processTypes]:"process-types",[O.incidentStatuses]:"incident-statuses",[O.ideaStatuses]:"idea-statuses",[O.orderStatuses]:"order-statuses",[O.processStatuses]:"process-statuses",[O.groupCompanies]:"group-companies"}[j];we&&b(we)},ic=async j=>{vn(N=>({...N,isDeleting:!0}));try{const N=pt.doctype;await Wo(pt.doctype,pt.name,j,!1),vn(we=>({...we,isOpen:!1,isDeleting:!1})),await Tt(),h.endsWith("-form")&&ac(N)}catch(N){console.error("Delete error:",N),alert((N==null?void 0:N.message)||"Delete failed. Please try again."),vn(we=>({...we,isDeleting:!1}))}},oc=async j=>{vn(N=>({...N,isDeleting:!0}));try{const N=pt.doctype;await Wo(pt.doctype,pt.name,j,!0),vn(we=>({...we,isOpen:!1,isDeleting:!1})),await Tt(),h.endsWith("-form")&&ac(N)}catch(N){console.error("Permanent delete error:",N),alert((N==null?void 0:N.message)||"Permanent delete failed. Please try again."),vn(we=>({...we,isDeleting:!1}))}},Al=async(j,N)=>{if(window.confirm(r.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){he(!0);try{await wy(j,N),alert(r.restoredOk||"Record restored successfully!"),await Tt()}catch(we){console.error("Restore error:",we),alert((we==null?void 0:we.message)||"Restore failed. Please try again.")}he(!1)}},yh=async j=>{try{await Ry(j),await Tt()}catch(N){console.error("Disable user error:",N)}},vh=async j=>{te(!0),he(!0);try{const N=await Et(O.incidents,j.name);mn({...bn(),...N})}catch{mn({...bn(),...j})}b("incidents-form"),he(!1)},jh=async j=>{te(!0),he(!0);try{const N=await Et(O.ideas,j.name);nn({...on(),...N})}catch{nn({...on(),...j})}b("ideas-form"),he(!1)},bh=async j=>{te(!0),he(!0);try{const N=await Et(O.orders,j.name);sn({...dn(),...N})}catch{sn({...dn(),...j})}b("orders-form"),he(!1)},Sh=async j=>{te(!0),he(!0);try{const N=await Xl(j.name);ln({...N,progress_indicators:N.progress_indicators||[],cycle_logs:N.cycle_logs||[]}),b("processes-form")}catch{ln({...j,progress_indicators:j.progress_indicators||[]}),b("processes-form")}he(!1)},wh=j=>Se(O.organizations,j,Rs,Ms(),"organizations-form",!0),kh=j=>{te(!0),As(j),b("group-companies-form")},_h=j=>{te(!1),As(j),b("group-companies-form")},Ch=async j=>{te(!0),he(!0);try{const N=await Et(O.managements,j.name);as({...us(),...N})}catch{as({...us(),...j})}b("managements-form"),he(!1)},zh=async j=>{te(!0),he(!0);try{const N=await Et(O.departments,j.name);is({...ps(),...N})}catch{is({...ps(),...j})}b("departments-form"),he(!1)},Ih=async j=>{te(!0),he(!0);try{const N=await Et(O.branches,j.name);os({...fs(),...N})}catch{os({...fs(),...j})}b("branches-form"),he(!1)},Th=async j=>{te(!0),he(!0);try{const N=await Et(O.cycles,j.name);ds({...hs(),...N})}catch{ds({...hs(),...j})}b("cycles-form"),he(!1)},Eh=async j=>{te(!0),he(!0);try{const N=await Et(O.kpiInput,j.name);cs({...gs(),...N})}catch{cs({...gs(),...j})}b("kpi-input-form"),he(!1)},tt=async(j,N,we,Gt,Rn)=>{ie("loading");try{if(N.name)await Ba(j,N.name,N),ie("success"),Tt(),setTimeout(()=>{ie("idle"),b(Gt)},1500);else if(Rn){const Ae=await Ui(j,N);Rn((Ae==null?void 0:Ae.data)??Ae),ie("success"),Tt(),setTimeout(()=>ie("idle"),1500)}else await Ui(j,N),we(),ie("success"),Tt(),setTimeout(()=>{ie("idle"),b(Gt)},1500)}catch(Ae){console.error("Submit error:",Ae),ie(Ae instanceof Error?Ae.message:"Error saving. Please try again.")}},Fe=async()=>{await Cy(),n()},Se=async(j,N,we,Gt,Rn,Ae)=>{te(Ae),he(!0);try{const hi=await Et(j,N.name);we({...Gt,...hi})}catch{we({...Gt,...N})}b(Rn),he(!1)},Ph=j=>Se(O.incidents,j,mn,bn(),"incidents-form",!1),Ah=j=>Se(O.ideas,j,nn,on(),"ideas-form",!1),Rh=j=>Se(O.orders,j,sn,dn(),"orders-form",!1),Dh=j=>{te(!1),he(!0),Xl(j.name).then(N=>{ln({...N,progress_indicators:N.progress_indicators||[],cycle_logs:N.cycle_logs||[]})}).catch(()=>{ln({...j,progress_indicators:j.progress_indicators||[]})}).finally(()=>{b("processes-form"),he(!1)})},Lh=j=>Se(O.organizations,j,Rs,Ms(),"organizations-form",!1),Oh=j=>Se(O.managements,j,as,us(),"managements-form",!1),Nh=j=>Se(O.departments,j,is,ps(),"departments-form",!1),Wh=j=>Se(O.branches,j,os,fs(),"branches-form",!1),Bh=j=>Se(O.cycles,j,ds,hs(),"cycles-form",!1),$h=j=>Se(O.kpiInput,j,cs,gs(),"kpi-input-form",!1),Uh=async j=>{te(!0),he(!0);try{const N=await Yy(j.name);Pl({...Hl(),...N})}catch{Pl({...Hl(),...j})}b("delegations-form"),he(!1)},Fh=async()=>{ie("loading");try{const j=[];Ht.incident_initial_evaluation&&j.push("incident_initial_evaluation"),Ht.idea_initial_evaluation&&j.push("idea_initial_evaluation"),await Hy(Ht.manager,j,Ht.organization,Ht.remarks||"",Ht.incident_name||"",Ht.idea_name||""),Pl(Hl()),ie("success"),Tt(),setTimeout(()=>{ie("idle"),b("delegations")},1500)}catch(j){console.error("Delegation submit error:",j),ie(j instanceof Error?j.message:"Error saving. Please try again.")}},Mh=async j=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){he(!0);try{await Ky(j),await Tt()}catch(N){console.error("Revoke delegation error:",N),alert(N instanceof Error?N.message:"Revoke failed. Please try again.")}he(!1)}},Hh=j=>Se(O.incidentTypes,j,Ds,Hs(),"incident-types-form",!0),Gh=j=>Se(O.incidentTypes,j,Ds,Hs(),"incident-types-form",!1),Kh=j=>Se(O.ideaTypes,j,Ls,Gs(),"idea-types-form",!0),Qh=j=>Se(O.ideaTypes,j,Ls,Gs(),"idea-types-form",!1),Yh=j=>Se(O.orderTypes,j,Os,Ks(),"order-types-form",!0),Xh=j=>Se(O.orderTypes,j,Os,Ks(),"order-types-form",!1),qh=j=>Se(O.processTypes,j,Ns,Qs(),"process-types-form",!0),Jh=j=>Se(O.processTypes,j,Ns,Qs(),"process-types-form",!1),Vh=j=>Se(O.incidentStatuses,j,Ws,Ys(),"incident-statuses-form",!0),Zh=j=>Se(O.incidentStatuses,j,Ws,Ys(),"incident-statuses-form",!1),eg=j=>Se(O.ideaStatuses,j,Bs,Xs(),"idea-statuses-form",!0),tg=j=>Se(O.ideaStatuses,j,Bs,Xs(),"idea-statuses-form",!1),ng=j=>Se(O.orderStatuses,j,$s,qs(),"order-statuses-form",!0),sg=j=>Se(O.orderStatuses,j,$s,qs(),"order-statuses-form",!1),lg=j=>Se(O.processStatuses,j,Us,Js(),"process-statuses-form",!0),rg=j=>Se(O.processStatuses,j,Us,Js(),"process-statuses-form",!1),ag=async j=>{Hd(j),b("profile")},ig=j=>{te(!1),Md(!1),Dr({...ta(),...j}),b("users-form")},og=async()=>{ie("loading");try{if(!El.name){const N=await Ui("User",{...El,send_welcome_email:0,user_type:"System User"});Dr({...ta(),...El,...(N==null?void 0:N.data)??N}),te(!0),ie("success"),Tt(),setTimeout(()=>ie("idle"),1500)}else{const{name:N,email:we,creation:Gt,full_name:Rn,...Ae}=El;await Ba("User",N,Ae),ie("success"),Tt(),setTimeout(()=>{ie("idle"),b("users")},1500)}}catch(j){console.error("User submit error:",j),ie(j instanceof Error?j.message:"Error saving. Please try again.")}},Me=()=>{const j=Be.find(N=>N.name===e.name||N.username===e.name);Hd(j||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),b("profile")},ui=(j,N)=>{if(N){const Gt={"processes-form":O.processes,"orders-form":O.orders,"incidents-form":O.incidents,"ideas-form":O.ideas}[j];if(Gt){te(!0),he(!0),(j==="processes-form"?Xl(N).then(Ae=>({...Ae,progress_indicators:Ae.progress_indicators||[],cycle_logs:Ae.cycle_logs||[]})):Et(Gt,N)).then(Ae=>{j==="processes-form"?ln(Ae):j==="orders-form"?sn({...dn(),...Ae}):j==="incidents-form"?mn({...bn(),...Ae}):j==="ideas-form"&&nn({...on(),...Ae}),b(j),he(!1)}).catch(()=>{b(j),he(!1)});return}}b(j)},Qe=j=>t.jsxs(t.Fragment,{children:[j,t.jsx(vu,{isOpen:pt.isOpen,doctype:pt.doctype,docname:pt.name,docTitle:pt.title,isAdmin:a==="Admin"||e.name==="Administrator",isDeleting:pt.isDeleting,onClose:()=>vn(N=>({...N,isOpen:!1})),onConfirmSoftDelete:ic,onConfirmPermanentDelete:oc})]});if(h==="incidents-form")return Qe(t.jsx(j0,{incForm:xn,setIncForm:mn,organizations:I,managements:H,departments:X,branches:W,incidentTypes:pe,incidentClasses:ae,incidentFields:it,incidentStatuses:zt,users:B,userRoleMap:hn,formStatus:Ge,viewMode:Ke||!u("incidents-form")||C(xn.workflow_state),canModify:u("incidents-form"),onEdit:u("incidents-form")&&!C(xn.workflow_state)&&!Fn("incident",xn.workflow_state)?()=>te(!1):void 0,onDelete:u("incidents-form")?j=>Te(O.incidents,j,xn.title||xn.number):void 0,onRestore:a==="Admin"?j=>Al(O.incidents,j):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,userRole:a,delegatedFunctions:$d,delegatedOrgs:oi,onSubmit:()=>tt(O.incidents,xn,()=>mn(bn()),"incidents",j=>mn({...bn(),...j})),onBack:()=>{b("incidents"),ie("idle")},onNavigate:b,onLogout:Fe,user:e,onRefresh:async()=>{if(xn.name){const j=await Et(O.incidents,xn.name).catch(()=>null);j&&mn({...bn(),...j})}Ee(O.incidents).then(j=>w(j||[])).catch(()=>{})}}));if(h==="ideas-form")return Qe(t.jsx(k0,{ideaForm:yn,setIdeaForm:nn,organizations:I,managements:H,departments:X,branches:W,ideaTypes:oe,ideaStatuses:L,users:B,userRoleMap:hn,formStatus:Ge,viewMode:Ke||!u("ideas-form")||C(yn.workflow_state),canModify:u("ideas-form"),onEdit:u("ideas-form")&&!C(yn.workflow_state)&&!Fn("idea",yn.workflow_state)?()=>te(!1):void 0,onDelete:u("ideas-form")?j=>Te(O.ideas,j,yn.title||yn.number):void 0,onRestore:a==="Admin"?j=>Al(O.ideas,j):void 0,onNavigateToOrder:j=>Se(O.orders,{name:j},sn,dn(),"orders-form",!0),darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,userRole:a,delegatedFunctions:$d,delegatedOrgs:oi,onSubmit:()=>tt(O.ideas,yn,()=>nn(on()),"ideas",j=>nn({...on(),...j})),onBack:()=>{b("ideas"),ie("idle")},onNavigate:b,onLogout:Fe,user:e,onRefresh:async()=>{if(yn.name){const j=await Et(O.ideas,yn.name).catch(()=>null);j&&nn({...on(),...j})}Ee(O.ideas).then(j=>F(j||[])).catch(()=>{})}}));if(h==="orders-form")return Qe(t.jsx(T0,{orderForm:ls,setOrderForm:sn,organizations:I,managements:H,departments:X,branches:W,orderTypes:ye,orderStatuses:R,cycles:gn,users:B,userRoleMap:hn,formStatus:Ge,viewMode:Ke||!u("orders-form"),canModify:u("orders-form"),onEdit:u("orders-form")&&!Fn("order",ls.workflow_state)?()=>te(!1):void 0,onDelete:u("orders-form")?j=>Te(O.orders,j,ls.title||ls.number):void 0,onRestore:a==="Admin"?j=>Al(O.orders,j):void 0,onNavigateToIdea:j=>Se(O.ideas,{name:j},nn,on(),"ideas-form",!0),darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,currentUser:e.name,userRole:a,onSubmit:()=>tt(O.orders,ls,()=>sn(dn()),"orders",j=>sn({...dn(),...j})),onBack:()=>{b("orders"),ie("idle")},onNavigate:b,onLogout:Fe,user:e,onRefresh:async()=>{if(ls.name){const j=await Et(O.orders,ls.name).catch(()=>null);j&&sn({...dn(),...j})}Ee(O.orders).then(j=>U(j||[])).catch(()=>{})}}));if(h==="processes-form")return Qe(t.jsx(D0,{processForm:rs,setProcessForm:ln,organizations:I,managements:H,departments:X,branches:W,processTypes:fe,processStatuses:ut,cycles:gn,users:B,userRoleMap:hn,formStatus:Ge,viewMode:Ke||!u("processes-form"),canModify:u("processes-form"),onEdit:u("processes-form")&&!Fn("process",rs.workflow_state)?()=>te(!1):void 0,onDelete:u("processes-form")?j=>Te(O.processes,j,rs.title||rs.number):void 0,onRestore:a==="Admin"?j=>Al(O.processes,j):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,userRole:e.role,onRefreshProcess:async()=>{if(rs.name)try{const j=await Xl(rs.name);ln({...j,progress_indicators:j.progress_indicators||[],cycle_logs:j.cycle_logs||[]})}catch{}Ee(O.processes).then(j=>D(j||[])).catch(()=>{})},onSubmit:()=>tt(O.processes,rs,()=>ln(ea()),"processes",j=>ln({...ea(),...j,progress_indicators:j.progress_indicators||[],cycle_logs:j.cycle_logs||[]})),onBack:()=>{b("processes"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="organizations-form")return Qe(t.jsx($0,{orgForm:Gd,setOrgForm:Rs,groupCompanies:di,formStatus:Ge,viewMode:Ke||!u("organizations-form"),onEdit:u("organizations-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.organizations,Gd,()=>Rs(Ms()),"organizations",j=>{Rs({...Ms(),...j}),te(!0)}),onBack:()=>{b("organizations"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="managements-form")return Qe(t.jsx(G0,{form:Kd,setForm:as,organizations:I,formStatus:Ge,viewMode:Ke||!u("managements-form"),onEdit:u("managements-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.managements,Kd,()=>as(us()),"managements",j=>{as({...us(),...j}),te(!0)}),onBack:()=>{b("managements"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="departments-form")return Qe(t.jsx(Y0,{form:Qd,setForm:is,organizations:I,managements:H,formStatus:Ge,viewMode:Ke||!u("departments-form"),onEdit:u("departments-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.departments,Qd,()=>is(ps()),"departments",j=>{is({...ps(),...j}),te(!0)}),onBack:()=>{b("departments"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="branches-form")return Qe(t.jsx(J0,{form:Yd,setForm:os,organizations:I,managements:H,departments:X,formStatus:Ge,viewMode:Ke||!u("branches-form"),onEdit:u("branches-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.branches,Yd,()=>os(fs()),"branches",j=>{os({...fs(),...j}),te(!0)}),onBack:()=>{b("branches"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="cycles-form")return Qe(t.jsx(T1,{form:sc,setForm:ds,organizations:I,formStatus:Ge,viewMode:Ke||!u("cycles-form"),onEdit:u("cycles-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.cycles,sc,()=>ds(hs()),"cycles",j=>{ds({...hs(),...j}),te(!0)}),onBack:()=>{b("cycles"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="kpi-input-form")return Qe(t.jsx(P1,{form:lc,setForm:cs,organizations:I,formStatus:Ge,viewMode:Ke||!u("kpi-input-form"),onEdit:u("kpi-input-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.kpiInput,lc,()=>cs(gs()),"kpi-input",j=>{cs({...gs(),...j}),te(!0)}),onBack:()=>{b("kpi-input"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="incident-types-form")return Qe(t.jsx(e1,{form:Xd,setForm:Ds,formStatus:Ge,viewMode:Ke||!u("incident-types-form"),onEdit:u("incident-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.incidentTypes,Xd,()=>Ds(Hs()),"incident-types",j=>{Ds({...Hs(),...j}),te(!0)}),onBack:()=>{b("incident-types"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="idea-types-form")return Qe(t.jsx(s1,{form:qd,setForm:Ls,formStatus:Ge,viewMode:Ke||!u("idea-types-form"),onEdit:u("idea-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.ideaTypes,qd,()=>Ls(Gs()),"idea-types",j=>{Ls({...Gs(),...j}),te(!0)}),onBack:()=>{b("idea-types"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="order-types-form")return Qe(t.jsx(a1,{form:Jd,setForm:Os,formStatus:Ge,viewMode:Ke||!u("order-types-form"),onEdit:u("order-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.orderTypes,Jd,()=>Os(Ks()),"order-types",j=>{Os({...Ks(),...j}),te(!0)}),onBack:()=>{b("order-types"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="process-types-form")return Qe(t.jsx(d1,{form:Vd,setForm:Ns,formStatus:Ge,viewMode:Ke||!u("process-types-form"),onEdit:u("process-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.processTypes,Vd,()=>Ns(Qs()),"process-types",j=>{Ns({...Qs(),...j}),te(!0)}),onBack:()=>{b("process-types"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="incident-statuses-form")return Qe(t.jsx(p1,{form:Zd,setForm:Ws,formStatus:Ge,viewMode:Ke||!u("incident-statuses-form"),onEdit:u("incident-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.incidentStatuses,Zd,()=>Ws(Ys()),"incident-statuses",j=>{Ws({...Ys(),...j}),te(!0)}),onBack:()=>{b("incident-statuses"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="idea-statuses-form")return Qe(t.jsx(g1,{form:ec,setForm:Bs,formStatus:Ge,viewMode:Ke||!u("idea-statuses-form"),onEdit:u("idea-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.ideaStatuses,ec,()=>Bs(Xs()),"idea-statuses",j=>{Bs({...Xs(),...j}),te(!0)}),onBack:()=>{b("idea-statuses"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="order-statuses-form")return Qe(t.jsx(y1,{form:tc,setForm:$s,formStatus:Ge,viewMode:Ke||!u("order-statuses-form"),onEdit:u("order-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.orderStatuses,tc,()=>$s(qs()),"order-statuses",j=>{$s({...qs(),...j}),te(!0)}),onBack:()=>{b("order-statuses"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="process-statuses-form")return Qe(t.jsx(b1,{form:nc,setForm:Us,formStatus:Ge,viewMode:Ke||!u("process-statuses-form"),onEdit:u("process-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.processStatuses,nc,()=>Us(Js()),"process-statuses",j=>{Us({...Js(),...j}),te(!0)}),onBack:()=>{b("process-statuses"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="users-form")return Qe(t.jsx(_1,{form:El,setForm:Dr,groupCompanies:di,organizations:I,managements:H,departments:X,branches:W,formStatus:Ge,viewMode:Ke||!u("users-form"),onEdit:u("users-form")?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,isSelfProfile:Fd,onSubmit:og,onBack:()=>{b(Fd?i?"dashboard":"inbox":"users"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="delegations-form"){const j=Ht.status==="Revoked"||Ht.status==="Accepted"||Ht.status==="Rejected";return Qe(t.jsx(N1,{form:Ht,setForm:Pl,organizations:I,users:B,userRoleMap:hn,incidents:f,ideas:Y,formStatus:Ge,viewMode:Ke||!u("delegations-form")||j,onEdit:u("delegations-form")&&!j?()=>te(!1):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:Fh,onBack:()=>{b("delegations"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}))}if(h==="group-companies-form")return Qe(t.jsx(F0,{form:Ud,setForm:As,users:B,formStatus:Ge,viewMode:Ke||!u("group-companies-form"),onEdit:u("group-companies-form")?()=>te(!1):void 0,onRestore:a==="Admin"?j=>Al(O.groupCompanies,j):void 0,darkMode:s,notifCount:z,onToggleDark:l,onCountChange:k,onViewProfile:Me,onSubmit:()=>tt(O.groupCompanies,Ud,()=>As(Ar()),"group-companies",j=>{As({...Ar(),...j}),te(!0)}),onBack:()=>{b("group-companies"),ie("idle")},onNavigate:b,onLogout:Fe,user:e}));const pi={...r.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},dg={"group-companies":{color:q.purple,formPage:"group-companies-form",reset:()=>As(Ar())},incidents:{color:q.accent,formPage:"incidents-form",reset:()=>mn({...bn(),organization:_||v})},ideas:{color:q.teal,formPage:"ideas-form",reset:()=>nn({...on(),organization:_||v})},orders:{color:q.purple,formPage:"orders-form",reset:()=>sn({...dn(),organization:_||v})},processes:{color:q.blue,formPage:"processes-form",reset:()=>{const j=oi.create_processes,N=_||(a==="Manager"&&j&&j.length===1?j[0]:v);ln({...ea(),organization:N})}},organizations:{color:q.accent,formPage:"organizations-form",reset:()=>Rs(Ms())},managements:{color:q.blue,formPage:"managements-form",reset:()=>as({...us(),organization:_||v})},departments:{color:q.teal,formPage:"departments-form",reset:()=>is({...ps(),custom_organization:_||v})},branches:{color:q.purple,formPage:"branches-form",reset:()=>os({...fs(),organization:_||v})},cycles:{color:q.teal,formPage:"cycles-form",reset:()=>ds({...hs(),organization:_||v})},"kpi-input":{color:q.blue,formPage:"kpi-input-form",reset:()=>cs({...gs(),organization:_||v})},"incident-types":{color:q.red,formPage:"incident-types-form",reset:()=>Ds(Hs())},"idea-types":{color:q.orange,formPage:"idea-types-form",reset:()=>Ls(Gs())},"order-types":{color:q.green,formPage:"order-types-form",reset:()=>Os(Ks())},"process-types":{color:q.accent,formPage:"process-types-form",reset:()=>Ns(Qs())},"incident-statuses":{color:q.red,formPage:"incident-statuses-form",reset:()=>Ws(Ys())},"idea-statuses":{color:q.teal,formPage:"idea-statuses-form",reset:()=>Bs(Xs())},"order-statuses":{color:q.purple,formPage:"order-statuses-form",reset:()=>$s(qs())},"process-statuses":{color:q.blue,formPage:"process-statuses-form",reset:()=>Us(Js())},users:{color:q.blue,formPage:"users-form",reset:()=>{Dr(ta()),Md(!1)}},delegations:{color:q.purple,formPage:"delegations-form",reset:()=>Pl(Hl())}},cg={"group-companies":"New Group Company",incidents:r.formTitle.newIncident,ideas:r.formTitle.newIdea,orders:r.formTitle.newOrder,processes:r.formTitle.newProcess,organizations:r.formTitle.newOrg,managements:r.formTitle.newMgmt,departments:r.formTitle.newDept,branches:r.formTitle.newBranch,users:r.formTitle.newUser,cycles:r.formTitle.newCycle,"kpi-input":r.formTitle.newKpi,delegations:r.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"},ug={incidents:f,ideas:Y,orders:$,processes:E,organizations:I,managements:H,departments:X,branches:W,cycles:gn,"kpi-input":Wd,"incident-types":pe,"idea-types":oe,"order-types":ye,"process-types":fe,"incident-statuses":zt,"idea-statuses":L,"order-statuses":R,"process-statuses":ut,users:Be,delegations:Bd},Rl=iy[h],Dl=ug[h],ee=u(h),fi=ee?dg[h]:null;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":q.bg},children:[t.jsx(eh,{collapsed:ph,onToggleCollapsed:hh,activePage:h,onNavigate:j=>b(j),hasDashboard:i,hasReports:d,hasDelegations:p,role:a,rtl:r.rtl,navLabels:r.nav,settingsLabel:r.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(lh,{notifCount:z,darkMode:s,onCountChange:k,onToggleDark:l,onNavigate:ui,onViewProfile:Me,onLogout:Fe,userName:e.full_name||e.name,userRole:a})}),h!=="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:pi[h]||h}),Dl&&t.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Dl.length," ",pi[h]?pi[h].toLowerCase():"records"]})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[Rl&&Dl&&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(),te(!1),ie("idle"),b(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:["+ ",cg[h]||r.new]})]})]}),Rl&&Dl&&gh&&t.jsx(jy,{title:Rl.label,rows:Dl,selectedRows:xh,pageRows:mh,columns:Rl.columns,defaultColumnKeys:Rl.defaultColumns,filenameBase:h,onClose:()=>ci(!1)}),t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:h==="profile"?0:"20px 24px",gap:h==="profile"?0:16},children:[_e&&t.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:r.loading}),!_e&&h==="dashboard"&&i&&t.jsx(c0,{incidents:f,ideas:Y,orders:$,processes:E,organizations:I,incidentStatuses:zt,ideaStatuses:L,orderStatuses:R,processStatuses:ut,selectedOrg:v,onOrgChange:g,onNavigate:ui,onNavigateStatus:y,userRole:a}),!_e&&h==="inbox"&&t.jsx(U1,{onNavigate:ui,onRefresh:Tt}),!_e&&h==="reports"&&d&&t.jsx(Q1,{organizations:I,userRole:a}),!_e&&h==="incidents"&&t.jsx(u0,{incidents:f,organizations:I,departments:X,branches:W,incidentStatuses:zt,initialOrg:v,initialStatus:o,onView:vh,onEdit:ee?Ph:void 0,onDelete:ee?j=>Te(O.incidents,j):void 0,canModify:ee,userRole:a,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="ideas"&&t.jsx(b0,{ideas:Y,organizations:I,departments:X,branches:W,ideaStatuses:L,initialOrg:v,initialStatus:o,onView:jh,onEdit:ee?Ah:void 0,onDelete:ee?j=>Te(O.ideas,j):void 0,canModify:ee,userRole:a,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="orders"&&t.jsx(_0,{orders:$,organizations:I,departments:X,branches:W,orderStatuses:R,initialOrg:v,initialStatus:o,onView:bh,onEdit:ee?Rh:void 0,onDelete:ee?j=>Te(O.orders,j):void 0,canModify:ee,userRole:a,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="processes"&&t.jsx(E0,{processes:E,organizations:I,departments:X,branches:W,processStatuses:ut,initialOrg:v,initialStatus:o,onView:Sh,onEdit:ee?Dh:void 0,onDelete:ee?j=>Te(O.processes,j):void 0,canModify:ee,userRole:a,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="organizations"&&t.jsx(B0,{organizations:I,onView:wh,onEdit:ee?Lh:void 0,onDelete:ee?j=>Te(O.organizations,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="group-companies"&&t.jsx(U0,{groupCompanies:di,onView:kh,onEdit:ee?_h:void 0,onDelete:ee?j=>Te(O.groupCompanies,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="managements"&&t.jsx(H0,{managements:H,onView:Ch,onEdit:ee?Oh:void 0,onDelete:ee?j=>Te(O.managements,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="departments"&&t.jsx(Q0,{departments:X,managements:H,onView:zh,onEdit:ee?Nh:void 0,onDelete:ee?j=>Te(O.departments,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="branches"&&t.jsx(q0,{branches:W,managements:H,departments:X,onView:Ih,onEdit:ee?Wh:void 0,onDelete:ee?j=>Te(O.branches,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="cycles"&&t.jsx(C1,{cycles:gn,canModify:ee,onView:Th,onEdit:ee?Bh:void 0,onDelete:ee?j=>Te(O.cycles,j):void 0,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="kpi-input"&&t.jsx(E1,{kpiInputs:Wd,canModify:ee,onView:Eh,onEdit:ee?$h:void 0,onDelete:ee?j=>Te(O.kpiInput,j):void 0,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="incident-types"&&t.jsx(Z0,{incidentTypes:pe,onView:Hh,onEdit:ee?Gh:void 0,onDelete:ee?j=>Te(O.incidentTypes,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="idea-types"&&t.jsx(n1,{ideaTypes:oe,onView:Kh,onEdit:ee?Qh:void 0,onDelete:ee?j=>Te(O.ideaTypes,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="order-types"&&t.jsx(r1,{orderTypes:ye,onView:Yh,onEdit:ee?Xh:void 0,onDelete:ee?j=>Te(O.orderTypes,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="process-types"&&t.jsx(o1,{processTypes:fe,onView:qh,onEdit:ee?Jh:void 0,onDelete:ee?j=>Te(O.processTypes,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="incident-statuses"&&t.jsx(u1,{incidentStatuses:zt,onView:Vh,onEdit:ee?Zh:void 0,onDelete:ee?j=>Te(O.incidentStatuses,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="idea-statuses"&&t.jsx(h1,{ideaStatuses:L,onView:eg,onEdit:ee?tg:void 0,onDelete:ee?j=>Te(O.ideaStatuses,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="order-statuses"&&t.jsx(m1,{orderStatuses:R,onView:ng,onEdit:ee?sg:void 0,onDelete:ee?j=>Te(O.orderStatuses,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="process-statuses"&&t.jsx(j1,{processStatuses:ut,onView:lg,onEdit:ee?rg:void 0,onDelete:ee?j=>Te(O.processStatuses,j):void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="users"&&t.jsx(k1,{users:Be,roleMap:hn,onView:ag,onEdit:ee?ig:void 0,onDelete:ee?j=>Te("User",j):void 0,onDisable:ee?yh:void 0,canModify:ee,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),!_e&&h==="delegations"&&p&&t.jsx(L1,{delegations:Bd,organizations:I,userRole:a,currentUser:e.name,onView:Uh,onRevoke:ee?Mh:void 0,onSelectionChange:(j,N)=>{$e(j),Ue(N)}}),h==="profile"&&(()=>{const j=!!Rr&&(Rr.name===e.name||Rr.email===e.name);return t.jsx(O0,{user:e,profileUser:Rr,sbUsers:Be,organizations:I,managements:H,departments:X,branches:W,darkMode:s,canModify:ee||j,onBack:()=>b(j?i?"dashboard":"inbox":"users"),onNavigate:b})})()]})]}),t.jsx(vu,{isOpen:pt.isOpen,doctype:pt.doctype,docname:pt.name,docTitle:pt.title,isAdmin:a==="Admin"||e.name==="Administrator",isDeleting:pt.isDeleting,onClose:()=>vn(j=>({...j,isOpen:!1})),onConfirmSoftDelete:ic,onConfirmPermanentDelete:oc})]})}function nv(e){return 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 sv(){const[e,n]=S.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[s,l]=S.useState(()=>localStorage.getItem("sb_dark")==="1"),r=()=>{const d=!s;l(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&&th().then(async d=>{const p=d||e.name,u=await sh(p);if(!u.length)return;const C=nv(u),x=await Ny();if(C!==e.role||p!==e.name||x!==(e.custom_organization||"")){const h={...e,name:p,role:C,custom_organization:x};n(h),localStorage.setItem("sidrah_user",JSON.stringify(h))}})},[e==null?void 0:e.name]);const a=d=>{n(d),localStorage.setItem("sidrah_user",JSON.stringify(d))},i=()=>{n(null),localStorage.removeItem("sidrah_user")};return e?t.jsx(tv,{user:e,onLogout:i,darkMode:s,onToggleDark:r}):t.jsx(l0,{onLogin:a})}Yf(document.getElementById("root")).render(t.jsx(S.StrictMode,{children:t.jsx(sv,{})}));