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

53 lines
506 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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 t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&l(a)}).observe(document,{childList:!0,subtree:!0});function s(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function l(r){if(r.ep)return;r.ep=!0;const i=s(r);fetch(r.href,i)}})();var Lu={exports:{}},Bi={},Du={exports:{}},de={};/**
* @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 gr=Symbol.for("react.element"),Ag=Symbol.for("react.portal"),Rg=Symbol.for("react.fragment"),Og=Symbol.for("react.strict_mode"),Lg=Symbol.for("react.profiler"),Dg=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"),rc=Symbol.iterator;function Fg(e){return e===null||typeof e!="object"?null:(e=rc&&e[rc]||e["@@iterator"],typeof e=="function"?e:null)}var Nu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Wu=Object.assign,Bu={};function gl(e,t,s){this.props=e,this.context=t,this.refs=Bu,this.updater=s||Nu}gl.prototype.isReactComponent={};gl.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};gl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function $u(){}$u.prototype=gl.prototype;function Bo(e,t,s){this.props=e,this.context=t,this.refs=Bu,this.updater=s||Nu}var $o=Bo.prototype=new $u;$o.constructor=Bo;Wu($o,gl.prototype);$o.isPureReactComponent=!0;var ic=Array.isArray,Uu=Object.prototype.hasOwnProperty,Uo={current:null},Fu={key:!0,ref:!0,__self:!0,__source:!0};function Mu(e,t,s){var l,r={},i=null,a=null;if(t!=null)for(l in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)Uu.call(t,l)&&!Fu.hasOwnProperty(l)&&(r[l]=t[l]);var c=arguments.length-2;if(c===1)r.children=s;else if(1<c){for(var d=Array(c),h=0;h<c;h++)d[h]=arguments[h+2];r.children=d}if(e&&e.defaultProps)for(l in c=e.defaultProps,c)r[l]===void 0&&(r[l]=c[l]);return{$$typeof:gr,type:e,key:i,ref:a,props:r,_owner:Uo.current}}function Mg(e,t){return{$$typeof:gr,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Fo(e){return typeof e=="object"&&e!==null&&e.$$typeof===gr}function Hg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var ac=/\/+/g;function pa(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Hg(""+e.key):t.toString(36)}function ei(e,t,s,l,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case gr:case Ag:a=!0}}if(a)return a=e,r=r(a),e=l===""?"."+pa(a,0):l,ic(r)?(s="",e!=null&&(s=e.replace(ac,"$&/")+"/"),ei(r,t,s,"",function(h){return h})):r!=null&&(Fo(r)&&(r=Mg(r,s+(!r.key||a&&a.key===r.key?"":(""+r.key).replace(ac,"$&/")+"/")+e)),t.push(r)),1;if(a=0,l=l===""?".":l+":",ic(e))for(var c=0;c<e.length;c++){i=e[c];var d=l+pa(i,c);a+=ei(i,t,s,d,r)}else if(d=Fg(e),typeof d=="function")for(e=d.call(e),c=0;!(i=e.next()).done;)i=i.value,d=l+pa(i,c++),a+=ei(i,t,s,d,r);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Tr(e,t,s){if(e==null)return e;var l=[],r=0;return ei(e,l,"","",function(i){return t.call(s,i,r++)}),l}function Gg(e){if(e._status===-1){var t=e._result;t=t(),t.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=t)}if(e._status===1)return e._result.default;throw e._result}var pt={current:null},ti={transition:null},Kg={ReactCurrentDispatcher:pt,ReactCurrentBatchConfig:ti,ReactCurrentOwner:Uo};function Hu(){throw Error("act(...) is not supported in production builds of React.")}de.Children={map:Tr,forEach:function(e,t,s){Tr(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return Tr(e,function(){t++}),t},toArray:function(e){return Tr(e,function(t){return t})||[]},only:function(e){if(!Fo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};de.Component=gl;de.Fragment=Rg;de.Profiler=Lg;de.PureComponent=Bo;de.StrictMode=Og;de.Suspense=Bg;de.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Kg;de.act=Hu;de.cloneElement=function(e,t,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,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Uo.current),t.key!==void 0&&(r=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(d in t)Uu.call(t,d)&&!Fu.hasOwnProperty(d)&&(l[d]=t[d]===void 0&&c!==void 0?c[d]:t[d])}var d=arguments.length-2;if(d===1)l.children=s;else if(1<d){c=Array(d);for(var h=0;h<d;h++)c[h]=arguments[h+2];l.children=c}return{$$typeof:gr,type:e.type,key:r,ref:i,props:l,_owner:a}};de.createContext=function(e){return e={$$typeof:Ng,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Dg,_context:e},e.Consumer=e};de.createElement=Mu;de.createFactory=function(e){var t=Mu.bind(null,e);return t.type=e,t};de.createRef=function(){return{current:null}};de.forwardRef=function(e){return{$$typeof:Wg,render:e}};de.isValidElement=Fo;de.lazy=function(e){return{$$typeof:Ug,_payload:{_status:-1,_result:e},_init:Gg}};de.memo=function(e,t){return{$$typeof:$g,type:e,compare:t===void 0?null:t}};de.startTransition=function(e){var t=ti.transition;ti.transition={};try{e()}finally{ti.transition=t}};de.unstable_act=Hu;de.useCallback=function(e,t){return pt.current.useCallback(e,t)};de.useContext=function(e){return pt.current.useContext(e)};de.useDebugValue=function(){};de.useDeferredValue=function(e){return pt.current.useDeferredValue(e)};de.useEffect=function(e,t){return pt.current.useEffect(e,t)};de.useId=function(){return pt.current.useId()};de.useImperativeHandle=function(e,t,s){return pt.current.useImperativeHandle(e,t,s)};de.useInsertionEffect=function(e,t){return pt.current.useInsertionEffect(e,t)};de.useLayoutEffect=function(e,t){return pt.current.useLayoutEffect(e,t)};de.useMemo=function(e,t){return pt.current.useMemo(e,t)};de.useReducer=function(e,t,s){return pt.current.useReducer(e,t,s)};de.useRef=function(e){return pt.current.useRef(e)};de.useState=function(e){return pt.current.useState(e)};de.useSyncExternalStore=function(e,t,s){return pt.current.useSyncExternalStore(e,t,s)};de.useTransition=function(){return pt.current.useTransition()};de.version="18.3.1";Du.exports=de;var w=Du.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=w,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,Zg={key:!0,ref:!0,__self:!0,__source:!0};function Gu(e,t,s){var l,r={},i=null,a=null;s!==void 0&&(i=""+s),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(l in t)qg.call(t,l)&&!Zg.hasOwnProperty(l)&&(r[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps,t)r[l]===void 0&&(r[l]=t[l]);return{$$typeof:Yg,type:e,key:i,ref:a,props:r,_owner:Jg.current}}Bi.Fragment=Xg;Bi.jsx=Gu;Bi.jsxs=Gu;Lu.exports=Bi;var n=Lu.exports,Ku={exports:{}},It={},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 t(O,H){var Y=O.length;O.push(H);e:for(;0<Y;){var V=Y-1>>>1,Z=O[V];if(0<r(Z,H))O[V]=H,O[Y]=Z,Y=V;else break e}}function s(O){return O.length===0?null:O[0]}function l(O){if(O.length===0)return null;var H=O[0],Y=O.pop();if(Y!==H){O[0]=Y;e:for(var V=0,Z=O.length,me=Z>>>1;V<me;){var fe=2*(V+1)-1,Xe=O[fe],se=fe+1,he=O[se];if(0>r(Xe,Y))se<Z&&0>r(he,Xe)?(O[V]=he,O[se]=Y,V=se):(O[V]=Xe,O[fe]=Y,V=fe);else if(se<Z&&0>r(he,Y))O[V]=he,O[se]=Y,V=se;else break e}}return H}function r(O,H){var Y=O.sortIndex-H.sortIndex;return Y!==0?Y:O.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,c=a.now();e.unstable_now=function(){return a.now()-c}}var d=[],h=[],j=1,p=null,u=3,y=!1,v=!1,f=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function o(O){for(var H=s(h);H!==null;){if(H.callback===null)l(h);else if(H.startTime<=O)l(h),H.sortIndex=H.expirationTime,t(d,H);else break;H=s(h)}}function m(O){if(f=!1,o(O),!v)if(s(d)!==null)v=!0,pe(_);else{var H=s(h);H!==null&&re(m,H.startTime-O)}}function _(O,H){v=!1,f&&(f=!1,g(C),C=-1),y=!0;var Y=u;try{for(o(H),p=s(d);p!==null&&(!(p.expirationTime>H)||O&&!D());){var V=p.callback;if(typeof V=="function"){p.callback=null,u=p.priorityLevel;var Z=V(p.expirationTime<=H);H=e.unstable_now(),typeof Z=="function"?p.callback=Z:p===s(d)&&l(d),o(H)}else l(d);p=s(d)}if(p!==null)var me=!0;else{var fe=s(h);fe!==null&&re(m,fe.startTime-H),me=!1}return me}finally{p=null,u=Y,y=!1}}var T=!1,E=null,C=-1,R=5,B=-1;function D(){return!(e.unstable_now()-B<R)}function L(){if(E!==null){var O=e.unstable_now();B=O;var H=!0;try{H=E(!0,O)}finally{H?z():(T=!1,E=null)}}else T=!1}var z;if(typeof x=="function")z=function(){x(L)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,M=A.port2;A.port1.onmessage=L,z=function(){M.postMessage(null)}}else z=function(){S(L,0)};function pe(O){E=O,T||(T=!0,z())}function re(O,H){C=S(function(){O(e.unstable_now())},H)}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(O){O.callback=null},e.unstable_continueExecution=function(){v||y||(v=!0,pe(_))},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return u},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(O){switch(u){case 1:case 2:case 3:var H=3;break;default:H=u}var Y=u;u=H;try{return O()}finally{u=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(O,H){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var Y=u;u=O;try{return H()}finally{u=Y}},e.unstable_scheduleCallback=function(O,H,Y){var V=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?V+Y:V):Y=V,O){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=Y+Z,O={id:j++,callback:H,priorityLevel:O,startTime:Y,expirationTime:Z,sortIndex:-1},Y>V?(O.sortIndex=Y,t(h,O),s(d)===null&&O===s(h)&&(f?(g(C),C=-1):f=!0,re(m,Y-V))):(O.sortIndex=Z,t(d,O),v||y||(v=!0,pe(_))),O},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(O){var H=u;return function(){var Y=u;u=H;try{return O.apply(this,arguments)}finally{u=Y}}}})(Yu);Qu.exports=Yu;var Vg=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=w,Tt=Vg;function F(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Xu=new Set,Zl={};function xs(e,t){il(e,t),il(e+"Capture",t)}function il(e,t){for(Zl[e]=t,e=0;e<t.length;e++)Xu.add(t[e])}var fn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ha=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]*$/,oc={},dc={};function nx(e){return Ha.call(dc,e)?!0:Ha.call(oc,e)?!1:tx.test(e)?dc[e]=!0:(oc[e]=!0,!1)}function sx(e,t,s,l){if(s!==null&&s.type===0)return!1;switch(typeof t){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,t,s,l){if(t===null||typeof t>"u"||sx(e,t,s,l))return!0;if(l)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ft(e,t,s,l,r,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=l,this.attributeNamespace=r,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var st={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){st[e]=new ft(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];st[t]=new ft(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){st[e]=new ft(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){st[e]=new ft(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){st[e]=new ft(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){st[e]=new ft(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){st[e]=new ft(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){st[e]=new ft(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){st[e]=new ft(e,5,!1,e.toLowerCase(),null,!1,!1)});var Mo=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Mo,Ho);st[t]=new ft(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Mo,Ho);st[t]=new ft(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Mo,Ho);st[t]=new ft(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){st[e]=new ft(e,1,!1,e.toLowerCase(),null,!1,!1)});st.xlinkHref=new ft("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){st[e]=new ft(e,1,!1,e.toLowerCase(),null,!0,!0)});function Go(e,t,s,l){var r=st.hasOwnProperty(t)?st[t]:null;(r!==null?r.type!==0:l||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(lx(t,s,r,l)&&(s=null),l||r===null?nx(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):r.mustUseProperty?e[r.propertyName]=s===null?r.type===3?!1:"":s:(t=r.attributeName,l=r.attributeNamespace,s===null?e.removeAttribute(t):(r=r.type,s=r===3||r===4&&s===!0?"":""+s,l?e.setAttributeNS(l,t,s):e.setAttribute(t,s))))}var mn=ex.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ir=Symbol.for("react.element"),Us=Symbol.for("react.portal"),Fs=Symbol.for("react.fragment"),Ko=Symbol.for("react.strict_mode"),Ga=Symbol.for("react.profiler"),qu=Symbol.for("react.provider"),Ju=Symbol.for("react.context"),Qo=Symbol.for("react.forward_ref"),Ka=Symbol.for("react.suspense"),Qa=Symbol.for("react.suspense_list"),Yo=Symbol.for("react.memo"),jn=Symbol.for("react.lazy"),Zu=Symbol.for("react.offscreen"),cc=Symbol.iterator;function _l(e){return e===null||typeof e!="object"?null:(e=cc&&e[cc]||e["@@iterator"],typeof e=="function"?e:null)}var Ee=Object.assign,fa;function Wl(e){if(fa===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);fa=t&&t[1]||""}return`
`+fa+e}var ha=!1;function ga(e,t){if(!e||ha)return"";ha=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(h){var l=h}Reflect.construct(e,[],t)}else{try{t.call()}catch(h){l=h}e.call(t.prototype)}else{try{throw Error()}catch(h){l=h}e()}}catch(h){if(h&&l&&typeof h.stack=="string"){for(var r=h.stack.split(`
`),i=l.stack.split(`
`),a=r.length-1,c=i.length-1;1<=a&&0<=c&&r[a]!==i[c];)c--;for(;1<=a&&0<=c;a--,c--)if(r[a]!==i[c]){if(a!==1||c!==1)do if(a--,c--,0>c||r[a]!==i[c]){var d=`
`+r[a].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),d}while(1<=a&&0<=c);break}}}finally{ha=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?Wl(e):""}function rx(e){switch(e.tag){case 5:return Wl(e.type);case 16:return Wl("Lazy");case 13:return Wl("Suspense");case 19:return Wl("SuspenseList");case 0:case 2:case 15:return e=ga(e.type,!1),e;case 11:return e=ga(e.type.render,!1),e;case 1:return e=ga(e.type,!0),e;default:return""}}function Ya(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 Fs:return"Fragment";case Us:return"Portal";case Ga:return"Profiler";case Ko:return"StrictMode";case Ka:return"Suspense";case Qa: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 Qo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Yo:return t=e.displayName||null,t!==null?t:Ya(e.type)||"Memo";case jn:t=e._payload,e=e._init;try{return Ya(e(t))}catch{}}return null}function ix(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ya(t);case 8:return t===Ko?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Dn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Vu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ax(e){var t=Vu(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),l=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var r=s.get,i=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(a){l=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return l},setValue:function(a){l=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Pr(e){e._valueTracker||(e._valueTracker=ax(e))}function ep(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),l="";return e&&(l=Vu(e)?e.checked?"true":"false":e.value),e=l,e!==s?(t.setValue(e),!0):!1}function fi(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 Xa(e,t){var s=t.checked;return Ee({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function uc(e,t){var s=t.defaultValue==null?"":t.defaultValue,l=t.checked!=null?t.checked:t.defaultChecked;s=Dn(t.value!=null?t.value:s),e._wrapperState={initialChecked:l,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function tp(e,t){t=t.checked,t!=null&&Go(e,"checked",t,!1)}function qa(e,t){tp(e,t);var s=Dn(t.value),l=t.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}t.hasOwnProperty("value")?Ja(e,t.type,s):t.hasOwnProperty("defaultValue")&&Ja(e,t.type,Dn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function pc(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var l=t.type;if(!(l!=="submit"&&l!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function Ja(e,t,s){(t!=="number"||fi(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Bl=Array.isArray;function el(e,t,s,l){if(e=e.options,t){t={};for(var r=0;r<s.length;r++)t["$"+s[r]]=!0;for(s=0;s<e.length;s++)r=t.hasOwnProperty("$"+e[s].value),e[s].selected!==r&&(e[s].selected=r),r&&l&&(e[s].defaultSelected=!0)}else{for(s=""+Dn(s),t=null,r=0;r<e.length;r++){if(e[r].value===s){e[r].selected=!0,l&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function Za(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return Ee({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function fc(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(F(92));if(Bl(s)){if(1<s.length)throw Error(F(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:Dn(s)}}function np(e,t){var s=Dn(t.value),l=Dn(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),l!=null&&(e.defaultValue=""+l)}function hc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}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 Va(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?sp(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Er,lp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,l,r){MSApp.execUnsafeLocalFunction(function(){return e(t,s,l,r)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Er=Er||document.createElement("div"),Er.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Er.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Vl(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Ml={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(Ml).forEach(function(e){ox.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ml[t]=Ml[e]})});function rp(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||Ml.hasOwnProperty(e)&&Ml[e]?(""+t).trim():t+"px"}function ip(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var l=s.indexOf("--")===0,r=rp(s,t[s],l);s==="float"&&(s="cssFloat"),l?e.setProperty(s,r):e[s]=r}}var dx=Ee({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,t){if(t){if(dx[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function to(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var no=null;function Xo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var so=null,tl=null,nl=null;function gc(e){if(e=yr(e)){if(typeof so!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Hi(t),so(e.stateNode,e.type,t))}}function ap(e){tl?nl?nl.push(e):nl=[e]:tl=e}function op(){if(tl){var e=tl,t=nl;if(nl=tl=null,gc(e),t)for(e=0;e<t.length;e++)gc(t[e])}}function dp(e,t){return e(t)}function cp(){}var xa=!1;function up(e,t,s){if(xa)return e(t,s);xa=!0;try{return dp(e,t,s)}finally{xa=!1,(tl!==null||nl!==null)&&(cp(),op())}}function er(e,t){var s=e.stateNode;if(s===null)return null;var l=Hi(s);if(l===null)return null;s=l[t];e:switch(t){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(F(231,t,typeof s));return s}var lo=!1;if(fn)try{var kl={};Object.defineProperty(kl,"passive",{get:function(){lo=!0}}),window.addEventListener("test",kl,kl),window.removeEventListener("test",kl,kl)}catch{lo=!1}function cx(e,t,s,l,r,i,a,c,d){var h=Array.prototype.slice.call(arguments,3);try{t.apply(s,h)}catch(j){this.onError(j)}}var Hl=!1,hi=null,gi=!1,ro=null,ux={onError:function(e){Hl=!0,hi=e}};function px(e,t,s,l,r,i,a,c,d){Hl=!1,hi=null,cx.apply(ux,arguments)}function fx(e,t,s,l,r,i,a,c,d){if(px.apply(this,arguments),Hl){if(Hl){var h=hi;Hl=!1,hi=null}else throw Error(F(198));gi||(gi=!0,ro=h)}}function ms(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function pp(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function xc(e){if(ms(e)!==e)throw Error(F(188))}function hx(e){var t=e.alternate;if(!t){if(t=ms(e),t===null)throw Error(F(188));return t!==e?null:e}for(var s=e,l=t;;){var r=s.return;if(r===null)break;var i=r.alternate;if(i===null){if(l=r.return,l!==null){s=l;continue}break}if(r.child===i.child){for(i=r.child;i;){if(i===s)return xc(r),e;if(i===l)return xc(r),t;i=i.sibling}throw Error(F(188))}if(s.return!==l.return)s=r,l=i;else{for(var a=!1,c=r.child;c;){if(c===s){a=!0,s=r,l=i;break}if(c===l){a=!0,l=r,s=i;break}c=c.sibling}if(!a){for(c=i.child;c;){if(c===s){a=!0,s=i,l=r;break}if(c===l){a=!0,l=i,s=r;break}c=c.sibling}if(!a)throw Error(F(189))}}if(s.alternate!==l)throw Error(F(190))}if(s.tag!==3)throw Error(F(188));return s.stateNode.current===s?e:t}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 t=hp(e);if(t!==null)return t;e=e.sibling}return null}var gp=Tt.unstable_scheduleCallback,mc=Tt.unstable_cancelCallback,gx=Tt.unstable_shouldYield,xx=Tt.unstable_requestPaint,Ne=Tt.unstable_now,mx=Tt.unstable_getCurrentPriorityLevel,qo=Tt.unstable_ImmediatePriority,xp=Tt.unstable_UserBlockingPriority,xi=Tt.unstable_NormalPriority,yx=Tt.unstable_LowPriority,mp=Tt.unstable_IdlePriority,$i=null,tn=null;function vx(e){if(tn&&typeof tn.onCommitFiberRoot=="function")try{tn.onCommitFiberRoot($i,e,void 0,(e.current.flags&128)===128)}catch{}}var Mt=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 Ar=64,Rr=4194304;function $l(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 mi(e,t){var s=e.pendingLanes;if(s===0)return 0;var l=0,r=e.suspendedLanes,i=e.pingedLanes,a=s&268435455;if(a!==0){var c=a&~r;c!==0?l=$l(c):(i&=a,i!==0&&(l=$l(i)))}else a=s&~r,a!==0?l=$l(a):i!==0&&(l=$l(i));if(l===0)return 0;if(t!==0&&t!==l&&!(t&r)&&(r=l&-l,i=t&-t,r>=i||r===16&&(i&4194240)!==0))return t;if(l&4&&(l|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=l;0<t;)s=31-Mt(t),r=1<<s,l|=e[s],t&=~r;return l}function wx(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 _x(e,t){for(var s=e.suspendedLanes,l=e.pingedLanes,r=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Mt(i),c=1<<a,d=r[a];d===-1?(!(c&s)||c&l)&&(r[a]=wx(c,t)):d<=t&&(e.expiredLanes|=c),i&=~c}}function io(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function yp(){var e=Ar;return Ar<<=1,!(Ar&4194240)&&(Ar=64),e}function ma(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function xr(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Mt(t),e[t]=s}function kx(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<s;){var r=31-Mt(s),i=1<<r;t[r]=0,l[r]=-1,e[r]=-1,s&=~i}}function Jo(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var l=31-Mt(s),r=1<<l;r&t|e[l]&t&&(e[l]|=t),s&=~r}}var xe=0;function vp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var jp,Zo,bp,Sp,wp,ao=!1,Or=[],Tn=null,In=null,Pn=null,tr=new Map,nr=new Map,Sn=[],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 yc(e,t){switch(e){case"focusin":case"focusout":Tn=null;break;case"dragenter":case"dragleave":In=null;break;case"mouseover":case"mouseout":Pn=null;break;case"pointerover":case"pointerout":tr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":nr.delete(t.pointerId)}}function Cl(e,t,s,l,r,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:s,eventSystemFlags:l,nativeEvent:i,targetContainers:[r]},t!==null&&(t=yr(t),t!==null&&Zo(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,r!==null&&t.indexOf(r)===-1&&t.push(r),e)}function zx(e,t,s,l,r){switch(t){case"focusin":return Tn=Cl(Tn,e,t,s,l,r),!0;case"dragenter":return In=Cl(In,e,t,s,l,r),!0;case"mouseover":return Pn=Cl(Pn,e,t,s,l,r),!0;case"pointerover":var i=r.pointerId;return tr.set(i,Cl(tr.get(i)||null,e,t,s,l,r)),!0;case"gotpointercapture":return i=r.pointerId,nr.set(i,Cl(nr.get(i)||null,e,t,s,l,r)),!0}return!1}function _p(e){var t=rs(e.target);if(t!==null){var s=ms(t);if(s!==null){if(t=s.tag,t===13){if(t=pp(s),t!==null){e.blockedOn=t,wp(e.priority,function(){bp(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ni(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=oo(e.domEventName,e.eventSystemFlags,t[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 t=yr(s),t!==null&&Zo(t),e.blockedOn=s,!1;t.shift()}return!0}function vc(e,t,s){ni(e)&&s.delete(t)}function Tx(){ao=!1,Tn!==null&&ni(Tn)&&(Tn=null),In!==null&&ni(In)&&(In=null),Pn!==null&&ni(Pn)&&(Pn=null),tr.forEach(vc),nr.forEach(vc)}function zl(e,t){e.blockedOn===t&&(e.blockedOn=null,ao||(ao=!0,Tt.unstable_scheduleCallback(Tt.unstable_NormalPriority,Tx)))}function sr(e){function t(r){return zl(r,e)}if(0<Or.length){zl(Or[0],e);for(var s=1;s<Or.length;s++){var l=Or[s];l.blockedOn===e&&(l.blockedOn=null)}}for(Tn!==null&&zl(Tn,e),In!==null&&zl(In,e),Pn!==null&&zl(Pn,e),tr.forEach(t),nr.forEach(t),s=0;s<Sn.length;s++)l=Sn[s],l.blockedOn===e&&(l.blockedOn=null);for(;0<Sn.length&&(s=Sn[0],s.blockedOn===null);)_p(s),s.blockedOn===null&&Sn.shift()}var sl=mn.ReactCurrentBatchConfig,yi=!0;function Ix(e,t,s,l){var r=xe,i=sl.transition;sl.transition=null;try{xe=1,Vo(e,t,s,l)}finally{xe=r,sl.transition=i}}function Px(e,t,s,l){var r=xe,i=sl.transition;sl.transition=null;try{xe=4,Vo(e,t,s,l)}finally{xe=r,sl.transition=i}}function Vo(e,t,s,l){if(yi){var r=oo(e,t,s,l);if(r===null)za(e,t,l,vi,s),yc(e,l);else if(zx(r,e,t,s,l))l.stopPropagation();else if(yc(e,l),t&4&&-1<Cx.indexOf(e)){for(;r!==null;){var i=yr(r);if(i!==null&&jp(i),i=oo(e,t,s,l),i===null&&za(e,t,l,vi,s),i===r)break;r=i}r!==null&&l.stopPropagation()}else za(e,t,l,null,s)}}var vi=null;function oo(e,t,s,l){if(vi=null,e=Xo(l),e=rs(e),e!==null)if(t=ms(e),t===null)e=null;else if(s=t.tag,s===13){if(e=pp(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return vi=e,null}function kp(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 qo:return 1;case xp:return 4;case xi:case yx:return 16;case mp:return 536870912;default:return 16}default:return 16}}var _n=null,ed=null,si=null;function Cp(){if(si)return si;var e,t=ed,s=t.length,l,r="value"in _n?_n.value:_n.textContent,i=r.length;for(e=0;e<s&&t[e]===r[e];e++);var a=s-e;for(l=1;l<=a&&t[s-l]===r[i-l];l++);return si=r.slice(e,1<l?1-l:void 0)}function li(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Lr(){return!0}function jc(){return!1}function Pt(e){function t(s,l,r,i,a){this._reactName=s,this._targetInst=r,this.type=l,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var c in e)e.hasOwnProperty(c)&&(s=e[c],this[c]=s?s(i):i[c]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Lr:jc,this.isPropagationStopped=jc,this}return Ee(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Lr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Lr)},persist:function(){},isPersistent:Lr}),t}var xl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},td=Pt(xl),mr=Ee({},xl,{view:0,detail:0}),Ex=Pt(mr),ya,va,Tl,Ui=Ee({},mr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,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!==Tl&&(Tl&&e.type==="mousemove"?(ya=e.screenX-Tl.screenX,va=e.screenY-Tl.screenY):va=ya=0,Tl=e),ya)},movementY:function(e){return"movementY"in e?e.movementY:va}}),bc=Pt(Ui),Ax=Ee({},Ui,{dataTransfer:0}),Rx=Pt(Ax),Ox=Ee({},mr,{relatedTarget:0}),ja=Pt(Ox),Lx=Ee({},xl,{animationName:0,elapsedTime:0,pseudoElement:0}),Dx=Pt(Lx),Nx=Ee({},xl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Wx=Pt(Nx),Bx=Ee({},xl,{data:0}),Sc=Pt(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 t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Fx[e])?!!t[e]:!1}function nd(){return Mx}var Hx=Ee({},mr,{key:function(e){if(e.key){var t=$x[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=li(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:nd,charCode:function(e){return e.type==="keypress"?li(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?li(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Gx=Pt(Hx),Kx=Ee({},Ui,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wc=Pt(Kx),Qx=Ee({},mr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),Yx=Pt(Qx),Xx=Ee({},xl,{propertyName:0,elapsedTime:0,pseudoElement:0}),qx=Pt(Xx),Jx=Ee({},Ui,{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}),Zx=Pt(Jx),Vx=[9,13,27,32],sd=fn&&"CompositionEvent"in window,Gl=null;fn&&"documentMode"in document&&(Gl=document.documentMode);var em=fn&&"TextEvent"in window&&!Gl,zp=fn&&(!sd||Gl&&8<Gl&&11>=Gl),_c=" ",kc=!1;function Tp(e,t){switch(e){case"keyup":return Vx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ip(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ms=!1;function tm(e,t){switch(e){case"compositionend":return Ip(t);case"keypress":return t.which!==32?null:(kc=!0,_c);case"textInput":return e=t.data,e===_c&&kc?null:e;default:return null}}function nm(e,t){if(Ms)return e==="compositionend"||!sd&&Tp(e,t)?(e=Cp(),si=ed=_n=null,Ms=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return zp&&t.locale!=="ko"?null:t.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 Cc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!sm[e.type]:t==="textarea"}function Pp(e,t,s,l){ap(l),t=ji(t,"onChange"),0<t.length&&(s=new td("onChange","change",null,s,l),e.push({event:s,listeners:t}))}var Kl=null,lr=null;function lm(e){Up(e,0)}function Fi(e){var t=Ks(e);if(ep(t))return e}function rm(e,t){if(e==="change")return t}var Ep=!1;if(fn){var ba;if(fn){var Sa="oninput"in document;if(!Sa){var zc=document.createElement("div");zc.setAttribute("oninput","return;"),Sa=typeof zc.oninput=="function"}ba=Sa}else ba=!1;Ep=ba&&(!document.documentMode||9<document.documentMode)}function Tc(){Kl&&(Kl.detachEvent("onpropertychange",Ap),lr=Kl=null)}function Ap(e){if(e.propertyName==="value"&&Fi(lr)){var t=[];Pp(t,lr,e,Xo(e)),up(lm,t)}}function im(e,t,s){e==="focusin"?(Tc(),Kl=t,lr=s,Kl.attachEvent("onpropertychange",Ap)):e==="focusout"&&Tc()}function am(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Fi(lr)}function om(e,t){if(e==="click")return Fi(t)}function dm(e,t){if(e==="input"||e==="change")return Fi(t)}function cm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Gt=typeof Object.is=="function"?Object.is:cm;function rr(e,t){if(Gt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),l=Object.keys(t);if(s.length!==l.length)return!1;for(l=0;l<s.length;l++){var r=s[l];if(!Ha.call(t,r)||!Gt(e[r],t[r]))return!1}return!0}function Ic(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Pc(e,t){var s=Ic(e);e=0;for(var l;s;){if(s.nodeType===3){if(l=e+s.textContent.length,e<=t&&l>=t)return{node:s,offset:t-e};e=l}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Ic(s)}}function Rp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Rp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Op(){for(var e=window,t=fi();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=fi(e.document)}return t}function ld(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function um(e){var t=Op(),s=e.focusedElem,l=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Rp(s.ownerDocument.documentElement,s)){if(l!==null&&ld(s)){if(t=l.start,e=l.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var r=s.textContent.length,i=Math.min(l.start,r);l=l.end===void 0?i:Math.min(l.end,r),!e.extend&&i>l&&(r=l,l=i,i=r),r=Pc(s,i);var a=Pc(s,l);r&&a&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(r.node,r.offset),e.removeAllRanges(),i>l?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var pm=fn&&"documentMode"in document&&11>=document.documentMode,Hs=null,co=null,Ql=null,uo=!1;function Ec(e,t,s){var l=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;uo||Hs==null||Hs!==fi(l)||(l=Hs,"selectionStart"in l&&ld(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}),Ql&&rr(Ql,l)||(Ql=l,l=ji(co,"onSelect"),0<l.length&&(t=new td("onSelect","select",null,t,s),e.push({event:t,listeners:l}),t.target=Hs)))}function Dr(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Gs={animationend:Dr("Animation","AnimationEnd"),animationiteration:Dr("Animation","AnimationIteration"),animationstart:Dr("Animation","AnimationStart"),transitionend:Dr("Transition","TransitionEnd")},wa={},Lp={};fn&&(Lp=document.createElement("div").style,"AnimationEvent"in window||(delete Gs.animationend.animation,delete Gs.animationiteration.animation,delete Gs.animationstart.animation),"TransitionEvent"in window||delete Gs.transitionend.transition);function Mi(e){if(wa[e])return wa[e];if(!Gs[e])return e;var t=Gs[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Lp)return wa[e]=t[s];return e}var Dp=Mi("animationend"),Np=Mi("animationiteration"),Wp=Mi("animationstart"),Bp=Mi("transitionend"),$p=new Map,Ac="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 Wn(e,t){$p.set(e,t),xs(t,[e])}for(var _a=0;_a<Ac.length;_a++){var ka=Ac[_a],fm=ka.toLowerCase(),hm=ka[0].toUpperCase()+ka.slice(1);Wn(fm,"on"+hm)}Wn(Dp,"onAnimationEnd");Wn(Np,"onAnimationIteration");Wn(Wp,"onAnimationStart");Wn("dblclick","onDoubleClick");Wn("focusin","onFocus");Wn("focusout","onBlur");Wn(Bp,"onTransitionEnd");il("onMouseEnter",["mouseout","mouseover"]);il("onMouseLeave",["mouseout","mouseover"]);il("onPointerEnter",["pointerout","pointerover"]);il("onPointerLeave",["pointerout","pointerover"]);xs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));xs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));xs("onBeforeInput",["compositionend","keypress","textInput","paste"]);xs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));xs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));xs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ul="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(Ul));function Rc(e,t,s){var l=e.type||"unknown-event";e.currentTarget=s,fx(l,t,void 0,e),e.currentTarget=null}function Up(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var l=e[s],r=l.event;l=l.listeners;e:{var i=void 0;if(t)for(var a=l.length-1;0<=a;a--){var c=l[a],d=c.instance,h=c.currentTarget;if(c=c.listener,d!==i&&r.isPropagationStopped())break e;Rc(r,c,h),i=d}else for(a=0;a<l.length;a++){if(c=l[a],d=c.instance,h=c.currentTarget,c=c.listener,d!==i&&r.isPropagationStopped())break e;Rc(r,c,h),i=d}}}if(gi)throw e=ro,gi=!1,ro=null,e}function Se(e,t){var s=t[xo];s===void 0&&(s=t[xo]=new Set);var l=e+"__bubble";s.has(l)||(Fp(t,e,2,!1),s.add(l))}function Ca(e,t,s){var l=0;t&&(l|=4),Fp(s,e,l,t)}var Nr="_reactListening"+Math.random().toString(36).slice(2);function ir(e){if(!e[Nr]){e[Nr]=!0,Xu.forEach(function(s){s!=="selectionchange"&&(gm.has(s)||Ca(s,!1,e),Ca(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Nr]||(t[Nr]=!0,Ca("selectionchange",!1,t))}}function Fp(e,t,s,l){switch(kp(t)){case 1:var r=Ix;break;case 4:r=Px;break;default:r=Vo}s=r.bind(null,t,s,e),r=void 0,!lo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(r=!0),l?r!==void 0?e.addEventListener(t,s,{capture:!0,passive:r}):e.addEventListener(t,s,!0):r!==void 0?e.addEventListener(t,s,{passive:r}):e.addEventListener(t,s,!1)}function za(e,t,s,l,r){var i=l;if(!(t&1)&&!(t&2)&&l!==null)e:for(;;){if(l===null)return;var a=l.tag;if(a===3||a===4){var c=l.stateNode.containerInfo;if(c===r||c.nodeType===8&&c.parentNode===r)break;if(a===4)for(a=l.return;a!==null;){var d=a.tag;if((d===3||d===4)&&(d=a.stateNode.containerInfo,d===r||d.nodeType===8&&d.parentNode===r))return;a=a.return}for(;c!==null;){if(a=rs(c),a===null)return;if(d=a.tag,d===5||d===6){l=i=a;continue e}c=c.parentNode}}l=l.return}up(function(){var h=i,j=Xo(s),p=[];e:{var u=$p.get(e);if(u!==void 0){var y=td,v=e;switch(e){case"keypress":if(li(s)===0)break e;case"keydown":case"keyup":y=Gx;break;case"focusin":v="focus",y=ja;break;case"focusout":v="blur",y=ja;break;case"beforeblur":case"afterblur":y=ja;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":y=bc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":y=Rx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":y=Yx;break;case Dp:case Np:case Wp:y=Dx;break;case Bp:y=qx;break;case"scroll":y=Ex;break;case"wheel":y=Zx;break;case"copy":case"cut":case"paste":y=Wx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":y=wc}var f=(t&4)!==0,S=!f&&e==="scroll",g=f?u!==null?u+"Capture":null:u;f=[];for(var x=h,o;x!==null;){o=x;var m=o.stateNode;if(o.tag===5&&m!==null&&(o=m,g!==null&&(m=er(x,g),m!=null&&f.push(ar(x,m,o)))),S)break;x=x.return}0<f.length&&(u=new y(u,v,null,s,j),p.push({event:u,listeners:f}))}}if(!(t&7)){e:{if(u=e==="mouseover"||e==="pointerover",y=e==="mouseout"||e==="pointerout",u&&s!==no&&(v=s.relatedTarget||s.fromElement)&&(rs(v)||v[hn]))break e;if((y||u)&&(u=j.window===j?j:(u=j.ownerDocument)?u.defaultView||u.parentWindow:window,y?(v=s.relatedTarget||s.toElement,y=h,v=v?rs(v):null,v!==null&&(S=ms(v),v!==S||v.tag!==5&&v.tag!==6)&&(v=null)):(y=null,v=h),y!==v)){if(f=bc,m="onMouseLeave",g="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(f=wc,m="onPointerLeave",g="onPointerEnter",x="pointer"),S=y==null?u:Ks(y),o=v==null?u:Ks(v),u=new f(m,x+"leave",y,s,j),u.target=S,u.relatedTarget=o,m=null,rs(j)===h&&(f=new f(g,x+"enter",v,s,j),f.target=o,f.relatedTarget=S,m=f),S=m,y&&v)t:{for(f=y,g=v,x=0,o=f;o;o=Es(o))x++;for(o=0,m=g;m;m=Es(m))o++;for(;0<x-o;)f=Es(f),x--;for(;0<o-x;)g=Es(g),o--;for(;x--;){if(f===g||g!==null&&f===g.alternate)break t;f=Es(f),g=Es(g)}f=null}else f=null;y!==null&&Oc(p,u,y,f,!1),v!==null&&S!==null&&Oc(p,S,v,f,!0)}}e:{if(u=h?Ks(h):window,y=u.nodeName&&u.nodeName.toLowerCase(),y==="select"||y==="input"&&u.type==="file")var _=rm;else if(Cc(u))if(Ep)_=dm;else{_=am;var T=im}else(y=u.nodeName)&&y.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(_=om);if(_&&(_=_(e,h))){Pp(p,_,s,j);break e}T&&T(e,u,h),e==="focusout"&&(T=u._wrapperState)&&T.controlled&&u.type==="number"&&Ja(u,"number",u.value)}switch(T=h?Ks(h):window,e){case"focusin":(Cc(T)||T.contentEditable==="true")&&(Hs=T,co=h,Ql=null);break;case"focusout":Ql=co=Hs=null;break;case"mousedown":uo=!0;break;case"contextmenu":case"mouseup":case"dragend":uo=!1,Ec(p,s,j);break;case"selectionchange":if(pm)break;case"keydown":case"keyup":Ec(p,s,j)}var E;if(sd)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Ms?Tp(e,s)&&(C="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(C="onCompositionStart");C&&(zp&&s.locale!=="ko"&&(Ms||C!=="onCompositionStart"?C==="onCompositionEnd"&&Ms&&(E=Cp()):(_n=j,ed="value"in _n?_n.value:_n.textContent,Ms=!0)),T=ji(h,C),0<T.length&&(C=new Sc(C,e,null,s,j),p.push({event:C,listeners:T}),E?C.data=E:(E=Ip(s),E!==null&&(C.data=E)))),(E=em?tm(e,s):nm(e,s))&&(h=ji(h,"onBeforeInput"),0<h.length&&(j=new Sc("onBeforeInput","beforeinput",null,s,j),p.push({event:j,listeners:h}),j.data=E))}Up(p,t)})}function ar(e,t,s){return{instance:e,listener:t,currentTarget:s}}function ji(e,t){for(var s=t+"Capture",l=[];e!==null;){var r=e,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=er(e,s),i!=null&&l.unshift(ar(e,i,r)),i=er(e,t),i!=null&&l.push(ar(e,i,r))),e=e.return}return l}function Es(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Oc(e,t,s,l,r){for(var i=t._reactName,a=[];s!==null&&s!==l;){var c=s,d=c.alternate,h=c.stateNode;if(d!==null&&d===l)break;c.tag===5&&h!==null&&(c=h,r?(d=er(s,i),d!=null&&a.unshift(ar(s,d,c))):r||(d=er(s,i),d!=null&&a.push(ar(s,d,c)))),s=s.return}a.length!==0&&e.push({event:t,listeners:a})}var xm=/\r\n?/g,mm=/\u0000|\uFFFD/g;function Lc(e){return(typeof e=="string"?e:""+e).replace(xm,`
`).replace(mm,"")}function Wr(e,t,s){if(t=Lc(t),Lc(e)!==t&&s)throw Error(F(425))}function bi(){}var po=null,fo=null;function ho(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var go=typeof setTimeout=="function"?setTimeout:void 0,ym=typeof clearTimeout=="function"?clearTimeout:void 0,Dc=typeof Promise=="function"?Promise:void 0,vm=typeof queueMicrotask=="function"?queueMicrotask:typeof Dc<"u"?function(e){return Dc.resolve(null).then(e).catch(jm)}:go;function jm(e){setTimeout(function(){throw e})}function Ta(e,t){var s=t,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),sr(t);return}l--}else s!=="$"&&s!=="$?"&&s!=="$!"||l++;s=r}while(s);sr(t)}function En(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Nc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var ml=Math.random().toString(36).slice(2),en="__reactFiber$"+ml,or="__reactProps$"+ml,hn="__reactContainer$"+ml,xo="__reactEvents$"+ml,bm="__reactListeners$"+ml,Sm="__reactHandles$"+ml;function rs(e){var t=e[en];if(t)return t;for(var s=e.parentNode;s;){if(t=s[hn]||s[en]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=Nc(e);e!==null;){if(s=e[en])return s;e=Nc(e)}return t}e=s,s=e.parentNode}return null}function yr(e){return e=e[en]||e[hn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ks(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Hi(e){return e[or]||null}var mo=[],Qs=-1;function Bn(e){return{current:e}}function we(e){0>Qs||(e.current=mo[Qs],mo[Qs]=null,Qs--)}function je(e,t){Qs++,mo[Qs]=e.current,e.current=t}var Nn={},at=Bn(Nn),mt=Bn(!1),cs=Nn;function al(e,t){var s=e.type.contextTypes;if(!s)return Nn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===t)return l.__reactInternalMemoizedMaskedChildContext;var r={},i;for(i in s)r[i]=t[i];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=r),r}function yt(e){return e=e.childContextTypes,e!=null}function Si(){we(mt),we(at)}function Wc(e,t,s){if(at.current!==Nn)throw Error(F(168));je(at,t),je(mt,s)}function Mp(e,t,s){var l=e.stateNode;if(t=t.childContextTypes,typeof l.getChildContext!="function")return s;l=l.getChildContext();for(var r in l)if(!(r in t))throw Error(F(108,ix(e)||"Unknown",r));return Ee({},s,l)}function wi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Nn,cs=at.current,je(at,e),je(mt,mt.current),!0}function Bc(e,t,s){var l=e.stateNode;if(!l)throw Error(F(169));s?(e=Mp(e,t,cs),l.__reactInternalMemoizedMergedChildContext=e,we(mt),we(at),je(at,e)):we(mt),je(mt,s)}var dn=null,Gi=!1,Ia=!1;function Hp(e){dn===null?dn=[e]:dn.push(e)}function wm(e){Gi=!0,Hp(e)}function $n(){if(!Ia&&dn!==null){Ia=!0;var e=0,t=xe;try{var s=dn;for(xe=1;e<s.length;e++){var l=s[e];do l=l(!0);while(l!==null)}dn=null,Gi=!1}catch(r){throw dn!==null&&(dn=dn.slice(e+1)),gp(qo,$n),r}finally{xe=t,Ia=!1}}return null}var Ys=[],Xs=0,_i=null,ki=0,Et=[],At=0,us=null,cn=1,un="";function ss(e,t){Ys[Xs++]=ki,Ys[Xs++]=_i,_i=e,ki=t}function Gp(e,t,s){Et[At++]=cn,Et[At++]=un,Et[At++]=us,us=e;var l=cn;e=un;var r=32-Mt(l)-1;l&=~(1<<r),s+=1;var i=32-Mt(t)+r;if(30<i){var a=r-r%5;i=(l&(1<<a)-1).toString(32),l>>=a,r-=a,cn=1<<32-Mt(t)+r|s<<r|l,un=i+e}else cn=1<<i|s<<r|l,un=e}function rd(e){e.return!==null&&(ss(e,1),Gp(e,1,0))}function id(e){for(;e===_i;)_i=Ys[--Xs],Ys[Xs]=null,ki=Ys[--Xs],Ys[Xs]=null;for(;e===us;)us=Et[--At],Et[At]=null,un=Et[--At],Et[At]=null,cn=Et[--At],Et[At]=null}var zt=null,Ct=null,ze=!1,Ut=null;function Kp(e,t){var s=Rt(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function $c(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,zt=e,Ct=En(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,zt=e,Ct=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=us!==null?{id:cn,overflow:un}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=Rt(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,zt=e,Ct=null,!0):!1;default:return!1}}function yo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function vo(e){if(ze){var t=Ct;if(t){var s=t;if(!$c(e,t)){if(yo(e))throw Error(F(418));t=En(s.nextSibling);var l=zt;t&&$c(e,t)?Kp(l,s):(e.flags=e.flags&-4097|2,ze=!1,zt=e)}}else{if(yo(e))throw Error(F(418));e.flags=e.flags&-4097|2,ze=!1,zt=e}}}function Uc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;zt=e}function Br(e){if(e!==zt)return!1;if(!ze)return Uc(e),ze=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ho(e.type,e.memoizedProps)),t&&(t=Ct)){if(yo(e))throw Qp(),Error(F(418));for(;t;)Kp(e,t),t=En(t.nextSibling)}if(Uc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(F(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){Ct=En(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}Ct=null}}else Ct=zt?En(e.stateNode.nextSibling):null;return!0}function Qp(){for(var e=Ct;e;)e=En(e.nextSibling)}function ol(){Ct=zt=null,ze=!1}function ad(e){Ut===null?Ut=[e]:Ut.push(e)}var _m=mn.ReactCurrentBatchConfig;function Il(e,t,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(F(309));var l=s.stateNode}if(!l)throw Error(F(147,e));var r=l,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var c=r.refs;a===null?delete c[i]:c[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(F(284));if(!s._owner)throw Error(F(290,e))}return e}function $r(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Fc(e){var t=e._init;return t(e._payload)}function Yp(e){function t(g,x){if(e){var o=g.deletions;o===null?(g.deletions=[x],g.flags|=16):o.push(x)}}function s(g,x){if(!e)return null;for(;x!==null;)t(g,x),x=x.sibling;return null}function l(g,x){for(g=new Map;x!==null;)x.key!==null?g.set(x.key,x):g.set(x.index,x),x=x.sibling;return g}function r(g,x){return g=Ln(g,x),g.index=0,g.sibling=null,g}function i(g,x,o){return g.index=o,e?(o=g.alternate,o!==null?(o=o.index,o<x?(g.flags|=2,x):o):(g.flags|=2,x)):(g.flags|=1048576,x)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function c(g,x,o,m){return x===null||x.tag!==6?(x=Da(o,g.mode,m),x.return=g,x):(x=r(x,o),x.return=g,x)}function d(g,x,o,m){var _=o.type;return _===Fs?j(g,x,o.props.children,m,o.key):x!==null&&(x.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===jn&&Fc(_)===x.type)?(m=r(x,o.props),m.ref=Il(g,x,o),m.return=g,m):(m=ui(o.type,o.key,o.props,null,g.mode,m),m.ref=Il(g,x,o),m.return=g,m)}function h(g,x,o,m){return x===null||x.tag!==4||x.stateNode.containerInfo!==o.containerInfo||x.stateNode.implementation!==o.implementation?(x=Na(o,g.mode,m),x.return=g,x):(x=r(x,o.children||[]),x.return=g,x)}function j(g,x,o,m,_){return x===null||x.tag!==7?(x=ds(o,g.mode,m,_),x.return=g,x):(x=r(x,o),x.return=g,x)}function p(g,x,o){if(typeof x=="string"&&x!==""||typeof x=="number")return x=Da(""+x,g.mode,o),x.return=g,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Ir:return o=ui(x.type,x.key,x.props,null,g.mode,o),o.ref=Il(g,null,x),o.return=g,o;case Us:return x=Na(x,g.mode,o),x.return=g,x;case jn:var m=x._init;return p(g,m(x._payload),o)}if(Bl(x)||_l(x))return x=ds(x,g.mode,o,null),x.return=g,x;$r(g,x)}return null}function u(g,x,o,m){var _=x!==null?x.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return _!==null?null:c(g,x,""+o,m);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Ir:return o.key===_?d(g,x,o,m):null;case Us:return o.key===_?h(g,x,o,m):null;case jn:return _=o._init,u(g,x,_(o._payload),m)}if(Bl(o)||_l(o))return _!==null?null:j(g,x,o,m,null);$r(g,o)}return null}function y(g,x,o,m,_){if(typeof m=="string"&&m!==""||typeof m=="number")return g=g.get(o)||null,c(x,g,""+m,_);if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Ir:return g=g.get(m.key===null?o:m.key)||null,d(x,g,m,_);case Us:return g=g.get(m.key===null?o:m.key)||null,h(x,g,m,_);case jn:var T=m._init;return y(g,x,o,T(m._payload),_)}if(Bl(m)||_l(m))return g=g.get(o)||null,j(x,g,m,_,null);$r(x,m)}return null}function v(g,x,o,m){for(var _=null,T=null,E=x,C=x=0,R=null;E!==null&&C<o.length;C++){E.index>C?(R=E,E=null):R=E.sibling;var B=u(g,E,o[C],m);if(B===null){E===null&&(E=R);break}e&&E&&B.alternate===null&&t(g,E),x=i(B,x,C),T===null?_=B:T.sibling=B,T=B,E=R}if(C===o.length)return s(g,E),ze&&ss(g,C),_;if(E===null){for(;C<o.length;C++)E=p(g,o[C],m),E!==null&&(x=i(E,x,C),T===null?_=E:T.sibling=E,T=E);return ze&&ss(g,C),_}for(E=l(g,E);C<o.length;C++)R=y(E,g,C,o[C],m),R!==null&&(e&&R.alternate!==null&&E.delete(R.key===null?C:R.key),x=i(R,x,C),T===null?_=R:T.sibling=R,T=R);return e&&E.forEach(function(D){return t(g,D)}),ze&&ss(g,C),_}function f(g,x,o,m){var _=_l(o);if(typeof _!="function")throw Error(F(150));if(o=_.call(o),o==null)throw Error(F(151));for(var T=_=null,E=x,C=x=0,R=null,B=o.next();E!==null&&!B.done;C++,B=o.next()){E.index>C?(R=E,E=null):R=E.sibling;var D=u(g,E,B.value,m);if(D===null){E===null&&(E=R);break}e&&E&&D.alternate===null&&t(g,E),x=i(D,x,C),T===null?_=D:T.sibling=D,T=D,E=R}if(B.done)return s(g,E),ze&&ss(g,C),_;if(E===null){for(;!B.done;C++,B=o.next())B=p(g,B.value,m),B!==null&&(x=i(B,x,C),T===null?_=B:T.sibling=B,T=B);return ze&&ss(g,C),_}for(E=l(g,E);!B.done;C++,B=o.next())B=y(E,g,C,B.value,m),B!==null&&(e&&B.alternate!==null&&E.delete(B.key===null?C:B.key),x=i(B,x,C),T===null?_=B:T.sibling=B,T=B);return e&&E.forEach(function(L){return t(g,L)}),ze&&ss(g,C),_}function S(g,x,o,m){if(typeof o=="object"&&o!==null&&o.type===Fs&&o.key===null&&(o=o.props.children),typeof o=="object"&&o!==null){switch(o.$$typeof){case Ir:e:{for(var _=o.key,T=x;T!==null;){if(T.key===_){if(_=o.type,_===Fs){if(T.tag===7){s(g,T.sibling),x=r(T,o.props.children),x.return=g,g=x;break e}}else if(T.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===jn&&Fc(_)===T.type){s(g,T.sibling),x=r(T,o.props),x.ref=Il(g,T,o),x.return=g,g=x;break e}s(g,T);break}else t(g,T);T=T.sibling}o.type===Fs?(x=ds(o.props.children,g.mode,m,o.key),x.return=g,g=x):(m=ui(o.type,o.key,o.props,null,g.mode,m),m.ref=Il(g,x,o),m.return=g,g=m)}return a(g);case Us:e:{for(T=o.key;x!==null;){if(x.key===T)if(x.tag===4&&x.stateNode.containerInfo===o.containerInfo&&x.stateNode.implementation===o.implementation){s(g,x.sibling),x=r(x,o.children||[]),x.return=g,g=x;break e}else{s(g,x);break}else t(g,x);x=x.sibling}x=Na(o,g.mode,m),x.return=g,g=x}return a(g);case jn:return T=o._init,S(g,x,T(o._payload),m)}if(Bl(o))return v(g,x,o,m);if(_l(o))return f(g,x,o,m);$r(g,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,x!==null&&x.tag===6?(s(g,x.sibling),x=r(x,o),x.return=g,g=x):(s(g,x),x=Da(o,g.mode,m),x.return=g,g=x),a(g)):s(g,x)}return S}var dl=Yp(!0),Xp=Yp(!1),Ci=Bn(null),zi=null,qs=null,od=null;function dd(){od=qs=zi=null}function cd(e){var t=Ci.current;we(Ci),e._currentValue=t}function jo(e,t,s){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===s)break;e=e.return}}function ll(e,t){zi=e,od=qs=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(xt=!0),e.firstContext=null)}function Lt(e){var t=e._currentValue;if(od!==e)if(e={context:e,memoizedValue:t,next:null},qs===null){if(zi===null)throw Error(F(308));qs=e,zi.dependencies={lanes:0,firstContext:e}}else qs=qs.next=e;return t}var is=null;function ud(e){is===null?is=[e]:is.push(e)}function qp(e,t,s,l){var r=t.interleaved;return r===null?(s.next=s,ud(t)):(s.next=r.next,r.next=s),t.interleaved=s,gn(e,l)}function gn(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var bn=!1;function pd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Jp(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function pn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function An(e,t,s){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,ce&2){var r=l.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),l.pending=t,gn(e,s)}return r=l.interleaved,r===null?(t.next=t,ud(l)):(t.next=r.next,r.next=t),l.interleaved=t,gn(e,s)}function ri(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var l=t.lanes;l&=e.pendingLanes,s|=l,t.lanes=s,Jo(e,s)}}function Mc(e,t){var s=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,s===l)){var r=null,i=null;if(s=s.firstBaseUpdate,s!==null){do{var a={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};i===null?r=i=a:i=i.next=a,s=s.next}while(s!==null);i===null?r=i=t:i=i.next=t}else r=i=t;s={baseState:l.baseState,firstBaseUpdate:r,lastBaseUpdate:i,shared:l.shared,effects:l.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function Ti(e,t,s,l){var r=e.updateQueue;bn=!1;var i=r.firstBaseUpdate,a=r.lastBaseUpdate,c=r.shared.pending;if(c!==null){r.shared.pending=null;var d=c,h=d.next;d.next=null,a===null?i=h:a.next=h,a=d;var j=e.alternate;j!==null&&(j=j.updateQueue,c=j.lastBaseUpdate,c!==a&&(c===null?j.firstBaseUpdate=h:c.next=h,j.lastBaseUpdate=d))}if(i!==null){var p=r.baseState;a=0,j=h=d=null,c=i;do{var u=c.lane,y=c.eventTime;if((l&u)===u){j!==null&&(j=j.next={eventTime:y,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var v=e,f=c;switch(u=t,y=s,f.tag){case 1:if(v=f.payload,typeof v=="function"){p=v.call(y,p,u);break e}p=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=f.payload,u=typeof v=="function"?v.call(y,p,u):v,u==null)break e;p=Ee({},p,u);break e;case 2:bn=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,u=r.effects,u===null?r.effects=[c]:u.push(c))}else y={eventTime:y,lane:u,tag:c.tag,payload:c.payload,callback:c.callback,next:null},j===null?(h=j=y,d=p):j=j.next=y,a|=u;if(c=c.next,c===null){if(c=r.shared.pending,c===null)break;u=c,c=u.next,u.next=null,r.lastBaseUpdate=u,r.shared.pending=null}}while(!0);if(j===null&&(d=p),r.baseState=d,r.firstBaseUpdate=h,r.lastBaseUpdate=j,t=r.shared.interleaved,t!==null){r=t;do a|=r.lane,r=r.next;while(r!==t)}else i===null&&(r.shared.lanes=0);fs|=a,e.lanes=a,e.memoizedState=p}}function Hc(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var l=e[t],r=l.callback;if(r!==null){if(l.callback=null,l=s,typeof r!="function")throw Error(F(191,r));r.call(l)}}}var vr={},nn=Bn(vr),dr=Bn(vr),cr=Bn(vr);function as(e){if(e===vr)throw Error(F(174));return e}function fd(e,t){switch(je(cr,t),je(dr,e),je(nn,vr),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Va(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Va(t,e)}we(nn),je(nn,t)}function cl(){we(nn),we(dr),we(cr)}function Zp(e){as(cr.current);var t=as(nn.current),s=Va(t,e.type);t!==s&&(je(dr,e),je(nn,s))}function hd(e){dr.current===e&&(we(nn),we(dr))}var Ie=Bn(0);function Ii(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Pa=[];function gd(){for(var e=0;e<Pa.length;e++)Pa[e]._workInProgressVersionPrimary=null;Pa.length=0}var ii=mn.ReactCurrentDispatcher,Ea=mn.ReactCurrentBatchConfig,ps=0,Pe=null,Ke=null,Ze=null,Pi=!1,Yl=!1,ur=0,km=0;function lt(){throw Error(F(321))}function xd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Gt(e[s],t[s]))return!1;return!0}function md(e,t,s,l,r,i){if(ps=i,Pe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ii.current=e===null||e.memoizedState===null?Im:Pm,e=s(l,r),Yl){i=0;do{if(Yl=!1,ur=0,25<=i)throw Error(F(301));i+=1,Ze=Ke=null,t.updateQueue=null,ii.current=Em,e=s(l,r)}while(Yl)}if(ii.current=Ei,t=Ke!==null&&Ke.next!==null,ps=0,Ze=Ke=Pe=null,Pi=!1,t)throw Error(F(300));return e}function yd(){var e=ur!==0;return ur=0,e}function Vt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ze===null?Pe.memoizedState=Ze=e:Ze=Ze.next=e,Ze}function Dt(){if(Ke===null){var e=Pe.alternate;e=e!==null?e.memoizedState:null}else e=Ke.next;var t=Ze===null?Pe.memoizedState:Ze.next;if(t!==null)Ze=t,Ke=e;else{if(e===null)throw Error(F(310));Ke=e,e={memoizedState:Ke.memoizedState,baseState:Ke.baseState,baseQueue:Ke.baseQueue,queue:Ke.queue,next:null},Ze===null?Pe.memoizedState=Ze=e:Ze=Ze.next=e}return Ze}function pr(e,t){return typeof t=="function"?t(e):t}function Aa(e){var t=Dt(),s=t.queue;if(s===null)throw Error(F(311));s.lastRenderedReducer=e;var l=Ke,r=l.baseQueue,i=s.pending;if(i!==null){if(r!==null){var a=r.next;r.next=i.next,i.next=a}l.baseQueue=r=i,s.pending=null}if(r!==null){i=r.next,l=l.baseState;var c=a=null,d=null,h=i;do{var j=h.lane;if((ps&j)===j)d!==null&&(d=d.next={lane:0,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null}),l=h.hasEagerState?h.eagerState:e(l,h.action);else{var p={lane:j,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null};d===null?(c=d=p,a=l):d=d.next=p,Pe.lanes|=j,fs|=j}h=h.next}while(h!==null&&h!==i);d===null?a=l:d.next=c,Gt(l,t.memoizedState)||(xt=!0),t.memoizedState=l,t.baseState=a,t.baseQueue=d,s.lastRenderedState=l}if(e=s.interleaved,e!==null){r=e;do i=r.lane,Pe.lanes|=i,fs|=i,r=r.next;while(r!==e)}else r===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function Ra(e){var t=Dt(),s=t.queue;if(s===null)throw Error(F(311));s.lastRenderedReducer=e;var l=s.dispatch,r=s.pending,i=t.memoizedState;if(r!==null){s.pending=null;var a=r=r.next;do i=e(i,a.action),a=a.next;while(a!==r);Gt(i,t.memoizedState)||(xt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),s.lastRenderedState=i}return[i,l]}function Vp(){}function ef(e,t){var s=Pe,l=Dt(),r=t(),i=!Gt(l.memoizedState,r);if(i&&(l.memoizedState=r,xt=!0),l=l.queue,vd(sf.bind(null,s,l,e),[e]),l.getSnapshot!==t||i||Ze!==null&&Ze.memoizedState.tag&1){if(s.flags|=2048,fr(9,nf.bind(null,s,l,r,t),void 0,null),Ve===null)throw Error(F(349));ps&30||tf(s,t,r)}return r}function tf(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=Pe.updateQueue,t===null?(t={lastEffect:null,stores:null},Pe.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function nf(e,t,s,l){t.value=s,t.getSnapshot=l,lf(t)&&rf(e)}function sf(e,t,s){return s(function(){lf(t)&&rf(e)})}function lf(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Gt(e,s)}catch{return!0}}function rf(e){var t=gn(e,1);t!==null&&Ht(t,e,1,-1)}function Gc(e){var t=Vt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:e},t.queue=e,e=e.dispatch=Tm.bind(null,Pe,e),[t.memoizedState,e]}function fr(e,t,s,l){return e={tag:e,create:t,destroy:s,deps:l,next:null},t=Pe.updateQueue,t===null?(t={lastEffect:null,stores:null},Pe.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(l=s.next,s.next=e,e.next=l,t.lastEffect=e)),e}function af(){return Dt().memoizedState}function ai(e,t,s,l){var r=Vt();Pe.flags|=e,r.memoizedState=fr(1|t,s,void 0,l===void 0?null:l)}function Ki(e,t,s,l){var r=Dt();l=l===void 0?null:l;var i=void 0;if(Ke!==null){var a=Ke.memoizedState;if(i=a.destroy,l!==null&&xd(l,a.deps)){r.memoizedState=fr(t,s,i,l);return}}Pe.flags|=e,r.memoizedState=fr(1|t,s,i,l)}function Kc(e,t){return ai(8390656,8,e,t)}function vd(e,t){return Ki(2048,8,e,t)}function of(e,t){return Ki(4,2,e,t)}function df(e,t){return Ki(4,4,e,t)}function cf(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function uf(e,t,s){return s=s!=null?s.concat([e]):null,Ki(4,4,cf.bind(null,t,e),s)}function jd(){}function pf(e,t){var s=Dt();t=t===void 0?null:t;var l=s.memoizedState;return l!==null&&t!==null&&xd(t,l[1])?l[0]:(s.memoizedState=[e,t],e)}function ff(e,t){var s=Dt();t=t===void 0?null:t;var l=s.memoizedState;return l!==null&&t!==null&&xd(t,l[1])?l[0]:(e=e(),s.memoizedState=[e,t],e)}function hf(e,t,s){return ps&21?(Gt(s,t)||(s=yp(),Pe.lanes|=s,fs|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,xt=!0),e.memoizedState=s)}function Cm(e,t){var s=xe;xe=s!==0&&4>s?s:4,e(!0);var l=Ea.transition;Ea.transition={};try{e(!1),t()}finally{xe=s,Ea.transition=l}}function gf(){return Dt().memoizedState}function zm(e,t,s){var l=On(e);if(s={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null},xf(e))mf(t,s);else if(s=qp(e,t,s,l),s!==null){var r=ut();Ht(s,e,l,r),yf(s,t,l)}}function Tm(e,t,s){var l=On(e),r={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null};if(xf(e))mf(t,r);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,c=i(a,s);if(r.hasEagerState=!0,r.eagerState=c,Gt(c,a)){var d=t.interleaved;d===null?(r.next=r,ud(t)):(r.next=d.next,d.next=r),t.interleaved=r;return}}catch{}finally{}s=qp(e,t,r,l),s!==null&&(r=ut(),Ht(s,e,l,r),yf(s,t,l))}}function xf(e){var t=e.alternate;return e===Pe||t!==null&&t===Pe}function mf(e,t){Yl=Pi=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function yf(e,t,s){if(s&4194240){var l=t.lanes;l&=e.pendingLanes,s|=l,t.lanes=s,Jo(e,s)}}var Ei={readContext:Lt,useCallback:lt,useContext:lt,useEffect:lt,useImperativeHandle:lt,useInsertionEffect:lt,useLayoutEffect:lt,useMemo:lt,useReducer:lt,useRef:lt,useState:lt,useDebugValue:lt,useDeferredValue:lt,useTransition:lt,useMutableSource:lt,useSyncExternalStore:lt,useId:lt,unstable_isNewReconciler:!1},Im={readContext:Lt,useCallback:function(e,t){return Vt().memoizedState=[e,t===void 0?null:t],e},useContext:Lt,useEffect:Kc,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,ai(4194308,4,cf.bind(null,t,e),s)},useLayoutEffect:function(e,t){return ai(4194308,4,e,t)},useInsertionEffect:function(e,t){return ai(4,2,e,t)},useMemo:function(e,t){var s=Vt();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var l=Vt();return t=s!==void 0?s(t):t,l.memoizedState=l.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},l.queue=e,e=e.dispatch=zm.bind(null,Pe,e),[l.memoizedState,e]},useRef:function(e){var t=Vt();return e={current:e},t.memoizedState=e},useState:Gc,useDebugValue:jd,useDeferredValue:function(e){return Vt().memoizedState=e},useTransition:function(){var e=Gc(!1),t=e[0];return e=Cm.bind(null,e[1]),Vt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var l=Pe,r=Vt();if(ze){if(s===void 0)throw Error(F(407));s=s()}else{if(s=t(),Ve===null)throw Error(F(349));ps&30||tf(l,t,s)}r.memoizedState=s;var i={value:s,getSnapshot:t};return r.queue=i,Kc(sf.bind(null,l,i,e),[e]),l.flags|=2048,fr(9,nf.bind(null,l,i,s,t),void 0,null),s},useId:function(){var e=Vt(),t=Ve.identifierPrefix;if(ze){var s=un,l=cn;s=(l&~(1<<32-Mt(l)-1)).toString(32)+s,t=":"+t+"R"+s,s=ur++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=km++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Pm={readContext:Lt,useCallback:pf,useContext:Lt,useEffect:vd,useImperativeHandle:uf,useInsertionEffect:of,useLayoutEffect:df,useMemo:ff,useReducer:Aa,useRef:af,useState:function(){return Aa(pr)},useDebugValue:jd,useDeferredValue:function(e){var t=Dt();return hf(t,Ke.memoizedState,e)},useTransition:function(){var e=Aa(pr)[0],t=Dt().memoizedState;return[e,t]},useMutableSource:Vp,useSyncExternalStore:ef,useId:gf,unstable_isNewReconciler:!1},Em={readContext:Lt,useCallback:pf,useContext:Lt,useEffect:vd,useImperativeHandle:uf,useInsertionEffect:of,useLayoutEffect:df,useMemo:ff,useReducer:Ra,useRef:af,useState:function(){return Ra(pr)},useDebugValue:jd,useDeferredValue:function(e){var t=Dt();return Ke===null?t.memoizedState=e:hf(t,Ke.memoizedState,e)},useTransition:function(){var e=Ra(pr)[0],t=Dt().memoizedState;return[e,t]},useMutableSource:Vp,useSyncExternalStore:ef,useId:gf,unstable_isNewReconciler:!1};function Bt(e,t){if(e&&e.defaultProps){t=Ee({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function bo(e,t,s,l){t=e.memoizedState,s=s(l,t),s=s==null?t:Ee({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Qi={isMounted:function(e){return(e=e._reactInternals)?ms(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var l=ut(),r=On(e),i=pn(l,r);i.payload=t,s!=null&&(i.callback=s),t=An(e,i,r),t!==null&&(Ht(t,e,r,l),ri(t,e,r))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var l=ut(),r=On(e),i=pn(l,r);i.tag=1,i.payload=t,s!=null&&(i.callback=s),t=An(e,i,r),t!==null&&(Ht(t,e,r,l),ri(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=ut(),l=On(e),r=pn(s,l);r.tag=2,t!=null&&(r.callback=t),t=An(e,r,l),t!==null&&(Ht(t,e,l,s),ri(t,e,l))}};function Qc(e,t,s,l,r,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,i,a):t.prototype&&t.prototype.isPureReactComponent?!rr(s,l)||!rr(r,i):!0}function vf(e,t,s){var l=!1,r=Nn,i=t.contextType;return typeof i=="object"&&i!==null?i=Lt(i):(r=yt(t)?cs:at.current,l=t.contextTypes,i=(l=l!=null)?al(e,r):Nn),t=new t(s,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Qi,e.stateNode=t,t._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=i),t}function Yc(e,t,s,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,l),t.state!==e&&Qi.enqueueReplaceState(t,t.state,null)}function So(e,t,s,l){var r=e.stateNode;r.props=s,r.state=e.memoizedState,r.refs={},pd(e);var i=t.contextType;typeof i=="object"&&i!==null?r.context=Lt(i):(i=yt(t)?cs:at.current,r.context=al(e,i)),r.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(bo(e,t,i,s),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(t=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),t!==r.state&&Qi.enqueueReplaceState(r,r.state,null),Ti(e,s,r,l),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function ul(e,t){try{var s="",l=t;do s+=rx(l),l=l.return;while(l);var r=s}catch(i){r=`
Error generating stack: `+i.message+`
`+i.stack}return{value:e,source:t,stack:r,digest:null}}function Oa(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function wo(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var Am=typeof WeakMap=="function"?WeakMap:Map;function jf(e,t,s){s=pn(-1,s),s.tag=3,s.payload={element:null};var l=t.value;return s.callback=function(){Ri||(Ri=!0,Ro=l),wo(e,t)},s}function bf(e,t,s){s=pn(-1,s),s.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var r=t.value;s.payload=function(){return l(r)},s.callback=function(){wo(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(s.callback=function(){wo(e,t),typeof l!="function"&&(Rn===null?Rn=new Set([this]):Rn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),s}function Xc(e,t,s){var l=e.pingCache;if(l===null){l=e.pingCache=new Am;var r=new Set;l.set(t,r)}else r=l.get(t),r===void 0&&(r=new Set,l.set(t,r));r.has(s)||(r.add(s),e=Km.bind(null,e,t,s),t.then(e,e))}function qc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Jc(e,t,s,l,r){return e.mode&1?(e.flags|=65536,e.lanes=r,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=pn(-1,1),t.tag=2,An(s,t,1))),s.lanes|=1),e)}var Rm=mn.ReactCurrentOwner,xt=!1;function ct(e,t,s,l){t.child=e===null?Xp(t,null,s,l):dl(t,e.child,s,l)}function Zc(e,t,s,l,r){s=s.render;var i=t.ref;return ll(t,r),l=md(e,t,s,l,i,r),s=yd(),e!==null&&!xt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,xn(e,t,r)):(ze&&s&&rd(t),t.flags|=1,ct(e,t,l,r),t.child)}function Vc(e,t,s,l,r){if(e===null){var i=s.type;return typeof i=="function"&&!Td(i)&&i.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=i,Sf(e,t,i,l,r)):(e=ui(s.type,null,l,t,t.mode,r),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&r)){var a=i.memoizedProps;if(s=s.compare,s=s!==null?s:rr,s(a,l)&&e.ref===t.ref)return xn(e,t,r)}return t.flags|=1,e=Ln(i,l),e.ref=t.ref,e.return=t,t.child=e}function Sf(e,t,s,l,r){if(e!==null){var i=e.memoizedProps;if(rr(i,l)&&e.ref===t.ref)if(xt=!1,t.pendingProps=l=i,(e.lanes&r)!==0)e.flags&131072&&(xt=!0);else return t.lanes=e.lanes,xn(e,t,r)}return _o(e,t,s,l,r)}function wf(e,t,s){var l=t.pendingProps,r=l.children,i=e!==null?e.memoizedState:null;if(l.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},je(Zs,kt),kt|=s;else{if(!(s&1073741824))return e=i!==null?i.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,je(Zs,kt),kt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=i!==null?i.baseLanes:s,je(Zs,kt),kt|=l}else i!==null?(l=i.baseLanes|s,t.memoizedState=null):l=s,je(Zs,kt),kt|=l;return ct(e,t,r,s),t.child}function _f(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function _o(e,t,s,l,r){var i=yt(s)?cs:at.current;return i=al(t,i),ll(t,r),s=md(e,t,s,l,i,r),l=yd(),e!==null&&!xt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,xn(e,t,r)):(ze&&l&&rd(t),t.flags|=1,ct(e,t,s,r),t.child)}function eu(e,t,s,l,r){if(yt(s)){var i=!0;wi(t)}else i=!1;if(ll(t,r),t.stateNode===null)oi(e,t),vf(t,s,l),So(t,s,l,r),l=!0;else if(e===null){var a=t.stateNode,c=t.memoizedProps;a.props=c;var d=a.context,h=s.contextType;typeof h=="object"&&h!==null?h=Lt(h):(h=yt(s)?cs:at.current,h=al(t,h));var j=s.getDerivedStateFromProps,p=typeof j=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(c!==l||d!==h)&&Yc(t,a,l,h),bn=!1;var u=t.memoizedState;a.state=u,Ti(t,l,a,r),d=t.memoizedState,c!==l||u!==d||mt.current||bn?(typeof j=="function"&&(bo(t,s,j,l),d=t.memoizedState),(c=bn||Qc(t,s,c,l,u,d,h))?(p||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=d),a.props=l,a.state=d,a.context=h,l=c):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{a=t.stateNode,Jp(e,t),c=t.memoizedProps,h=t.type===t.elementType?c:Bt(t.type,c),a.props=h,p=t.pendingProps,u=a.context,d=s.contextType,typeof d=="object"&&d!==null?d=Lt(d):(d=yt(s)?cs:at.current,d=al(t,d));var y=s.getDerivedStateFromProps;(j=typeof y=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(c!==p||u!==d)&&Yc(t,a,l,d),bn=!1,u=t.memoizedState,a.state=u,Ti(t,l,a,r);var v=t.memoizedState;c!==p||u!==v||mt.current||bn?(typeof y=="function"&&(bo(t,s,y,l),v=t.memoizedState),(h=bn||Qc(t,s,h,l,u,v,d)||!1)?(j||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(l,v,d),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(l,v,d)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=v),a.props=l,a.state=v,a.context=d,l=h):(typeof a.componentDidUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),l=!1)}return ko(e,t,s,l,i,r)}function ko(e,t,s,l,r,i){_f(e,t);var a=(t.flags&128)!==0;if(!l&&!a)return r&&Bc(t,s,!1),xn(e,t,i);l=t.stateNode,Rm.current=t;var c=a&&typeof s.getDerivedStateFromError!="function"?null:l.render();return t.flags|=1,e!==null&&a?(t.child=dl(t,e.child,null,i),t.child=dl(t,null,c,i)):ct(e,t,c,i),t.memoizedState=l.state,r&&Bc(t,s,!0),t.child}function kf(e){var t=e.stateNode;t.pendingContext?Wc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Wc(e,t.context,!1),fd(e,t.containerInfo)}function tu(e,t,s,l,r){return ol(),ad(r),t.flags|=256,ct(e,t,s,l),t.child}var Co={dehydrated:null,treeContext:null,retryLane:0};function zo(e){return{baseLanes:e,cachePool:null,transitions:null}}function Cf(e,t,s){var l=t.pendingProps,r=Ie.current,i=!1,a=(t.flags&128)!==0,c;if((c=a)||(c=e!==null&&e.memoizedState===null?!1:(r&2)!==0),c?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(r|=1),je(Ie,r&1),e===null)return vo(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=l.children,e=l.fallback,i?(l=t.mode,i=t.child,a={mode:"hidden",children:a},!(l&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=qi(a,l,0,null),e=ds(e,l,s,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=zo(s),t.memoizedState=Co,e):bd(t,a));if(r=e.memoizedState,r!==null&&(c=r.dehydrated,c!==null))return Om(e,t,a,l,c,r,s);if(i){i=l.fallback,a=t.mode,r=e.child,c=r.sibling;var d={mode:"hidden",children:l.children};return!(a&1)&&t.child!==r?(l=t.child,l.childLanes=0,l.pendingProps=d,t.deletions=null):(l=Ln(r,d),l.subtreeFlags=r.subtreeFlags&14680064),c!==null?i=Ln(c,i):(i=ds(i,a,s,null),i.flags|=2),i.return=t,l.return=t,l.sibling=i,t.child=l,l=i,i=t.child,a=e.child.memoizedState,a=a===null?zo(s):{baseLanes:a.baseLanes|s,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~s,t.memoizedState=Co,l}return i=e.child,e=i.sibling,l=Ln(i,{mode:"visible",children:l.children}),!(t.mode&1)&&(l.lanes=s),l.return=t,l.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=l,t.memoizedState=null,l}function bd(e,t){return t=qi({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ur(e,t,s,l){return l!==null&&ad(l),dl(t,e.child,null,s),e=bd(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Om(e,t,s,l,r,i,a){if(s)return t.flags&256?(t.flags&=-257,l=Oa(Error(F(422))),Ur(e,t,a,l)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=l.fallback,r=t.mode,l=qi({mode:"visible",children:l.children},r,0,null),i=ds(i,r,a,null),i.flags|=2,l.return=t,i.return=t,l.sibling=i,t.child=l,t.mode&1&&dl(t,e.child,null,a),t.child.memoizedState=zo(a),t.memoizedState=Co,i);if(!(t.mode&1))return Ur(e,t,a,null);if(r.data==="$!"){if(l=r.nextSibling&&r.nextSibling.dataset,l)var c=l.dgst;return l=c,i=Error(F(419)),l=Oa(i,l,void 0),Ur(e,t,a,l)}if(c=(a&e.childLanes)!==0,xt||c){if(l=Ve,l!==null){switch(a&-a){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|a)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,gn(e,r),Ht(l,e,r,-1))}return zd(),l=Oa(Error(F(421))),Ur(e,t,a,l)}return r.data==="$?"?(t.flags|=128,t.child=e.child,t=Qm.bind(null,e),r._reactRetry=t,null):(e=i.treeContext,Ct=En(r.nextSibling),zt=t,ze=!0,Ut=null,e!==null&&(Et[At++]=cn,Et[At++]=un,Et[At++]=us,cn=e.id,un=e.overflow,us=t),t=bd(t,l.children),t.flags|=4096,t)}function nu(e,t,s){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),jo(e.return,t,s)}function La(e,t,s,l,r){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:s,tailMode:r}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=l,i.tail=s,i.tailMode=r)}function zf(e,t,s){var l=t.pendingProps,r=l.revealOrder,i=l.tail;if(ct(e,t,l.children,s),l=Ie.current,l&2)l=l&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&nu(e,s,t);else if(e.tag===19)nu(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(je(Ie,l),!(t.mode&1))t.memoizedState=null;else switch(r){case"forwards":for(s=t.child,r=null;s!==null;)e=s.alternate,e!==null&&Ii(e)===null&&(r=s),s=s.sibling;s=r,s===null?(r=t.child,t.child=null):(r=s.sibling,s.sibling=null),La(t,!1,r,s,i);break;case"backwards":for(s=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&Ii(e)===null){t.child=r;break}e=r.sibling,r.sibling=s,s=r,r=e}La(t,!0,s,null,i);break;case"together":La(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function oi(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function xn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),fs|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(F(153));if(t.child!==null){for(e=t.child,s=Ln(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Ln(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Lm(e,t,s){switch(t.tag){case 3:kf(t),ol();break;case 5:Zp(t);break;case 1:yt(t.type)&&wi(t);break;case 4:fd(t,t.stateNode.containerInfo);break;case 10:var l=t.type._context,r=t.memoizedProps.value;je(Ci,l._currentValue),l._currentValue=r;break;case 13:if(l=t.memoizedState,l!==null)return l.dehydrated!==null?(je(Ie,Ie.current&1),t.flags|=128,null):s&t.child.childLanes?Cf(e,t,s):(je(Ie,Ie.current&1),e=xn(e,t,s),e!==null?e.sibling:null);je(Ie,Ie.current&1);break;case 19:if(l=(s&t.childLanes)!==0,e.flags&128){if(l)return zf(e,t,s);t.flags|=128}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),je(Ie,Ie.current),l)break;return null;case 22:case 23:return t.lanes=0,wf(e,t,s)}return xn(e,t,s)}var Tf,To,If,Pf;Tf=function(e,t){for(var s=t.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===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};To=function(){};If=function(e,t,s,l){var r=e.memoizedProps;if(r!==l){e=t.stateNode,as(nn.current);var i=null;switch(s){case"input":r=Xa(e,r),l=Xa(e,l),i=[];break;case"select":r=Ee({},r,{value:void 0}),l=Ee({},l,{value:void 0}),i=[];break;case"textarea":r=Za(e,r),l=Za(e,l),i=[];break;default:typeof r.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=bi)}eo(s,l);var a;s=null;for(h in r)if(!l.hasOwnProperty(h)&&r.hasOwnProperty(h)&&r[h]!=null)if(h==="style"){var c=r[h];for(a in c)c.hasOwnProperty(a)&&(s||(s={}),s[a]="")}else h!=="dangerouslySetInnerHTML"&&h!=="children"&&h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(Zl.hasOwnProperty(h)?i||(i=[]):(i=i||[]).push(h,null));for(h in l){var d=l[h];if(c=r!=null?r[h]:void 0,l.hasOwnProperty(h)&&d!==c&&(d!=null||c!=null))if(h==="style")if(c){for(a in c)!c.hasOwnProperty(a)||d&&d.hasOwnProperty(a)||(s||(s={}),s[a]="");for(a in d)d.hasOwnProperty(a)&&c[a]!==d[a]&&(s||(s={}),s[a]=d[a])}else s||(i||(i=[]),i.push(h,s)),s=d;else h==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,c=c?c.__html:void 0,d!=null&&c!==d&&(i=i||[]).push(h,d)):h==="children"?typeof d!="string"&&typeof d!="number"||(i=i||[]).push(h,""+d):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&(Zl.hasOwnProperty(h)?(d!=null&&h==="onScroll"&&Se("scroll",e),i||c===d||(i=[])):(i=i||[]).push(h,d))}s&&(i=i||[]).push("style",s);var h=i;(t.updateQueue=h)&&(t.flags|=4)}};Pf=function(e,t,s,l){s!==l&&(t.flags|=4)};function Pl(e,t){if(!ze)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.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?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function rt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,l=0;if(t)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,t}function Dm(e,t,s){var l=t.pendingProps;switch(id(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rt(t),null;case 1:return yt(t.type)&&Si(),rt(t),null;case 3:return l=t.stateNode,cl(),we(mt),we(at),gd(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Br(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ut!==null&&(Do(Ut),Ut=null))),To(e,t),rt(t),null;case 5:hd(t);var r=as(cr.current);if(s=t.type,e!==null&&t.stateNode!=null)If(e,t,s,l,r),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!l){if(t.stateNode===null)throw Error(F(166));return rt(t),null}if(e=as(nn.current),Br(t)){l=t.stateNode,s=t.type;var i=t.memoizedProps;switch(l[en]=t,l[or]=i,e=(t.mode&1)!==0,s){case"dialog":Se("cancel",l),Se("close",l);break;case"iframe":case"object":case"embed":Se("load",l);break;case"video":case"audio":for(r=0;r<Ul.length;r++)Se(Ul[r],l);break;case"source":Se("error",l);break;case"img":case"image":case"link":Se("error",l),Se("load",l);break;case"details":Se("toggle",l);break;case"input":uc(l,i),Se("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!i.multiple},Se("invalid",l);break;case"textarea":fc(l,i),Se("invalid",l)}eo(s,i),r=null;for(var a in i)if(i.hasOwnProperty(a)){var c=i[a];a==="children"?typeof c=="string"?l.textContent!==c&&(i.suppressHydrationWarning!==!0&&Wr(l.textContent,c,e),r=["children",c]):typeof c=="number"&&l.textContent!==""+c&&(i.suppressHydrationWarning!==!0&&Wr(l.textContent,c,e),r=["children",""+c]):Zl.hasOwnProperty(a)&&c!=null&&a==="onScroll"&&Se("scroll",l)}switch(s){case"input":Pr(l),pc(l,i,!0);break;case"textarea":Pr(l),hc(l);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(l.onclick=bi)}l=r,t.updateQueue=l,l!==null&&(t.flags|=4)}else{a=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=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=a.createElement(s,{is:l.is}):(e=a.createElement(s),s==="select"&&(a=e,l.multiple?a.multiple=!0:l.size&&(a.size=l.size))):e=a.createElementNS(e,s),e[en]=t,e[or]=l,Tf(e,t,!1,!1),t.stateNode=e;e:{switch(a=to(s,l),s){case"dialog":Se("cancel",e),Se("close",e),r=l;break;case"iframe":case"object":case"embed":Se("load",e),r=l;break;case"video":case"audio":for(r=0;r<Ul.length;r++)Se(Ul[r],e);r=l;break;case"source":Se("error",e),r=l;break;case"img":case"image":case"link":Se("error",e),Se("load",e),r=l;break;case"details":Se("toggle",e),r=l;break;case"input":uc(e,l),r=Xa(e,l),Se("invalid",e);break;case"option":r=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},r=Ee({},l,{value:void 0}),Se("invalid",e);break;case"textarea":fc(e,l),r=Za(e,l),Se("invalid",e);break;default:r=l}eo(s,r),c=r;for(i in c)if(c.hasOwnProperty(i)){var d=c[i];i==="style"?ip(e,d):i==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,d!=null&&lp(e,d)):i==="children"?typeof d=="string"?(s!=="textarea"||d!=="")&&Vl(e,d):typeof d=="number"&&Vl(e,""+d):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Zl.hasOwnProperty(i)?d!=null&&i==="onScroll"&&Se("scroll",e):d!=null&&Go(e,i,d,a))}switch(s){case"input":Pr(e),pc(e,l,!1);break;case"textarea":Pr(e),hc(e);break;case"option":l.value!=null&&e.setAttribute("value",""+Dn(l.value));break;case"select":e.multiple=!!l.multiple,i=l.value,i!=null?el(e,!!l.multiple,i,!1):l.defaultValue!=null&&el(e,!!l.multiple,l.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=bi)}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&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return rt(t),null;case 6:if(e&&t.stateNode!=null)Pf(e,t,e.memoizedProps,l);else{if(typeof l!="string"&&t.stateNode===null)throw Error(F(166));if(s=as(cr.current),as(nn.current),Br(t)){if(l=t.stateNode,s=t.memoizedProps,l[en]=t,(i=l.nodeValue!==s)&&(e=zt,e!==null))switch(e.tag){case 3:Wr(l.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Wr(l.nodeValue,s,(e.mode&1)!==0)}i&&(t.flags|=4)}else l=(s.nodeType===9?s:s.ownerDocument).createTextNode(l),l[en]=t,t.stateNode=l}return rt(t),null;case 13:if(we(Ie),l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ze&&Ct!==null&&t.mode&1&&!(t.flags&128))Qp(),ol(),t.flags|=98560,i=!1;else if(i=Br(t),l!==null&&l.dehydrated!==null){if(e===null){if(!i)throw Error(F(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[en]=t}else ol(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;rt(t),i=!1}else Ut!==null&&(Do(Ut),Ut=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(t.child.flags|=8192,t.mode&1&&(e===null||Ie.current&1?Qe===0&&(Qe=3):zd())),t.updateQueue!==null&&(t.flags|=4),rt(t),null);case 4:return cl(),To(e,t),e===null&&ir(t.stateNode.containerInfo),rt(t),null;case 10:return cd(t.type._context),rt(t),null;case 17:return yt(t.type)&&Si(),rt(t),null;case 19:if(we(Ie),i=t.memoizedState,i===null)return rt(t),null;if(l=(t.flags&128)!==0,a=i.rendering,a===null)if(l)Pl(i,!1);else{if(Qe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Ii(e),a!==null){for(t.flags|=128,Pl(i,!1),l=a.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),t.subtreeFlags=0,l=s,s=t.child;s!==null;)i=s,e=l,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return je(Ie,Ie.current&1|2),t.child}e=e.sibling}i.tail!==null&&Ne()>pl&&(t.flags|=128,l=!0,Pl(i,!1),t.lanes=4194304)}else{if(!l)if(e=Ii(a),e!==null){if(t.flags|=128,l=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),Pl(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ze)return rt(t),null}else 2*Ne()-i.renderingStartTime>pl&&s!==1073741824&&(t.flags|=128,l=!0,Pl(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(s=i.last,s!==null?s.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ne(),t.sibling=null,s=Ie.current,je(Ie,l?s&1|2:s&1),t):(rt(t),null);case 22:case 23:return Cd(),l=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(t.flags|=8192),l&&t.mode&1?kt&1073741824&&(rt(t),t.subtreeFlags&6&&(t.flags|=8192)):rt(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function Nm(e,t){switch(id(t),t.tag){case 1:return yt(t.type)&&Si(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cl(),we(mt),we(at),gd(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return hd(t),null;case 13:if(we(Ie),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));ol()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return we(Ie),null;case 4:return cl(),null;case 10:return cd(t.type._context),null;case 22:case 23:return Cd(),null;case 24:return null;default:return null}}var Fr=!1,it=!1,Wm=typeof WeakSet=="function"?WeakSet:Set,q=null;function Js(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(l){Oe(e,t,l)}else s.current=null}function Io(e,t,s){try{s()}catch(l){Oe(e,t,l)}}var su=!1;function Bm(e,t){if(po=yi,e=Op(),ld(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,i=l.focusNode;l=l.focusOffset;try{s.nodeType,i.nodeType}catch{s=null;break e}var a=0,c=-1,d=-1,h=0,j=0,p=e,u=null;t:for(;;){for(var y;p!==s||r!==0&&p.nodeType!==3||(c=a+r),p!==i||l!==0&&p.nodeType!==3||(d=a+l),p.nodeType===3&&(a+=p.nodeValue.length),(y=p.firstChild)!==null;)u=p,p=y;for(;;){if(p===e)break t;if(u===s&&++h===r&&(c=a),u===i&&++j===l&&(d=a),(y=p.nextSibling)!==null)break;p=u,u=p.parentNode}p=y}s=c===-1||d===-1?null:{start:c,end:d}}else s=null}s=s||{start:0,end:0}}else s=null;for(fo={focusedElem:e,selectionRange:s},yi=!1,q=t;q!==null;)if(t=q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,q=e;else for(;q!==null;){t=q;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var f=v.memoizedProps,S=v.memoizedState,g=t.stateNode,x=g.getSnapshotBeforeUpdate(t.elementType===t.type?f:Bt(t.type,f),S);g.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var o=t.stateNode.containerInfo;o.nodeType===1?o.textContent="":o.nodeType===9&&o.documentElement&&o.removeChild(o.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(m){Oe(t,t.return,m)}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}return v=su,su=!1,v}function Xl(e,t,s){var l=t.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var r=l=l.next;do{if((r.tag&e)===e){var i=r.destroy;r.destroy=void 0,i!==void 0&&Io(t,s,i)}r=r.next}while(r!==l)}}function Yi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var l=s.create;s.destroy=l()}s=s.next}while(s!==t)}}function Po(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function Ef(e){var t=e.alternate;t!==null&&(e.alternate=null,Ef(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[en],delete t[or],delete t[xo],delete t[bm],delete t[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 lu(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 Eo(e,t,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=bi));else if(l!==4&&(e=e.child,e!==null))for(Eo(e,t,s),e=e.sibling;e!==null;)Eo(e,t,s),e=e.sibling}function Ao(e,t,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Ao(e,t,s),e=e.sibling;e!==null;)Ao(e,t,s),e=e.sibling}var tt=null,$t=!1;function yn(e,t,s){for(s=s.child;s!==null;)Rf(e,t,s),s=s.sibling}function Rf(e,t,s){if(tn&&typeof tn.onCommitFiberUnmount=="function")try{tn.onCommitFiberUnmount($i,s)}catch{}switch(s.tag){case 5:it||Js(s,t);case 6:var l=tt,r=$t;tt=null,yn(e,t,s),tt=l,$t=r,tt!==null&&($t?(e=tt,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):tt.removeChild(s.stateNode));break;case 18:tt!==null&&($t?(e=tt,s=s.stateNode,e.nodeType===8?Ta(e.parentNode,s):e.nodeType===1&&Ta(e,s),sr(e)):Ta(tt,s.stateNode));break;case 4:l=tt,r=$t,tt=s.stateNode.containerInfo,$t=!0,yn(e,t,s),tt=l,$t=r;break;case 0:case 11:case 14:case 15:if(!it&&(l=s.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){r=l=l.next;do{var i=r,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&Io(s,t,a),r=r.next}while(r!==l)}yn(e,t,s);break;case 1:if(!it&&(Js(s,t),l=s.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=s.memoizedProps,l.state=s.memoizedState,l.componentWillUnmount()}catch(c){Oe(s,t,c)}yn(e,t,s);break;case 21:yn(e,t,s);break;case 22:s.mode&1?(it=(l=it)||s.memoizedState!==null,yn(e,t,s),it=l):yn(e,t,s);break;default:yn(e,t,s)}}function ru(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Wm),t.forEach(function(l){var r=Ym.bind(null,e,l);s.has(l)||(s.add(l),l.then(r,r))})}}function Wt(e,t){var s=t.deletions;if(s!==null)for(var l=0;l<s.length;l++){var r=s[l];try{var i=e,a=t,c=a;e:for(;c!==null;){switch(c.tag){case 5:tt=c.stateNode,$t=!1;break e;case 3:tt=c.stateNode.containerInfo,$t=!0;break e;case 4:tt=c.stateNode.containerInfo,$t=!0;break e}c=c.return}if(tt===null)throw Error(F(160));Rf(i,a,r),tt=null,$t=!1;var d=r.alternate;d!==null&&(d.return=null),r.return=null}catch(h){Oe(r,t,h)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Of(t,e),t=t.sibling}function Of(e,t){var s=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Wt(t,e),qt(e),l&4){try{Xl(3,e,e.return),Yi(3,e)}catch(f){Oe(e,e.return,f)}try{Xl(5,e,e.return)}catch(f){Oe(e,e.return,f)}}break;case 1:Wt(t,e),qt(e),l&512&&s!==null&&Js(s,s.return);break;case 5:if(Wt(t,e),qt(e),l&512&&s!==null&&Js(s,s.return),e.flags&32){var r=e.stateNode;try{Vl(r,"")}catch(f){Oe(e,e.return,f)}}if(l&4&&(r=e.stateNode,r!=null)){var i=e.memoizedProps,a=s!==null?s.memoizedProps:i,c=e.type,d=e.updateQueue;if(e.updateQueue=null,d!==null)try{c==="input"&&i.type==="radio"&&i.name!=null&&tp(r,i),to(c,a);var h=to(c,i);for(a=0;a<d.length;a+=2){var j=d[a],p=d[a+1];j==="style"?ip(r,p):j==="dangerouslySetInnerHTML"?lp(r,p):j==="children"?Vl(r,p):Go(r,j,p,h)}switch(c){case"input":qa(r,i);break;case"textarea":np(r,i);break;case"select":var u=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!i.multiple;var y=i.value;y!=null?el(r,!!i.multiple,y,!1):u!==!!i.multiple&&(i.defaultValue!=null?el(r,!!i.multiple,i.defaultValue,!0):el(r,!!i.multiple,i.multiple?[]:"",!1))}r[or]=i}catch(f){Oe(e,e.return,f)}}break;case 6:if(Wt(t,e),qt(e),l&4){if(e.stateNode===null)throw Error(F(162));r=e.stateNode,i=e.memoizedProps;try{r.nodeValue=i}catch(f){Oe(e,e.return,f)}}break;case 3:if(Wt(t,e),qt(e),l&4&&s!==null&&s.memoizedState.isDehydrated)try{sr(t.containerInfo)}catch(f){Oe(e,e.return,f)}break;case 4:Wt(t,e),qt(e);break;case 13:Wt(t,e),qt(e),r=e.child,r.flags&8192&&(i=r.memoizedState!==null,r.stateNode.isHidden=i,!i||r.alternate!==null&&r.alternate.memoizedState!==null||(_d=Ne())),l&4&&ru(e);break;case 22:if(j=s!==null&&s.memoizedState!==null,e.mode&1?(it=(h=it)||j,Wt(t,e),it=h):Wt(t,e),qt(e),l&8192){if(h=e.memoizedState!==null,(e.stateNode.isHidden=h)&&!j&&e.mode&1)for(q=e,j=e.child;j!==null;){for(p=q=j;q!==null;){switch(u=q,y=u.child,u.tag){case 0:case 11:case 14:case 15:Xl(4,u,u.return);break;case 1:Js(u,u.return);var v=u.stateNode;if(typeof v.componentWillUnmount=="function"){l=u,s=u.return;try{t=l,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(f){Oe(l,s,f)}}break;case 5:Js(u,u.return);break;case 22:if(u.memoizedState!==null){au(p);continue}}y!==null?(y.return=u,q=y):au(p)}j=j.sibling}e:for(j=null,p=e;;){if(p.tag===5){if(j===null){j=p;try{r=p.stateNode,h?(i=r.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(c=p.stateNode,d=p.memoizedProps.style,a=d!=null&&d.hasOwnProperty("display")?d.display:null,c.style.display=rp("display",a))}catch(f){Oe(e,e.return,f)}}}else if(p.tag===6){if(j===null)try{p.stateNode.nodeValue=h?"":p.memoizedProps}catch(f){Oe(e,e.return,f)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;j===p&&(j=null),p=p.return}j===p&&(j=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Wt(t,e),qt(e),l&4&&ru(e);break;case 21:break;default:Wt(t,e),qt(e)}}function qt(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(Af(s)){var l=s;break e}s=s.return}throw Error(F(160))}switch(l.tag){case 5:var r=l.stateNode;l.flags&32&&(Vl(r,""),l.flags&=-33);var i=lu(e);Ao(e,i,r);break;case 3:case 4:var a=l.stateNode.containerInfo,c=lu(e);Eo(e,c,a);break;default:throw Error(F(161))}}catch(d){Oe(e,e.return,d)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function $m(e,t,s){q=e,Lf(e)}function Lf(e,t,s){for(var l=(e.mode&1)!==0;q!==null;){var r=q,i=r.child;if(r.tag===22&&l){var a=r.memoizedState!==null||Fr;if(!a){var c=r.alternate,d=c!==null&&c.memoizedState!==null||it;c=Fr;var h=it;if(Fr=a,(it=d)&&!h)for(q=r;q!==null;)a=q,d=a.child,a.tag===22&&a.memoizedState!==null?ou(r):d!==null?(d.return=a,q=d):ou(r);for(;i!==null;)q=i,Lf(i),i=i.sibling;q=r,Fr=c,it=h}iu(e)}else r.subtreeFlags&8772&&i!==null?(i.return=r,q=i):iu(e)}}function iu(e){for(;q!==null;){var t=q;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:it||Yi(5,t);break;case 1:var l=t.stateNode;if(t.flags&4&&!it)if(s===null)l.componentDidMount();else{var r=t.elementType===t.type?s.memoizedProps:Bt(t.type,s.memoizedProps);l.componentDidUpdate(r,s.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Hc(t,i,l);break;case 3:var a=t.updateQueue;if(a!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}Hc(t,a,s)}break;case 5:var c=t.stateNode;if(s===null&&t.flags&4){s=c;var d=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":d.autoFocus&&s.focus();break;case"img":d.src&&(s.src=d.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var h=t.alternate;if(h!==null){var j=h.memoizedState;if(j!==null){var p=j.dehydrated;p!==null&&sr(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}it||t.flags&512&&Po(t)}catch(u){Oe(t,t.return,u)}}if(t===e){q=null;break}if(s=t.sibling,s!==null){s.return=t.return,q=s;break}q=t.return}}function au(e){for(;q!==null;){var t=q;if(t===e){q=null;break}var s=t.sibling;if(s!==null){s.return=t.return,q=s;break}q=t.return}}function ou(e){for(;q!==null;){var t=q;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Yi(4,t)}catch(d){Oe(t,s,d)}break;case 1:var l=t.stateNode;if(typeof l.componentDidMount=="function"){var r=t.return;try{l.componentDidMount()}catch(d){Oe(t,r,d)}}var i=t.return;try{Po(t)}catch(d){Oe(t,i,d)}break;case 5:var a=t.return;try{Po(t)}catch(d){Oe(t,a,d)}}}catch(d){Oe(t,t.return,d)}if(t===e){q=null;break}var c=t.sibling;if(c!==null){c.return=t.return,q=c;break}q=t.return}}var Um=Math.ceil,Ai=mn.ReactCurrentDispatcher,Sd=mn.ReactCurrentOwner,Ot=mn.ReactCurrentBatchConfig,ce=0,Ve=null,Fe=null,nt=0,kt=0,Zs=Bn(0),Qe=0,hr=null,fs=0,Xi=0,wd=0,ql=null,gt=null,_d=0,pl=1/0,on=null,Ri=!1,Ro=null,Rn=null,Mr=!1,kn=null,Oi=0,Jl=0,Oo=null,di=-1,ci=0;function ut(){return ce&6?Ne():di!==-1?di:di=Ne()}function On(e){return e.mode&1?ce&2&&nt!==0?nt&-nt:_m.transition!==null?(ci===0&&(ci=yp()),ci):(e=xe,e!==0||(e=window.event,e=e===void 0?16:kp(e.type)),e):1}function Ht(e,t,s,l){if(50<Jl)throw Jl=0,Oo=null,Error(F(185));xr(e,s,l),(!(ce&2)||e!==Ve)&&(e===Ve&&(!(ce&2)&&(Xi|=s),Qe===4&&wn(e,nt)),vt(e,l),s===1&&ce===0&&!(t.mode&1)&&(pl=Ne()+500,Gi&&$n()))}function vt(e,t){var s=e.callbackNode;_x(e,t);var l=mi(e,e===Ve?nt:0);if(l===0)s!==null&&mc(s),e.callbackNode=null,e.callbackPriority=0;else if(t=l&-l,e.callbackPriority!==t){if(s!=null&&mc(s),t===1)e.tag===0?wm(du.bind(null,e)):Hp(du.bind(null,e)),vm(function(){!(ce&6)&&$n()}),s=null;else{switch(vp(l)){case 1:s=qo;break;case 4:s=xp;break;case 16:s=xi;break;case 536870912:s=mp;break;default:s=xi}s=Mf(s,Df.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function Df(e,t){if(di=-1,ci=0,ce&6)throw Error(F(327));var s=e.callbackNode;if(rl()&&e.callbackNode!==s)return null;var l=mi(e,e===Ve?nt:0);if(l===0)return null;if(l&30||l&e.expiredLanes||t)t=Li(e,l);else{t=l;var r=ce;ce|=2;var i=Wf();(Ve!==e||nt!==t)&&(on=null,pl=Ne()+500,os(e,t));do try{Hm();break}catch(c){Nf(e,c)}while(!0);dd(),Ai.current=i,ce=r,Fe!==null?t=0:(Ve=null,nt=0,t=Qe)}if(t!==0){if(t===2&&(r=io(e),r!==0&&(l=r,t=Lo(e,r))),t===1)throw s=hr,os(e,0),wn(e,l),vt(e,Ne()),s;if(t===6)wn(e,l);else{if(r=e.current.alternate,!(l&30)&&!Fm(r)&&(t=Li(e,l),t===2&&(i=io(e),i!==0&&(l=i,t=Lo(e,i))),t===1))throw s=hr,os(e,0),wn(e,l),vt(e,Ne()),s;switch(e.finishedWork=r,e.finishedLanes=l,t){case 0:case 1:throw Error(F(345));case 2:ls(e,gt,on);break;case 3:if(wn(e,l),(l&130023424)===l&&(t=_d+500-Ne(),10<t)){if(mi(e,0)!==0)break;if(r=e.suspendedLanes,(r&l)!==l){ut(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=go(ls.bind(null,e,gt,on),t);break}ls(e,gt,on);break;case 4:if(wn(e,l),(l&4194240)===l)break;for(t=e.eventTimes,r=-1;0<l;){var a=31-Mt(l);i=1<<a,a=t[a],a>r&&(r=a),l&=~i}if(l=r,l=Ne()-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(ls.bind(null,e,gt,on),l);break}ls(e,gt,on);break;case 5:ls(e,gt,on);break;default:throw Error(F(329))}}}return vt(e,Ne()),e.callbackNode===s?Df.bind(null,e):null}function Lo(e,t){var s=ql;return e.current.memoizedState.isDehydrated&&(os(e,t).flags|=256),e=Li(e,t),e!==2&&(t=gt,gt=s,t!==null&&Do(t)),e}function Do(e){gt===null?gt=e:gt.push.apply(gt,e)}function Fm(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var l=0;l<s.length;l++){var r=s[l],i=r.getSnapshot;r=r.value;try{if(!Gt(i(),r))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function wn(e,t){for(t&=~wd,t&=~Xi,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-Mt(t),l=1<<s;e[s]=-1,t&=~l}}function du(e){if(ce&6)throw Error(F(327));rl();var t=mi(e,0);if(!(t&1))return vt(e,Ne()),null;var s=Li(e,t);if(e.tag!==0&&s===2){var l=io(e);l!==0&&(t=l,s=Lo(e,l))}if(s===1)throw s=hr,os(e,0),wn(e,t),vt(e,Ne()),s;if(s===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ls(e,gt,on),vt(e,Ne()),null}function kd(e,t){var s=ce;ce|=1;try{return e(t)}finally{ce=s,ce===0&&(pl=Ne()+500,Gi&&$n())}}function hs(e){kn!==null&&kn.tag===0&&!(ce&6)&&rl();var t=ce;ce|=1;var s=Ot.transition,l=xe;try{if(Ot.transition=null,xe=1,e)return e()}finally{xe=l,Ot.transition=s,ce=t,!(ce&6)&&$n()}}function Cd(){kt=Zs.current,we(Zs)}function os(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,ym(s)),Fe!==null)for(s=Fe.return;s!==null;){var l=s;switch(id(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&Si();break;case 3:cl(),we(mt),we(at),gd();break;case 5:hd(l);break;case 4:cl();break;case 13:we(Ie);break;case 19:we(Ie);break;case 10:cd(l.type._context);break;case 22:case 23:Cd()}s=s.return}if(Ve=e,Fe=e=Ln(e.current,null),nt=kt=t,Qe=0,hr=null,wd=Xi=fs=0,gt=ql=null,is!==null){for(t=0;t<is.length;t++)if(s=is[t],l=s.interleaved,l!==null){s.interleaved=null;var r=l.next,i=s.pending;if(i!==null){var a=i.next;i.next=r,l.next=a}s.pending=l}is=null}return e}function Nf(e,t){do{var s=Fe;try{if(dd(),ii.current=Ei,Pi){for(var l=Pe.memoizedState;l!==null;){var r=l.queue;r!==null&&(r.pending=null),l=l.next}Pi=!1}if(ps=0,Ze=Ke=Pe=null,Yl=!1,ur=0,Sd.current=null,s===null||s.return===null){Qe=1,hr=t,Fe=null;break}e:{var i=e,a=s.return,c=s,d=t;if(t=nt,c.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){var h=d,j=c,p=j.tag;if(!(j.mode&1)&&(p===0||p===11||p===15)){var u=j.alternate;u?(j.updateQueue=u.updateQueue,j.memoizedState=u.memoizedState,j.lanes=u.lanes):(j.updateQueue=null,j.memoizedState=null)}var y=qc(a);if(y!==null){y.flags&=-257,Jc(y,a,c,i,t),y.mode&1&&Xc(i,h,t),t=y,d=h;var v=t.updateQueue;if(v===null){var f=new Set;f.add(d),t.updateQueue=f}else v.add(d);break e}else{if(!(t&1)){Xc(i,h,t),zd();break e}d=Error(F(426))}}else if(ze&&c.mode&1){var S=qc(a);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Jc(S,a,c,i,t),ad(ul(d,c));break e}}i=d=ul(d,c),Qe!==4&&(Qe=2),ql===null?ql=[i]:ql.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=jf(i,d,t);Mc(i,g);break e;case 1:c=d;var x=i.type,o=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Rn===null||!Rn.has(o)))){i.flags|=65536,t&=-t,i.lanes|=t;var m=bf(i,c,t);Mc(i,m);break e}}i=i.return}while(i!==null)}$f(s)}catch(_){t=_,Fe===s&&s!==null&&(Fe=s=s.return);continue}break}while(!0)}function Wf(){var e=Ai.current;return Ai.current=Ei,e===null?Ei:e}function zd(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),Ve===null||!(fs&268435455)&&!(Xi&268435455)||wn(Ve,nt)}function Li(e,t){var s=ce;ce|=2;var l=Wf();(Ve!==e||nt!==t)&&(on=null,os(e,t));do try{Mm();break}catch(r){Nf(e,r)}while(!0);if(dd(),ce=s,Ai.current=l,Fe!==null)throw Error(F(261));return Ve=null,nt=0,Qe}function Mm(){for(;Fe!==null;)Bf(Fe)}function Hm(){for(;Fe!==null&&!gx();)Bf(Fe)}function Bf(e){var t=Ff(e.alternate,e,kt);e.memoizedProps=e.pendingProps,t===null?$f(e):Fe=t,Sd.current=null}function $f(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=Nm(s,t),s!==null){s.flags&=32767,Fe=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Qe=6,Fe=null;return}}else if(s=Dm(s,t,kt),s!==null){Fe=s;return}if(t=t.sibling,t!==null){Fe=t;return}Fe=t=e}while(t!==null);Qe===0&&(Qe=5)}function ls(e,t,s){var l=xe,r=Ot.transition;try{Ot.transition=null,xe=1,Gm(e,t,s,l)}finally{Ot.transition=r,xe=l}return null}function Gm(e,t,s,l){do rl();while(kn!==null);if(ce&6)throw Error(F(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(F(177));e.callbackNode=null,e.callbackPriority=0;var i=s.lanes|s.childLanes;if(kx(e,i),e===Ve&&(Fe=Ve=null,nt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||Mr||(Mr=!0,Mf(xi,function(){return rl(),null})),i=(s.flags&15990)!==0,s.subtreeFlags&15990||i){i=Ot.transition,Ot.transition=null;var a=xe;xe=1;var c=ce;ce|=4,Sd.current=null,Bm(e,s),Of(s,e),um(fo),yi=!!po,fo=po=null,e.current=s,$m(s),xx(),ce=c,xe=a,Ot.transition=i}else e.current=s;if(Mr&&(Mr=!1,kn=e,Oi=r),i=e.pendingLanes,i===0&&(Rn=null),vx(s.stateNode),vt(e,Ne()),t!==null)for(l=e.onRecoverableError,s=0;s<t.length;s++)r=t[s],l(r.value,{componentStack:r.stack,digest:r.digest});if(Ri)throw Ri=!1,e=Ro,Ro=null,e;return Oi&1&&e.tag!==0&&rl(),i=e.pendingLanes,i&1?e===Oo?Jl++:(Jl=0,Oo=e):Jl=0,$n(),null}function rl(){if(kn!==null){var e=vp(Oi),t=Ot.transition,s=xe;try{if(Ot.transition=null,xe=16>e?16:e,kn===null)var l=!1;else{if(e=kn,kn=null,Oi=0,ce&6)throw Error(F(331));var r=ce;for(ce|=4,q=e.current;q!==null;){var i=q,a=i.child;if(q.flags&16){var c=i.deletions;if(c!==null){for(var d=0;d<c.length;d++){var h=c[d];for(q=h;q!==null;){var j=q;switch(j.tag){case 0:case 11:case 15:Xl(8,j,i)}var p=j.child;if(p!==null)p.return=j,q=p;else for(;q!==null;){j=q;var u=j.sibling,y=j.return;if(Ef(j),j===h){q=null;break}if(u!==null){u.return=y,q=u;break}q=y}}}var v=i.alternate;if(v!==null){var f=v.child;if(f!==null){v.child=null;do{var S=f.sibling;f.sibling=null,f=S}while(f!==null)}}q=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,q=a;else e:for(;q!==null;){if(i=q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Xl(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,q=g;break e}q=i.return}}var x=e.current;for(q=x;q!==null;){a=q;var o=a.child;if(a.subtreeFlags&2064&&o!==null)o.return=a,q=o;else e:for(a=x;q!==null;){if(c=q,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Yi(9,c)}}catch(_){Oe(c,c.return,_)}if(c===a){q=null;break e}var m=c.sibling;if(m!==null){m.return=c.return,q=m;break e}q=c.return}}if(ce=r,$n(),tn&&typeof tn.onPostCommitFiberRoot=="function")try{tn.onPostCommitFiberRoot($i,e)}catch{}l=!0}return l}finally{xe=s,Ot.transition=t}}return!1}function cu(e,t,s){t=ul(s,t),t=jf(e,t,1),e=An(e,t,1),t=ut(),e!==null&&(xr(e,1,t),vt(e,t))}function Oe(e,t,s){if(e.tag===3)cu(e,e,s);else for(;t!==null;){if(t.tag===3){cu(t,e,s);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Rn===null||!Rn.has(l))){e=ul(s,e),e=bf(t,e,1),t=An(t,e,1),e=ut(),t!==null&&(xr(t,1,e),vt(t,e));break}}t=t.return}}function Km(e,t,s){var l=e.pingCache;l!==null&&l.delete(t),t=ut(),e.pingedLanes|=e.suspendedLanes&s,Ve===e&&(nt&s)===s&&(Qe===4||Qe===3&&(nt&130023424)===nt&&500>Ne()-_d?os(e,0):wd|=s),vt(e,t)}function Uf(e,t){t===0&&(e.mode&1?(t=Rr,Rr<<=1,!(Rr&130023424)&&(Rr=4194304)):t=1);var s=ut();e=gn(e,t),e!==null&&(xr(e,t,s),vt(e,s))}function Qm(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Uf(e,s)}function Ym(e,t){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(F(314))}l!==null&&l.delete(t),Uf(e,s)}var Ff;Ff=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||mt.current)xt=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return xt=!1,Lm(e,t,s);xt=!!(e.flags&131072)}else xt=!1,ze&&t.flags&1048576&&Gp(t,ki,t.index);switch(t.lanes=0,t.tag){case 2:var l=t.type;oi(e,t),e=t.pendingProps;var r=al(t,at.current);ll(t,s),r=md(null,t,l,e,r,s);var i=yd();return t.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,yt(l)?(i=!0,wi(t)):i=!1,t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,pd(t),r.updater=Qi,t.stateNode=r,r._reactInternals=t,So(t,l,e,s),t=ko(null,t,l,!0,i,s)):(t.tag=0,ze&&i&&rd(t),ct(null,t,r,s),t=t.child),t;case 16:l=t.elementType;e:{switch(oi(e,t),e=t.pendingProps,r=l._init,l=r(l._payload),t.type=l,r=t.tag=qm(l),e=Bt(l,e),r){case 0:t=_o(null,t,l,e,s);break e;case 1:t=eu(null,t,l,e,s);break e;case 11:t=Zc(null,t,l,e,s);break e;case 14:t=Vc(null,t,l,Bt(l.type,e),s);break e}throw Error(F(306,l,""))}return t;case 0:return l=t.type,r=t.pendingProps,r=t.elementType===l?r:Bt(l,r),_o(e,t,l,r,s);case 1:return l=t.type,r=t.pendingProps,r=t.elementType===l?r:Bt(l,r),eu(e,t,l,r,s);case 3:e:{if(kf(t),e===null)throw Error(F(387));l=t.pendingProps,i=t.memoizedState,r=i.element,Jp(e,t),Ti(t,l,null,s);var a=t.memoizedState;if(l=a.element,i.isDehydrated)if(i={element:l,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){r=ul(Error(F(423)),t),t=tu(e,t,l,s,r);break e}else if(l!==r){r=ul(Error(F(424)),t),t=tu(e,t,l,s,r);break e}else for(Ct=En(t.stateNode.containerInfo.firstChild),zt=t,ze=!0,Ut=null,s=Xp(t,null,l,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(ol(),l===r){t=xn(e,t,s);break e}ct(e,t,l,s)}t=t.child}return t;case 5:return Zp(t),e===null&&vo(t),l=t.type,r=t.pendingProps,i=e!==null?e.memoizedProps:null,a=r.children,ho(l,r)?a=null:i!==null&&ho(l,i)&&(t.flags|=32),_f(e,t),ct(e,t,a,s),t.child;case 6:return e===null&&vo(t),null;case 13:return Cf(e,t,s);case 4:return fd(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=dl(t,null,l,s):ct(e,t,l,s),t.child;case 11:return l=t.type,r=t.pendingProps,r=t.elementType===l?r:Bt(l,r),Zc(e,t,l,r,s);case 7:return ct(e,t,t.pendingProps,s),t.child;case 8:return ct(e,t,t.pendingProps.children,s),t.child;case 12:return ct(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(l=t.type._context,r=t.pendingProps,i=t.memoizedProps,a=r.value,je(Ci,l._currentValue),l._currentValue=a,i!==null)if(Gt(i.value,a)){if(i.children===r.children&&!mt.current){t=xn(e,t,s);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var c=i.dependencies;if(c!==null){a=i.child;for(var d=c.firstContext;d!==null;){if(d.context===l){if(i.tag===1){d=pn(-1,s&-s),d.tag=2;var h=i.updateQueue;if(h!==null){h=h.shared;var j=h.pending;j===null?d.next=d:(d.next=j.next,j.next=d),h.pending=d}}i.lanes|=s,d=i.alternate,d!==null&&(d.lanes|=s),jo(i.return,s,t),c.lanes|=s;break}d=d.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(F(341));a.lanes|=s,c=a.alternate,c!==null&&(c.lanes|=s),jo(a,s,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}ct(e,t,r.children,s),t=t.child}return t;case 9:return r=t.type,l=t.pendingProps.children,ll(t,s),r=Lt(r),l=l(r),t.flags|=1,ct(e,t,l,s),t.child;case 14:return l=t.type,r=Bt(l,t.pendingProps),r=Bt(l.type,r),Vc(e,t,l,r,s);case 15:return Sf(e,t,t.type,t.pendingProps,s);case 17:return l=t.type,r=t.pendingProps,r=t.elementType===l?r:Bt(l,r),oi(e,t),t.tag=1,yt(l)?(e=!0,wi(t)):e=!1,ll(t,s),vf(t,l,r),So(t,l,r,s),ko(null,t,l,!0,e,s);case 19:return zf(e,t,s);case 22:return wf(e,t,s)}throw Error(F(156,t.tag))};function Mf(e,t){return gp(e,t)}function Xm(e,t,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=t,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 Rt(e,t,s,l){return new Xm(e,t,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===Qo)return 11;if(e===Yo)return 14}return 2}function Ln(e,t){var s=e.alternate;return s===null?(s=Rt(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,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,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function ui(e,t,s,l,r,i){var a=2;if(l=e,typeof e=="function")Td(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Fs:return ds(s.children,r,i,t);case Ko:a=8,r|=8;break;case Ga:return e=Rt(12,s,t,r|2),e.elementType=Ga,e.lanes=i,e;case Ka:return e=Rt(13,s,t,r),e.elementType=Ka,e.lanes=i,e;case Qa:return e=Rt(19,s,t,r),e.elementType=Qa,e.lanes=i,e;case Zu:return qi(s,r,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qu:a=10;break e;case Ju:a=9;break e;case Qo:a=11;break e;case Yo:a=14;break e;case jn:a=16,l=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=Rt(a,s,t,r),t.elementType=e,t.type=l,t.lanes=i,t}function ds(e,t,s,l){return e=Rt(7,e,l,t),e.lanes=s,e}function qi(e,t,s,l){return e=Rt(22,e,l,t),e.elementType=Zu,e.lanes=s,e.stateNode={isHidden:!1},e}function Da(e,t,s){return e=Rt(6,e,null,t),e.lanes=s,e}function Na(e,t,s){return t=Rt(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Jm(e,t,s,l,r){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ma(0),this.expirationTimes=ma(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ma(0),this.identifierPrefix=l,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Id(e,t,s,l,r,i,a,c,d){return e=new Jm(e,t,s,c,d),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Rt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:l,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},pd(i),e}function Zm(e,t,s){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Us,key:l==null?null:""+l,children:e,containerInfo:t,implementation:s}}function Hf(e){if(!e)return Nn;e=e._reactInternals;e:{if(ms(e)!==e||e.tag!==1)throw Error(F(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(yt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(F(171))}if(e.tag===1){var s=e.type;if(yt(s))return Mp(e,s,t)}return t}function Gf(e,t,s,l,r,i,a,c,d){return e=Id(s,l,!0,e,r,i,a,c,d),e.context=Hf(null),s=e.current,l=ut(),r=On(s),i=pn(l,r),i.callback=t??null,An(s,i,r),e.current.lanes=r,xr(e,r,l),vt(e,l),e}function Ji(e,t,s,l){var r=t.current,i=ut(),a=On(r);return s=Hf(s),t.context===null?t.context=s:t.pendingContext=s,t=pn(i,a),t.payload={element:e},l=l===void 0?null:l,l!==null&&(t.callback=l),e=An(r,t,a),e!==null&&(Ht(e,r,a,i),ri(e,r,a)),a}function Di(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 uu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Pd(e,t){uu(e,t),(e=e.alternate)&&uu(e,t)}function Vm(){return null}var Kf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ed(e){this._internalRoot=e}Zi.prototype.render=Ed.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Ji(e,t,null,null)};Zi.prototype.unmount=Ed.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;hs(function(){Ji(null,e,null,null)}),t[hn]=null}};function Zi(e){this._internalRoot=e}Zi.prototype.unstable_scheduleHydration=function(e){if(e){var t=Sp();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Sn.length&&t!==0&&t<Sn[s].priority;s++);Sn.splice(s,0,e),s===0&&_p(e)}};function Ad(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Vi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function pu(){}function ey(e,t,s,l,r){if(r){if(typeof l=="function"){var i=l;l=function(){var h=Di(a);i.call(h)}}var a=Gf(t,l,e,0,null,!1,!1,"",pu);return e._reactRootContainer=a,e[hn]=a.current,ir(e.nodeType===8?e.parentNode:e),hs(),a}for(;r=e.lastChild;)e.removeChild(r);if(typeof l=="function"){var c=l;l=function(){var h=Di(d);c.call(h)}}var d=Id(e,0,!1,null,null,!1,!1,"",pu);return e._reactRootContainer=d,e[hn]=d.current,ir(e.nodeType===8?e.parentNode:e),hs(function(){Ji(t,d,s,l)}),d}function ea(e,t,s,l,r){var i=s._reactRootContainer;if(i){var a=i;if(typeof r=="function"){var c=r;r=function(){var d=Di(a);c.call(d)}}Ji(t,a,e,r)}else a=ey(s,t,e,r,l);return Di(a)}jp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=$l(t.pendingLanes);s!==0&&(Jo(t,s|1),vt(t,Ne()),!(ce&6)&&(pl=Ne()+500,$n()))}break;case 13:hs(function(){var l=gn(e,1);if(l!==null){var r=ut();Ht(l,e,1,r)}}),Pd(e,1)}};Zo=function(e){if(e.tag===13){var t=gn(e,134217728);if(t!==null){var s=ut();Ht(t,e,134217728,s)}Pd(e,134217728)}};bp=function(e){if(e.tag===13){var t=On(e),s=gn(e,t);if(s!==null){var l=ut();Ht(s,e,t,l)}Pd(e,t)}};Sp=function(){return xe};wp=function(e,t){var s=xe;try{return xe=e,t()}finally{xe=s}};so=function(e,t,s){switch(t){case"input":if(qa(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var l=s[t];if(l!==e&&l.form===e.form){var r=Hi(l);if(!r)throw Error(F(90));ep(l),qa(l,r)}}}break;case"textarea":np(e,s);break;case"select":t=s.value,t!=null&&el(e,!!s.multiple,t,!1)}};dp=kd;cp=hs;var ty={usingClientEntryPoint:!1,Events:[yr,Ks,Hi,ap,op,kd]},El={findFiberByHostInstance:rs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ny={bundleType:El.bundleType,version:El.version,rendererPackageName:El.rendererPackageName,rendererConfig:El.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:mn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=fp(e),e===null?null:e.stateNode},findFiberByHostInstance:El.findFiberByHostInstance||Vm,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hr.isDisabled&&Hr.supportsFiber)try{$i=Hr.inject(ny),tn=Hr}catch{}}It.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ty;It.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ad(t))throw Error(F(200));return Zm(e,t,null,s)};It.createRoot=function(e,t){if(!Ad(e))throw Error(F(299));var s=!1,l="",r=Kf;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onRecoverableError!==void 0&&(r=t.onRecoverableError)),t=Id(e,1,!1,null,null,s,!1,l,r),e[hn]=t.current,ir(e.nodeType===8?e.parentNode:e),new Ed(t)};It.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(F(188)):(e=Object.keys(e).join(","),Error(F(268,e)));return e=fp(t),e=e===null?null:e.stateNode,e};It.flushSync=function(e){return hs(e)};It.hydrate=function(e,t,s){if(!Vi(t))throw Error(F(200));return ea(null,e,t,!0,s)};It.hydrateRoot=function(e,t,s){if(!Ad(e))throw Error(F(405));var l=s!=null&&s.hydratedSources||null,r=!1,i="",a=Kf;if(s!=null&&(s.unstable_strictMode===!0&&(r=!0),s.identifierPrefix!==void 0&&(i=s.identifierPrefix),s.onRecoverableError!==void 0&&(a=s.onRecoverableError)),t=Gf(t,null,e,1,s??null,r,!1,i,a),e[hn]=t.current,ir(e),l)for(e=0;e<l.length;e++)s=l[e],r=s._getVersion,r=r(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,r]:t.mutableSourceEagerHydrationData.push(s,r);return new Zi(t)};It.render=function(e,t,s){if(!Vi(t))throw Error(F(200));return ea(null,e,t,!1,s)};It.unmountComponentAtNode=function(e){if(!Vi(e))throw Error(F(40));return e._reactRootContainer?(hs(function(){ea(null,null,e,!1,function(){e._reactRootContainer=null,e[hn]=null})}),!0):!1};It.unstable_batchedUpdates=kd;It.unstable_renderSubtreeIntoContainer=function(e,t,s,l){if(!Vi(s))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return ea(e,t,s,!1,l)};It.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=It;var sy=Ku.exports,Yf,fu=sy;Yf=fu.createRoot,fu.hydrateRoot;const oe="",W={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"},N={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 iy(e){return e!=="Admin"&&e!=="Auditor"?[]:Xf.filter(({id:t})=>e==="Admin"||!ry.has(t))}const vn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],ay={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:vn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:vn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:vn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:vn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:vn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:vn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:vn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:vn([{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:"Auditor"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"create_processes",label:"Create Processes"},{key:"update_process_status",label:"Update Process Status"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","status","requested_on"]}},oy=()=>n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),dy=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.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=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]});function Ye({onView:e,onEdit:t,onDelete:s}){const[l,r]=w.useState(!1),i=(c,d,h,j,p)=>h?n.jsx("button",{onClick:u=>{u.stopPropagation(),h()},title:p,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:c,color:d,flexShrink:0,transition:"opacity 0.15s"},onMouseEnter:u=>u.currentTarget.style.opacity="0.75",onMouseLeave:u=>u.currentTarget.style.opacity="1",children:j},p):null,a=s?()=>{l?(r(!1),s()):r(!0)}:void 0;return n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[i("#e0f7fa","#0891b2",e,n.jsx(oy,{}),"View"),i("#dcfce7","#16a34a",t,n.jsx(dy,{}),"Edit"),s&&n.jsx("button",{onClick:c=>{c.stopPropagation(),a==null||a()},title:l?"Click again to confirm delete":"Delete",style:{minWidth:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:l?8:"50%",padding:l?"0 8px":0,border:"none",cursor:"pointer",background:l?"#ef4444":"#fee2e2",color:l?"white":"#ef4444",flexShrink:0,fontSize:l?11:14,fontWeight:700,transition:"all 0.15s",gap:4},onMouseEnter:c=>c.currentTarget.style.opacity="0.8",onMouseLeave:c=>c.currentTarget.style.opacity="1",onBlur:()=>r(!1),children:l?"✓ Sure?":n.jsx(cy,{})})]})}const P={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},I={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 ge(e,t){return e.filter(s=>uy(s)||s.name===t)}const py={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function Cn(e,t){return!!t&&py[e].includes(t)}function fl(e,t,s,l){return e.filter(r=>{const i=t[r.name]||[];return!(i.includes("SB Admin")||i.includes("System Manager")||!i.includes(s)||l&&r.custom_organization&&r.custom_organization!==l)})}const hl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0},jt=(e,t)=>n.jsx("span",{style:{background:t,color:"white",padding:"4px 12px",borderRadius:12,fontSize:12,fontWeight:600,display:"inline-block"},children:e}),ta=e=>{switch(e){case"New":return"#e74c3c";case"Under Progress":return"#f39c12";case"Executed":return"#27ae60";case"Overdue":return"#7f1d1d";default:return"#95a5a6"}};function jr({deletedBy:e,deletedOn:t,reason:s,onRestore:l,isRestoring:r}){return n.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,padding:"12px 16px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",color:"#991b1b",fontSize:13},children:[n.jsxs("div",{children:[n.jsxs("div",{style:{fontWeight:700,fontSize:14,display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[n.jsx("span",{children:"⚠️"}),n.jsx("span",{children:"DELETED RECORD / سجل محذوف"})]}),n.jsxs("div",{style:{fontSize:12,color:"#7f1d1d"},children:[e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Deleted By:"})," ",e," "]}),t&&n.jsxs("span",{children:["| ",n.jsx("strong",{children:"Deleted On:"})," ",t," "]}),s&&n.jsxs("div",{children:[n.jsx("strong",{children:"Reason:"})," ",s]})]})]}),l&&n.jsxs("button",{onClick:l,disabled:r,style:{background:"#dc2626",color:"white",border:"none",borderRadius:6,padding:"8px 16px",fontSize:12,fontWeight:700,cursor:r?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{children:"↺"}),n.jsx("span",{children:r?"Restoring...":"Restore Record / استعادة"})]})]})}const fy="modulepreload",hy=function(e){return"/"+e},hu={},gy=function(t,s,l){let r=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=Promise.allSettled(s.map(d=>{if(d=hy(d),d in hu)return;hu[d]=!0;const h=d.endsWith(".css"),j=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${j}`))return;const p=document.createElement("link");if(p.rel=h?"stylesheet":fy,h||(p.as="script"),p.crossOrigin="",p.href=d,c&&p.setAttribute("nonce",c),document.head.appendChild(p),h)return new Promise((u,y)=>{p.addEventListener("load",u),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return r.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};function qf(e,t){const s=e[t.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function xy(e,t){const s=URL.createObjectURL(e),l=document.createElement("a");l.href=s,l.download=t,l.click(),URL.revokeObjectURL(s)}function my(e,t,s){const l=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),r=t.map(a=>e.map(c=>`"${qf(a,c).replace(/"/g,'""')}"`).join(",")).join(`
`),i=new Blob([l+`
`+r],{type:"text/csv;charset=utf-8;"});xy(i,`${s}.csv`)}async function yy(e,t,s){const l=await gy(()=>import("./xlsx-D_0l8YDs.js"),[]),r=t.map(c=>{const d={};for(const h of e)d[h.label]=qf(c,h);return d}),i=l.utils.json_to_sheet(r,{header:e.map(c=>c.label)}),a=l.utils.book_new();l.utils.book_append_sheet(a,i,"Export"),l.writeFile(a,`${s}.xlsx`)}const Gr="#16a34a";function vy({title:e,rows:t,columns:s,defaultColumnKeys:l,orgField:r,organizations:i,filenameBase:a,onClose:c}){const[d,h]=w.useState(""),[j,p]=w.useState("csv"),[u,y]=w.useState(new Set(l)),v=d?t.filter(m=>m[r||"organization"]===d):t,f=s.filter(m=>u.has(m.key)),S=m=>{y(_=>{const T=new Set(_);return T.has(m)?T.delete(m):T.add(m),T})},g=async()=>{f.length===0||v.length===0||(j==="csv"?my(f,v,a):await yy(f,v,a),c())},x={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},o={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick:c,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:n.jsxs("div",{onClick:m=>m.stopPropagation(),style:{width:560,maxWidth:"92vw",maxHeight:"86vh",background:"white",borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.3)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[n.jsxs("div",{style:{background:Gr,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[n.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e]}),n.jsx("button",{onClick:c,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:"✕"})]}),n.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1},children:[r&&i&&i.length>0&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"Filter by Organization"}),n.jsxs("select",{value:d,onChange:m=>h(m.target.value),style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",boxSizing:"border-box"},children:[n.jsxs("option",{value:"",children:["All Organizations (",t.length," total)"]}),i.map(m=>n.jsx("option",{value:m.name,children:m.organization_name||m.name},m.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"File Format"}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Comma-separated values"},{id:"xlsx",label:"Excel",desc:"XLSX spreadsheet"}].map(m=>n.jsxs("div",{onClick:()=>p(m.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${j===m.id?Gr:"#e5e7eb"}`,background:j===m.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:m.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:m.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:m.desc})]})]},m.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...x,marginBottom:0},children:"Columns to Export"}),n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[n.jsx("button",{onClick:()=>y(new Set(s.map(m=>m.key))),style:o,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>y(new Set(l)),style:o,children:"Reset to Default"})]})]}),n.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"10px 12px"},children:s.map(m=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:u.has(m.key),onChange:()=>S(m.key),style:{accentColor:Gr,cursor:"pointer"}}),m.label]},m.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[u.size," column",u.size!==1?"s":""," selected"]})]})]}),n.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("span",{style:{fontSize:12,color:"#888"},children:d?`Exporting ${v.length} filtered row${v.length!==1?"s":""}`:`Exporting all ${v.length} row${v.length!==1?"s":""}`}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:c,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),n.jsx("button",{onClick:g,disabled:f.length===0||v.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Gr,color:"white",fontWeight:700,fontSize:13,cursor:f.length===0||v.length===0?"not-allowed":"pointer",opacity:f.length===0||v.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}function Jf({collapsed:e,onToggleCollapsed:t,activePage:s,onNavigate:l,hasDashboard:r,hasReports:i,hasDelegations:a,role:c,hideSettings:d,rtl:h,navLabels:j,settingsLabel:p}){const u=d?[]:iy(c);return n.jsxs("div",{style:{width:e?58:230,background:"linear-gradient(175deg, #1a0f42 0%, #2a1260 45%, #102840 100%)",color:"white",flexShrink:0,display:"flex",flexDirection:"column",position:"sticky",top:0,height:"100vh",transition:"width 0.22s ease",overflow:"hidden"},children:[n.jsxs("div",{style:{padding:e?"16px 0":"16px 20px 14px",borderBottom:"1px solid rgba(255,255,255,0.08)",display:"flex",alignItems:"center",justifyContent:e?"center":"space-between",gap:8,flexShrink:0},children:[!e&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[n.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"linear-gradient(135deg, #312e81 0%, #4f46e5 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.jsx("span",{style:{fontSize:16,color:"white",fontWeight:800,fontFamily:"serif"},children:"S"})}),n.jsx("span",{style:{fontSize:16,fontWeight:700,whiteSpace:"nowrap",color:"white"},children:h?"صدرة":"Sidrah"})]}),n.jsx("button",{onClick:t,title:e?h?"توسيع":"Expand":h?"طي":"Collapse",style:{background:"rgba(255,255,255,0.08)",border:"none",borderRadius:7,color:"rgba(255,255,255,0.7)",cursor:"pointer",fontSize:12,padding:"5px 8px",flexShrink:0,lineHeight:1,transition:"background 0.15s"},children:e?"▶":"✕"})]}),n.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[ly.filter(({id:y})=>(y!=="dashboard"||r)&&(y!=="reports"||i)&&(y!=="delegations"||a)).map(({id:y,icon:v})=>{const f=j[y]||y,S=y===s;return n.jsxs("div",{onClick:()=>l(y),title:e?f:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:S?"rgba(139,92,246,0.28)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:S?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:v}),!e&&f]},y)}),u.length>0&&n.jsxs(n.Fragment,{children:[!e&&n.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,color:"rgba(255,255,255,0.6)",fontWeight:700,letterSpacing:1,textTransform:"uppercase",marginTop:8},children:p}),e&&n.jsx("div",{style:{margin:"10px auto",width:28,borderTop:"1px solid rgba(255,255,255,0.12)"}}),u.map(({id:y,icon:v})=>{const f=j[y]||y,S=y===s;return n.jsxs("div",{onClick:()=>l(y),title:e?f:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:S?"rgba(139,92,246,0.25)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:S?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:v}),!e&&f]},y)})]})]})]})}const Zf="sidrah_rtl",No="sidrah-lang-change";function Vs(){try{return localStorage.getItem(Zf)==="1"}catch{return!1}}function Vf(){const e=!Vs();try{localStorage.setItem(Zf,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,t]=w.useState(Vs);return w.useEffect(()=>{const s=()=>t(Vs());return window.addEventListener(No,s),document.documentElement.setAttribute("dir",Vs()?"rtl":"ltr"),document.documentElement.setAttribute("lang",Vs()?"ar":"en-GB"),()=>window.removeEventListener(No,s)},[]),e?by:jy}const jy={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 IS DELETED",deletedBy:"Deleted By",deletedOn:"Deleted On",deletedReason:"Reason",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"}},by={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:"السبب",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:"بواسطة"}},yl=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 gs="";async function Rd(){try{const e=await fetch(`${oe}/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 gs=s,s}}catch(e){console.error("CSRF fetch error:",e)}return gs}async function Kt(){return gs||await Rd(),gs}function Ni(e,t){try{if(e!=null&&e._server_messages){const s=JSON.parse(e._server_messages);if(s.length){const l=JSON.parse(s[0]);if(l!=null&&l.message)return l.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function _t(e,t,s=[]){if(yl.has(e)){const a=`${oe}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,c=await fetch(a,{credentials:"include",headers:{Accept:"application/json"}});if(!c.ok)throw new Error(`API Error: ${c.status}`);return(await c.json()).message}const l=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",r=await fetch(`${oe}/api/v1/resource/${e}/${encodeURIComponent(t)}${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 pi(e,t,s="",l=!1){const r=await Kt();if(yl.has(e)){const c=new URLSearchParams({doctype:e,name:t});s&&c.append("reason",s),l&&c.append("permanent","1");const d=await fetch(`${oe}/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:c.toString()});if(!d.ok){const h=await d.json().catch(()=>({}));throw new Error(Ni(h,`Error deleting ${t}`))}return}const i=new URLSearchParams({doctype:e,name:t});s&&i.append("reason",s),l&&i.append("permanent","1");const a=await fetch(`${oe}/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:i.toString()});if(!a.ok){const c=await a.json().catch(()=>({}));throw new Error(Ni(c,`Error deleting ${t}`))}return await a.json()}async function Sy(e,t){const s=await Kt();if(yl.has(e)){const i=new URLSearchParams({doctype:e,name:t}),a=await fetch(`${oe}/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:i.toString()});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(Ni(d,`Error restoring ${t}`))}return(await a.json()).message||{success:!0}}const l=new URLSearchParams({doctype:e,name:t}),r=await fetch(`${oe}/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 i=await r.json().catch(()=>({}));throw new Error(Ni(i,`Error restoring ${t}`))}return await r.json()}async function Ce(e){if(yl.has(e))try{const l=`${oe}/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 t=encodeURIComponent('["*"]'),s=`${oe}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;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 Wa(e,t){const s=await Kt();if(yl.has(e)){const r=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${oe}/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(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.message||c.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const l=`${oe}/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(t)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const i=await r.json();throw new Error(i.message||i.exc||`API Error: ${r.status}`)}return await r.json()}catch(r){throw console.error("Post error:",r),r}}async function Wi(e,t,s){const l=await Kt();if(yl.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(s)}),a=await fetch(`${oe}/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:i.toString()});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error updating ${e}`)}return{data:(await a.json()).message}}const r=`${oe}/api/v1/resource/${e}/${encodeURIComponent(t)}`;try{const i=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(i.status===401||i.status===403)throw new Error("Permission denied - login required");if(!i.ok){const a=await i.json();throw new Error(a.message||"Update Error")}return await i.json()}catch(i){throw console.error("Update error:",i),i}}async function wy(){const e=`${oe}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.status===401||t.status===403?[]:t.ok?(await t.json()).data||[]:[]}catch(t){return console.error("Get users error:",t),[]}}async function _y(e,t){const s=new FormData;s.append("usr",e),s.append("pwd",t);const r=await(await fetch(`${oe}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return r.csrf_token?gs=r.csrf_token:await Rd(),r}async function ky(){const e=await Kt();try{await fetch(`${oe}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}gs=""}function Cy(){return gs}async function eh(){try{const e=await fetch(`${oe}/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 zy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${oe}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).data||[]:[]}catch{return[]}}async function Ty(){const e=`${oe}/api/method/sidrah_business.api.get_user_role_map`;try{const t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function th(e,t){await Wi("User",e,{new_password:t})}async function Iy(e=20){try{const t=`${oe}/api/method/sidrah_business.api.get_notifications?limit=${e}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Py(){const e=await Kt();try{await fetch(`${oe}/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 Ey(e){const t=await Kt();try{await fetch(`${oe}/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":t},body:new URLSearchParams({name:e}).toString()})}catch{}}async function Ay(e){const t=await Kt(),s=new URLSearchParams({name:e});await fetch(`${oe}/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":t},body:s.toString()})}async function Ry(e,t){try{const s=`${oe}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function Oy(e,t,s){const l=await Kt(),r=new URLSearchParams({doctype:e,docname:t,content:s}),i=await fetch(`${oe}/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(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function Ly(e,t){try{const s=`${oe}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function nh(e){try{const t=`${oe}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,s=await fetch(t,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Dy(){try{const e=`${oe}/api/method/sidrah_business.api.get_my_organization`,t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.ok&&(await t.json()).message||""}catch{return""}}async function ys(e,t={}){const s=await Kt(),l=new URLSearchParams(t),r=await fetch(`${oe}/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 a=await r.json().catch(()=>({}));throw new Error(a.message||a.exc||`Error calling ${e}`)}return(await r.json()).message}async function Ny(e,t,s="",l,r,i){const a={name:e,action:t,comment:s};return l!==void 0&&(a.stage=l),i!==void 0&&(a.cycle_status=i),ys("apply_order_workflow",a)}async function Wy(e,t,s=""){return ys("apply_incident_workflow",{name:e,action:t,fields_json:s})}async function By(e,t,s=""){return ys("apply_idea_workflow",{name:e,action:t,fields_json:s})}async function $y(e=""){const t=`${oe}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function Uy(e,t={}){return ys("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function Fy(){try{const e=`${oe}/api/method/sidrah_business.api.get_inbox_items`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function My(e,t,s="",l=""){return ys("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:s,remarks:l})}async function Hy(e,t,s=""){return ys("respond_to_delegation",{name:e,response:t,remarks:s})}async function Gy(e,t=""){return ys("revoke_delegation",{name:e,remarks:t})}async function Ky(){try{const e=`${oe}/api/method/sidrah_business.api.get_delegations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Qy(e){const t=`${oe}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error("Failed to load delegation");return(await s.json()).message}async function Yy(){try{const e=`${oe}/api/method/sidrah_business.api.get_my_delegated_functions`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Xy(){try{const e=`${oe}/api/method/sidrah_business.api.get_my_delegated_organizations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function qy(){try{const e=await Kt(),t=await fetch(`${oe}/api/method/sidrah_business.api.get_group_companies`,{method:"GET",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":e}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Jy(){const e=Cy();return e||Rd()}async function Fl(e){const t=await fetch(`${oe}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.message||`Failed to load process (${t.status})`)}const s=await t.json();return s.message||s.data}async function Zy(e,t,s={}){const l=await Jy(),r=new URLSearchParams({name:e,action:t});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 i=await fetch(`${oe}/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(!i.ok){const c=await i.json().catch(()=>({})),d=c.message||(c.exception?String(c.exception).split(`
`).pop():"")||c.exc_type||`Workflow action "${t}" failed (${i.status})`;throw new Error(d)}const a=await i.json();return a.message||a.data}const Vy=["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"],gu=new Set(Vy),e0={"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 xu(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return gu.has(e)?e:null;const t=window.location.pathname.split("/").filter(Boolean).pop()||"";return gu.has(t)?t:null}function t0(e){return e?e0[e]??e:null}function n0(e){return`#/${e}`}function s0({onLogin:e}){const t=ne(),[s,l]=w.useState(""),[r,i]=w.useState(""),[a,c]=w.useState(""),[d,h]=w.useState(!1),[j,p]=w.useState(!1),[u,y]=w.useState(!1),v=async()=>{if(!s||!r){c(t.login.emptyFields);return}h(!0),c("");try{const S=await _y(s,r);if(S.message==="Logged In"){const x=await eh()||s,o=await nh(x),m=o.some(_=>["SB Admin","System Manager"].includes(_))?"Admin":o.includes("SB Auditor")?"Auditor":o.includes("SB Owner")?"Owner":o.includes("SB X-Auditor")?"XAuditor":o.includes("SB Manager")?"Manager":"Employee";e({name:x,full_name:S.full_name||s,role:m})}else c(t.login.invalidCreds)}catch(S){c(t.login.connError+(S instanceof Error?S.message:"Unknown"))}h(!1)},f=S=>({width:"100%",padding:"13px 16px",border:`1.5px solid ${S?"#4f46e5":"#e5e7eb"}`,borderRadius:10,fontSize:15,background:"#ffffff",color:"#374151",outline:"none",transition:"border-color 0.2s, box-shadow 0.2s",boxSizing:"border-box",boxShadow:S?"0 0 0 3px rgba(79,70,229,0.12)":"none"});return n.jsx("div",{style:{minHeight:"100vh",background:"#f3f4f6",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif"},children:n.jsxs("div",{style:{background:"white",borderRadius:20,padding:"48px 44px 40px",width:420,boxShadow:"0 4px 32px rgba(0,0,0,0.10)"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[n.jsx("div",{style:{width:72,height:72,borderRadius:18,background:"linear-gradient(135deg, #312e81 0%, #4f46e5 100%)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 18px",boxShadow:"0 4px 16px rgba(79,70,229,0.3)"},children:n.jsx("span",{style:{fontSize:32,color:"white",fontWeight:800,fontFamily:"serif"},children:"S"})}),n.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#1e1b4b"},children:t.rtl?"صدرة للأعمال":"Sidrah Business"}),n.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:6},children:t.login.subtitle})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[n.jsx("input",{value:s,onChange:S=>l(S.target.value),onKeyDown:S=>S.key==="Enter"&&v(),onFocus:()=>p(!0),onBlur:()=>p(!1),style:f(j),placeholder:t.login.usernamePlaceholder,autoComplete:"username"}),n.jsx("input",{type:"password",value:r,onChange:S=>i(S.target.value),onKeyDown:S=>S.key==="Enter"&&v(),onFocus:()=>y(!0),onBlur:()=>y(!1),style:f(u),placeholder:t.login.passwordPlaceholder,autoComplete:"current-password"}),a&&n.jsx("div",{style:{padding:"10px 14px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:13},children:a}),n.jsx("button",{onClick:v,disabled:d,style:{background:d?"#a5b4fc":"#4f46e5",color:"white",border:"none",padding:"14px",borderRadius:10,fontSize:15,cursor:d?"not-allowed":"pointer",fontWeight:700,marginTop:4,transition:"background 0.2s, transform 0.1s",letterSpacing:"0.01em"},onMouseEnter:S=>{d||(S.currentTarget.style.background="#4338ca")},onMouseLeave:S=>{d||(S.currentTarget.style.background="#4f46e5")},children:d?t.login.signingIn:t.login.signIn})]}),n.jsx("div",{style:{textAlign:"center",marginTop:14},children:n.jsx("button",{onClick:Vf,style:{fontSize:12,color:"#9ca3af",background:"none",border:"none",cursor:"pointer"},children:t.switchLang})})]})})}function l0(e,t){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,i=s&255,a=c=>Math.round(c+(255-c)*t);return`rgb(${a(l)}, ${a(r)}, ${a(i)})`}function Al(e,t){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,i=s&255;return`rgba(${l}, ${r}, ${i}, ${t})`}function Kr({title:e,data:t,color:s,onSelect:l}){const[,r]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((d,h)=>l0(s,Math.min(h*.16,.7))),c=i.map(([d,h,j],p)=>[d,h,j,a[p]]).filter(([,d])=>d>0);return n.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:[n.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${Al(s,.09)} 0%, transparent 55%)`}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${Al(s,.35)})`}}),n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[n.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),n.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 ${Al(s,.35)}`},children:r})]}),r>0&&n.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:Al(s,.1),marginBottom:13},children:c.map(([d,h,j,p],u)=>n.jsx("div",{title:`${d}: ${h}`,onClick:y=>{y.stopPropagation(),l==null||l(j)},style:{flex:`${h} 0 0`,background:p,borderRight:u<c.length-1?"2px solid white":"none",cursor:l?"pointer":"default"}},d))}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:i.map(([d,h,j],p)=>n.jsxs("div",{className:"status-card-row",onClick:h>0?u=>{u.stopPropagation(),l==null||l(j)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:h>0&&l?"pointer":"default",transition:"background 0.12s"},children:[n.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:a[p],flexShrink:0,boxShadow:`0 0 0 3px ${Al(a[p],.18)}`}}),n.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),n.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:h})]},d))})]})}function Nt({value:e,onChange:t,organizations:s,placeholder:l="-- Choose organization --",disabled:r=!1,small:i=!1}){var p;const[a,c]=w.useState(!1),d=w.useRef(null);w.useEffect(()=>{const u=y=>{d.current&&!d.current.contains(y.target)&&c(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const h=e?((p=s.find(u=>u.organization_name===e||u.name===e))==null?void 0:p.organization_name)??e:l,j=s.filter(u=>!!u.is_active||u.organization_name===e||u.name===e);return n.jsxs("div",{ref:d,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!r&&c(u=>!u),style:{width:"100%",padding:i?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:i?11:12,cursor:r?"default":"pointer",height:i?28:34,background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",borderColor:a?"#3498db":"#ddd",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[n.jsx("span",{children:h}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:a?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),a&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx(mu,{label:l,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{t(""),c(!1)}}),j.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),j.map(u=>n.jsx(mu,{label:u.organization_name,selected:e===u.organization_name||e===u.name,active:!!u.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(u.organization_name),c(!1)}},u.name))]})})]})}function mu({label:e,selected:t,active:s,isPlaceholder:l,small:r,onClick:i}){const[a,c]=w.useState(!1),d=t?"#2563eb":a?"#f0f4ff":"transparent",h=t?"white":l?"#aaa":s?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:i,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{padding:r?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:d,color:h,transition:"background 0.1s"},children:e})}function zn({items:e,type:t,onNavigate:s}){const l=ne();if(!e.length)return null;const r=t==="process"?"processes-form":"orders-form",i=t==="process"?l.dash.escalatedProcesses:l.dash.escalatedOrders;return n.jsxs("div",{children:[n.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[i," (",e.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(a=>n.jsxs("div",{onClick:()=>s(r,a.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:700,fontSize:12},children:a.number||a.name}),n.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:a.title})]}),n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[l.dash.level," ",a.escalation_level]})]},a.name))})]})}function r0({kpi:e}){const t=ne();return n.jsxs("div",{style:{background:"white",borderRadius:8,padding:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:13,marginBottom:2},children:e.organization}),n.jsx("div",{style:{fontSize:11,color:"#888",marginBottom:8},children:e.period}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[{label:t.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—"},{label:t.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—"},{label:t.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—"},{label:t.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—"},{label:t.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—"},{label:t.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—"}].map(({label:s,val:l})=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700},children:s}),n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1a2332"},children:l})]},s))})]})}function i0({data:e}){if(!e.length)return n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const t=Math.max(...e.map(s=>s.pass+s.fail+s.unknown),1);return n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",gap:10,alignItems:"flex-end",overflowX:"auto",paddingBottom:4},children:e.map(s=>{const l=s.pass+s.fail+s.unknown||1,r=80;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,minWidth:48},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:1,height:r,width:32},children:[n.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/t*r),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:s.pass?2:0}}),n.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/t*r),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:s.fail?2:0}}),n.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/t*r),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:s.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:s.month.replace(/^(\d{4})-(\d{2})$/,(i,a,c)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+c-1]}
${a}`)}),n.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:l>1?Math.round(s.pass/l*100)+"%":"—"})]},s.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([s,l])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:s,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:l})]},l))})]})}function Ft({label:e,icon:t,onClick:s}){return n.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:7,padding:"7px 12px",background:"white",border:"1px solid #e8e8e8",borderRadius:8,cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 0.15s"},onMouseEnter:l=>l.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:l=>l.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[n.jsx("span",{style:{fontSize:15},children:t}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function a0({dashData:e,fi:t,fid:s,fo:l,fp:r,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,onNavigate:h,onNavigateStatus:j}){const p=ne(),u=(e==null?void 0:e.escalated_processes)||[],y=(e==null?void 0:e.escalated_orders)||[],v=(e==null?void 0:e.attention_processes)||[],f=(e==null?void 0:e.attention_orders)||[],S=(e==null?void 0:e.untriaged_incidents)||[],g=(e==null?void 0:e.overdue_triage)||[],x=u.length>0||y.length>0,o=v.length>0||f.length>0,m=[["Total",t.length,""],...i.map(C=>[C.name1||C.name,t.filter(R=>R.status===C.name).length,C.name])],_=[["Total",s.length,""],...a.map(C=>[C.name1||C.name,s.filter(R=>R.status===C.name).length,C.name])],T=[["Total",l.length,""],...c.map(C=>[C.name1||C.name,l.filter(R=>R.status===C.name).length,C.name])],E=[["Total",r.length,""],...d.map(C=>[C.name1||C.name,r.filter(R=>R.status===C.name).length,C.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(Ft,{label:"Incidents",icon:"⚠️",onClick:()=>h("incidents")}),n.jsx(Ft,{label:"Ideas",icon:"💡",onClick:()=>h("ideas")}),n.jsx(Ft,{label:"Orders",icon:"📦",onClick:()=>h("orders")}),n.jsx(Ft,{label:"Processes",icon:"⚙️",onClick:()=>h("processes")}),n.jsx(Ft,{label:"Inbox",icon:"📥",onClick:()=>h("inbox")}),n.jsx(Ft,{label:"Reports",icon:"📊",onClick:()=>h("reports")})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[n.jsx("div",{onClick:()=>h("incidents"),style:{cursor:"pointer"},children:n.jsx(Kr,{title:p.dash.incidents,color:N.orange,data:m,onSelect:C=>j("incidents",C)})}),n.jsx("div",{onClick:()=>h("ideas"),style:{cursor:"pointer"},children:n.jsx(Kr,{title:p.dash.ideas,color:N.blue,data:_,onSelect:C=>j("ideas",C)})}),n.jsx("div",{onClick:()=>h("orders"),style:{cursor:"pointer"},children:n.jsx(Kr,{title:p.dash.orders,color:N.purple,data:T,onSelect:C=>j("orders",C)})}),n.jsx("div",{onClick:()=>h("processes"),style:{cursor:"pointer"},children:n.jsx(Kr,{title:p.dash.processes,color:N.red,data:E,onSelect:C=>j("processes",C)})})]}),x&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:p.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(zn,{items:u,type:"process",onNavigate:h}),n.jsx(zn,{items:y,type:"order",onNavigate:h})]})]}),o&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:p.dash.level1}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(zn,{items:v,type:"process",onNavigate:h}),n.jsx(zn,{items:f,type:"order",onNavigate:h})]})]}),g.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:8},children:[p.dash.overduePrefix,g.length,p.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:g.map(C=>n.jsxs("div",{onClick:()=>h("incidents-form",C.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:C.number||C.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:C.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:C.date})]},C.name))})]}),S.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:N.orange,marginBottom:8},children:[p.dash.untriaged," (",S.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(C=>n.jsxs("div",{onClick:()=>h("incidents-form",C.name),style:{padding:"8px 12px",background:"#fffbeb",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:C.number||C.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:C.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:C.date})]},C.name))})]})]})}function o0({dashData:e,selectedOrg:t,onNavigate:s}){const l=ne(),[r,i]=w.useState([]),[a,c]=w.useState([]),[d,h]=w.useState(!1),j=(e==null?void 0:e.escalated_processes)||[],p=(e==null?void 0:e.escalated_orders)||[],u=(e==null?void 0:e.attention_processes)||[],y=(e==null?void 0:e.attention_orders)||[],v=(e==null?void 0:e.kpi_inputs)||[];w.useEffect(()=>{h(!0);const g=new URLSearchParams({months:"6"});t&&g.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${g}`,{credentials:"include",headers:{Accept:"application/json"}}).then(x=>x.json()).then(x=>{const o=x.message||[],m={};for(const _ of o)m[_.month]||(m[_.month]={pass:0,fail:0,unknown:0}),_.status==="Pass"?m[_.month].pass=_.count:_.status==="Fail"?m[_.month].fail=_.count:_.status==="Unknown"&&(m[_.month].unknown=_.count);i(Object.entries(m).map(([_,T])=>({month:_,...T})))}).catch(()=>{}).finally(()=>h(!1))},[t]),w.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 x;c((((x=g.message)==null?void 0:x.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const f=j.length>0||p.length>0,S=u.length>0||y.length>0;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[n.jsx(Ft,{label:"Manage Users & Roles",icon:"👥",onClick:()=>s("users")}),n.jsx(Ft,{label:"Change Active Cycle",icon:"🔄",onClick:()=>s("cycles")}),n.jsx(Ft,{label:"KPI Inputs",icon:"📈",onClick:()=>s("kpi-input")}),n.jsx(Ft,{label:"Reports",icon:"📊",onClick:()=>s("reports")}),n.jsx(Ft,{label:"Organizations",icon:"🏢",onClick:()=>s("organizations")})]}),v.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:l.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:v.map(g=>n.jsx(r0,{kpi:g},g.name))}),n.jsx("button",{onClick:()=>s("kpi-input"),style:{marginTop:10,padding:"6px 14px",borderRadius:7,border:"1px solid #2980b9",background:"white",color:"#2980b9",fontWeight:600,fontSize:12,cursor:"pointer"},children:l.dash.manageKpi})]}),f&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",j.length+p.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(zn,{items:j,type:"process",onNavigate:s}),n.jsx(zn,{items:p,type:"order",onNavigate:s})]})]}),S&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",u.length+y.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(zn,{items:u,type:"process",onNavigate:s}),n.jsx(zn,{items:y,type:"order",onNavigate:s})]})]}),n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:4},children:"Process Trend — Last 6 Months"}),n.jsx("p",{style:{fontSize:11,color:"#888",marginBottom:10},children:"Pass/Fail/Unknown ratio per month across all processes. Pass % shown at bottom of each bar."}),d?n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):n.jsx(i0,{data:r})]}),a.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:"Log Book — Recent Activity"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(g=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:g},g))})}),n.jsx("tbody",{children:a.map((g,x)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:g.timestamp?String(g.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:g.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:g.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:g.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.changes||"—"})]},x))})]})}),n.jsx("button",{onClick:()=>s("reports"),style:{marginTop:12,padding:"7px 16px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log (Reports →)"})]})]})}function d0({incidents:e,ideas:t,orders:s,processes:l,organizations:r,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,selectedOrg:h,onOrgChange:j,onNavigate:p,onNavigateStatus:u,userRole:y}){const[v,f]=w.useState(null);w.useEffect(()=>{$y(h).then(f)},[h]);const S=h?e.filter(R=>R.organization===h):e,g=h?t.filter(R=>R.organization===h):t,x=h?s.filter(R=>R.organization===h):s,o=h?l.filter(R=>R.organization===h):l,m=y==="Admin",_=y==="Owner",[T,E]=w.useState("level1"),C=_||m&&T==="level2";return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"8px 14px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#4f46e5",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e1b4b",whiteSpace:"nowrap"},children:"Filter"})]}),n.jsx("div",{style:{flex:1,minWidth:160,maxWidth:260},children:n.jsx(Nt,{value:h,onChange:j,organizations:r,placeholder:"All Organizations",small:!0})}),m&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(R=>n.jsx("button",{onClick:()=>E(R),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:T===R?R==="level2"?N.purple:N.blue:"transparent",color:T===R?"white":"#6b7280",transition:"all 0.15s"},children:R==="level1"?"Level 1":"Level 2"},R))}),!m&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:C?N.purple:N.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:C?"Level 2 — Owner":"Level 1 — Operational"})]}),C?n.jsx(o0,{dashData:v,selectedOrg:h,onNavigate:p}):n.jsx(a0,{dashData:v,fi:S,fid:g,fo:x,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,onNavigate:p,onNavigateStatus:u})]})}const Me={fontSize:10,color:"#6b7280",fontWeight:600,marginBottom:3,display:"block",textTransform:"uppercase",letterSpacing:.4},He={width:"100%",padding:"4px 8px",border:"1px solid #d1d5db",borderRadius:6,fontSize:11,background:"white",color:"#374151",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:28};function na({children:e}){const[t,s]=w.useState(!1);return n.jsxs("div",{style:{borderRadius:8,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",flexShrink:0},children:[n.jsxs("div",{onClick:()=>s(l=>!l),style:{background:"#4f46e5",color:"white",padding:"9px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none"},children:[n.jsx("span",{style:{fontSize:13,opacity:.9},children:t?"▲":"▼"}),n.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Filters"})]}),t&&n.jsx("div",{style:{background:"white",padding:"12px 16px",borderTop:"1px solid #e5e7eb"},children:e})]})}const le=20,yu=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 We({page:e,pageSize:t=le,total:s,onPageChange:l}){if(s===0)return null;const r=Math.max(1,Math.ceil(s/t)),i=(e-1)*t+1,a=Math.min(e*t,s);return n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[n.jsxs("span",{children:["Showing ",i," to ",a," of ",s," results"]}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{disabled:e<=1,onClick:()=>l(e-1),style:yu(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=r,onClick:()=>l(e+1),style:yu(e>=r),children:"Next"})]})]})}function c0({incidents:e,organizations:t,departments:s,branches:l,incidentStatuses:r,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:h,onDelete:j}){const p=ne(),[u,y]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),v=(o,m)=>y(_=>({..._,[o]:m})),[f,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((f-1)*le,f*le);return n.jsxs(n.Fragment,{children:[n.jsx(na,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.numberTitle}),n.jsx("input",{style:He,value:u.search,onChange:o=>v("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.organization}),n.jsxs("select",{style:He,value:u.organization,onChange:o=>v("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.department}),n.jsxs("select",{style:He,value:u.department,onChange:o=>v("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.branch}),n.jsxs("select",{style:He,value:u.branch,onChange:o=>v("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),l.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.status}),n.jsxs("select",{style:He,value:u.status,onChange:o=>v("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>y({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIncidents})}):x.map((o,m)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:o.custom_is_deleted?"#fef2f2":m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.type?jt(o.type,"#e74c3c"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?jt(p.deletedBadge,"#dc2626"):o.status?jt(o.status,ta(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Ye,{onView:()=>d==null?void 0:d(o),onEdit:c&&h&&!o.custom_is_deleted&&!Cn("incident",o.workflow_state)?()=>h(o):void 0,onDelete:c&&j&&!o.custom_is_deleted?()=>j(o.name):void 0})})]},o.name))})]})}),n.jsx(We,{page:f,total:g.length,onPageChange:S})]})}function u0(e){if(!e)return"";const[t,s,l]=e.split("-");return!t||!s||!l?"":`${l}/${s}/${t}`}function ve({value:e,onChange:t,disabled:s,style:l,min:r,max:i}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:u0(e),placeholder:"DD/MM/YYYY",style:{...l,pointerEvents:"none",paddingRight:30}}),n.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:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),n.jsx("input",{type:"date",value:e||"",disabled:s,min:r,max:i,onChange:a=>t(a.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:s?"default":"pointer",border:"none",padding:0,margin:0}})]})}function p0({title:e,children:t}){return n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"18px 20px",marginBottom:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&n.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16,color:"#1e1b4b"},children:e}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:13},children:t})]})}const vu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function f0(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function sh({notifCount:e,darkMode:t,onCountChange:s,onToggleDark:l,onViewProfile:r,onLogout:i,onNavigate:a,userName:c,userRole:d}){const[h,j]=w.useState(!1),[p,u]=w.useState([]),[y,v]=w.useState(!1),f=w.useRef(null);w.useEffect(()=>{const B=D=>{f.current&&!f.current.contains(D.target)&&j(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const S=async()=>{v(!0);const B=await Iy(30);u(B),v(!1)},g=()=>{const B=!h;j(B),B&&S()},x=async()=>{await Py(),u(B=>B.map(D=>({...D,read:1}))),s(0)},o=B=>{B.read||(Ey(B.name),u(L=>L.map(z=>z.name===B.name?{...z,read:1}:z)),s(Math.max(0,e-1)));const D=B.document_type?vu[B.document_type]:void 0;D&&a&&(a(D,B.document_type==="SB Delegation"?void 0:B.document_name),j(!1))},m=p.filter(B=>!B.read).length,_=B=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:t?"#2d3748":"#f3f4f6",color:t?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...B}),T=t,E=T?"#1a202c":"white",C=T?"#2d3748":"#e5e7eb",R=T?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[c&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginRight:4,lineHeight:1.25},children:[n.jsx("span",{style:{fontSize:13,fontWeight:600,color:T?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:c}),d&&n.jsx("span",{style:{fontSize:11,color:T?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:d})]}),n.jsx("button",{style:_({background:"#4f46e5",color:"white"}),onClick:r,title:"My Profile",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),n.jsxs("div",{ref:f,style:{position:"relative"},children:[n.jsxs("button",{style:_(),onClick:g,title:"Notifications",children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&n.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})]}),h&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:E,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${C}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${C}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:E},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:R},children:["Notifications",m>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[m," new"]})]}),m>0&&n.jsx("button",{onClick:x,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),n.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[y&&n.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!y&&p.length===0&&n.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[n.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),n.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!y&&p.map(B=>{const D=!!(B.document_type&&vu[B.document_type]&&a);return n.jsxs("div",{onClick:()=>o(B),style:{padding:"11px 16px",borderBottom:`1px solid ${T?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:B.read?E:T?"#1e3a5f":"#eff6ff",cursor:D?"pointer":"default",transition:"background 0.12s"},onMouseEnter:L=>{D&&(L.currentTarget.style.background=T?"#243244":"#e0ecfd")},onMouseLeave:L=>{L.currentTarget.style.background=B.read?E:T?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:B.read?400:600,color:R,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.subject||`${B.document_type}: ${B.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:B.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:T?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[B.document_type.replace("SB ",""),B.document_name?` · ${B.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:f0(B.creation)})]}),!B.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},B.name)})]})]})]}),n.jsx("button",{style:_(),onClick:Vf,title:Vs()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:_(),onClick:l,title:t?"Light mode":"Dark mode",children:t?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),n.jsx("button",{style:_({background:T?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:i,title:"Logout",children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16,17 21,12 16,7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Be({title:e,activePage:t,user:s,formStatus:l,buttonText:r,buttonColor:i,viewMode:a,onEdit:c,hideSettings:d,rightPanel:h,darkMode:j,notifCount:p,onToggleDark:u,onCountChange:y,onViewProfile:v,onSubmit:f,onBack:S,onNavigate:g,onLogout:x,children:o}){const m=ne(),_=m.nav[t]||t,T=s.role,E=T==="Admin"||T==="Owner"||T==="Auditor"||T==="Manager",C=T==="Admin"||T==="Owner"||T==="Auditor"||T==="Manager",R=T==="Admin"||T==="Auditor"||T==="Manager",B=E?"dashboard":"inbox",[D,L]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),z=()=>L(A=>{const M=!A;return localStorage.setItem("sb_sidebar",M?"1":"0"),M});return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:N.bg},children:[n.jsx(Jf,{collapsed:D,onToggleCollapsed:z,activePage:t,onNavigate:g,hasDashboard:E,hasReports:C,hasDelegations:R,role:T,hideSettings:d,rtl:m.rtl,navLabels:m.nav,settingsLabel:m.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"10px 20px",borderBottom:"1px solid #e9eaf0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("button",{onClick:S,title:m.back,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"1.5px solid #e5e7eb",background:"white",cursor:"pointer",color:"#4f46e5",flexShrink:0},children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1e1b4b"},children:e}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:1},children:[n.jsx("span",{onClick:()=>g(B),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:A=>A.currentTarget.style.textDecoration="underline",onMouseLeave:A=>A.currentTarget.style.textDecoration="none",children:m.home}),!d&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:S,style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:A=>A.currentTarget.style.textDecoration="underline",onMouseLeave:A=>A.currentTarget.style.textDecoration="none",children:_})]})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[a&&c&&n.jsxs("button",{onClick:c,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:7,border:"none",background:"#4f46e5",color:"white",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI"},children:[n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m.edit]}),n.jsx(sh,{notifCount:p,darkMode:j,onCountChange:y,onToggleDark:u,onNavigate:g,onViewProfile:v,onLogout:x,userName:s.full_name||s.name,userRole:s.role})]})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px",display:"grid",gridTemplateColumns:h?"1fr auto":"1fr",gap:14,alignItems:"start"},children:[n.jsx("div",{style:{minWidth:0},children:n.jsxs(p0,{children:[o,!a&&n.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[n.jsx("button",{onClick:S,style:{padding:"9px 22px",borderRadius:8,border:"1.5px solid #e5e7eb",cursor:"pointer",fontSize:13,fontWeight:600,background:"white",color:"#374151",fontFamily:"Segoe UI"},children:m.cancel}),n.jsx("button",{onClick:f,disabled:l==="loading",style:{padding:"9px 22px",borderRadius:8,background:i,color:"white",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,opacity:l==="loading"?.7:1,boxShadow:"0 2px 10px rgba(79,70,229,0.18)",fontFamily:"Segoe UI"},children:l==="loading"?m.saving:r})]}),l==="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:10},children:m.savedOk}),l!=="idle"&&l!=="loading"&&l!=="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:10},children:l})]})}),h&&n.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start"},children:h})]})]})]})}function ue({value:e,onChange:t,items:s,placeholder:l="-- Select --",disabled:r=!1}){var p;const[i,a]=w.useState(!1),[c,d]=w.useState(""),h=w.useRef(null);w.useEffect(()=>{const u=y=>{h.current&&!h.current.contains(y.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const j=e?((p=s.find(u=>u.name===e))==null?void 0:p.label)??e:l;return n.jsxs("div",{ref:h,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!r&&a(u=>!u),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:i?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:r?"default":"pointer",background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[n.jsx("span",{children:j}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:i?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),i&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx("div",{onClick:()=>{t(""),a(!1)},onMouseEnter:()=>d("__placeholder"),onMouseLeave:()=>d(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:c==="__placeholder"?"#f5f5f5":"transparent"},children:l}),s.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),s.map(u=>n.jsx("div",{onClick:()=>{t(u.name),a(!1)},onMouseEnter:()=>d(u.name),onMouseLeave:()=>d(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===u.name?"#2563eb":c===u.name?"#f0f4ff":"transparent",color:e===u.name?"white":"#1a2332",transition:"background 0.1s"},children:u.label},u.name))]})})]})}function h0(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/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 sa({doctype:e,docname:t,currentUserName:s}){const l=ne(),[r,i]=w.useState([]),[a,c]=w.useState(!1),[d,h]=w.useState(""),[j,p]=w.useState(!1),[u,y]=w.useState(!1),[v,f]=w.useState(!1),[S,g]=w.useState(""),x=5,o=w.useCallback(async()=>{c(!0);const C=await Ry(e,t);i(C),c(!1)},[e,t]);w.useEffect(()=>{o()},[o]);const m=async()=>{const C=d.trim();if(!(!C||j)){p(!0),g("");try{await Oy(e,t,C),h(""),await o()}catch{g("Failed to post comment. Please try again.")}p(!1)}},_=async C=>{if(window.confirm("Delete this comment?"))try{await pi("Comment",C),i(R=>R.filter(B=>B.name!==C))}catch{alert("Failed to delete comment.")}},T=v?r:r.slice(-x),E=Math.max(0,r.length-x);return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>y(C=>!C),style:{padding:"12px 20px",borderBottom:u?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",l.comments.title,r.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:r.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{onClick:C=>{C.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:u?"▼":"▲"})]})]}),!u&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!v&&E>0&&n.jsxs("button",{onClick:()=>f(!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 ",E," older comment",E!==1?"s":""]}),a&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!a&&r.length===0&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:l.comments.noComments}),!a&&T.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:T.map(C=>{const R=C.comment_by||C.comment_email||C.owner||"Unknown",B=C.owner===s||C.comment_by===s;return n.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[n.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(R)}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:R}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:h0(C.creation)})]}),B&&n.jsx("button",{onClick:()=>_(C.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),n.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:C.content||""}})]})]},C.name)})}),n.jsxs("div",{style:{borderTop:r.length>0?"1px solid #f0f0f0":"none",paddingTop:r.length>0?14:0},children:[n.jsx("textarea",{value:d,onChange:C=>h(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&m()},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"}}),S&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:S}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:m,disabled:!d.trim()||j,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!d.trim()||j?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!d.trim()||j?.6:1},children:j?l.saving:l.comments.post})})]})]})]})}function ju(e){if(!e)return"";const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/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,t=>t.toUpperCase())}function bu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function Wo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Su(e){return Wo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function m0(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const s=(t.changed||[]).map(l=>({field:l[0]||"",oldVal:bu(l[1]),newVal:bu(l[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:s,added:(t.added||[]).length,removed:(t.removed||[]).length,rowChanged:(t.row_changed||[]).length}}function la({doctype:e,docname:t,docCreation:s,docOwner:l}){const r=ne(),[i,a]=w.useState([]),[c,d]=w.useState(!1),[h,j]=w.useState(!0),[p,u]=w.useState(!1),y=5,v=w.useCallback(async()=>{d(!0);const x=await Ly(e,t);a(x.map(m0)),d(!1)},[e,t]);w.useEffect(()=>{h||v()},[h,v]);const f=p?i:i.slice(0,y),S=i.length-y,g=(x,o=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:x,border:"2px solid white",boxShadow:o?`0 0 0 2px ${x}44`:"none"});return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>j(x=>!x),style:{padding:"12px 20px",borderBottom:h?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",r.activity.title,!h&&i.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:i.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!h&&n.jsx("button",{onClick:x=>{x.stopPropagation(),v()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:h?"▼":"▲"})]})]}),!h&&n.jsxs("div",{style:{padding:"16px 20px"},children:[c&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!c&&n.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[n.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[f.map((x,o)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g(o===0?"#3498db":"#d1d5db",o===0)}),n.jsxs("div",{style:{background:o===0?"#eff6ff":"#f9fafb",border:`1px solid ${o===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[n.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:Su(x.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Wo(x.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ju(x.creation)})]}),x.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:x.changes.map((m,_)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:x0(m.field)}),n.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),n.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:m.oldVal}),n.jsx("span",{style:{color:"#6b7280"},children:" → "}),n.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:m.newVal})]},_))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",x.added>0&&n.jsxs("span",{children:[" · +",x.added," row(s)"]}),x.removed>0&&n.jsxs("span",{children:[" · -",x.removed," row(s)"]}),x.rowChanged>0&&n.jsxs("span",{children:[" · ~",x.rowChanged," row(s) modified"]})]})]})]},x.name)),s&&l&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g("#22c55e")}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[n.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:Su(l)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Wo(l)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ju(s)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",r.activity.created]})]})]}),i.length===0&&!s&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!c&&S>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>u(x=>!x),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:p?"▲ Show less":`▼ Show all (${i.length})`})})]})]})}const Ba={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Rl={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},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:t,organizations:s,managements:l,departments:r,branches:i,incidentTypes:a,incidentClasses:c,incidentFields:d,incidentStatuses:h,users:j,userRoleMap:p={},formStatus:u,viewMode:y,onEdit:v,onRestore:f,darkMode:S,notifCount:g,onToggleDark:x,onCountChange:o,onViewProfile:m,userRole:_,onSubmit:T,onBack:E,onNavigate:C,onLogout:R,user:B,onRefresh:D}){var dt;const L=ne(),z=k=>t({...e,...k}),A=y?{background:"#f9f9f9"}:{},M=fl(j,p,"SB Manager",e.organization),[pe,re]=w.useState(""),[O,H]=w.useState(!1),Y=e.name?y?`${L.formTitle.viewIncident}${e.number||e.name}`:L.formTitle.editIncident:L.formTitle.newIncident,V=ge(l,e.management).map(k=>({name:k.name,label:k.name1||k.name})),Z=ge(r,e.department).map(k=>({name:k.name,label:k.department_name||k.name})),me=ge(i,e.branch).map(k=>({name:k.name,label:k.branch||k.name})),fe=ge(a,e.type).map(k=>({name:k.name,label:k.name1||k.name})),Xe=ge(c,e.incident_class).map(k=>({name:k.name,label:k.name1||k.name})),se=ge(d,e.incident_field).map(k=>({name:k.name,label:k.name1||k.name})),he=e.workflow_state||"New",X=_==="Employee",Q=_==="Auditor"||_==="Admin",$e=_==="Manager",et=e.name?he==="New"?[{label:L.wf.submit,action:"Submit",color:"#2563eb"}]:he==="Initial Evaluation"&&Q?[{label:L.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:L.wf.reject,action:"Reject",color:"#dc2626"}]:he==="Accept & Under Progress"&&($e||Q)?[{label:L.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:he==="working on resolution"&&($e||Q)?[{label:L.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function U(k){if(e.name){H(!0),re("");try{const ee={};k==="Assign to Manager"&&(e.assigned_to&&(ee.assigned_to=e.assigned_to),e.priority&&(ee.priority=e.priority),e.economy_class&&(ee.economy_class=e.economy_class),e.entity_scope&&(ee.entity_scope=e.entity_scope),e.hses_field&&(ee.hses_field=e.hses_field),ee.product_relation=String(e.product_relation??0),ee.repeated=String(e.repeated??0)),k==="Submit Solution"&&(e.solution&&(ee.solution=e.solution),e.summary&&(ee.summary=e.summary),e.cost&&(ee.cost=String(e.cost))),(k==="Resolution complete"||k==="Submit Solution")&&e.auditor_comment&&(ee.auditor_comment=e.auditor_comment),await Wy(e.name,k,JSON.stringify(ee)),re("Done"),D==null||D()}catch(ee){re(ee.message||"Error")}finally{H(!1)}}}const ke=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"#f8fafc",borderRadius:10,padding:16,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:14},children:L.wf.workflow}),n.jsx("span",{style:v0(he),children:he})]}),he==="Initial Evaluation"&&Q&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:I,children:L.wf.assignToManager}),n.jsxs("select",{style:P,value:e.assigned_to||"",onChange:k=>z({assigned_to:k.target.value}),children:[n.jsx("option",{value:"",children:L.field.selectMgr}),M.map(k=>n.jsx("option",{value:k.name,children:k.full_name||k.name},k.name))]})]}),(he==="Accept & Under Progress"||he==="working on resolution")&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:I,children:L.field.solution}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical"},value:e.solution||"",onChange:k=>z({solution:k.target.value}),placeholder:L.field.solutionPlaceholder}),n.jsx("label",{style:{...I,marginTop:8},children:L.field.actualCost}),n.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:k=>z({cost:parseFloat(k.target.value)||0}),placeholder:"0.00"})]}),he==="working on resolution"&&Q&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:I,children:L.field.auditorComment}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:k=>z({auditor_comment:k.target.value}),placeholder:L.field.commentPlaceholder})]}),et.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:et.map(k=>n.jsx("button",{onClick:()=>U(k.action),disabled:O,style:{padding:"8px 18px",borderRadius:8,border:"none",background:k.color,color:"white",fontWeight:700,cursor:O?"not-allowed":"pointer",opacity:O?.7:1},children:O?L.wf.applying:k.label},k.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:L.wf.noActions}),pe&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:pe==="Done"?N.green:N.red},children:pe})]}),n.jsx(sa,{doctype:W.incidents,docname:e.name,currentUserName:B.name}),n.jsx(la,{doctype:W.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Be,{title:Y,activePage:"incidents",user:B,formStatus:u,buttonText:L.saveIncident,buttonColor:N.accent,viewMode:y,onEdit:v,darkMode:S,notifCount:g,onToggleDark:x,onCountChange:o,onViewProfile:m,rightPanel:ke,onSubmit:T,onBack:E,onNavigate:C,onLogout:R,children:[e.custom_is_deleted===1&&n.jsx(jr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:f?()=>f(e.name):void 0}),n.jsxs("div",{style:e.name?Rl:Ba,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[L.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:k=>z({organization:k}),organizations:s,disabled:y||!!B.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.title}),n.jsx("input",{style:{...P,...A},value:e.title,disabled:y,onChange:k=>z({title:k.target.value})})]})]}),n.jsxs("div",{style:Rl,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.management}),n.jsx(ue,{value:e.management,onChange:k=>z({management:k}),items:V,placeholder:L.field.select,disabled:y})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.department}),n.jsx(ue,{value:e.department,onChange:k=>z({department:k}),items:Z,placeholder:L.field.select,disabled:y})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.section}),n.jsx("input",{style:{...P,...A},value:e.section_field||"",disabled:y,onChange:k=>z({section_field:k.target.value})})]})]}),n.jsxs("div",{style:Ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.branch}),n.jsx(ue,{value:e.branch,onChange:k=>z({branch:k}),items:me,placeholder:L.field.select,disabled:y})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.hsesField}),n.jsx("input",{style:{...P,...A},value:e.hses_field||"",disabled:y,onChange:k=>z({hses_field:k.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:Rl,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.type}),n.jsx(ue,{value:e.type,onChange:k=>z({type:k}),items:fe,placeholder:L.field.selectType,disabled:y})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.incidentClass}),n.jsx(ue,{value:e.incident_class,onChange:k=>z({incident_class:k}),items:Xe,placeholder:L.field.selectClass,disabled:y})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.incidentField}),n.jsx(ue,{value:e.incident_field,onChange:k=>z({incident_field:k}),items:se,placeholder:L.field.selectField,disabled:y})]})]}),n.jsxs("div",{style:Rl,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.date}),n.jsx(ve,{value:e.date,onChange:k=>z({date:k}),disabled:!0,style:{...P,background:"#f9f9f9"}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.time}),n.jsx("input",{type:"time",style:{...P,background:"#f9f9f9"},value:e.time,disabled:!0,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.assignedTo}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#334155"},value:((dt=M.find(k=>k.name===e.assigned_to))==null?void 0:dt.full_name)||e.assigned_to||"Unassigned",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[L.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"New",readOnly:!0,disabled:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.description}),n.jsx("textarea",{style:{...P,...A,height:120,resize:"vertical"},value:e.description,disabled:y,onChange:k=>z({description:k.target.value})})]}),!X&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:L.steps.auditorTriage}),n.jsxs("div",{style:Rl,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.priority}),n.jsxs("select",{style:{...P,...y||!Q?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:y||!Q,onChange:k=>z({priority:k.target.value}),children:[n.jsx("option",{value:"",children:L.field.select}),n.jsx("option",{value:"High",children:L.field.high}),n.jsx("option",{value:"Normal",children:L.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.economyClass}),n.jsxs("select",{style:{...P,...y||!Q?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:y||!Q,onChange:k=>z({economy_class:k.target.value}),children:[n.jsx("option",{value:"",children:L.field.select}),n.jsx("option",{value:"Expenses",children:L.field.expenses}),n.jsx("option",{value:"Capital",children:L.field.capital}),n.jsx("option",{value:"Earn",children:L.field.earn}),n.jsx("option",{value:"Pay/Loss",children:L.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.entityScope}),n.jsxs("select",{style:{...P,...y||!Q?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:y||!Q,onChange:k=>z({entity_scope:k.target.value}),children:[n.jsx("option",{value:"",children:L.field.select}),n.jsx("option",{value:"Upstream",children:L.field.upstream}),n.jsx("option",{value:"On-stream",children:L.field.onstream}),n.jsx("option",{value:"Downstream",children:L.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:y||!Q,onChange:k=>z({product_relation:k.target.checked?1:0})})," ",L.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:y||!Q,onChange:k=>z({repeated:k.target.checked?1:0})})," ",L.field.repeatedEvent]})]})]}),!X&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:L.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.solution}),n.jsx("textarea",{style:{...P,height:100,resize:"vertical",...y&&!$e&&!Q?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:y&&!$e&&!Q,onChange:k=>z({solution:k.target.value}),placeholder:L.field.solutionPlaceholder})]}),n.jsxs("div",{style:Ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...y&&!$e&&!Q?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:y&&!$e&&!Q,onChange:k=>z({cost:parseFloat(k.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:L.field.summary}),n.jsx("input",{style:{...P,...y&&!$e&&!Q?{background:"#f9f9f9"}:{}},value:e.summary||"",disabled:y&&!$e&&!Q,onChange:k=>z({summary:k.target.value}),placeholder:"Brief summary"})]})]})]}),!X&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:L.steps.ownerComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...y&&!Q?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:y&&!Q,onChange:k=>z({auditor_comment:k.target.value}),placeholder:L.field.commentPlaceholder})]})]})}function b0({ideas:e,organizations:t,departments:s,branches:l,ideaStatuses:r,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:h,onDelete:j}){const p=ne(),[u,y]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),v=(o,m)=>y(_=>({..._,[o]:m})),[f,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((f-1)*le,f*le);return n.jsxs(n.Fragment,{children:[n.jsx(na,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.numberTitle}),n.jsx("input",{style:He,value:u.search,onChange:o=>v("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.organization}),n.jsxs("select",{style:He,value:u.organization,onChange:o=>v("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.department}),n.jsxs("select",{style:He,value:u.department,onChange:o=>v("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.branch}),n.jsxs("select",{style:He,value:u.branch,onChange:o=>v("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),l.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.status}),n.jsxs("select",{style:He,value:u.status,onChange:o=>v("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>y({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIdeas})}):x.map((o,m)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:o.custom_is_deleted?"#fef2f2":m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{children:o.title||"—"}),o.sb_order&&n.jsxs("span",{style:{fontSize:11,background:"#dcfce7",color:"#166534",border:"1px solid #86efac",borderRadius:4,padding:"1px 6px",fontWeight:700},children:["📦 ",o.sb_order]})]})}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?jt(p.deletedBadge,"#dc2626"):o.status?jt(o.status,ta(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Ye,{onView:()=>d==null?void 0:d(o),onEdit:c&&h&&!o.custom_is_deleted&&!Cn("idea",o.workflow_state)?()=>h(o):void 0,onDelete:c&&j&&!o.custom_is_deleted?()=>j(o.name):void 0})})]},o.name))})]})}),n.jsx(We,{page:f,total:g.length,onPageChange:S})]})}const $a={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Qr={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},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 _0({ideaForm:e,setIdeaForm:t,organizations:s,managements:l,departments:r,branches:i,ideaTypes:a,ideaStatuses:c,users:d=[],userRoleMap:h={},formStatus:j,viewMode:p,onEdit:u,onRestore:y,onNavigateToOrder:v,darkMode:f,notifCount:S,onToggleDark:g,onCountChange:x,onViewProfile:o,userRole:m,onSubmit:_,onBack:T,onNavigate:E,onLogout:C,user:R,onRefresh:B}){var et;const D=ne(),L=U=>t({...e,...U}),z=p?{background:"#f9f9f9"}:{},A=fl(d,h,"SB Manager",e.organization),[M,pe]=w.useState(""),[re,O]=w.useState(!1),H=e.name?p?`${D.formTitle.viewIdea}${e.number||e.title||e.name}`:D.formTitle.editIdea:D.formTitle.newIdea,Y=ge(l,e.management).map(U=>({name:U.name,label:U.name1||U.name})),V=ge(r,e.department).map(U=>({name:U.name,label:U.department_name||U.name})),Z=ge(i,e.branch).map(U=>({name:U.name,label:U.branch||U.name})),me=ge(a,e.type).map(U=>({name:U.name,label:U.name1||U.name})),fe=e.workflow_state||"New",Xe=m==="Employee",se=m==="Auditor"||m==="Admin",he=m==="Manager",X=e.name?fe==="New"?[{label:D.wf.submit,action:"Submit",color:"#2563eb"}]:fe==="Initial Evaluation"&&se?[{label:D.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:fe==="Accept & Under Progress"&&(he||se)?[{label:D.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:fe==="working on proposal"&&se?[{label:D.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function Q(U){if(e.name){O(!0),pe("");try{const ke={};U==="Assign to Manager"&&(e.assigned_to&&(ke.assigned_to=e.assigned_to),e.priority&&(ke.priority=e.priority),e.economy_class&&(ke.economy_class=e.economy_class),e.entity_scope&&(ke.entity_scope=e.entity_scope),e.hses_field&&(ke.hses_field=e.hses_field),ke.product_relation=String(e.product_relation??0),ke.repeated=String(e.repeated??0)),U==="Submit Proposal"&&(e.solution&&(ke.solution=e.solution),e.proposed_condition&&(ke.proposed_condition=e.proposed_condition),e.cost&&(ke.cost=String(e.cost))),e.auditor_comment&&(U==="Move to Outsourcing"||U==="Reject")&&(ke.auditor_comment=e.auditor_comment);const dt=await By(e.name,U,JSON.stringify(ke));dt!=null&&dt.created_order&&L({sb_order:dt.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),pe("Done"),B==null||B()}catch(ke){pe(ke.message||"Error")}finally{O(!1)}}}const $e=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"#f8fafc",borderRadius:10,padding:16,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:14},children:D.wf.workflow}),n.jsx("span",{style:w0(fe),children:fe})]}),fe==="Initial Evaluation"&&se&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:I,children:D.wf.assignToManager}),n.jsxs("select",{style:P,value:e.assigned_to||"",onChange:U=>L({assigned_to:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.selectMgr}),A.map(U=>n.jsx("option",{value:U.name,children:U.full_name||U.name},U.name))]})]}),fe==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:I,children:D.field.solution}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical"},value:e.solution||"",onChange:U=>L({solution:U.target.value}),placeholder:D.field.solutionPlaceholder}),n.jsx("label",{style:{...I,marginTop:8},children:D.field.actualCost}),n.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:U=>L({cost:parseFloat(U.target.value)||0}),placeholder:"0.00"})]}),fe==="working on proposal"&&se&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:I,children:D.field.auditorComment}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:U=>L({auditor_comment:U.target.value}),placeholder:D.field.commentPlaceholder})]}),X.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:X.map(U=>n.jsx("button",{onClick:()=>Q(U.action),disabled:re,style:{padding:"8px 18px",borderRadius:8,border:"none",background:U.color,color:"white",fontWeight:700,cursor:re?"not-allowed":"pointer",opacity:re?.7:1},children:re?D.wf.applying:U.label},U.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:D.wf.noActions}),M&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:M==="Done"?N.green:N.red},children:M})]}),n.jsx(sa,{doctype:W.ideas,docname:e.name,currentUserName:R.name}),n.jsx(la,{doctype:W.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Be,{title:H,activePage:"ideas",user:R,formStatus:j,buttonText:D.saveIdea,buttonColor:N.teal,viewMode:p,onEdit:u,darkMode:f,notifCount:S,onToggleDark:g,onCountChange:x,onViewProfile:o,rightPanel:$e,onSubmit:_,onBack:T,onNavigate:E,onLogout:C,children:[e.custom_is_deleted===1&&n.jsx(jr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:y?()=>y(e.name):void 0}),e.sb_order&&n.jsxs("div",{style:{background:"linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%)",border:"1px solid #86efac",borderRadius:8,padding:"12px 16px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("span",{style:{fontSize:20},children:"📦"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#166534",textTransform:"uppercase",letterSpacing:"0.5px"},children:D.field.convertedToOrder}),n.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#14532d"},children:e.sb_order})]})]}),v&&n.jsxs("button",{type:"button",onClick:()=>v(e.sb_order),style:{background:"#16a34a",color:"#fff",border:"none",borderRadius:6,padding:"6px 14px",fontWeight:600,fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[D.field.viewOrder," →"]})]}),n.jsxs("div",{style:e.name?Qr:$a,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[D.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:U=>L({organization:U}),organizations:s,disabled:p||!!R.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.title}),n.jsx("input",{style:{...P,...z},value:e.title,disabled:p,onChange:U=>L({title:U.target.value})})]})]}),n.jsxs("div",{style:Qr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.management}),n.jsx(ue,{value:e.management,onChange:U=>L({management:U}),items:Y,placeholder:D.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.department}),n.jsx(ue,{value:e.department,onChange:U=>L({department:U}),items:V,placeholder:D.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.section}),n.jsx("input",{style:{...P,...z},value:e.section_field||"",disabled:p,onChange:U=>L({section_field:U.target.value})})]})]}),n.jsxs("div",{style:$a,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.branch}),n.jsx(ue,{value:e.branch,onChange:U=>L({branch:U}),items:Z,placeholder:D.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.date}),n.jsx(ve,{value:e.date||"",onChange:U=>L({date:U}),disabled:!0,style:{...P,background:"#f9f9f9"}})]})]}),n.jsxs("div",{style:Qr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.type}),n.jsx(ue,{value:e.type,onChange:U=>L({type:U}),items:me,placeholder:D.field.selectType,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.ideaClass}),n.jsxs("select",{style:{...P,...z},value:e.idea_class||"",disabled:p,onChange:U=>L({idea_class:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Safety",children:"Safety"}),n.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.hsesField}),n.jsx("input",{style:{...P,...z},value:e.hses_field||"",disabled:p,onChange:U=>L({hses_field:U.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:$a,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.assignedTo}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#334155"},value:((et=A.find(U=>U.name===e.assigned_to))==null?void 0:et.full_name)||e.assigned_to||"Unassigned",readOnly:!0,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[D.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"New",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.currentCondition}),n.jsx("textarea",{style:{...P,...z,height:110,resize:"vertical"},value:e.current_condition,disabled:p,onChange:U=>L({current_condition:U.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.proposedCondition}),n.jsx("textarea",{style:{...P,...z,height:110,resize:"vertical"},value:e.proposed_condition,disabled:p,onChange:U=>L({proposed_condition:U.target.value})})]}),!Xe&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:D.steps.auditorEval}),n.jsxs("div",{style:Qr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.priority}),n.jsxs("select",{style:{...P,...p&&!se?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:p&&!se,onChange:U=>L({priority:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"High",children:D.field.high}),n.jsx("option",{value:"Normal",children:D.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.economyClass}),n.jsxs("select",{style:{...P,...p&&!se?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:p&&!se,onChange:U=>L({economy_class:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Expenses",children:D.field.expenses}),n.jsx("option",{value:"Capital",children:D.field.capital}),n.jsx("option",{value:"Earn",children:D.field.earn}),n.jsx("option",{value:"Pay/Loss",children:D.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.entityScope}),n.jsxs("select",{style:{...P,...p&&!se?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:p&&!se,onChange:U=>L({entity_scope:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Upstream",children:D.field.upstream}),n.jsx("option",{value:"On-stream",children:D.field.onstream}),n.jsx("option",{value:"Downstream",children:D.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:p&&!se,onChange:U=>L({product_relation:U.target.checked?1:0})})," ",D.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:p&&!se,onChange:U=>L({repeated:U.target.checked?1:0})})," ",D.field.repeatedEvent]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:I,children:D.wf.assignToManager}),n.jsxs("select",{style:{...P,...p||!se?{background:"#f9f9f9"}:{}},value:e.assigned_to||"",disabled:p||!se,onChange:U=>L({assigned_to:U.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),A.map(U=>n.jsx("option",{value:U.name,children:U.full_name||U.name},U.name))]})]})]}),!Xe&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:D.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:D.field.solution}),n.jsx("textarea",{style:{...P,height:100,resize:"vertical",...p&&!he&&!se?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:p&&!he&&!se,onChange:U=>L({solution:U.target.value}),placeholder:D.field.solutionPlaceholder})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:I,children:D.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...p&&!he&&!se?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:p&&!he&&!se,onChange:U=>L({cost:parseFloat(U.target.value)||0}),placeholder:"0.00"})]})]}),!Xe&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:D.steps.ownerComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...p&&!se?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:p&&!se,onChange:U=>L({auditor_comment:U.target.value}),placeholder:D.field.commentPlaceholder})]})]})}function k0({orders:e,organizations:t,departments:s,branches:l,orderStatuses:r,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:h,onDelete:j}){const p=ne(),[u,y]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),v=(o,m)=>y(_=>({..._,[o]:m})),[f,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((f-1)*le,f*le);return n.jsxs(n.Fragment,{children:[n.jsx(na,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.numberTitle}),n.jsx("input",{style:He,value:u.search,onChange:o=>v("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.organization}),n.jsxs("select",{style:He,value:u.organization,onChange:o=>v("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.department}),n.jsxs("select",{style:He,value:u.department,onChange:o=>v("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.branch}),n.jsxs("select",{style:He,value:u.branch,onChange:o=>v("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),l.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.status}),n.jsxs("select",{style:He,value:u.status,onChange:o=>v("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>y({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noOrders})}):x.map((o,m)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:o.custom_is_deleted?"#fef2f2":m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{children:o.title||"—"}),o.sb_idea&&n.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1e40af",border:"1px solid #93c5fd",borderRadius:4,padding:"1px 6px",fontWeight:700},children:["💡 ",o.sb_idea]})]})}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.type?jt(o.type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?jt(p.deletedBadge,"#dc2626"):o.status?jt(o.status,ta(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Ye,{onView:()=>d==null?void 0:d(o),onEdit:c&&h&&!o.custom_is_deleted&&!Cn("order",o.workflow_state)?()=>h(o):void 0,onDelete:c&&j&&!o.custom_is_deleted?()=>j(o.name):void 0})})]},o.name))})]})}),n.jsx(We,{page:f,total:g.length,onPageChange:S})]})}const Yr={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ol={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},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:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function T0(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 I0({orderForm:e,setOrderForm:t,organizations:s,managements:l,departments:r,branches:i,orderTypes:a,orderStatuses:c,cycles:d=[],users:h,userRoleMap:j={},formStatus:p,viewMode:u,onEdit:y,onRestore:v,onNavigateToIdea:f,darkMode:S,notifCount:g,onToggleDark:x,onCountChange:o,onViewProfile:m,currentUser:_,userRole:T,onSubmit:E,onBack:C,onNavigate:R,onLogout:B,user:D,onRefresh:L}){var Fn;const z=ne(),A=$=>t({...e,...$}),M=u?{background:"#f9f9f9"}:{},pe=fl(h,j,"SB Employee",e.organization),[re,O]=w.useState(""),[H,Y]=w.useState(""),[V,Z]=w.useState(!1),[me,fe]=w.useState("Agree"),Xe=e.name?u?`${z.formTitle.viewOrder}${e.number||e.title||e.name}`:z.formTitle.editOrder:z.formTitle.newOrder,se=ge(l,e.management).map($=>({name:$.name,label:$.name1||$.name})),he=ge(r,e.department).map($=>({name:$.name,label:$.department_name||$.name})),X=ge(i,e.branch).map($=>({name:$.name,label:$.branch||$.name})),Q=ge(a,e.type).map($=>({name:$.name,label:$.name1||$.name})),$e=ge(d,e.cycle).map($=>({name:$.name,label:$.name1||$.name})),et=!!e.name,U=e.workflow_state||"Draft",ke=Math.min(5,(e.stage||0)+1),[dt,k]=w.useState(ke);w.useEffect(()=>{k(Math.min(5,(e.stage||0)+1))},[e.stage]);const ee=T==="Auditor"||T==="Admin",G=T==="Auditor"||T==="Admin"||T==="Manager",Sr=G||T==="Owner",sn=!!(_&&(e.actor===_||e.assigned_to===_)),wr=et?U==="Closed"?[]:U==="Draft"&&G?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:U==="Pending Actor"&&(sn||G)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:U==="Review"&&Sr?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:U==="In Study"&&Sr?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function Un($){if(e.name){Z(!0),O("");try{let qe;$==="Update Status"&&(qe=me);const vs=await Ny(e.name,$,H,$==="Update Status"?String(dt):void 0,void 0,qe);if(Y(""),fe("Agree"),O("Done"),vs){const bt=vs;t({...e,...bt,stage:bt.stage??e.stage,completion_pct:bt.completion_pct??e.completion_pct,workflow_state:bt.workflow_state??e.workflow_state})}L==null||L()}catch(qe){O(qe.message||"Error")}finally{Z(!1)}}}const ra=et?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"#f8fafc",borderRadius:10,padding:16,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:14},children:z.wf.workflow}),n.jsx("span",{style:T0(U),children:U})]}),U==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:14,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:["Stage (1–5) — ",dt*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...P,maxWidth:80},value:dt,onChange:$=>k(Math.min(5,Math.max(1,parseInt($.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Cycle Status"}),n.jsxs("select",{style:{...P,minWidth:140},value:me,onChange:$=>fe($.target.value),children:[n.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),n.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),n.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),n.jsxs("div",{style:{marginBottom:14},children:[n.jsxs("label",{style:I,children:["Comment ",me==="Deviate"&&U==="Pending Actor"?n.jsx("span",{style:{color:N.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...P,height:64,resize:"vertical",borderColor:me==="Deviate"&&!H?"#fca5a5":void 0},value:H,onChange:$=>Y($.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:wr.map($=>{const qe=$.action==="Update Status"&&me==="Deviate"&&!H.trim();return n.jsx("button",{onClick:()=>Un($.action),disabled:V||qe,title:qe?"Comment required when status is Deviate":void 0,style:{padding:"8px 18px",borderRadius:8,border:"none",background:$.color,color:"white",fontWeight:700,cursor:V||qe?"not-allowed":"pointer",opacity:V||qe?.5:1},children:V?z.wf.applying:$.label},$.action)})}),re&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:re==="Done"?N.green:N.red},children:re}),wr.length===0&&n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:z.wf.noActions})]}),n.jsx(sa,{doctype:W.orders,docname:e.name,currentUserName:D.name}),n.jsx(la,{doctype:W.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Be,{title:Xe,activePage:"orders",user:D,formStatus:p,buttonText:z.saveOrder,buttonColor:N.purple,viewMode:u,onEdit:y,darkMode:S,notifCount:g,onToggleDark:x,onCountChange:o,onViewProfile:m,rightPanel:ra,onSubmit:E,onBack:C,onNavigate:R,onLogout:B,children:[e.custom_is_deleted===1&&n.jsx(jr,{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&&n.jsxs("div",{style:{background:"linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%)",border:"1px solid #93c5fd",borderRadius:8,padding:"12px 16px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("span",{style:{fontSize:20},children:"💡"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#1e40af",textTransform:"uppercase",letterSpacing:"0.5px"},children:z.field.originatingIdea}),n.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#1e3a8a"},children:e.sb_idea})]})]}),f&&n.jsxs("button",{type:"button",onClick:()=>f(e.sb_idea),style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"6px 14px",fontWeight:600,fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[z.field.viewIdea," →"]})]}),n.jsxs("div",{style:e.name?Ol:Yr,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[z.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:$=>A({organization:$}),organizations:s,disabled:u||!!D.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.title}),n.jsx("input",{style:{...P,...M},value:e.title,disabled:u,onChange:$=>A({title:$.target.value})})]})]}),n.jsxs("div",{style:Ol,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.management}),n.jsx(ue,{value:e.management,onChange:$=>A({management:$}),items:se,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.department}),n.jsx(ue,{value:e.department,onChange:$=>A({department:$}),items:he,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.section}),n.jsx("input",{style:{...P,...M},value:e.section_field||"",disabled:u,onChange:$=>A({section_field:$.target.value})})]})]}),n.jsxs("div",{style:Yr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.branch}),n.jsx(ue,{value:e.branch,onChange:$=>A({branch:$}),items:X,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.type}),n.jsx(ue,{value:e.type,onChange:$=>A({type:$}),items:Q,placeholder:z.field.selectType,disabled:u})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:Ol,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.priority}),n.jsxs("select",{style:{...P,...M},value:e.priority||"",disabled:u,onChange:$=>A({priority:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"High",children:z.field.high}),n.jsx("option",{value:"Normal",children:z.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.economyClass}),n.jsxs("select",{style:{...P,...M},value:e.economy_class||"",disabled:u,onChange:$=>A({economy_class:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Expenses",children:z.field.expenses}),n.jsx("option",{value:"Capital",children:z.field.capital}),n.jsx("option",{value:"Earn",children:z.field.earn}),n.jsx("option",{value:"Pay/Loss",children:z.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.entityScope}),n.jsxs("select",{style:{...P,...M},value:e.entity_scope||"",disabled:u,onChange:$=>A({entity_scope:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Upstream",children:z.field.upstream}),n.jsx("option",{value:"On-stream",children:z.field.onstream}),n.jsx("option",{value:"Downstream",children:z.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:u,onChange:$=>A({planned:$.target.checked?1:0})})," Planned"]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:$=>A({product_relation:$.target.checked?1:0})})," ",z.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:I,children:z.field.hsesField}),n.jsx("input",{style:{...P,...M},value:e.hses_field||"",disabled:u,onChange:$=>A({hses_field:$.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:Ol,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.budget}),n.jsx("input",{type:"number",style:{...P,...M},value:e.budget||"",disabled:u,onChange:$=>A({budget:parseFloat($.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...M},value:e.actual_cost||"",disabled:u,onChange:$=>A({actual_cost:parseFloat($.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Variance"}),(()=>{const $=(e.budget||0)-(e.actual_cost||0);return n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontWeight:700,fontSize:13,background:$>=0?"#f0fdf4":"#fef2f2",color:$>=0?"#166534":"#dc2626",border:`1px solid ${$>=0?"#bbf7d0":"#fecaca"}`},children:[$>=0?"+":"",$.toFixed(2)]})})()]})]}),n.jsxs("div",{style:Yr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.currency}),n.jsxs("select",{style:{...P,...M},value:e.currency||"",disabled:u,onChange:$=>A({currency:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"SAR",children:"SAR"}),n.jsx("option",{value:"USD",children:"USD"}),n.jsx("option",{value:"EUR",children:"EUR"}),n.jsx("option",{value:"AED",children:"AED"}),n.jsx("option",{value:"GBP",children:"GBP"})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[z.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"Draft",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{style:Ol,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.startingDate}),n.jsx(ve,{value:e.starting_date,onChange:$=>A({starting_date:$}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.endingDate}),n.jsx(ve,{value:e.ending_date,onChange:$=>A({ending_date:$}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.actor}),n.jsxs("select",{style:{...P,...u||!ee?{background:"#f9f9f9"}:{}},value:e.actor||e.assigned_to||"",disabled:u||!ee,onChange:$=>A({actor:$.target.value,assigned_to:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),pe.map($=>n.jsx("option",{value:$.name,children:$.full_name||$.name},$.name))]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:12},children:"Cycle & Progress"}),n.jsxs("div",{style:Yr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:$=>A({cycle:$}),items:$e,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...P,background:"#f9f9f9",maxWidth:80},value:e.stage||1,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Completion"}),n.jsx("input",{style:{...P,background:"#f9f9f9",maxWidth:100},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd"},children:C0[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.escalationLevel}),n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",background:"#fecaca",color:"#e74c3c",borderRadius:8,fontWeight:700,fontSize:13},children:["Level ",e.escalation_level]})]})]})]})]}),et&&((Fn=e.order_cycle_log)==null?void 0:Fn.length)>0&&n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:10},children:"Cycle History"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map($=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:$},$))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map(($,qe)=>{const vs=$.status==="Agree"?"#166534":$.status==="Deviate"?"#c2410c":"#92400e",bt=$.status==="Agree"?"#f0fdf4":$.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:$.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:$.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:$.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:bt,color:vs,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:$.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:$.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:$.comment?"normal":"italic"},children:$.comment||"—"})]},qe)})})]})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.description}),n.jsx("textarea",{style:{...P,...M,height:100,resize:"vertical"},value:e.description,disabled:u,onChange:$=>A({description:$.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.notes}),n.jsx("textarea",{style:{...P,...M,height:100,resize:"vertical"},value:e.notes,disabled:u,onChange:$=>A({notes:$.target.value})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:z.field.auditorComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...u&&sn&&!G?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:u&&sn&&!G,onChange:$=>A({auditor_comment:$.target.value}),placeholder:z.field.commentPlaceholder})]})]})}function P0({processes:e,organizations:t,departments:s,branches:l,processStatuses:r,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:h,onDelete:j}){const p=ne(),[u,y]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),v=(o,m)=>y(_=>({..._,[o]:m})),[f,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((f-1)*le,f*le);return n.jsxs(n.Fragment,{children:[n.jsx(na,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.numberTitle}),n.jsx("input",{style:He,value:u.search,onChange:o=>v("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.organization}),n.jsxs("select",{style:He,value:u.organization,onChange:o=>v("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.department}),n.jsxs("select",{style:He,value:u.department,onChange:o=>v("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.branch}),n.jsxs("select",{style:He,value:u.branch,onChange:o=>v("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),l.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Me,children:p.filter.status}),n.jsxs("select",{style:He,value:u.status,onChange:o=>v("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>y({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.field.cycleType}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noProcesses})}):x.map((o,m)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:o.custom_is_deleted?"#fef2f2":m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.cycle_type?jt(o.cycle_type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.custom_is_deleted?jt(p.deletedBadge,"#dc2626"):o.status?jt(o.status,ta(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Ye,{onView:()=>d==null?void 0:d(o),onEdit:c&&h&&!o.custom_is_deleted&&!Cn("process",o.workflow_state)?()=>h(o):void 0,onDelete:c&&j&&!o.custom_is_deleted?()=>j(o.name):void 0})})]},o.name))})]})}),n.jsx(We,{page:f,total:g.length,onPageChange:S})]})}const E0={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 wu(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 Xr={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function R0({processName:e,userRole:t,onRefresh:s,canUpdateStatus:l=!0}){const[r,i]=w.useState(null),[a,c]=w.useState(!0),[d,h]=w.useState(""),[j,p]=w.useState(!1),[u,y]=w.useState(""),[v,f]=w.useState(""),[S,g]=w.useState("Pass"),[x,o]=w.useState(""),[m,_]=w.useState({}),T=w.useCallback(async()=>{if(!e){c(!1);return}c(!0),h("");try{const z=await Fl(e);i(z);const A={};for(const M of z.progress_indicators||[])A[M.name]=M.actual_value!=null?String(M.actual_value):"";_(A)}catch(z){h(z instanceof Error?z.message:"Failed to load process")}c(!1)},[e]);if(w.useEffect(()=>{T()},[T]),a)return n.jsx("div",{style:{width:260,flexShrink:0},children:n.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(d||!r)return n.jsx("div",{style:{width:260,flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:n.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:d||"Could not load workflow"})})});const E=r.workflow_state||"Draft",C=E0[E]??[],R=t==="Employee"||t==="Manager",B=t!=="Manager"||l,D=C.filter(z=>(t==="Admin"||z.allowedRoles.includes(t))&&(z.action!=="Update Status"||B)),L=async z=>{p(!0),y(""),f("");try{const A={};if(z==="Update Status"){A.actor_status=S,A.actor_comment=x;const pe=r.progress_indicators||[];pe.length>0&&(A.progress_indicators=pe.map(re=>({name:re.name,actual_value:m[re.name]??""})))}z==="Add Comment"&&x&&(A.actor_comment=x);const M=await Zy(r.name,z,A);i(M),o(""),f(`Done — now: ${M.workflow_state||"updated"}`),s==null||s()}catch(A){y(A instanceof Error?A.message:"Action failed")}p(!1)};return n.jsx("div",{style:{width:260,flexShrink:0},children:n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),n.jsx("div",{style:wu(E),children:E})]}),E==="Pending Actor"&&R&&B&&n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.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&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Actual Value"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.progress_indicators.map(z=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{style:{fontSize:11,color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:z.name1,children:z.name1||z.name}),n.jsx("input",{type:"number",value:m[z.name]??"",onChange:A=>_(M=>({...M,[z.name]:A.target.value})),style:{...Xr,width:70,flexShrink:0},placeholder:"0"})]},z.name))})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),n.jsxs("select",{value:S,onChange:z=>g(z.target.value),style:Xr,children:[n.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),n.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),n.jsx("textarea",{value:x,onChange:z=>o(z.target.value),style:{...Xr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(E==="Pending Comment"||E==="Review")&&!R&&n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.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&&n.jsxs("div",{style:{marginBottom:8,padding:"6px 10px",background:"#f8fafc",borderRadius:6,border:"1px solid #e2e8f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",marginBottom:3},children:"Latest cycle status:"}),(()=>{const z=r.cycle_logs,A=z[z.length-1],M=A.status==="Pass"?"#16a34a":A.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:M},children:[A.status," ",A.comment?`— ${A.comment}`:""]})})()]}),n.jsx("textarea",{value:x,onChange:z=>o(z.target.value),style:{...Xr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:D.length>0?"1px solid #f0f0f0":"none"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),D.length===0&&n.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",n.jsx("strong",{children:t})," in ",n.jsx("strong",{children:E}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:D.map(z=>n.jsxs("button",{onClick:()=>L(z.action),disabled:j,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:z.action==="Close Process"?"#64748b":z.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:j?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:j?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("span",{children:j?"Applying…":z.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",z.next]})]},z.action))}),u&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:u}),v&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:v})]}),C.length>0&&n.jsxs("div",{style:{padding:"12px 14px"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),C.map(z=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:z.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:wu(z.next),children:z.next})]},z.action))]})]})})}const qr={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},Jn={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function O0({processForm:e,setProcessForm:t,organizations:s,managements:l,departments:r,branches:i,processTypes:a,processStatuses:c,cycles:d=[],users:h=[],userRoleMap:j={},formStatus:p,viewMode:u,onEdit:y,onRestore:v,darkMode:f,notifCount:S,onToggleDark:g,onCountChange:x,onViewProfile:o,userRole:m,delegatedFunctions:_=[],delegatedOrgs:T=null,onRefreshProcess:E,onSubmit:C,onBack:R,onNavigate:B,onLogout:D,user:L}){const z=ne(),A=k=>t({...e,...k}),M=u?{background:"#f9f9f9"}:{},pe=!u&&m==="Manager"&&Array.isArray(T),re=pe?s.filter(k=>(T||[]).includes(k.organization_name||k.name)):s,O=pe&&(T||[]).length===1||!!L.custom_organization,H=ge(l,e.management).map(k=>({name:k.name,label:k.name1||k.name})),Y=ge(r,e.department).map(k=>({name:k.name,label:k.department_name||k.name})),V=ge(i,e.branch).map(k=>({name:k.name,label:k.branch||k.name})),Z=ge(a,e.type).map(k=>({name:k.name,label:k.name1||k.name})),me=ge(d,e.cycle).map(k=>({name:k.name,label:k.name1||k.name})),fe=fl(h,j,"SB Employee",e.organization).map(k=>({name:k.name,label:k.full_name||k.name})),Xe=fl(h,j,"SB Manager",e.organization).map(k=>({name:k.name,label:k.full_name||k.name})),se=(k,ee)=>{const G=[...e.cycle_logs||[]];G[k]={...G[k],...ee},A({cycle_logs:G})},he=()=>{A({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},X=k=>{const ee=[...e.cycle_logs||[]];ee.splice(k,1),A({cycle_logs:ee})},Q=(k,ee)=>{const G=[...e.progress_indicators||[]];G[k]={...G[k],...ee},A({progress_indicators:G})},$e=()=>{A({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},et=k=>{const ee=[...e.progress_indicators||[]];ee.splice(k,1),A({progress_indicators:ee})},U=e.name?u?`${z.formTitle.viewProcess}${e.title||e.name}`:z.formTitle.editProcess:z.formTitle.newProcess,ke=m!=="Manager"||e.actor===L.name||_.includes("update_process_status"),dt=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsx(R0,{processName:e.name,userRole:m||L.role||"Employee",onRefresh:E,canUpdateStatus:ke}),n.jsx(sa,{doctype:W.processes,docname:e.name,currentUserName:L.name}),n.jsx(la,{doctype:W.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):void 0;return n.jsxs(Be,{title:U,activePage:"processes",user:L,formStatus:p,buttonText:z.saveProcess,buttonColor:N.blue,viewMode:u,onEdit:y,darkMode:f,notifCount:S,onToggleDark:g,onCountChange:x,onViewProfile:o,rightPanel:dt,onSubmit:C,onBack:R,onNavigate:B,onLogout:D,children:[e.custom_is_deleted===1&&n.jsx(jr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:v?()=>v(e.name):void 0}),n.jsxs("div",{style:e.name?Jn:qr,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[z.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:k=>A({organization:k}),organizations:re,disabled:u||O}),pe&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(T||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(T||[]).length>1?"s":""}: ${(T||[]).join(", ")}`})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.title}),n.jsx("input",{style:{...P,...M},value:e.title,disabled:u,onChange:k=>A({title:k.target.value})})]})]}),n.jsx("div",{style:qr,children:n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.type}),n.jsx(ue,{value:e.type,onChange:k=>A({type:k}),items:Z,placeholder:z.field.selectType,disabled:u})]})}),n.jsxs("div",{style:Jn,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.management}),n.jsx(ue,{value:e.management,onChange:k=>A({management:k}),items:H,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.department}),n.jsx(ue,{value:e.department,onChange:k=>A({department:k}),items:Y,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.section}),n.jsx("input",{style:{...P,...M},value:e.section_field||"",disabled:u,onChange:k=>A({section_field:k.target.value})})]})]}),n.jsxs("div",{style:qr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.branch}),n.jsx(ue,{value:e.branch,onChange:k=>A({branch:k}),items:V,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[z.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"Draft",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:Jn,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.chainLocation}),n.jsxs("select",{style:{...P,...M},value:e.chain_location||"",disabled:u,onChange:k=>A({chain_location:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Upstream",children:"Upstream"}),n.jsx("option",{value:"On-stream",children:"On-stream"}),n.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.economyClass}),n.jsxs("select",{style:{...P,...M},value:e.economy_class||"",disabled:u,onChange:k=>A({economy_class:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Expenses",children:z.field.expenses}),n.jsx("option",{value:"Capital",children:z.field.capital}),n.jsx("option",{value:"Earn",children:z.field.earn}),n.jsx("option",{value:"Pay/Loss",children:z.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.impactLevel}),n.jsxs("select",{style:{...P,...M},value:e.impact_level||"",disabled:u,onChange:k=>A({impact_level:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"High",children:z.field.high}),n.jsx("option",{value:"Normal",children:z.field.normal})]})]})]}),n.jsxs("div",{style:Jn,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.entityScope}),n.jsxs("select",{style:{...P,...M},value:e.entity_scope||"",disabled:u,onChange:k=>A({entity_scope:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Upstream",children:z.field.upstream}),n.jsx("option",{value:"On-stream",children:z.field.onstream}),n.jsx("option",{value:"Downstream",children:z.field.downstream})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.hsesField}),n.jsx("input",{style:{...P,...M},value:e.hses_field||"",disabled:u,onChange:k=>A({hses_field:k.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:22},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:k=>A({product_relation:k.target.checked?1:0})})," ",z.field.productRelation]})})]})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:"KPI"}),n.jsxs("div",{style:Jn,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.kpiName}),n.jsx("input",{style:{...P,...M},value:e.kpi_name||"",disabled:u,onChange:k=>A({kpi_name:k.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.kpiType}),n.jsxs("select",{style:{...P,...M},value:e.kpi_type||"",disabled:u,onChange:k=>A({kpi_type:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Human",children:"Human"}),n.jsx("option",{value:"Substantial",children:"Substantial"}),n.jsx("option",{value:"System",children:"System"}),n.jsx("option",{value:"Value",children:"Value"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.kpiMeasure}),n.jsx("input",{style:{...P,...M},value:e.kpi_measure||"",disabled:u,onChange:k=>A({kpi_measure:k.target.value}),placeholder:"Unit of measure"})]})]})]}),n.jsxs("div",{style:Jn,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.dateStart}),n.jsx(ve,{value:e.date_start,onChange:k=>A({date_start:k}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.dateEnd}),n.jsx(ve,{value:e.date_end,onChange:k=>A({date_end:k}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.cycleType}),n.jsxs("select",{style:{...P,...M},value:e.cycle_type||"",disabled:u,onChange:k=>A({cycle_type:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:qr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Milestone 1"}),n.jsx(ve,{value:e.long_cycle_date_1||"",onChange:k=>A({long_cycle_date_1:k}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Milestone 2"}),n.jsx(ve,{value:e.long_cycle_date_2||"",onChange:k=>A({long_cycle_date_2:k}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Milestone 3"}),n.jsx(ve,{value:e.long_cycle_date_3||"",onChange:k=>A({long_cycle_date_3:k}),disabled:u,style:{...P,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Milestone 4"}),n.jsx(ve,{value:e.long_cycle_date_4||"",onChange:k=>A({long_cycle_date_4:k}),disabled:u,style:{...P,...M}})]})]})]}),n.jsxs("div",{style:{marginTop:24,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...I,margin:0,fontSize:15},children:"Progress Indicators"}),!u&&n.jsx("button",{type:"button",onClick:$e,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Order"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Name"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Type"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Unit"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Target"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Min"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Max"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Manager"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actual Value"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Comment"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?14:15,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((k,ee)=>n.jsxs("tr",{style:{background:ee%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M,width:60},value:k.order??"",disabled:u,onChange:G=>Q(ee,{order:G.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M},value:k.name1,disabled:u,onChange:G=>Q(ee,{name1:G.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M},value:k.type,disabled:u,onChange:G=>Q(ee,{type:G.target.value}),children:[n.jsx("option",{children:"Nominal"}),n.jsx("option",{children:"Ordinal"}),n.jsx("option",{children:"Interval"}),n.jsx("option",{children:"Ratio"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M,width:70},type:"text",value:k.unit??"",disabled:u,onChange:G=>Q(ee,{unit:G.target.value}),placeholder:"e.g. °C, kg, %"})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M,minWidth:120},value:k.cycle,disabled:u,onChange:G=>Q(ee,{cycle:G.target.value}),children:[n.jsx("option",{value:"",children:"--"}),me.map(G=>n.jsx("option",{value:G.name,children:G.label},G.name)),k.cycle&&!me.some(G=>G.name===k.cycle)&&n.jsx("option",{value:k.cycle,children:k.cycle})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M,width:80},value:k.target,disabled:u,onChange:G=>Q(ee,{target:G.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M,width:80},value:k.minimum,disabled:u,onChange:G=>Q(ee,{minimum:G.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M,width:80},value:k.maximum,disabled:u,onChange:G=>Q(ee,{maximum:G.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M,minWidth:140},value:k.manager,disabled:u,onChange:G=>Q(ee,{manager:G.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Xe.map(G=>n.jsx("option",{value:G.name,children:G.label},G.name)),k.manager&&!Xe.some(G=>G.name===k.manager)&&n.jsx("option",{value:k.manager,children:k.manager})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M,width:90},type:"number",value:k.actual_value??"",disabled:u,onChange:G=>Q(ee,{actual_value:parseFloat(G.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M},value:k.cycle_status??"",disabled:u,onChange:G=>Q(ee,{cycle_status:G.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(ve,{value:k.cycle_date||"",onChange:G=>Q(ee,{cycle_date:G}),disabled:u,style:{...P,...M,width:110}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M},value:k.cycle_comment??"",disabled:u,onChange:G=>Q(ee,{cycle_comment:G.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M},value:k.status??"",disabled:u,onChange:G=>Q(ee,{status:G.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),!u&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>et(ee),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},ee))]})]})})]}),n.jsxs("div",{style:{marginTop:28,borderTop:"1px solid #e9ecef",paddingTop:20},children:[n.jsx("div",{style:{...I,fontSize:15,marginBottom:14},children:"Cycle & Assignment"}),n.jsxs("div",{style:Jn,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:k=>A({cycle:k}),items:me,placeholder:z.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.actor}),n.jsxs("select",{style:{...P,...M},value:e.actor||"",disabled:u,onChange:k=>A({actor:k.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),fe.map(k=>n.jsx("option",{value:k.name,children:k.label},k.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:z.field.costPerCycle}),n.jsx("input",{style:{...P,...M},type:"number",value:e.cost_per_cycle||"",disabled:u,onChange:k=>A({cost_per_cycle:parseFloat(k.target.value)||0}),placeholder:"0.00"})]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:I,children:z.field.escalationLevel}),n.jsx("input",{style:{...P,...M,maxWidth:120},type:"number",value:e.escalation_level||"",disabled:u,onChange:k=>A({escalation_level:parseInt(k.target.value)||0})})]})]}),n.jsxs("div",{style:{marginTop:28,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...I,margin:0,fontSize:15},children:"Cycle History"}),!u&&n.jsx("button",{type:"button",onClick:he,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actor"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Comment"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?5:6,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No cycle history"})}),(e.cycle_logs||[]).map((k,ee)=>n.jsxs("tr",{style:{background:ee%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M},value:k.cycle||"",disabled:u,onChange:G=>se(ee,{cycle:G.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),me.map(G=>n.jsx("option",{value:G.name,children:G.label},G.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(ve,{value:k.cycle_date||"",onChange:G=>se(ee,{cycle_date:G}),disabled:u,style:{...P,...M,width:130}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M},value:k.status,disabled:u,onChange:G=>se(ee,{status:G.target.value}),children:[n.jsx("option",{value:"Pass",children:"Pass"}),n.jsx("option",{value:"Fail",children:"Fail"}),n.jsx("option",{value:"Unknown",children:"Unknown"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...M},value:k.actor||"",disabled:u,onChange:G=>se(ee,{actor:G.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),fe.map(G=>n.jsx("option",{value:G.name,children:G.label},G.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...M},value:k.comment||"",disabled:u,onChange:G=>se(ee,{comment:G.target.value})})}),!u&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>X(ee),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},ee))]})]})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:16},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:z.field.auditorComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",background:"#f9f9f9"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:z.field.commentPlaceholder})]})]})}const L0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function D0({user:e,profileUser:t,darkMode:s,canModify:l,onBack:r,organizations:i=[],managements:a=[],departments:c=[],branches:d=[]}){const h=t||{},j=!!l&&e.role==="Admin",[p,u]=w.useState({first_name:h.first_name||"",middle_name:h.middle_name||"",last_name:h.last_name||"",mobile_no:h.mobile_no||"",custom_organization:h.custom_organization||"",custom_management:h.custom_management||"",custom_department:h.custom_department||"",custom_branch:h.custom_branch||"",custom_number:h.custom_number||"",custom_category:h.custom_category||""}),[y,v]=w.useState(""),[f,S]=w.useState(!1),[g,x]=w.useState({new:"",confirm:""}),[o,m]=w.useState(""),_=h.email||h.name||"",T=[p.first_name,p.middle_name,p.last_name].filter(Boolean).join(" ")||h.full_name||"",E=h.username||h.name||"",C=p.custom_category||"",R=h.enabled===0?"Inactive":"Active",B=L0[e.role]||"#6b7280",D=s,L=D?"#0f172a":"#f0f2f5",z=D?"#1e293b":"white",A=D?"#2d3748":"#e5e7eb",M=D?"#e2e8f0":"#1a2332",pe=D?"#94a3b8":"#6b7280",re=D?"#374151":"white",O=D?"#2d3748":"#f9fafb",H={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${A}`,fontSize:13,background:re,color:M,fontFamily:"inherit",outline:"none"},Y={...H,background:O,color:pe},V={...H,cursor:"pointer"},Z={fontSize:12,fontWeight:600,color:pe,marginBottom:5,display:"block"},me={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},fe={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},Xe=async()=>{if(l){v("saving");try{await Wi("User",h.name,{first_name:p.first_name,middle_name:p.middle_name,last_name:p.last_name,mobile_no:p.mobile_no,custom_organization:p.custom_organization,custom_management:p.custom_management,custom_department:p.custom_department,custom_branch:p.custom_branch,custom_number:p.custom_number,custom_category:p.custom_category}),v("saved"),setTimeout(()=>v(""),2e3)}catch{v("error"),setTimeout(()=>v(""),3e3)}}},se=async()=>{if(!g.new){m("Enter a new password");return}if(g.new!==g.confirm){m("Passwords do not match");return}m("saving");try{await th(h.name,g.new),m("done"),x({new:"",confirm:""}),setTimeout(()=>{m(""),S(!1)},2e3)}catch{m("error")}},he=({title:X,icon:Q,children:$e})=>n.jsxs("div",{style:{background:z,borderRadius:12,padding:22,border:`1px solid ${A}`,boxShadow:`0 1px 4px rgba(0,0,0,${D?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${A}`},children:[Q,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:M},children:X})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:$e})]});return n.jsxs("div",{style:{background:L,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:z,borderBottom:`1px solid ${A}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[n.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:M,fontFamily:"inherit"},children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),l&&n.jsxs("button",{onClick:Xe,style:{display:"flex",alignItems:"center",gap:8,background:y==="saved"?"#16a34a":y==="error"?"#dc2626":"#16a34a",color:"white",border:"none",borderRadius:8,padding:"9px 22px",fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),n.jsx("polyline",{points:"17,21 17,13 7,13 7,21"}),n.jsx("polyline",{points:"7,3 7,8 15,8"})]}),y==="saving"?"Saving…":y==="saved"?"Saved!":y==="error"?"Error":"Save Changes"]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:22,padding:"0 28px"},children:[n.jsxs("div",{style:{borderRadius:14,overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.12)",alignSelf:"start"},children:[n.jsxs("div",{style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",padding:"32px 20px 28px",display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[n.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:n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"rgba(255,255,255,0.9)",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]})}),n.jsx("div",{style:{fontSize:17,fontWeight:700,color:"white",textAlign:"center",lineHeight:1.3},children:T||_}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:_})]}),n.jsx("div",{style:{background:z},children:[{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:B,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),label:"Username",value:E},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:B,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),n.jsx("circle",{cx:"9",cy:"7",r:"4"}),n.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),n.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:C||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:R==="Active"?"#16a34a":"#dc2626",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),label:"Status",value:R,valueColor:R==="Active"?"#16a34a":"#dc2626"},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:B,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:_},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:B,strokeWidth:"2",strokeLinecap:"round",children:n.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:p.mobile_no||"—"}].map(({icon:X,label:Q,value:$e,valueColor:et})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${A}`},children:[n.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:X}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:11,color:pe,marginBottom:1},children:Q}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:et||M,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$e})]})]},Q))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(he,{title:"Basic Information",icon:n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]}),children:[n.jsxs("div",{style:me,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Email ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]})}),n.jsx("input",{style:{...Y,paddingLeft:32},value:_,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:Y,value:T,readOnly:!0})]})]}),n.jsxs("div",{style:fe,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:l?H:Y,value:p.first_name,readOnly:!l,onChange:X=>u(Q=>({...Q,first_name:X.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"Middle Name"}),n.jsx("input",{style:l?H:Y,value:p.middle_name,readOnly:!l,onChange:X=>u(Q=>({...Q,middle_name:X.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"Last Name"}),n.jsx("input",{style:l?H:Y,value:p.last_name,readOnly:!l,onChange:X=>u(Q=>({...Q,last_name:X.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:me,children:[n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"Phone Number"}),n.jsx("input",{style:l?H:Y,value:p.mobile_no,readOnly:!l,onChange:X=>u(Q=>({...Q,mobile_no:X.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...Y,paddingRight:44},value:p.custom_number||h.name||"",readOnly:!0}),n.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:n.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"white",children:[n.jsx("circle",{cx:"5",cy:"12",r:"2"}),n.jsx("circle",{cx:"12",cy:"12",r:"2"}),n.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Category ",!j&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?n.jsxs("select",{style:V,value:p.custom_category,onChange:X=>u(Q=>({...Q,custom_category:X.target.value})),children:[n.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(X=>n.jsx("option",{value:X,children:X},X))]}):n.jsx("input",{style:Y,value:C||"—",readOnly:!0})]})]}),n.jsxs(he,{title:"Organization Information",icon:n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#8b5cf6",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),n.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),children:[n.jsxs("div",{style:me,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Organization ",!j&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?n.jsxs("select",{style:V,value:p.custom_organization,onChange:X=>u(Q=>({...Q,custom_organization:X.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),ge(i,p.custom_organization).map(X=>n.jsx("option",{value:X.name,children:X.organization_name||X.name},X.name))]}):n.jsx("input",{style:Y,value:p.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Management ",!j&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?n.jsxs("select",{style:V,value:p.custom_management,onChange:X=>u(Q=>({...Q,custom_management:X.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),ge(a,p.custom_management).map(X=>n.jsx("option",{value:X.name,children:X.name1||X.name},X.name))]}):n.jsx("input",{style:Y,value:p.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:me,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Department ",!j&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?n.jsxs("select",{style:V,value:p.custom_department,onChange:X=>u(Q=>({...Q,custom_department:X.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),ge(c,p.custom_department).map(X=>n.jsx("option",{value:X.name,children:X.department_name||X.name},X.name))]}):n.jsx("input",{style:Y,value:p.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Branch ",!j&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),j?n.jsxs("select",{style:V,value:p.custom_branch,onChange:X=>u(Q=>({...Q,custom_branch:X.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),ge(d,p.custom_branch).map(X=>n.jsx("option",{value:X.name,children:X.branch||X.name},X.name))]}):n.jsx("input",{style:Y,value:p.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:z,borderRadius:12,padding:22,border:`1px solid ${A}`,boxShadow:`0 1px 4px rgba(0,0,0,${D?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("span",{style:{fontSize:14,fontWeight:700,color:M},children:"Change Password"})]}),l&&n.jsx("button",{onClick:()=>{S(X=>!X),m("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:f?"Cancel":"Change Password"})]}),f&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:fe,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:H,value:g.new,onChange:X=>x(Q=>({...Q,new:X.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:H,value:g.confirm,onChange:X=>x(Q=>({...Q,confirm:X.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:se,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:o==="saving"?"Saving…":"Update Password"})})]}),o&&o!=="saving"&&n.jsx("div",{style:{fontSize:13,color:o==="done"?"#16a34a":"#dc2626",fontWeight:500},children:o==="done"?"Password updated successfully":o==="error"?"Failed to update password":o})]})]})]})]})]})}function _e({label:e,val:t,color:s}){return n.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:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s},children:t}),n.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const lh={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={...lh,cursor:"pointer"};function ot({filters:e,defaultOpen:t=!1}){const[s,l]=w.useState(t);return n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.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:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:s?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),s&&n.jsx("div",{style:{padding:"18px 20px"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((r,i)=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:r.label}),r.type==="search"?n.jsx("input",{style:lh,placeholder:r.placeholder,value:r.value,onChange:a=>r.onChange(a.target.value)}):n.jsx("select",{style:N0,value:r.value,onChange:a=>r.onChange(a.target.value),children:r.options.map(a=>n.jsx("option",{value:a.value,children:a.label},a.value))})]},i))})})]})}function W0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function B0({organizations:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),[j,p]=w.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},y=w.useMemo(()=>e.filter(g=>{const x=[g.organization_name,g.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!x.includes(a.toLowerCase())||d!=="all"&&g.type!==d||j!=="all"&&(g.is_active?"Active":"Inactive")!==j)}),[e,a,d,j]),[v,f]=w.useState(1);w.useEffect(()=>{f(1)},[a,d,j]);const S=y.slice((v-1)*le,v*le);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:y.length,color:"#1a2332"}),n.jsx(_e,{label:"Active",val:y.filter(g=>g.is_active).length,color:N.green}),n.jsx(_e,{label:"Government",val:y.filter(g=>g.type==="Government").length,color:N.blue}),n.jsx(_e,{label:"Private",val:y.filter(g=>g.type==="Private").length,color:N.orange})]}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:j,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:u,children:i.col.name}),n.jsx("th",{style:u,children:i.col.type}),n.jsx("th",{style:u,children:i.col.city}),n.jsx("th",{style:u,children:i.field.creationDate}),n.jsx("th",{style:u,children:i.col.status}),n.jsx("th",{style:u,children:i.col.actions})]})}),n.jsx("tbody",{children:y.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((g,x)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(g),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:W0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:jt(g.is_active?i.field.statusActive:i.field.statusInactive,g.is_active?N.green:N.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(g),onEdit:t&&l?()=>l(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(We,{page:v,total:y.length,onPageChange:f})]})}const rn=e=>({background:e?"#f9f9f9":void 0});function $0({orgForm:e,setOrgForm:t,groupCompanies:s=[],formStatus:l,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,user:f}){const S=ne(),g=e.name?r&&e.organization_name||S.formTitle.editOrg:S.formTitle.newOrg,x=s.map(o=>({name:o.name,label:o.company_name?`${o.company_name} (${o.name})`:o.name}));return n.jsxs(Be,{title:g,activePage:"organizations",user:f,formStatus:l,buttonText:S.saveOrg,buttonColor:N.accent,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.orgName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...P,...rn(r||!!e.name)},value:e.organization_name,disabled:r||!!e.name,required:!0,onChange:o=>t({...e,organization_name:o.target.value})})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.orgAcronym," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...P,...rn(r||!!e.name)},value:e.acronym||"",disabled:r||!!e.name,required:!0,onChange:o=>t({...e,acronym:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Group Company (Tenant)"}),n.jsx(ue,{value:e.group_company||"",onChange:o=>t({...e,group_company:o}),items:x,placeholder:"Select Group Company",disabled:r||!!f.custom_group_company})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.organizationType}),n.jsxs("select",{style:{...P,...rn(r)},value:e.type,disabled:r,onChange:o=>t({...e,type:o.target.value}),children:[n.jsx("option",{children:"Government"}),n.jsx("option",{children:"Private"}),n.jsx("option",{children:"Non-Profit"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.orgCity}),n.jsx("input",{type:"text",style:{...P,...rn(r)},value:e.city,disabled:r,onChange:o=>t({...e,city:o.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.contactEmail}),n.jsx("input",{type:"email",style:{...P,...rn(r)},value:e.contact_email,disabled:r,onChange:o=>t({...e,contact_email:o.target.value})})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>t({...e,creation_date:o}),disabled:r,style:{...P,...rn(r)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.status}),n.jsxs("select",{style:{...P,...rn(r)},value:e.is_active?"Active":"Inactive",disabled:r,onChange:o=>t({...e,is_active:o.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...rn(r)},value:e.incident_triage_window_days??3,disabled:r,onChange:o=>t({...e,incident_triage_window_days:parseInt(o.target.value)||3})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...rn(r)},value:e.incident_resolution_window_days??5,disabled:r,onChange:o=>t({...e,incident_resolution_window_days:parseInt(o.target.value)||5})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})]})}function U0({groupCompanies:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=[f.company_name,f.acronym,f.code,f.owner_user].filter(Boolean).join(" ").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total Group Cos",val:p.length,color:"#1a2332"}),n.jsx(_e,{label:"Active",val:p.filter(f=>(f.status||"Active")==="Active").length,color:N.green}),n.jsx(_e,{label:"Inactive",val:p.filter(f=>f.status==="Inactive").length,color:N.orange})]}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Inactive",label:"Inactive"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:"#fafafa"},children:[n.jsx("th",{style:j,children:"Company Name"}),n.jsx("th",{style:j,children:"Code / Acronym"}),n.jsx("th",{style:j,children:"Group Co Owner"}),n.jsx("th",{style:j,children:"Status"}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsxs("tbody",{children:[v.map((f,S)=>{const g=f.custom_is_deleted===1;return n.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:g?"#fef2f2":S%2===0?"white":"#fafafa"},children:[n.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[f.company_name,g&&n.jsx("span",{style:{marginLeft:8},children:jt(i.deletedBadge,"#ef4444")})]}),n.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:[f.code,f.acronym].filter(Boolean).join(" / ")||"—"}),n.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:f.owner_user||"—"}),n.jsx("td",{style:{padding:"12px 14px"},children:jt(f.status||"Active",(f.status||"Active")==="Active"?N.green:N.orange)}),n.jsx("td",{style:{padding:"12px 14px"},children:n.jsx(Ye,{onView:s?()=>s(f):void 0,onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name)}),p.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:24,textAlign:"center",color:"#aaa"},children:"No Group Companies found"})})]})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}const _u={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function F0({form:e,setForm:t,users:s=[],formStatus:l,viewMode:r,onEdit:i,onRestore:a,darkMode:c,notifCount:d,onToggleDark:h,onCountChange:j,onViewProfile:p,onSubmit:u,onBack:y,onNavigate:v,onLogout:f,user:S}){const g=_=>t({...e,..._}),x=r?{background:"#f9f9f9"}:{},o=e.name?r?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",m=s.map(_=>({name:_.name,label:_.full_name?`${_.full_name} (${_.name})`:_.name}));return n.jsxs(Be,{title:o,activePage:"group-companies",user:S,formStatus:l,buttonText:"Save Group Company",buttonColor:N.purple,viewMode:r,onEdit:i,darkMode:c,notifCount:d,onToggleDark:h,onCountChange:j,onViewProfile:p,onSubmit:u,onBack:y,onNavigate:v,onLogout:f,children:[e.custom_is_deleted===1&&n.jsx(jr,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:a?()=>a(e.name):void 0}),n.jsxs("div",{style:_u,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:["Company Name ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.company_name||"",disabled:r||!!e.name,onChange:_=>g({company_name:_.target.value}),placeholder:"e.g. Company A Group"})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Company Code"}),n.jsx("input",{style:{...P,...x},value:e.code||"",disabled:r,onChange:_=>g({code:_.target.value}),placeholder:"e.g. CO-A"})]})]}),n.jsxs("div",{style:{..._u,marginTop:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Acronym"}),n.jsx("input",{style:{...P,...x},value:e.acronym||"",disabled:r,onChange:_=>g({acronym:_.target.value}),placeholder:"e.g. CAG"})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Status"}),n.jsxs("select",{style:{...P,...x},value:e.status||"Active",disabled:r,onChange:_=>g({status:_.target.value}),children:[n.jsx("option",{value:"Active",children:"Active"}),n.jsx("option",{value:"Inactive",children:"Inactive"})]})]})]}),n.jsxs("div",{style:{marginTop:16},children:[n.jsx("label",{style:I,children:"Group Co Owner / Admin User"}),n.jsx(ue,{value:e.owner_user||"",onChange:_=>g({owner_user:_}),items:m,placeholder:"Select owner user",disabled:r})]}),n.jsxs("div",{style:{marginTop:16},children:[n.jsx("label",{style:I,children:"Notes"}),n.jsx("textarea",{style:{...P,...x,height:80,resize:"vertical"},value:e.notes||"",disabled:r,onChange:_=>g({notes:_.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})}function M0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function H0({managements:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.blue})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:M0(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function G0({form:e,setForm:t,organizations:s,formStatus:l,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,user:f}){const S=ne(),g=m=>t(_=>({..._,...m})),x=r?{background:"#f9f9f9"}:{},o=e.name?r?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return n.jsxs(Be,{title:o,activePage:"managements",user:f,formStatus:l,buttonText:S.saveMgmt,buttonColor:N.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:m=>g({organization:m}),organizations:s,disabled:r||!!f.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.name1,disabled:r||!!e.name,onChange:m=>g({name1:m.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:m=>g({creation_date:m}),disabled:r,style:{...P,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.status}),n.jsxs("select",{style:{...P,...x},value:e.status||"Active",disabled:r,onChange:m=>g({status:m.target.value}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})]})}function K0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function Q0({departments:e,managements:t,canModify:s,onView:l,onEdit:r,onDelete:i}){const a=ne(),[c,d]=w.useState(""),[h,j]=w.useState(""),[p,u]=w.useState("all"),y=o=>{var m;return((m=t.find(_=>_.name===o))==null?void 0:m.name1)||o||"—"},v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(o=>{const m=(o.department_name||o.name||"").toLowerCase();return!(c&&!m.includes(c.toLowerCase())||h&&o.custom_management!==h||p!=="all"&&(o.custom_status||"Active")!==p)}),[e,c,h,p]),[S,g]=w.useState(1);w.useEffect(()=>{g(1)},[c,h,p]);const x=f.slice((S-1)*le,S*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:N.teal})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:c,onChange:d,placeholder:"Search by name…"},{type:"select",label:a.col.management,value:h,onChange:j,options:[{value:"",label:"All Managements"},...t.map(o=>({value:o.name,label:o.name1||o.name}))]},{type:"select",label:"Status",value:p,onChange:u,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.col.management}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):x.map((o,m)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(o),style:{borderTop:"1px solid #f0f0f0",background:m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.department_name||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:y(o.custom_management)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:K0(o.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:o.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Ye,{onView:()=>l==null?void 0:l(o),onEdit:s&&r?()=>r(o):void 0,onDelete:s&&i?()=>i(o.name):void 0})})]},o.name))})]})}),n.jsx(We,{page:S,total:f.length,onPageChange:g})]})}const Y0={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function X0({form:e,setForm:t,organizations:s,managements:l,formStatus:r,viewMode:i,onEdit:a,darkMode:c,notifCount:d,onToggleDark:h,onCountChange:j,onViewProfile:p,onSubmit:u,onBack:y,onNavigate:v,onLogout:f,user:S}){const g=ne(),x=T=>t(E=>({...E,...T})),o=i?{background:"#f9f9f9"}:{},m=e.name?i?`${g.formTitle.editDept}: ${e.department_name||e.name}`:g.formTitle.editDept:g.formTitle.newDept,_=ge(l,e.custom_management).map(T=>({name:T.name,label:T.name1||T.name}));return n.jsxs(Be,{title:m,activePage:"departments",user:S,formStatus:r,buttonText:g.saveDept,buttonColor:N.teal,viewMode:i,onEdit:a,darkMode:c,notifCount:d,onToggleDark:h,onCountChange:j,onViewProfile:p,onSubmit:u,onBack:y,onNavigate:v,onLogout:f,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[g.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.custom_organization,onChange:T=>x({custom_organization:T}),organizations:s,disabled:i||!!S.custom_organization})]}),n.jsxs("div",{style:Y0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[g.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.department_name,disabled:i||!!e.name,onChange:T=>x({department_name:T.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:g.field.management}),n.jsx(ue,{value:e.custom_management,onChange:T=>x({custom_management:T}),items:_,placeholder:g.field.select,disabled:i})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:g.field.creationDate}),n.jsx(ve,{value:e.custom_creation_date||"",onChange:T=>x({custom_creation_date:T}),disabled:i,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.custom_status||"Active",disabled:i,onChange:T=>x({custom_status:T.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})]})}function q0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function J0({branches:e,managements:t,departments:s,canModify:l,onView:r,onEdit:i,onDelete:a}){const c=ne(),[d,h]=w.useState(""),[j,p]=w.useState(""),[u,y]=w.useState(""),[v,f]=w.useState("all"),S=E=>{var C;return((C=t.find(R=>R.name===E))==null?void 0:C.name1)||E||"—"},g=E=>{var C;return((C=s.find(R=>R.name===E))==null?void 0:C.department_name)||E||"—"},x={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=w.useMemo(()=>e.filter(E=>{const C=(E.branch||E.name||"").toLowerCase();return!(d&&!C.includes(d.toLowerCase())||j&&E.management!==j||u&&E.department!==u||v!=="all"&&(E.custom_status||"Active")!==v)}),[e,d,j,u,v]),[m,_]=w.useState(1);w.useEffect(()=>{_(1)},[d,j,u,v]);const T=o.slice((m-1)*le,m*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:o.length,color:N.purple})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:d,onChange:h,placeholder:"Search by name…"},{type:"select",label:c.col.management,value:j,onChange:p,options:[{value:"",label:"All Managements"},...t.map(E=>({value:E.name,label:E.name1||E.name}))]},{type:"select",label:c.col.department,value:u,onChange:y,options:[{value:"",label:"All Departments"},...s.map(E=>({value:E.name,label:E.department_name||E.name}))]},{type:"select",label:"Status",value:v,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:c.field.statusActive},{value:"Inactive",label:c.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:x,children:c.col.branch}),n.jsx("th",{style:x,children:c.col.management}),n.jsx("th",{style:x,children:c.col.department}),n.jsx("th",{style:x,children:c.field.creationDate}),n.jsx("th",{style:x,children:c.field.status}),n.jsx("th",{style:x,children:c.col.actions})]})}),n.jsx("tbody",{children:o.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noData})}):T.map((E,C)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(E),style:{borderTop:"1px solid #f0f0f0",background:C%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:E.branch||E.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:S(E.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:g(E.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:q0(E.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:E.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:E.custom_status==="Inactive"?c.field.statusInactive:c.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:R=>R.stopPropagation(),children:n.jsx(Ye,{onView:()=>r==null?void 0:r(E),onEdit:l&&i?()=>i(E):void 0,onDelete:l&&a?()=>a(E.name):void 0})})]},E.name))})]})}),n.jsx(We,{page:m,total:o.length,onPageChange:_})]})}const Z0={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function V0({form:e,setForm:t,organizations:s,managements:l,departments:r,formStatus:i,viewMode:a,onEdit:c,darkMode:d,notifCount:h,onToggleDark:j,onCountChange:p,onViewProfile:u,onSubmit:y,onBack:v,onNavigate:f,onLogout:S,user:g}){const x=ne(),o=C=>t(R=>({...R,...C})),m=a?{background:"#f9f9f9"}:{},_=e.name?a?`${x.formTitle.editBranch}: ${e.branch||e.name}`:x.formTitle.editBranch:x.formTitle.newBranch,T=ge(l,e.management).map(C=>({name:C.name,label:C.name1||C.name})),E=ge(r,e.department).map(C=>({name:C.name,label:C.department_name||C.name}));return n.jsxs(Be,{title:_,activePage:"branches",user:g,formStatus:i,buttonText:x.saveBranch,buttonColor:N.purple,viewMode:a,onEdit:c,darkMode:d,notifCount:h,onToggleDark:j,onCountChange:p,onViewProfile:u,onSubmit:y,onBack:v,onNavigate:f,onLogout:S,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[x.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:C=>o({organization:C}),organizations:s,disabled:a||!!g.custom_organization})]}),n.jsxs("div",{style:Z0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[x.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...m},value:e.branch,disabled:a||!!e.name,onChange:C=>o({branch:C.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:x.field.management}),n.jsx(ue,{value:e.management,onChange:C=>o({management:C}),items:T,placeholder:x.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:x.field.department}),n.jsx(ue,{value:e.department,onChange:C=>o({department:C}),items:E,placeholder:x.field.select,disabled:a})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:x.field.creationDate}),n.jsx(ve,{value:e.custom_creation_date||"",onChange:C=>o({custom_creation_date:C}),disabled:a,style:{...P,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:x.field.status}),n.jsxs("select",{style:{...P,...m},value:e.custom_status||"Active",disabled:a,onChange:C=>o({custom_status:C.target.value}),children:[n.jsx("option",{value:"Active",children:x.field.statusActive}),n.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})]})}function e1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function t1({incidentTypes:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.red})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:e1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function n1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(Be,{title:x,activePage:"incident-types",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.red,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function s1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function l1({ideaTypes:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.teal})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:s1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function r1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(Be,{title:x,activePage:"idea-types",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.teal,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function i1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function a1({orderTypes:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.purple})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:i1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function o1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(Be,{title:x,activePage:"order-types",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.purple,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function d1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function c1({processTypes:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.blue})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:d1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function u1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(Be,{title:x,activePage:"process-types",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.blue,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function p1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function f1({incidentStatuses:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.red})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.notifyManager}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:p1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function h1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(Be,{title:x,activePage:"incident-statuses",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.red,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:hl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function g1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function x1({ideaStatuses:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.teal})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.notifyManager}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:g1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function m1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(Be,{title:x,activePage:"idea-statuses",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.teal,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:hl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function y1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function v1({orderStatuses:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.purple})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.notifyManager}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:y1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function j1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(Be,{title:x,activePage:"order-statuses",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.purple,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:hl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function b1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function S1({processStatuses:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=w.useMemo(()=>e.filter(f=>{const S=(f.name1||f.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(f.status||"Active")!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:p.length,color:N.blue})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:i.col.name}),n.jsx("th",{style:j,children:i.field.notifyManager}),n.jsx("th",{style:j,children:i.field.creationDate}),n.jsx("th",{style:j,children:i.field.status}),n.jsx("th",{style:j,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.name1||f.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:b1(f.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:f.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:f.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}function w1({form:e,setForm:t,formStatus:s,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,user:v}){const f=ne(),S=o=>t(m=>({...m,...o})),g=l?{background:"#f9f9f9"}:{},x=e.name?l?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(Be,{title:x,activePage:"process-statuses",user:v,formStatus:s,buttonText:f.saveName,buttonColor:N.blue,viewMode:l,onEdit:r,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:h,onSubmit:j,onBack:p,onNavigate:u,onLogout:y,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:l||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:hl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.creationDate}),n.jsx(ve,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:l,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:f.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:l,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}const _1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function k1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function C1({users:e,canModify:t,onView:s,onEdit:l,onDisable:r}){const i=ne(),[a,c]=w.useState(!1),[d,h]=w.useState(""),[j,p]=w.useState(""),[u,y]=w.useState(""),[v,f]=w.useState("active"),[S,g]=w.useState(1),[x,o]=w.useState(null),[m,_]=w.useState(""),[T,E]=w.useState("idle"),[C,R]=w.useState(null),B=async()=>{if(!(!x||!m.trim())){E("loading");try{await th(x.name,m.trim()),E("success"),setTimeout(()=>{o(null),_(""),E("idle")},1200)}catch{E("error")}}},D=async O=>{if(window.confirm(i.users.disableConfirm)){R(O);try{await(r==null?void 0:r(O))}finally{R(null)}}},L=e.filter(O=>{if(v==="active"&&(O.enabled===0||O.enabled==="0")||v==="inactive"&&O.enabled!==0&&O.enabled!=="0")return!1;const H=O.custom_category||"";if(u&&H!==u)return!1;const Y=O.custom_organization||"";if(j&&!Y.toLowerCase().includes(j.toLowerCase()))return!1;if(d){const V=d.toLowerCase();if(![O.full_name,O.email,O.name,O.username,O.mobile_no].join(" ").toLowerCase().includes(V))return!1}return!0}),z=[...new Set(e.map(O=>O.custom_organization).filter(Boolean))],A=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];w.useEffect(()=>{g(1)},[d,j,u,v]);const M=L.slice((S-1)*le,S*le),pe={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},re={...pe,cursor:"pointer"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:["Total: ",L.length," users"]}),n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>c(O=>!O),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:a?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),a&&n.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:14},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),n.jsx("input",{style:pe,placeholder:"Name, email, username…",value:d,onChange:O=>h(O.target.value)})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),n.jsxs("select",{style:re,value:j,onChange:O=>p(O.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),z.map(O=>n.jsx("option",{value:O,children:O},O))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),n.jsxs("select",{style:re,value:u,onChange:O=>y(O.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),A.map(O=>n.jsx("option",{value:O,children:O},O))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),n.jsxs("select",{style:re,value:v,onChange:O=>f(O.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:O,w:H})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:H,letterSpacing:.3,textTransform:"uppercase"},children:O},O))})}),n.jsx("tbody",{children:L.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:13,style:{padding:"48px 20px",textAlign:"center",color:"#aaa",fontSize:14},children:"No users found"})}):M.map((O,H)=>{const Y=O.custom_category||"",V=_1[Y]||"#6b7280";return n.jsxs("tr",{onClick:()=>s==null?void 0:s(O),style:{borderBottom:"1px solid #f3f4f6",background:H%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:Z=>Z.currentTarget.style.background="#f0f7ff",onMouseLeave:Z=>Z.currentTarget.style.background=H%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:Y?n.jsx("span",{style:{background:V+"18",color:V,border:`1px solid ${V}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:Y}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:O.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:O.full_name||O.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:O.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:O.email||O.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:O.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:O.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:O.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:O.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:O.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:k1(O.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:O.enabled?"#16a34a":"#dc2626",fontWeight:600},children:O.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:Z=>Z.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:Z=>{Z.stopPropagation(),s==null||s(O)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t&&l&&n.jsx("button",{onClick:Z=>{Z.stopPropagation(),l(O)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t&&n.jsx("button",{onClick:Z=>{Z.stopPropagation(),o({name:O.name,email:O.email||O.name}),_(""),E("idle")},title:"Set Password",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fef3c7",color:"#d97706"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),t&&n.jsx("button",{onClick:Z=>{Z.stopPropagation(),D(O.name)},disabled:C===O.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:C===O.name?.5:1},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},O.name)})})]})}),n.jsx(We,{page:S,total:L.length,onPageChange:g}),x&&n.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[n.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:i.users.setPassword}),n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",n.jsx("strong",{children:x.email})]}),n.jsx("input",{type:"password",value:m,onChange:O=>_(O.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:O=>O.key==="Enter"&&B(),autoFocus:!0}),T==="success"&&n.jsx("div",{style:{color:"#166534",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Password updated successfully"}),T==="error"&&n.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"}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:B,disabled:T==="loading"||!m.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:m.trim()?1:.5},children:T==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),_(""),E("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}const Jr={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function z1({form:e,setForm:t,groupCompanies:s=[],organizations:l,managements:r,departments:i,branches:a,formStatus:c,viewMode:d,onEdit:h,darkMode:j,notifCount:p,onToggleDark:u,onCountChange:y,onViewProfile:v,isSelfProfile:f,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,user:m}){const _=ne(),T=A=>t(M=>({...M,...A})),E=d?{background:"#f9f9f9"}:{},C=!e.name,R=f?"My Profile":C?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,B=s.map(A=>({name:A.name,label:A.company_name?`${A.company_name} (${A.name})`:A.name})),D=ge(r,e.custom_management).map(A=>({name:A.name,label:A.name1||A.name})),L=ge(i,e.custom_department).map(A=>({name:A.name,label:A.department_name||A.name})),z=ge(a,e.custom_branch).map(A=>({name:A.name,label:A.branch||A.name}));return n.jsxs(Be,{title:R,activePage:"users",user:m,formStatus:c,buttonText:_.saveUser,buttonColor:N.blue,viewMode:d,onEdit:h,darkMode:j,notifCount:p,onToggleDark:u,onCountChange:y,onViewProfile:v,hideSettings:f,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:"Group Company (Tenant)"}),n.jsx(ue,{value:e.custom_group_company||"",onChange:A=>T({custom_group_company:A}),items:B,placeholder:"-- Select Group Company --",disabled:d||!!m.custom_group_company})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.organization}),n.jsx(Nt,{value:e.custom_organization,onChange:A=>T({custom_organization:A}),organizations:l,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.management}),n.jsx(ue,{value:e.custom_management,onChange:A=>T({custom_management:A}),items:D,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:Jr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.department}),n.jsx(ue,{value:e.custom_department,onChange:A=>T({custom_department:A}),items:L,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.branch}),n.jsx(ue,{value:e.custom_branch,onChange:A=>T({custom_branch:A}),items:z,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:Jr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.number}),n.jsx("input",{style:{...P,...E},value:e.custom_number,disabled:d,onChange:A=>T({custom_number:A.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[_.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...E},value:e.first_name,disabled:d,onChange:A=>T({first_name:A.target.value}),placeholder:"Full name",required:!0})]})]}),n.jsxs("div",{style:Jr,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.username}),n.jsx("input",{style:{...P,...E},value:e.username,disabled:d,onChange:A=>T({username:A.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.phoneNumber}),n.jsx("input",{style:{...P,...E},value:e.mobile_no,disabled:d,onChange:A=>T({mobile_no:A.target.value}),placeholder:"Phone number"})]})]}),n.jsxs("div",{style:Jr,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[_.field.emailAddress," ",C&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...d||!C?{background:"#f9f9f9"}:{}},value:e.email,disabled:d||!C,onChange:A=>T({email:A.target.value}),placeholder:"user@example.com",type:"email",required:C})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:_.field.category}),n.jsxs("select",{style:{...P,...E},value:e.custom_category,disabled:d,onChange:A=>T({custom_category:A.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{children:"Admin"}),n.jsx("option",{children:"Chairman"}),n.jsx("option",{children:"Auditor"}),n.jsx("option",{children:"X-Auditor"}),n.jsx("option",{children:"Manager"}),n.jsx("option",{children:"Employee"})]})]})]})]})}const ku={Active:N.green,Closed:N.gray};function T1({cycles:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState(""),[j,p]=w.useState("all"),u=w.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),y=w.useMemo(()=>e.filter(o=>{const m=(o.name1||o.name||"").toLowerCase();return!(a&&!m.includes(a.toLowerCase())||d&&o.organization!==d||j!=="all"&&o.status!==j)}),[e,a,d,j]),[v,f]=w.useState(1);w.useEffect(()=>{f(1)},[a,d,j]);const S=y.slice((v-1)*le,v*le),g=y.filter(o=>o.status==="Active").length,x=y.filter(o=>o.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:y.length,color:N.teal}),n.jsx(_e,{label:"Active",val:g,color:N.green}),n.jsx(_e,{label:"Closed",val:x,color:N.gray})]}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:d,onChange:h,options:[{value:"",label:"All Organizations"},...u.map(o=>({value:o,label:o}))]},{type:"select",label:"Status",value:j,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.name}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.frequency}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.startDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.endDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:y.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((o,m)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:ku[o.status]+"22",color:ku[o.status]||"#666"},children:o.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(o),onEdit:t&&l?()=>l(o):void 0,onDelete:t&&r?()=>r(o.name):void 0})})]},o.name))})]})}),n.jsx(We,{page:v,total:y.length,onPageChange:f})]})}const Ua={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},I1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],P1=["Active","Closed"];function E1({form:e,setForm:t,organizations:s,formStatus:l,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,user:f}){const S=ne(),g=m=>t(_=>({..._,...m})),x=r?{background:"#f9f9f9"}:{},o=e.name?r?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return n.jsxs(Be,{title:o,activePage:"cycles",user:f,formStatus:l,buttonText:S.saveCycle,buttonColor:N.teal,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,children:[n.jsxs("div",{style:Ua,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.name1||"",disabled:r||!!e.name,onChange:m=>g({name1:m.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:m=>g({organization:m}),organizations:s,disabled:r||!!f.custom_organization})]})]}),n.jsxs("div",{style:Ua,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.col.frequency}),n.jsx(ue,{value:e.frequency,onChange:m=>g({frequency:m}),items:I1.map(m=>({name:m,label:m})),placeholder:"-- Select Frequency --",disabled:r})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.status}),n.jsx(ue,{value:e.status,onChange:m=>g({status:m}),items:P1.map(m=>({name:m,label:m})),placeholder:"-- Select Status --",disabled:r})]})]}),n.jsxs("div",{style:Ua,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.dateStart}),n.jsx(ve,{value:e.start_date||"",onChange:m=>g({start_date:m}),disabled:r,style:{...P,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.dateEnd}),n.jsx(ve,{value:e.end_date||"",onChange:m=>g({end_date:m}),disabled:r,style:{...P,...x}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...x,maxWidth:160},value:e.update_window_days??2,disabled:r,onChange:m=>g({update_window_days:parseInt(m.target.value)||2})}),n.jsx("span",{style:{fontSize:12,color:"#888",marginLeft:8},children:"Grace period after cycle ends before Unknown is auto-assigned"})]})]})}function A1({kpiInputs:e,canModify:t,onView:s,onEdit:l,onDelete:r}){const i=ne(),[a,c]=w.useState(""),[d,h]=w.useState(""),j=w.useMemo(()=>[...new Set(e.map(f=>f.organization).filter(Boolean))],[e]),p=w.useMemo(()=>e.filter(f=>{const S=[f.organization,f.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d&&f.organization!==d)}),[e,a,d]),[u,y]=w.useState(1);w.useEffect(()=>{y(1)},[a,d]);const v=p.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total Records",val:p.length,color:N.blue})}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:d,onChange:h,options:[{value:"",label:"All Organizations"},...j.map(f=>({value:f,label:f}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):v.map((f,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(f),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:f.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.period||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.revenue_growth!=null?`${f.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.net_profit!=null?f.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:f.customer_satisfaction!=null?f.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(Ye,{onView:()=>s==null?void 0:s(f),onEdit:t&&l?()=>l(f):void 0,onDelete:t&&r?()=>r(f.name):void 0})})]},f.name))})]})}),n.jsx(We,{page:u,total:p.length,onPageChange:y})]})}const Cu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},zu={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function R1({form:e,setForm:t,organizations:s,formStatus:l,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,user:f}){const S=ne(),g=_=>t(T=>({...T,..._})),x=r?{background:"#f9f9f9"}:{},o=_=>T=>g({[_]:parseFloat(T.target.value)||0}),m=e.name?r?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return n.jsxs(Be,{title:m,activePage:"kpi-input",user:f,formStatus:l,buttonText:S.saveKpi,buttonColor:N.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:h,onViewProfile:j,onSubmit:p,onBack:u,onNavigate:y,onLogout:v,children:[n.jsxs("div",{style:Cu,children:[n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Nt,{value:e.organization,onChange:_=>g({organization:_}),organizations:s,disabled:r||!!f.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[S.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.period||"",disabled:r,onChange:_=>g({period:_.target.value}),placeholder:"e.g. Q1 2026"})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Financial KPIs"}),n.jsxs("div",{style:zu,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.revenue_growth||"",disabled:r,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.net_profit||"",disabled:r,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.cash_flow||"",disabled:r,onChange:o("cash_flow")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Operational KPIs"}),n.jsxs("div",{style:zu,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.strategic_goal_pct||"",disabled:r,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.customer_satisfaction||"",disabled:r,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.employee_turnover_pct||"",disabled:r,onChange:o("employee_turnover_pct")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Safety & Compliance"}),n.jsxs("div",{style:Cu,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...P,...x},value:e.open_safety_incidents||"",disabled:r,onChange:_=>g({open_safety_incidents:parseInt(_.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:I,children:S.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.compliance_score||"",disabled:r,onChange:o("compliance_score")})]})]})]})]})}const O1={create_processes:"Create Processes",update_process_status:"Update Process Status"},Tu={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function L1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function D1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function N1({delegations:e,organizations:t,userRole:s,currentUser:l,onView:r,onRevoke:i}){const a=ne(),[c,d]=w.useState(""),[h,j]=w.useState(""),[p,u]=w.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=w.useMemo(()=>e.filter(m=>{const _=`${m.auditor} ${m.manager}`.toLowerCase();return!(c&&!_.includes(c.toLowerCase())||h&&m.organization!==h||p!=="all"&&m.status!==p)}),[e,c,h,p]),[f,S]=w.useState(1);w.useEffect(()=>{S(1)},[c,h,p]);const g=v.slice((f-1)*le,f*le),x=v.filter(m=>m.status==="Pending").length,o=v.filter(m=>m.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:v.length,color:N.purple}),n.jsx(_e,{label:"Pending",val:x,color:N.orange}),n.jsx(_e,{label:"Accepted",val:o,color:N.green})]}),n.jsx(ot,{filters:[{type:"search",label:"Search",value:c,onChange:d,placeholder:"Auditor or Manager…"},{type:"select",label:a.col.organization,value:h,onChange:j,options:[{value:"",label:"All Organizations"},...t.map(m=>({value:m.organization_name||m.name,label:m.organization_name||m.name}))]},{type:"select",label:"Status",value:p,onChange:u,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:a.col.number}),n.jsx("th",{style:y,children:a.col.auditor}),n.jsx("th",{style:y,children:a.col.manager}),n.jsx("th",{style:y,children:a.col.organization}),n.jsx("th",{style:y,children:a.col.functions}),n.jsx("th",{style:y,children:a.col.status}),n.jsx("th",{style:y,children:a.col.requestedOn}),n.jsx("th",{style:y,children:a.col.actions})]})}),n.jsx("tbody",{children:v.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):g.map((m,_)=>{const T=!!i&&(m.status==="Pending"||m.status==="Accepted")&&(s==="Admin"||s==="Auditor"&&m.auditor===l);return n.jsxs("tr",{onClick:()=>r==null?void 0:r(m),style:{borderTop:"1px solid #f0f0f0",background:_%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:m.number||m.name}),n.jsx("td",{style:{padding:"10px 14px"},children:m.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:m.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:m.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:D1(m).map(E=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:O1[E]||E},E))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(Tu[m.status]||N.gray)+"22",color:Tu[m.status]||N.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:m.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:L1(m.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:E=>E.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>r==null?void 0:r(m),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),T&&n.jsx("button",{onClick:()=>i==null?void 0:i(m.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"})]})})]},m.name)})})]})}),n.jsx(We,{page:f,total:v.length,onPageChange:S})]})}const Iu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Pu={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function W1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function B1({form:e,setForm:t,organizations:s,users:l,userRoleMap:r,formStatus:i,viewMode:a,onEdit:c,darkMode:d,notifCount:h,onToggleDark:j,onCountChange:p,onViewProfile:u,onSubmit:y,onBack:v,onNavigate:f,onLogout:S,user:g}){var E;const x=ne(),o=C=>t(R=>({...R,...C})),m=a?{background:"#f9f9f9"}:{},_=fl(l,r,"SB Manager").map(C=>({name:C.name,label:C.full_name||C.name})),T=e.name?`${x.formTitle.viewDelegation}${e.number||e.name}`:x.formTitle.newDelegation;return n.jsxs(Be,{title:T,activePage:"delegations",user:g,formStatus:i,buttonText:x.saveDelegation,buttonColor:N.purple,viewMode:a,onEdit:c,darkMode:d,notifCount:h,onToggleDark:j,onCountChange:p,onViewProfile:u,onSubmit:y,onBack:v,onNavigate:f,onLogout:S,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(Pu[e.status]||N.gray)+"22",color:Pu[e.status]||N.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:Iu,children:[n.jsxs("div",{children:[n.jsx("label",{style:I,children:x.col.auditor}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.auditor||g.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:I,children:[x.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(ue,{value:e.manager,onChange:C=>o({manager:C}),items:_,placeholder:"-- Select Manager --",disabled:a})]})]}),n.jsx("div",{style:Iu,children:n.jsxs("div",{children:[n.jsx("label",{style:I,children:x.col.organization}),n.jsx(Nt,{value:e.organization,onChange:C=>o({organization:C}),organizations:s,placeholder:"-- All Organizations --",disabled:a})]})}),n.jsxs("div",{style:{marginTop:8},children:[n.jsxs("label",{style:I,children:[x.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginTop:6},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:hl,checked:!!e.create_processes,disabled:a,onChange:C=>o({create_processes:C.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Create Processes"})]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:hl,checked:!!e.update_process_status,disabled:a,onChange:C=>o({update_process_status:C.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Update Process Status"})]})]})]}),!a&&n.jsxs("div",{style:{marginTop:20},children:[n.jsx("label",{style:I,children:"Remarks"}),n.jsx("textarea",{style:{...P,...m,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:C=>o({remarks:C.target.value}),placeholder:"Optional note for the Manager…"})]}),a&&(((E=e.delegation_log)==null?void 0:E.length)??0)>0&&n.jsxs("div",{style:{marginTop:28},children:[n.jsx("label",{style:I,children:"Audit Trail"}),n.jsx("div",{style:{background:"white",borderRadius:8,border:"1px solid #eee",overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Action"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Actor"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((C,R)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0"},children:[n.jsx("td",{style:{padding:"8px 14px",fontWeight:600},children:C.action}),n.jsx("td",{style:{padding:"8px 14px"},children:C.actor}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:W1(C.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:C.remarks||"—"})]},C.name||R))})]})})]})]})}const Eu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Ll={process:N.blue,order:N.purple,incident:N.red,idea:N.green,delegation:N.orange},Au={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Dl(e,t){const s=e.replace("#",""),l=parseInt(s.substring(0,2),16),r=parseInt(s.substring(2,4),16),i=parseInt(s.substring(4,6),16);return`rgba(${l}, ${r}, ${i}, ${t})`}function $1({onNavigate:e,onRefresh:t}){const s=ne(),[l,r]=w.useState([]),[i,a]=w.useState(!0),[c,d]=w.useState(""),[h,j]=w.useState(""),p=()=>Fy().then(g=>{r(g),a(!1)});w.useEffect(()=>{p()},[]);const u=l.filter(g=>g.requires_action),y=l.filter(g=>!g.requires_action),v={};for(const g of l)v[g.type]=(v[g.type]||0)+1;const f=async(g,x)=>{d(g),j("");try{await Hy(g,x),await p(),t==null||t()}catch{j(g)}d("")};function S(g,x,o){return x.length===0?null:n.jsxs("div",{style:{marginBottom:28},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("span",{style:{fontSize:12,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:o?N.accent:"#8a8fa3"},children:g}),n.jsx("span",{style:{fontSize:11,fontWeight:700,minWidth:22,textAlign:"center",padding:"2px 7px",borderRadius:999,color:o?"white":"#6b7280",background:o?N.accent:"#e9eaf2"},children:x.length}),n.jsx("div",{style:{flex:1,height:1,background:"linear-gradient(90deg, #e6e7f0, transparent)"}})]}),n.jsx("div",{className:"inbox-card-grid",children:x.map((m,_)=>{const T=m.type!=="delegation",E=Ll[m.type]||N.gray;return n.jsxs("div",{className:"inbox-card",onClick:T?()=>e(Eu[m.type],m.name):void 0,style:{borderTop:`3px solid ${E}`,cursor:T?"pointer":"default"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[n.jsx("div",{style:{width:38,height:38,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:17,background:Dl(E,.14)},children:Au[m.type]||"📌"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13,color:E,letterSpacing:.3},children:m.number}),m.requires_action&&n.jsx("span",{style:{fontSize:10,fontWeight:700,color:N.red,background:Dl(N.red,.12),padding:"1px 7px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4},children:"Action"})]}),n.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:600,marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.title}),n.jsxs("div",{className:"inbox-card-meta",style:{marginTop:5,fontSize:12},children:[m.action,m.organization&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),m.organization]}),m.date&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),m.date]})]}),h===m.name&&n.jsx("div",{style:{marginTop:6,fontSize:12,color:N.red,fontWeight:600},children:"Failed to respond — please try again."})]})]}),m.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,marginTop:14},children:[n.jsx("button",{onClick:()=>f(m.name,"Accepted"),disabled:c===m.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:N.green,color:"white",fontWeight:700,fontSize:13,cursor:c===m.name?"wait":"pointer",opacity:c===m.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>f(m.name,"Rejected"),disabled:c===m.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:N.red,color:"white",fontWeight:700,fontSize:13,cursor:c===m.name?"wait":"pointer",opacity:c===m.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:C=>{C.stopPropagation(),e(Eu[m.type],m.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:m.requires_action?E:Dl(E,.12),color:m.requires_action?"white":E,fontWeight:700,fontSize:13,cursor:"pointer"},children:m.requires_action?"Act Now →":s.view})]},_)})})]})}return n.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!i&&l.length>0&&n.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:24},children:Object.entries(v).map(([g,x])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"6px 12px 6px 9px",borderRadius:999,background:Dl(Ll[g]||N.gray,.1),border:`1px solid ${Dl(Ll[g]||N.gray,.25)}`},children:[n.jsx("span",{style:{fontSize:13},children:Au[g]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Ll[g]||N.gray,textTransform:"capitalize"},children:g}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Ll[g]||N.gray,opacity:.7},children:x})]},g))}),i&&n.jsx("p",{style:{color:"#888"},children:s.loading}),!i&&l.length===0&&n.jsxs("div",{className:"inbox-empty",children:[n.jsx("div",{style:{fontSize:46,marginBottom:10},children:"✨"}),n.jsx("p",{style:{fontSize:16,fontWeight:600},children:s.inbox.noMessages}),n.jsx("p",{style:{fontSize:13,marginTop:4,opacity:.7},children:"You're all caught up — nothing needs your attention right now."})]}),!i&&S("Needs Action",u,!0),!i&&S("Informational",y,!1)]})}const U1=[{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 F1(e,t){const s=e.map(r=>Od[r]||r).join(","),l=t.map(r=>e.map(i=>`"${r[i]??""}"`).join(",")).join(`
`);return s+`
`+l}function M1(e,t){const s=new Blob([e],{type:"text/csv"}),l=URL.createObjectURL(s),r=document.createElement("a");r.href=l,r.download=t,r.click(),URL.revokeObjectURL(l)}const Ru=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function H1(e,t,s){const l=e.map(h=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Ru(Od[h]||h)}</th>`).join(""),r=t.map(h=>`<tr>${e.map(j=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Ru(h[j])}</td>`).join("")}</tr>`).join(""),i=`<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>`,a=new Blob(["\uFEFF"+i],{type:"application/vnd.ms-excel"}),c=URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=s,d.click(),URL.revokeObjectURL(c)}const rh="report-print-area",Fa="report-print-portal";function G1(){const e=document.getElementById(rh);if(!e)return;const t=document.createElement("div");t.id=Fa,t.innerHTML=e.innerHTML,document.body.appendChild(t);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
#${Fa} { display: none; }
@media print {
#root { display: none !important; }
#${Fa} { display: block !important; }
}
`,document.head.appendChild(s);const l=()=>{t.remove(),s.remove(),window.removeEventListener("afterprint",l)};window.addEventListener("afterprint",l),window.print()}const Ou={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Ma={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function K1({organizations:e,userRole:t}){const s=ne(),l=U1.filter(R=>R.roles.includes(t)),[r,i]=w.useState(""),[a,c]=w.useState(""),[d,h]=w.useState(""),[j,p]=w.useState(""),[u,y]=w.useState(String(new Date().getFullYear())),[v,f]=w.useState([]),[S,g]=w.useState([]),[x,o]=w.useState(!1),[m,_]=w.useState(""),T=l.find(R=>R.id===r);async function E(){if(r){o(!0),_(""),g([]),f([]);try{const R={};a&&(R.organization=a),d&&(R.from_date=d),j&&(R.to_date=j),(T==null?void 0:T.extraFilter)==="year"&&u&&(R.year=u);const B=await Uy(r,R);f(B.columns||[]),g(B.rows||[])}catch(R){_(R.message||"Error running report")}finally{o(!1)}}}const C=(T==null?void 0:T.label)||r;return n.jsxs("div",{children:[n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:l.map(R=>n.jsxs("div",{onClick:()=>i(R.id),style:{background:r===R.id?"#ebf5fb":"white",border:r===R.id?`2px solid ${N.accent}`:"2px solid transparent",borderRadius:10,padding:"14px 16px",cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:R.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:R.description})]},R.id))}),n.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),n.jsxs("select",{style:Ou,value:r,onChange:R=>i(R.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),l.map(R=>n.jsx("option",{value:R.id,children:R.label},R.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:Ou,value:a,onChange:R=>c(R.target.value),children:[n.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(R=>n.jsx("option",{value:R.name,children:R.organization_name||R.name},R.name))]})]}),(T==null?void 0:T.extraFilter)==="year"?n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),n.jsx("input",{type:"number",style:{...Ma,width:90},value:u,onChange:R=>y(R.target.value),min:2020,max:2099})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),n.jsx(ve,{value:d,onChange:h,style:Ma})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(ve,{value:j,onChange:p,style:Ma})]})]}),n.jsx("button",{onClick:E,disabled:!r||x,style:{padding:"9px 20px",borderRadius:8,border:"none",background:N.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:x?s.loading:s.reports.generate}),S.length>0&&n.jsx("button",{onClick:()=>M1(F1(v,S),`${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"}),S.length>0&&n.jsx("button",{onClick:()=>H1(v,S,`${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"}),S.length>0&&n.jsx("button",{onClick:G1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),m&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:m}),S.length>0&&n.jsxs("div",{id:rh,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[n.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontWeight:700,color:"#333"},children:C}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[S.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:v.map(R=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Od[R]||R.replace(/_/g," ").toUpperCase()},R))})}),n.jsx("tbody",{children:S.map((R,B)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:B%2===0?"white":"#fafafa"},children:v.map(D=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:R[D]!=null?String(R[D]):"—"},D))},B))})]})]}),!x&&S.length===0&&r&&!m&&n.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&&n.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 br=()=>new Date().toISOString().split("T")[0],Ld=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Q1=()=>new Date().toTimeString().slice(0,5),an=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:br(),time:Q1(),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:""}),Jt=()=>({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:br(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),Zt=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:br(),ending_date:Ld(),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:""}),Zr=()=>({name:"",title:"",date_start:br(),date_end:Ld(),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:""}),As=()=>({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}),Zn=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Vn=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),es=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Rs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Os=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ls=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ds=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ns=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ws=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Bs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),$s=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Vr=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),ts=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:br(),end_date:Ld(),update_window_days:2}),ns=()=>({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}),Nl=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),Y1=new Set(["incidents","incidents-form","ideas","ideas-form"]),X1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),q1=new Set(Xf.flatMap(({id:e})=>[e,`${e}-form`])),J1=new Set(["Admin","Owner","Auditor","Manager"]),Z1=new Set(["Admin","Owner","Auditor","Manager"]),V1=new Set(["Admin","Auditor","Manager"]);function ev({user:e,onLogout:t,darkMode:s,onToggleDark:l}){const r=ne(),i=e.role,a=J1.has(i),c=Z1.has(i),d=V1.has(i),h=b=>b==="users"||b==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(X1.has(b)||(b==="processes"||b==="processes-form")&&Wd.includes("create_processes")):Y1.has(b),j=b=>i==="Employee"&&!!b&&b!=="New",p=a?"dashboard":"inbox",u=b=>b==="dashboard"?a:b==="reports"?c:b==="delegations"||b==="delegations-form"?d:b==="users"||b==="users-form"?i==="Admin":q1.has(b)?i==="Admin"||i==="Auditor":!0,[y,v]=w.useState(()=>{const b=t0(xu());return b&&u(b)?b:p});w.useEffect(()=>{const b=n0(y);window.location.hash!==b&&window.history.pushState(null,"",b)},[y]),w.useEffect(()=>{const b=()=>{const K=xu();v(K&&u(K)?K:p)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[]);const f=e.custom_organization||"",[S,g]=w.useState(""),[x,o]=w.useState("");w.useEffect(()=>{if(!x)return;const b=setTimeout(()=>o(""),0);return()=>clearTimeout(b)},[x]);const m=(b,K)=>{o(K),v(b)},[_,T]=w.useState(0),[E,C]=w.useState([]),[R,B]=w.useState([]),[D,L]=w.useState([]),[z,A]=w.useState([]),[M,pe]=w.useState([]),[re,O]=w.useState([]),[H,Y]=w.useState([]),[V,Z]=w.useState([]),[me,fe]=w.useState([]),[Xe,se]=w.useState([]),[he,X]=w.useState([]),[Q,$e]=w.useState([]),[et,U]=w.useState([]),[ke,dt]=w.useState([]),[k,ee]=w.useState([]),[G,Sr]=w.useState([]),[sn,wr]=w.useState([]),[Un,ra]=w.useState([]),[Fn,$]=w.useState([]),[qe,vs]=w.useState({}),[bt,ih]=w.useState([]),[_r,ah]=w.useState([]),[Dd,oh]=w.useState([]),[Nd,dh]=w.useState([]),[Wd,ch]=w.useState([]),[Bd,uh]=w.useState({}),[ia,ph]=w.useState([]),kr=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[$d,js]=w.useState(kr()),[be,ae]=w.useState(!0),[Le,ie]=w.useState("idle"),[De,te]=w.useState(!1),[Ud,Fd]=w.useState(!1),[Cr,Md]=w.useState(null),[fh,hh]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),gh=()=>hh(b=>{const K=!b;return localStorage.setItem("sb_sidebar",K?"1":"0"),K}),[xh,aa]=w.useState(!1);w.useEffect(()=>{aa(!1)},[y]);const[Mn,ln]=w.useState(an()),[Hn,Qt]=w.useState(Jt()),[vl,Yt]=w.useState(Zt()),[jl,Xt]=w.useState(Zr()),[Hd,bs]=w.useState(As()),[Gd,Gn]=w.useState(Zn()),[Kd,Kn]=w.useState(Vn()),[Qd,Qn]=w.useState(es()),[Yd,Ss]=w.useState(Rs()),[Xd,ws]=w.useState(Os()),[qd,_s]=w.useState(Ls()),[Jd,ks]=w.useState(Ds()),[Zd,Cs]=w.useState(Ns()),[Vd,zs]=w.useState(Ws()),[ec,Ts]=w.useState(Bs()),[tc,Is]=w.useState($s()),[bl,zr]=w.useState(Vr()),[nc,Yn]=w.useState(ts()),[sc,Xn]=w.useState(ns()),[Ps,Sl]=w.useState(Nl()),St=async()=>{ae(!0);try{const[b,K,ht,Je,wt,Te,ua,pg,fg,hg,gg,xg,mg,yg,vg,jg,bg,Sg,wg,_g,kg,Cg,zg,Tg,Ig,Pg,Eg]=await Promise.all([Ce(W.incidents),Ce(W.organizations),Ce(W.ideas),Ce(W.orders),Ce(W.processes),wy(),Ce(W.managements),Ce(W.departments),Ce(W.branches),Ce(W.incidentTypes),Ce(W.incidentClass),Ce(W.incidentField),Ce(W.ideaTypes),Ce(W.orderTypes),Ce(W.processTypes),Ce(W.incidentStatuses),Ce(W.ideaStatuses),Ce(W.orderStatuses),Ce(W.processStatuses),zy(),Ty(),Ce(W.cycles),Ce(W.kpiInput),Ky(),Yy(),Xy(),qy()]);C(b||[]),B(K||[]),L(ht||[]),A(Je||[]),pe(wt||[]),ih(Te||[]),O(ua||[]),Y(pg||[]),Z(fg||[]),fe(hg||[]),se(gg||[]),X(xg||[]),$e(mg||[]),U(yg||[]),dt(vg||[]),ee(jg||[]),Sr(bg||[]),wr(Sg||[]),ra(wg||[]),$(_g||[]),vs(kg||{}),ah(Cg||[]),oh(zg||[]),dh(Tg||[]),ch(Ig||[]),uh(Pg||{}),ph(Eg||[])}catch(b){console.error("Error loading data:",b)}ae(!1)},lc=async()=>{try{const b=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(b.ok){const K=await b.json();T(Number(K.message)||0)}}catch{}};w.useEffect(()=>{St(),lc();const b=setInterval(lc,6e4);return()=>clearInterval(b)},[e.name]);const Ue=async(b,K)=>{if(i==="Admin"||e.name==="Administrator"){const Je=window.confirm(r.rtl?"اضغط [OK] للحذف المؤقت (Soft Delete)، أو [Cancel] للحذف النهائي (Permanent Delete).":"Click [OK] for Soft Delete (move to deleted), or [Cancel] for Permanent Delete.");ae(!0);try{if(Je)await pi(b,K,"",!1);else if(window.confirm(r.rtl?"تأكيد الحذف النهائي؟ لا يمكن التراجع عن هذا الإجراء!":"Confirm PERMANENT delete? This action CANNOT be undone!"))await pi(b,K,"",!0);else{ae(!1);return}await St()}catch(wt){console.error("Delete error:",wt),alert((wt==null?void 0:wt.message)||"Delete failed. Please try again.")}ae(!1)}else{if(!window.confirm(r.rtl?"هل أنت متأكد من نقل هذا السجل للمحذوفات؟":"Are you sure you want to move this record to deleted?"))return;ae(!0);try{await pi(b,K,"",!1),await St()}catch(Je){console.error("Delete error:",Je),alert((Je==null?void 0:Je.message)||"Delete failed. Please try again.")}ae(!1)}},wl=async(b,K)=>{if(window.confirm(r.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){ae(!0);try{await Sy(b,K),alert(r.restoredOk||"Record restored successfully!"),await St()}catch(ht){console.error("Restore error:",ht),alert((ht==null?void 0:ht.message)||"Restore failed. Please try again.")}ae(!1)}},mh=async b=>{try{await Ay(b),await St()}catch(K){console.error("Disable user error:",K)}},yh=async b=>{te(!0),ae(!0);try{const K=await _t(W.incidents,b.name);ln({...an(),...K})}catch{ln({...an(),...b})}v("incidents-form"),ae(!1)},vh=async b=>{te(!0),ae(!0);try{const K=await _t(W.ideas,b.name);Qt({...Jt(),...K})}catch{Qt({...Jt(),...b})}v("ideas-form"),ae(!1)},jh=async b=>{te(!0),ae(!0);try{const K=await _t(W.orders,b.name);Yt({...Zt(),...K})}catch{Yt({...Zt(),...b})}v("orders-form"),ae(!1)},bh=async b=>{te(!0),ae(!0);try{const K=await Fl(b.name);Xt({...K,progress_indicators:K.progress_indicators||[],cycle_logs:K.cycle_logs||[]}),v("processes-form")}catch{Xt({...b,progress_indicators:b.progress_indicators||[]}),v("processes-form")}ae(!1)},Sh=b=>ye(W.organizations,b,bs,As(),"organizations-form",!0),wh=b=>{te(!0),js(b),v("group-companies-form")},_h=b=>{te(!1),js(b),v("group-companies-form")},kh=async b=>{te(!0),ae(!0);try{const K=await _t(W.managements,b.name);Gn({...Zn(),...K})}catch{Gn({...Zn(),...b})}v("managements-form"),ae(!1)},Ch=async b=>{te(!0),ae(!0);try{const K=await _t(W.departments,b.name);Kn({...Vn(),...K})}catch{Kn({...Vn(),...b})}v("departments-form"),ae(!1)},zh=async b=>{te(!0),ae(!0);try{const K=await _t(W.branches,b.name);Qn({...es(),...K})}catch{Qn({...es(),...b})}v("branches-form"),ae(!1)},Th=async b=>{te(!0),ae(!0);try{const K=await _t(W.cycles,b.name);Yn({...ts(),...K})}catch{Yn({...ts(),...b})}v("cycles-form"),ae(!1)},Ih=async b=>{te(!0),ae(!0);try{const K=await _t(W.kpiInput,b.name);Xn({...ns(),...K})}catch{Xn({...ns(),...b})}v("kpi-input-form"),ae(!1)},Ge=async(b,K,ht,Je,wt)=>{ie("loading");try{if(K.name)await Wi(b,K.name,K),ie("success"),St(),setTimeout(()=>{ie("idle"),v(Je)},1500);else if(wt){const Te=await Wa(b,K);wt((Te==null?void 0:Te.data)??Te),ie("success"),St(),setTimeout(()=>ie("idle"),1500)}else await Wa(b,K),ht(),ie("success"),St(),setTimeout(()=>{ie("idle"),v(Je)},1500)}catch(Te){console.error("Submit error:",Te),ie(Te instanceof Error?Te.message:"Error saving. Please try again.")}},Ae=async()=>{await ky(),t()},ye=async(b,K,ht,Je,wt,Te)=>{te(Te),ae(!0);try{const ua=await _t(b,K.name);ht({...Je,...ua})}catch{ht({...Je,...K})}v(wt),ae(!1)},Ph=b=>ye(W.incidents,b,ln,an(),"incidents-form",!1),Eh=b=>ye(W.ideas,b,Qt,Jt(),"ideas-form",!1),Ah=b=>ye(W.orders,b,Yt,Zt(),"orders-form",!1),Rh=b=>{te(!1),ae(!0),Fl(b.name).then(K=>{Xt({...K,progress_indicators:K.progress_indicators||[],cycle_logs:K.cycle_logs||[]})}).catch(()=>{Xt({...b,progress_indicators:b.progress_indicators||[]})}).finally(()=>{v("processes-form"),ae(!1)})},Oh=b=>ye(W.organizations,b,bs,As(),"organizations-form",!1),Lh=b=>ye(W.managements,b,Gn,Zn(),"managements-form",!1),Dh=b=>ye(W.departments,b,Kn,Vn(),"departments-form",!1),Nh=b=>ye(W.branches,b,Qn,es(),"branches-form",!1),Wh=b=>ye(W.cycles,b,Yn,ts(),"cycles-form",!1),Bh=b=>ye(W.kpiInput,b,Xn,ns(),"kpi-input-form",!1),$h=async b=>{te(!0),ae(!0);try{const K=await Qy(b.name);Sl({...Nl(),...K})}catch{Sl({...Nl(),...b})}v("delegations-form"),ae(!1)},Uh=async()=>{ie("loading");try{const b=[];Ps.create_processes&&b.push("create_processes"),Ps.update_process_status&&b.push("update_process_status"),await My(Ps.manager,b,Ps.organization,Ps.remarks),Sl(Nl()),ie("success"),St(),setTimeout(()=>{ie("idle"),v("delegations")},1500)}catch(b){console.error("Delegation submit error:",b),ie(b instanceof Error?b.message:"Error saving. Please try again.")}},Fh=async b=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){ae(!0);try{await Gy(b),await St()}catch(K){console.error("Revoke delegation error:",K),alert(K instanceof Error?K.message:"Revoke failed. Please try again.")}ae(!1)}},Mh=b=>ye(W.incidentTypes,b,Ss,Rs(),"incident-types-form",!0),Hh=b=>ye(W.incidentTypes,b,Ss,Rs(),"incident-types-form",!1),Gh=b=>ye(W.ideaTypes,b,ws,Os(),"idea-types-form",!0),Kh=b=>ye(W.ideaTypes,b,ws,Os(),"idea-types-form",!1),Qh=b=>ye(W.orderTypes,b,_s,Ls(),"order-types-form",!0),Yh=b=>ye(W.orderTypes,b,_s,Ls(),"order-types-form",!1),Xh=b=>ye(W.processTypes,b,ks,Ds(),"process-types-form",!0),qh=b=>ye(W.processTypes,b,ks,Ds(),"process-types-form",!1),Jh=b=>ye(W.incidentStatuses,b,Cs,Ns(),"incident-statuses-form",!0),Zh=b=>ye(W.incidentStatuses,b,Cs,Ns(),"incident-statuses-form",!1),Vh=b=>ye(W.ideaStatuses,b,zs,Ws(),"idea-statuses-form",!0),eg=b=>ye(W.ideaStatuses,b,zs,Ws(),"idea-statuses-form",!1),tg=b=>ye(W.orderStatuses,b,Ts,Bs(),"order-statuses-form",!0),ng=b=>ye(W.orderStatuses,b,Ts,Bs(),"order-statuses-form",!1),sg=b=>ye(W.processStatuses,b,Is,$s(),"process-statuses-form",!0),lg=b=>ye(W.processStatuses,b,Is,$s(),"process-statuses-form",!1),rg=async b=>{Md(b),v("profile")},ig=b=>{te(!1),Fd(!1),zr({...Vr(),...b}),v("users-form")},ag=async()=>{ie("loading");try{if(!bl.name){const K=await Wa("User",{...bl,send_welcome_email:0,user_type:"System User"});zr({...Vr(),...bl,...(K==null?void 0:K.data)??K}),te(!0),ie("success"),St(),setTimeout(()=>ie("idle"),1500)}else{const{name:K,email:ht,creation:Je,full_name:wt,...Te}=bl;await Wi("User",K,Te),ie("success"),St(),setTimeout(()=>{ie("idle"),v("users")},1500)}}catch(b){console.error("User submit error:",b),ie(b instanceof Error?b.message:"Error saving. Please try again.")}},Re=()=>{const b=Fn.find(K=>K.name===e.name||K.username===e.name);Md(b||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),v("profile")},oa=(b,K)=>{if(K){const Je={"processes-form":W.processes,"orders-form":W.orders,"incidents-form":W.incidents,"ideas-form":W.ideas}[b];if(Je){te(!0),ae(!0),(b==="processes-form"?Fl(K).then(Te=>({...Te,progress_indicators:Te.progress_indicators||[],cycle_logs:Te.cycle_logs||[]})):_t(Je,K)).then(Te=>{b==="processes-form"?Xt(Te):b==="orders-form"?Yt({...Zt(),...Te}):b==="incidents-form"?ln({...an(),...Te}):b==="ideas-form"&&Qt({...Jt(),...Te}),v(b),ae(!1)}).catch(()=>{v(b),ae(!1)});return}}v(b)};if(y==="incidents-form")return n.jsx(j0,{incForm:Mn,setIncForm:ln,organizations:R,managements:re,departments:H,branches:V,incidentTypes:me,incidentClasses:Xe,incidentFields:he,incidentStatuses:k,users:bt,userRoleMap:qe,formStatus:Le,viewMode:De||!h("incidents-form")||j(Mn.workflow_state),onEdit:h("incidents-form")&&!j(Mn.workflow_state)&&!Cn("incident",Mn.workflow_state)?()=>te(!1):void 0,onRestore:i==="Admin"?b=>wl(W.incidents,b):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,userRole:i,onSubmit:()=>Ge(W.incidents,Mn,()=>ln(an()),"incidents",b=>ln({...an(),...b})),onBack:()=>{v("incidents"),ie("idle")},onNavigate:v,onLogout:Ae,user:e,onRefresh:async()=>{if(Mn.name){const b=await _t(W.incidents,Mn.name).catch(()=>null);b&&ln({...an(),...b})}Ce(W.incidents).then(b=>C(b||[])).catch(()=>{})}});if(y==="ideas-form")return n.jsx(_0,{ideaForm:Hn,setIdeaForm:Qt,organizations:R,managements:re,departments:H,branches:V,ideaTypes:Q,ideaStatuses:G,users:bt,userRoleMap:qe,formStatus:Le,viewMode:De||!h("ideas-form")||j(Hn.workflow_state),onEdit:h("ideas-form")&&!j(Hn.workflow_state)&&!Cn("idea",Hn.workflow_state)?()=>te(!1):void 0,onRestore:i==="Admin"?b=>wl(W.ideas,b):void 0,onNavigateToOrder:b=>ye(W.orders,{name:b},Yt,Zt(),"orders-form",!0),darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,userRole:i,onSubmit:()=>Ge(W.ideas,Hn,()=>Qt(Jt()),"ideas",b=>Qt({...Jt(),...b})),onBack:()=>{v("ideas"),ie("idle")},onNavigate:v,onLogout:Ae,user:e,onRefresh:async()=>{if(Hn.name){const b=await _t(W.ideas,Hn.name).catch(()=>null);b&&Qt({...Jt(),...b})}Ce(W.ideas).then(b=>L(b||[])).catch(()=>{})}});if(y==="orders-form")return n.jsx(I0,{orderForm:vl,setOrderForm:Yt,organizations:R,managements:re,departments:H,branches:V,orderTypes:et,orderStatuses:sn,cycles:_r,users:bt,userRoleMap:qe,formStatus:Le,viewMode:De||!h("orders-form"),onEdit:h("orders-form")&&!Cn("order",vl.workflow_state)?()=>te(!1):void 0,onRestore:i==="Admin"?b=>wl(W.orders,b):void 0,onNavigateToIdea:b=>ye(W.ideas,{name:b},Qt,Jt(),"ideas-form",!0),darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,currentUser:e.name,userRole:i,onSubmit:()=>Ge(W.orders,vl,()=>Yt(Zt()),"orders",b=>Yt({...Zt(),...b})),onBack:()=>{v("orders"),ie("idle")},onNavigate:v,onLogout:Ae,user:e,onRefresh:async()=>{if(vl.name){const b=await _t(W.orders,vl.name).catch(()=>null);b&&Yt({...Zt(),...b})}Ce(W.orders).then(b=>A(b||[])).catch(()=>{})}});if(y==="processes-form")return n.jsx(O0,{processForm:jl,setProcessForm:Xt,organizations:R,managements:re,departments:H,branches:V,processTypes:ke,processStatuses:Un,cycles:_r,users:bt,userRoleMap:qe,formStatus:Le,viewMode:De||!h("processes-form"),onEdit:h("processes-form")&&!Cn("process",jl.workflow_state)?()=>te(!1):void 0,onRestore:i==="Admin"?b=>wl(W.processes,b):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,userRole:e.role,delegatedFunctions:Wd,delegatedOrgs:Bd.create_processes,onRefreshProcess:async()=>{if(jl.name)try{const b=await Fl(jl.name);Xt({...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})}catch{}Ce(W.processes).then(b=>pe(b||[])).catch(()=>{})},onSubmit:()=>Ge(W.processes,jl,()=>Xt(Zr()),"processes",b=>Xt({...Zr(),...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})),onBack:()=>{v("processes"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="organizations-form")return n.jsx($0,{orgForm:Hd,setOrgForm:bs,groupCompanies:ia,formStatus:Le,viewMode:De||!h("organizations-form"),onEdit:h("organizations-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.organizations,Hd,()=>bs(As()),"organizations",b=>{bs({...As(),...b}),te(!0)}),onBack:()=>{v("organizations"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="managements-form")return n.jsx(G0,{form:Gd,setForm:Gn,organizations:R,formStatus:Le,viewMode:De||!h("managements-form"),onEdit:h("managements-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.managements,Gd,()=>Gn(Zn()),"managements",b=>{Gn({...Zn(),...b}),te(!0)}),onBack:()=>{v("managements"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="departments-form")return n.jsx(X0,{form:Kd,setForm:Kn,organizations:R,managements:re,formStatus:Le,viewMode:De||!h("departments-form"),onEdit:h("departments-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.departments,Kd,()=>Kn(Vn()),"departments",b=>{Kn({...Vn(),...b}),te(!0)}),onBack:()=>{v("departments"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="branches-form")return n.jsx(V0,{form:Qd,setForm:Qn,organizations:R,managements:re,departments:H,formStatus:Le,viewMode:De||!h("branches-form"),onEdit:h("branches-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.branches,Qd,()=>Qn(es()),"branches",b=>{Qn({...es(),...b}),te(!0)}),onBack:()=>{v("branches"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="cycles-form")return n.jsx(E1,{form:nc,setForm:Yn,organizations:R,formStatus:Le,viewMode:De||!h("cycles-form"),onEdit:h("cycles-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.cycles,nc,()=>Yn(ts()),"cycles",b=>{Yn({...ts(),...b}),te(!0)}),onBack:()=>{v("cycles"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="kpi-input-form")return n.jsx(R1,{form:sc,setForm:Xn,organizations:R,formStatus:Le,viewMode:De||!h("kpi-input-form"),onEdit:h("kpi-input-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.kpiInput,sc,()=>Xn(ns()),"kpi-input",b=>{Xn({...ns(),...b}),te(!0)}),onBack:()=>{v("kpi-input"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="incident-types-form")return n.jsx(n1,{form:Yd,setForm:Ss,formStatus:Le,viewMode:De||!h("incident-types-form"),onEdit:h("incident-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.incidentTypes,Yd,()=>Ss(Rs()),"incident-types",b=>{Ss({...Rs(),...b}),te(!0)}),onBack:()=>{v("incident-types"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="idea-types-form")return n.jsx(r1,{form:Xd,setForm:ws,formStatus:Le,viewMode:De||!h("idea-types-form"),onEdit:h("idea-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.ideaTypes,Xd,()=>ws(Os()),"idea-types",b=>{ws({...Os(),...b}),te(!0)}),onBack:()=>{v("idea-types"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="order-types-form")return n.jsx(o1,{form:qd,setForm:_s,formStatus:Le,viewMode:De||!h("order-types-form"),onEdit:h("order-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.orderTypes,qd,()=>_s(Ls()),"order-types",b=>{_s({...Ls(),...b}),te(!0)}),onBack:()=>{v("order-types"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="process-types-form")return n.jsx(u1,{form:Jd,setForm:ks,formStatus:Le,viewMode:De||!h("process-types-form"),onEdit:h("process-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.processTypes,Jd,()=>ks(Ds()),"process-types",b=>{ks({...Ds(),...b}),te(!0)}),onBack:()=>{v("process-types"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="incident-statuses-form")return n.jsx(h1,{form:Zd,setForm:Cs,formStatus:Le,viewMode:De||!h("incident-statuses-form"),onEdit:h("incident-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.incidentStatuses,Zd,()=>Cs(Ns()),"incident-statuses",b=>{Cs({...Ns(),...b}),te(!0)}),onBack:()=>{v("incident-statuses"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="idea-statuses-form")return n.jsx(m1,{form:Vd,setForm:zs,formStatus:Le,viewMode:De||!h("idea-statuses-form"),onEdit:h("idea-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.ideaStatuses,Vd,()=>zs(Ws()),"idea-statuses",b=>{zs({...Ws(),...b}),te(!0)}),onBack:()=>{v("idea-statuses"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="order-statuses-form")return n.jsx(j1,{form:ec,setForm:Ts,formStatus:Le,viewMode:De||!h("order-statuses-form"),onEdit:h("order-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.orderStatuses,ec,()=>Ts(Bs()),"order-statuses",b=>{Ts({...Bs(),...b}),te(!0)}),onBack:()=>{v("order-statuses"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="process-statuses-form")return n.jsx(w1,{form:tc,setForm:Is,formStatus:Le,viewMode:De||!h("process-statuses-form"),onEdit:h("process-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.processStatuses,tc,()=>Is($s()),"process-statuses",b=>{Is({...$s(),...b}),te(!0)}),onBack:()=>{v("process-statuses"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="users-form")return n.jsx(z1,{form:bl,setForm:zr,groupCompanies:ia,organizations:R,managements:re,departments:H,branches:V,formStatus:Le,viewMode:De||!h("users-form"),onEdit:h("users-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,isSelfProfile:Ud,onSubmit:ag,onBack:()=>{v(Ud?a?"dashboard":"inbox":"users"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="delegations-form")return n.jsx(B1,{form:Ps,setForm:Sl,organizations:R,users:bt,userRoleMap:qe,formStatus:Le,viewMode:De||!h("delegations-form"),onEdit:h("delegations-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:Uh,onBack:()=>{v("delegations"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});if(y==="group-companies-form")return n.jsx(F0,{form:$d,setForm:js,users:bt,formStatus:Le,viewMode:De||!h("group-companies-form"),onEdit:h("group-companies-form")?()=>te(!1):void 0,onRestore:i==="Admin"?b=>wl(W.groupCompanies,b):void 0,darkMode:s,notifCount:_,onToggleDark:l,onCountChange:T,onViewProfile:Re,onSubmit:()=>Ge(W.groupCompanies,$d,()=>js(kr()),"group-companies",b=>{js({...kr(),...b}),te(!0)}),onBack:()=>{v("group-companies"),ie("idle")},onNavigate:v,onLogout:Ae,user:e});const og={...r.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},dg={"group-companies":{color:N.purple,formPage:"group-companies-form",reset:()=>js(kr())},incidents:{color:N.accent,formPage:"incidents-form",reset:()=>ln({...an(),organization:f||S})},ideas:{color:N.teal,formPage:"ideas-form",reset:()=>Qt({...Jt(),organization:f||S})},orders:{color:N.purple,formPage:"orders-form",reset:()=>Yt({...Zt(),organization:f||S})},processes:{color:N.blue,formPage:"processes-form",reset:()=>{const b=Bd.create_processes,K=f||(i==="Manager"&&b&&b.length===1?b[0]:S);Xt({...Zr(),organization:K})}},organizations:{color:N.accent,formPage:"organizations-form",reset:()=>bs(As())},managements:{color:N.blue,formPage:"managements-form",reset:()=>Gn({...Zn(),organization:f||S})},departments:{color:N.teal,formPage:"departments-form",reset:()=>Kn({...Vn(),custom_organization:f||S})},branches:{color:N.purple,formPage:"branches-form",reset:()=>Qn({...es(),organization:f||S})},cycles:{color:N.teal,formPage:"cycles-form",reset:()=>Yn({...ts(),organization:f||S})},"kpi-input":{color:N.blue,formPage:"kpi-input-form",reset:()=>Xn({...ns(),organization:f||S})},"incident-types":{color:N.red,formPage:"incident-types-form",reset:()=>Ss(Rs())},"idea-types":{color:N.orange,formPage:"idea-types-form",reset:()=>ws(Os())},"order-types":{color:N.green,formPage:"order-types-form",reset:()=>_s(Ls())},"process-types":{color:N.accent,formPage:"process-types-form",reset:()=>ks(Ds())},"incident-statuses":{color:N.red,formPage:"incident-statuses-form",reset:()=>Cs(Ns())},"idea-statuses":{color:N.teal,formPage:"idea-statuses-form",reset:()=>zs(Ws())},"order-statuses":{color:N.purple,formPage:"order-statuses-form",reset:()=>Ts(Bs())},"process-statuses":{color:N.blue,formPage:"process-statuses-form",reset:()=>Is($s())},users:{color:N.blue,formPage:"users-form",reset:()=>{zr(Vr()),Fd(!1)}},delegations:{color:N.purple,formPage:"delegations-form",reset:()=>Sl(Nl())}},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:E,ideas:D,orders:z,processes:M,organizations:R,managements:re,departments:H,branches:V,cycles:_r,"kpi-input":Dd,"incident-types":me,"idea-types":Q,"order-types":et,"process-types":ke,"incident-statuses":k,"idea-statuses":G,"order-statuses":sn,"process-statuses":Un,users:Fn,delegations:Nd},qn=ay[y],da=ug[y],J=h(y),ca=J?dg[y]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":N.bg},children:[n.jsx(Jf,{collapsed:fh,onToggleCollapsed:gh,activePage:y,onNavigate:b=>v(b),hasDashboard:a,hasReports:c,hasDelegations:d,role:i,rtl:r.rtl,navLabels:r.nav,settingsLabel:r.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.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:n.jsx(sh,{notifCount:_,darkMode:s,onCountChange:T,onToggleDark:l,onNavigate:oa,onViewProfile:Re,onLogout:Ae,userName:e.full_name||e.name,userRole:i})}),y!=="profile"&&n.jsxs("div",{style:{background:s?"#1e293b":"white",padding:"9px 20px",borderBottom:`1px solid ${s?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:s?"#e2e8f0":"#1e1b4b"},children:og[y]||y}),n.jsxs("div",{style:{display:"flex",gap:8},children:[qn&&da&&n.jsx("button",{onClick:()=>aa(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),ca&&n.jsxs("button",{onClick:()=>{ca.reset(),te(!1),ie("idle"),v(ca.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",cg[y]||r.new]})]})]}),qn&&da&&xh&&n.jsx(vy,{title:qn.label,rows:da,columns:qn.columns,defaultColumnKeys:qn.defaultColumns,orgField:qn.orgField,organizations:qn.orgField?R:void 0,filenameBase:y,onClose:()=>aa(!1)}),n.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:y==="profile"?0:"20px 24px",gap:y==="profile"?0:16},children:[be&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:r.loading}),!be&&y==="dashboard"&&a&&n.jsx(d0,{incidents:E,ideas:D,orders:z,processes:M,organizations:R,incidentStatuses:k,ideaStatuses:G,orderStatuses:sn,processStatuses:Un,selectedOrg:S,onOrgChange:g,onNavigate:oa,onNavigateStatus:m,userRole:i}),!be&&y==="inbox"&&n.jsx($1,{onNavigate:oa,onRefresh:St}),!be&&y==="reports"&&c&&n.jsx(K1,{organizations:R,userRole:i}),!be&&y==="incidents"&&n.jsx(c0,{incidents:E,organizations:R,departments:H,branches:V,incidentStatuses:k,initialOrg:S,initialStatus:x,onView:yh,onEdit:J?Ph:void 0,onDelete:J?b=>Ue(W.incidents,b):void 0,canModify:J}),!be&&y==="ideas"&&n.jsx(b0,{ideas:D,organizations:R,departments:H,branches:V,ideaStatuses:G,initialOrg:S,initialStatus:x,onView:vh,onEdit:J?Eh:void 0,onDelete:J?b=>Ue(W.ideas,b):void 0,canModify:J}),!be&&y==="orders"&&n.jsx(k0,{orders:z,organizations:R,departments:H,branches:V,orderStatuses:sn,initialOrg:S,initialStatus:x,onView:jh,onEdit:J?Ah:void 0,onDelete:J?b=>Ue(W.orders,b):void 0,canModify:J}),!be&&y==="processes"&&n.jsx(P0,{processes:M,organizations:R,departments:H,branches:V,processStatuses:Un,initialOrg:S,initialStatus:x,onView:bh,onEdit:J?Rh:void 0,onDelete:J?b=>Ue(W.processes,b):void 0,canModify:J}),!be&&y==="organizations"&&n.jsx(B0,{organizations:R,onView:Sh,onEdit:J?Oh:void 0,onDelete:J?b=>Ue(W.organizations,b):void 0,canModify:J}),!be&&y==="group-companies"&&n.jsx(U0,{groupCompanies:ia,onView:wh,onEdit:J?_h:void 0,onDelete:J?b=>Ue(W.groupCompanies,b):void 0,canModify:J}),!be&&y==="managements"&&n.jsx(H0,{managements:re,onView:kh,onEdit:J?Lh:void 0,onDelete:J?b=>Ue(W.managements,b):void 0,canModify:J}),!be&&y==="departments"&&n.jsx(Q0,{departments:H,managements:re,onView:Ch,onEdit:J?Dh:void 0,onDelete:J?b=>Ue(W.departments,b):void 0,canModify:J}),!be&&y==="branches"&&n.jsx(J0,{branches:V,managements:re,departments:H,onView:zh,onEdit:J?Nh:void 0,onDelete:J?b=>Ue(W.branches,b):void 0,canModify:J}),!be&&y==="cycles"&&n.jsx(T1,{cycles:_r,canModify:J,onView:Th,onEdit:J?Wh:void 0,onDelete:J?b=>Ue(W.cycles,b):void 0}),!be&&y==="kpi-input"&&n.jsx(A1,{kpiInputs:Dd,canModify:J,onView:Ih,onEdit:J?Bh:void 0,onDelete:J?b=>Ue(W.kpiInput,b):void 0}),!be&&y==="incident-types"&&n.jsx(t1,{incidentTypes:me,onView:Mh,onEdit:J?Hh:void 0,onDelete:J?b=>Ue(W.incidentTypes,b):void 0,canModify:J}),!be&&y==="idea-types"&&n.jsx(l1,{ideaTypes:Q,onView:Gh,onEdit:J?Kh:void 0,onDelete:J?b=>Ue(W.ideaTypes,b):void 0,canModify:J}),!be&&y==="order-types"&&n.jsx(a1,{orderTypes:et,onView:Qh,onEdit:J?Yh:void 0,onDelete:J?b=>Ue(W.orderTypes,b):void 0,canModify:J}),!be&&y==="process-types"&&n.jsx(c1,{processTypes:ke,onView:Xh,onEdit:J?qh:void 0,onDelete:J?b=>Ue(W.processTypes,b):void 0,canModify:J}),!be&&y==="incident-statuses"&&n.jsx(f1,{incidentStatuses:k,onView:Jh,onEdit:J?Zh:void 0,onDelete:J?b=>Ue(W.incidentStatuses,b):void 0,canModify:J}),!be&&y==="idea-statuses"&&n.jsx(x1,{ideaStatuses:G,onView:Vh,onEdit:J?eg:void 0,onDelete:J?b=>Ue(W.ideaStatuses,b):void 0,canModify:J}),!be&&y==="order-statuses"&&n.jsx(v1,{orderStatuses:sn,onView:tg,onEdit:J?ng:void 0,onDelete:J?b=>Ue(W.orderStatuses,b):void 0,canModify:J}),!be&&y==="process-statuses"&&n.jsx(S1,{processStatuses:Un,onView:sg,onEdit:J?lg:void 0,onDelete:J?b=>Ue(W.processStatuses,b):void 0,canModify:J}),!be&&y==="users"&&n.jsx(C1,{users:Fn,roleMap:qe,onView:rg,onEdit:J?ig:void 0,onDelete:J?b=>Ue("User",b):void 0,onDisable:J?mh:void 0,canModify:J}),!be&&y==="delegations"&&d&&n.jsx(N1,{delegations:Nd,organizations:R,userRole:i,currentUser:e.name,onView:$h,onRevoke:J?Fh:void 0}),y==="profile"&&(()=>{const b=!!Cr&&(Cr.name===e.name||Cr.email===e.name);return n.jsx(D0,{user:e,profileUser:Cr,sbUsers:Fn,organizations:R,managements:re,departments:H,branches:V,darkMode:s,canModify:J||b,onBack:()=>v(b?a?"dashboard":"inbox":"users"),onNavigate:v})})()]})]})]})}function tv(e){return e.some(t=>["SB Admin","System Manager"].includes(t))?"Admin":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":e.includes("SB Manager")?"Manager":"Employee"}function nv(){const[e,t]=w.useState(()=>{try{const c=localStorage.getItem("sidrah_user");return c?JSON.parse(c):null}catch{return null}}),[s,l]=w.useState(()=>localStorage.getItem("sb_dark")==="1"),r=()=>{const c=!s;l(c),localStorage.setItem("sb_dark",c?"1":"0"),document.documentElement.classList.toggle("dark",c)};w.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),w.useEffect(()=>{e&&eh().then(async c=>{const d=c||e.name,h=await nh(d);if(!h.length)return;const j=tv(h),p=await Dy();if(j!==e.role||d!==e.name||p!==(e.custom_organization||"")){const y={...e,name:d,role:j,custom_organization:p};t(y),localStorage.setItem("sidrah_user",JSON.stringify(y))}})},[e==null?void 0:e.name]);const i=c=>{t(c),localStorage.setItem("sidrah_user",JSON.stringify(c))},a=()=>{t(null),localStorage.removeItem("sidrah_user")};return e?n.jsx(ev,{user:e,onLogout:a,darkMode:s,onToggleDark:r}):n.jsx(s0,{onLogin:i})}Yf(document.getElementById("root")).render(n.jsx(w.StrictMode,{children:n.jsx(nv,{})}));