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

53 lines
570 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

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

(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&l(o)}).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 Wu={exports:{}},Hi={},Nu={exports:{}},ce={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Ir=Symbol.for("react.element"),Pg=Symbol.for("react.portal"),Rg=Symbol.for("react.fragment"),Dg=Symbol.for("react.strict_mode"),Og=Symbol.for("react.profiler"),Lg=Symbol.for("react.provider"),Wg=Symbol.for("react.context"),Ng=Symbol.for("react.forward_ref"),Bg=Symbol.for("react.suspense"),$g=Symbol.for("react.memo"),Ug=Symbol.for("react.lazy"),cc=Symbol.iterator;function Fg(e){return e===null||typeof e!="object"?null:(e=cc&&e[cc]||e["@@iterator"],typeof e=="function"?e:null)}var Bu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},$u=Object.assign,Uu={};function El(e,n,s){this.props=e,this.context=n,this.refs=Uu,this.updater=s||Bu}El.prototype.isReactComponent={};El.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,n,"setState")};El.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Fu(){}Fu.prototype=El.prototype;function Mo(e,n,s){this.props=e,this.context=n,this.refs=Uu,this.updater=s||Bu}var Ho=Mo.prototype=new Fu;Ho.constructor=Mo;$u(Ho,El.prototype);Ho.isPureReactComponent=!0;var uc=Array.isArray,Mu=Object.prototype.hasOwnProperty,Go={current:null},Hu={key:!0,ref:!0,__self:!0,__source:!0};function Gu(e,n,s){var l,r={},i=null,o=null;if(n!=null)for(l in n.ref!==void 0&&(o=n.ref),n.key!==void 0&&(i=""+n.key),n)Mu.call(n,l)&&!Hu.hasOwnProperty(l)&&(r[l]=n[l]);var d=arguments.length-2;if(d===1)r.children=s;else if(1<d){for(var u=Array(d),c=0;c<d;c++)u[c]=arguments[c+2];r.children=u}if(e&&e.defaultProps)for(l in d=e.defaultProps,d)r[l]===void 0&&(r[l]=d[l]);return{$$typeof:Ir,type:e,key:i,ref:o,props:r,_owner:Go.current}}function Mg(e,n){return{$$typeof:Ir,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function Ko(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ir}function Hg(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return n[s]})}var pc=/\/+/g;function va(e,n){return typeof e=="object"&&e!==null&&e.key!=null?Hg(""+e.key):n.toString(36)}function ii(e,n,s,l,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case Ir:case Pg:o=!0}}if(o)return o=e,r=r(o),e=l===""?"."+va(o,0):l,uc(r)?(s="",e!=null&&(s=e.replace(pc,"$&/")+"/"),ii(r,n,s,"",function(c){return c})):r!=null&&(Ko(r)&&(r=Mg(r,s+(!r.key||o&&o.key===r.key?"":(""+r.key).replace(pc,"$&/")+"/")+e)),n.push(r)),1;if(o=0,l=l===""?".":l+":",uc(e))for(var d=0;d<e.length;d++){i=e[d];var u=l+va(i,d);o+=ii(i,n,s,u,r)}else if(u=Fg(e),typeof u=="function")for(e=u.call(e),d=0;!(i=e.next()).done;)i=i.value,u=l+va(i,d++),o+=ii(i,n,s,u,r);else if(i==="object")throw n=String(e),Error("Objects are not valid as a React child (found: "+(n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return o}function Br(e,n,s){if(e==null)return e;var l=[],r=0;return ii(e,l,"","",function(i){return n.call(s,i,r++)}),l}function Gg(e){if(e._status===-1){var n=e._result;n=n(),n.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var St={current:null},ai={transition:null},Kg={ReactCurrentDispatcher:St,ReactCurrentBatchConfig:ai,ReactCurrentOwner:Go};function Ku(){throw Error("act(...) is not supported in production builds of React.")}ce.Children={map:Br,forEach:function(e,n,s){Br(e,function(){n.apply(this,arguments)},s)},count:function(e){var n=0;return Br(e,function(){n++}),n},toArray:function(e){return Br(e,function(n){return n})||[]},only:function(e){if(!Ko(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ce.Component=El;ce.Fragment=Rg;ce.Profiler=Og;ce.PureComponent=Mo;ce.StrictMode=Dg;ce.Suspense=Bg;ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Kg;ce.act=Ku;ce.cloneElement=function(e,n,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var l=$u({},e.props),r=e.key,i=e.ref,o=e._owner;if(n!=null){if(n.ref!==void 0&&(i=n.ref,o=Go.current),n.key!==void 0&&(r=""+n.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(u in n)Mu.call(n,u)&&!Hu.hasOwnProperty(u)&&(l[u]=n[u]===void 0&&d!==void 0?d[u]:n[u])}var u=arguments.length-2;if(u===1)l.children=s;else if(1<u){d=Array(u);for(var c=0;c<u;c++)d[c]=arguments[c+2];l.children=d}return{$$typeof:Ir,type:e.type,key:r,ref:i,props:l,_owner:o}};ce.createContext=function(e){return e={$$typeof:Wg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Lg,_context:e},e.Consumer=e};ce.createElement=Gu;ce.createFactory=function(e){var n=Gu.bind(null,e);return n.type=e,n};ce.createRef=function(){return{current:null}};ce.forwardRef=function(e){return{$$typeof:Ng,render:e}};ce.isValidElement=Ko;ce.lazy=function(e){return{$$typeof:Ug,_payload:{_status:-1,_result:e},_init:Gg}};ce.memo=function(e,n){return{$$typeof:$g,type:e,compare:n===void 0?null:n}};ce.startTransition=function(e){var n=ai.transition;ai.transition={};try{e()}finally{ai.transition=n}};ce.unstable_act=Ku;ce.useCallback=function(e,n){return St.current.useCallback(e,n)};ce.useContext=function(e){return St.current.useContext(e)};ce.useDebugValue=function(){};ce.useDeferredValue=function(e){return St.current.useDeferredValue(e)};ce.useEffect=function(e,n){return St.current.useEffect(e,n)};ce.useId=function(){return St.current.useId()};ce.useImperativeHandle=function(e,n,s){return St.current.useImperativeHandle(e,n,s)};ce.useInsertionEffect=function(e,n){return St.current.useInsertionEffect(e,n)};ce.useLayoutEffect=function(e,n){return St.current.useLayoutEffect(e,n)};ce.useMemo=function(e,n){return St.current.useMemo(e,n)};ce.useReducer=function(e,n,s){return St.current.useReducer(e,n,s)};ce.useRef=function(e){return St.current.useRef(e)};ce.useState=function(e){return St.current.useState(e)};ce.useSyncExternalStore=function(e,n,s){return St.current.useSyncExternalStore(e,n,s)};ce.useTransition=function(){return St.current.useTransition()};ce.version="18.3.1";Nu.exports=ce;var S=Nu.exports;/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Qg=S,Yg=Symbol.for("react.element"),Xg=Symbol.for("react.fragment"),qg=Object.prototype.hasOwnProperty,Jg=Qg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vg={key:!0,ref:!0,__self:!0,__source:!0};function Qu(e,n,s){var l,r={},i=null,o=null;s!==void 0&&(i=""+s),n.key!==void 0&&(i=""+n.key),n.ref!==void 0&&(o=n.ref);for(l in n)qg.call(n,l)&&!Vg.hasOwnProperty(l)&&(r[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)r[l]===void 0&&(r[l]=n[l]);return{$$typeof:Yg,type:e,key:i,ref:o,props:r,_owner:Jg.current}}Hi.Fragment=Xg;Hi.jsx=Qu;Hi.jsxs=Qu;Wu.exports=Hi;var t=Wu.exports,Yu={exports:{}},Lt={},Xu={exports:{}},qu={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(e){function n(H,Y){var q=H.length;H.push(Y);e:for(;0<q;){var $=q-1>>>1,Z=H[$];if(0<r(Z,Y))H[$]=Y,H[q]=Z,q=$;else break e}}function s(H){return H.length===0?null:H[0]}function l(H){if(H.length===0)return null;var Y=H[0],q=H.pop();if(q!==Y){H[0]=q;e:for(var $=0,Z=H.length,pe=Z>>>1;$<pe;){var be=2*($+1)-1,ie=H[be],Ze=be+1,dt=H[Ze];if(0>r(ie,q))Ze<Z&&0>r(dt,ie)?(H[$]=dt,H[Ze]=q,$=Ze):(H[$]=ie,H[be]=q,$=be);else if(Ze<Z&&0>r(dt,q))H[$]=dt,H[Ze]=q,$=Ze;else break e}}return Y}function r(H,Y){var q=H.sortIndex-Y.sortIndex;return q!==0?q:H.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,d=o.now();e.unstable_now=function(){return o.now()-d}}var u=[],c=[],_=1,m=null,y=3,h=!1,b=!1,z=!1,j=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,a=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(H){for(var Y=s(c);Y!==null;){if(Y.callback===null)l(c);else if(Y.startTime<=H)l(c),Y.sortIndex=Y.expirationTime,n(u,Y);else break;Y=s(c)}}function g(H){if(z=!1,x(H),!b)if(s(u)!==null)b=!0,O(C);else{var Y=s(c);Y!==null&&M(g,Y.startTime-H)}}function C(H,Y){b=!1,z&&(z=!1,f(k),k=-1),h=!0;var q=y;try{for(x(Y),m=s(u);m!==null&&(!(m.expirationTime>Y)||H&&!Q());){var $=m.callback;if(typeof $=="function"){m.callback=null,y=m.priorityLevel;var Z=$(m.expirationTime<=Y);Y=e.unstable_now(),typeof Z=="function"?m.callback=Z:m===s(u)&&l(u),x(Y)}else l(u);m=s(u)}if(m!==null)var pe=!0;else{var be=s(c);be!==null&&M(g,be.startTime-Y),pe=!1}return pe}finally{m=null,y=q,h=!1}}var w=!1,p=null,k=-1,T=5,A=-1;function Q(){return!(e.unstable_now()-A<T)}function J(){if(p!==null){var H=e.unstable_now();A=H;var Y=!0;try{Y=p(!0,H)}finally{Y?W():(w=!1,p=null)}}else w=!1}var W;if(typeof a=="function")W=function(){a(J)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,I=U.port2;U.port1.onmessage=J,W=function(){I.postMessage(null)}}else W=function(){j(J,0)};function O(H){p=H,w||(w=!0,W())}function M(H,Y){k=j(function(){H(e.unstable_now())},Y)}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(H){H.callback=null},e.unstable_continueExecution=function(){b||h||(b=!0,O(C))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(H){switch(y){case 1:case 2:case 3:var Y=3;break;default:Y=y}var q=y;y=Y;try{return H()}finally{y=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,Y){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var q=y;y=H;try{return Y()}finally{y=q}},e.unstable_scheduleCallback=function(H,Y,q){var $=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?$+q:$):q=$,H){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=q+Z,H={id:_++,callback:Y,priorityLevel:H,startTime:q,expirationTime:Z,sortIndex:-1},q>$?(H.sortIndex=q,n(c,H),s(u)===null&&H===s(c)&&(z?(f(k),k=-1):z=!0,M(g,q-$))):(H.sortIndex=Z,n(u,H),b||h||(b=!0,O(C))),H},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(H){var Y=y;return function(){var q=y;y=Y;try{return H.apply(this,arguments)}finally{y=q}}}})(qu);Xu.exports=qu;var Zg=Xu.exports;/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ex=S,Ot=Zg;function G(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)n+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Ju=new Set,dr={};function Rs(e,n){bl(e,n),bl(e+"Capture",n)}function bl(e,n){for(dr[e]=n,e=0;e<n.length;e++)Ju.add(n[e])}var Tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qa=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]*$/,fc={},hc={};function nx(e){return Qa.call(hc,e)?!0:Qa.call(fc,e)?!1:tx.test(e)?hc[e]=!0:(fc[e]=!0,!1)}function sx(e,n,s,l){if(s!==null&&s.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function lx(e,n,s,l){if(n===null||typeof n>"u"||sx(e,n,s,l))return!0;if(l)return!1;if(s!==null)switch(s.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function wt(e,n,s,l,r,i,o){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=r,this.mustUseProperty=s,this.propertyName=e,this.type=n,this.sanitizeURL=i,this.removeEmptyString=o}var ft={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ft[e]=new wt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];ft[n]=new wt(n,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ft[e]=new wt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ft[e]=new wt(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){ft[e]=new wt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ft[e]=new wt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ft[e]=new wt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ft[e]=new wt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ft[e]=new wt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Qo=/[\-:]([a-z])/g;function Yo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(Qo,Yo);ft[n]=new wt(n,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(Qo,Yo);ft[n]=new wt(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(Qo,Yo);ft[n]=new wt(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ft[e]=new wt(e,1,!1,e.toLowerCase(),null,!1,!1)});ft.xlinkHref=new wt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ft[e]=new wt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xo(e,n,s,l){var r=ft.hasOwnProperty(n)?ft[n]:null;(r!==null?r.type!==0:l||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(lx(n,s,r,l)&&(s=null),l||r===null?nx(n)&&(s===null?e.removeAttribute(n):e.setAttribute(n,""+s)):r.mustUseProperty?e[r.propertyName]=s===null?r.type===3?!1:"":s:(n=r.attributeName,l=r.attributeNamespace,s===null?e.removeAttribute(n):(r=r.type,s=r===3||r===4&&s===!0?"":""+s,l?e.setAttributeNS(l,n,s):e.setAttribute(n,s))))}var Rn=ex.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$r=Symbol.for("react.element"),nl=Symbol.for("react.portal"),sl=Symbol.for("react.fragment"),qo=Symbol.for("react.strict_mode"),Ya=Symbol.for("react.profiler"),Vu=Symbol.for("react.provider"),Zu=Symbol.for("react.context"),Jo=Symbol.for("react.forward_ref"),Xa=Symbol.for("react.suspense"),qa=Symbol.for("react.suspense_list"),Vo=Symbol.for("react.memo"),Nn=Symbol.for("react.lazy"),ep=Symbol.for("react.offscreen"),gc=Symbol.iterator;function Bl(e){return e===null||typeof e!="object"?null:(e=gc&&e[gc]||e["@@iterator"],typeof e=="function"?e:null)}var Le=Object.assign,ja;function Xl(e){if(ja===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);ja=n&&n[1]||""}return`
`+ja+e}var ba=!1;function Sa(e,n){if(!e||ba)return"";ba=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(c){var l=c}Reflect.construct(e,[],n)}else{try{n.call()}catch(c){l=c}e.call(n.prototype)}else{try{throw Error()}catch(c){l=c}e()}}catch(c){if(c&&l&&typeof c.stack=="string"){for(var r=c.stack.split(`
`),i=l.stack.split(`
`),o=r.length-1,d=i.length-1;1<=o&&0<=d&&r[o]!==i[d];)d--;for(;1<=o&&0<=d;o--,d--)if(r[o]!==i[d]){if(o!==1||d!==1)do if(o--,d--,0>d||r[o]!==i[d]){var u=`
`+r[o].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=o&&0<=d);break}}}finally{ba=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?Xl(e):""}function rx(e){switch(e.tag){case 5:return Xl(e.type);case 16:return Xl("Lazy");case 13:return Xl("Suspense");case 19:return Xl("SuspenseList");case 0:case 2:case 15:return e=Sa(e.type,!1),e;case 11:return e=Sa(e.type.render,!1),e;case 1:return e=Sa(e.type,!0),e;default:return""}}function Ja(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 sl:return"Fragment";case nl:return"Portal";case Ya:return"Profiler";case qo:return"StrictMode";case Xa:return"Suspense";case qa:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Zu:return(e.displayName||"Context")+".Consumer";case Vu:return(e._context.displayName||"Context")+".Provider";case Jo:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Vo:return n=e.displayName||null,n!==null?n:Ja(e.type)||"Memo";case Nn:n=e._payload,e=e._init;try{return Ja(e(n))}catch{}}return null}function ix(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ja(n);case 8:return n===qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function es(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function tp(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function ax(e){var n=tp(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var r=s.get,i=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return r.call(this)},set:function(o){l=""+o,i.call(this,o)}}),Object.defineProperty(e,n,{enumerable:s.enumerable}),{getValue:function(){return l},setValue:function(o){l=""+o},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ur(e){e._valueTracker||(e._valueTracker=ax(e))}function np(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var s=n.getValue(),l="";return e&&(l=tp(e)?e.checked?"true":"false":e.value),e=l,e!==s?(n.setValue(e),!0):!1}function vi(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 Va(e,n){var s=n.checked;return Le({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function xc(e,n){var s=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;s=es(n.value!=null?n.value:s),e._wrapperState={initialChecked:l,initialValue:s,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function sp(e,n){n=n.checked,n!=null&&Xo(e,"checked",n,!1)}function Za(e,n){sp(e,n);var s=es(n.value),l=n.type;if(s!=null)l==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?eo(e,n.type,s):n.hasOwnProperty("defaultValue")&&eo(e,n.type,es(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function mc(e,n,s){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,s||n===e.value||(e.value=n),e.defaultValue=n}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function eo(e,n,s){(n!=="number"||vi(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var ql=Array.isArray;function gl(e,n,s,l){if(e=e.options,n){n={};for(var r=0;r<s.length;r++)n["$"+s[r]]=!0;for(s=0;s<e.length;s++)r=n.hasOwnProperty("$"+e[s].value),e[s].selected!==r&&(e[s].selected=r),r&&l&&(e[s].defaultSelected=!0)}else{for(s=""+es(s),n=null,r=0;r<e.length;r++){if(e[r].value===s){e[r].selected=!0,l&&(e[r].defaultSelected=!0);return}n!==null||e[r].disabled||(n=e[r])}n!==null&&(n.selected=!0)}}function to(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(G(91));return Le({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function yc(e,n){var s=n.value;if(s==null){if(s=n.children,n=n.defaultValue,s!=null){if(n!=null)throw Error(G(92));if(ql(s)){if(1<s.length)throw Error(G(93));s=s[0]}n=s}n==null&&(n=""),s=n}e._wrapperState={initialValue:es(s)}}function lp(e,n){var s=es(n.value),l=es(n.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),n.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),l!=null&&(e.defaultValue=""+l)}function vc(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function rp(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 no(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?rp(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Fr,ip=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,s,l,r){MSApp.execUnsafeLocalFunction(function(){return e(n,s,l,r)})}:e}(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(Fr=Fr||document.createElement("div"),Fr.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Fr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function cr(e,n){if(n){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=n;return}}e.textContent=n}var er={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(er).forEach(function(e){ox.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),er[n]=er[e]})});function ap(e,n,s){return n==null||typeof n=="boolean"||n===""?"":s||typeof n!="number"||n===0||er.hasOwnProperty(e)&&er[e]?(""+n).trim():n+"px"}function op(e,n){e=e.style;for(var s in n)if(n.hasOwnProperty(s)){var l=s.indexOf("--")===0,r=ap(s,n[s],l);s==="float"&&(s="cssFloat"),l?e.setProperty(s,r):e[s]=r}}var dx=Le({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function so(e,n){if(n){if(dx[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(G(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(G(61))}if(n.style!=null&&typeof n.style!="object")throw Error(G(62))}}function lo(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ro=null;function Zo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var io=null,xl=null,ml=null;function jc(e){if(e=Ar(e)){if(typeof io!="function")throw Error(G(280));var n=e.stateNode;n&&(n=Xi(n),io(e.stateNode,e.type,n))}}function dp(e){xl?ml?ml.push(e):ml=[e]:xl=e}function cp(){if(xl){var e=xl,n=ml;if(ml=xl=null,jc(e),n)for(e=0;e<n.length;e++)jc(n[e])}}function up(e,n){return e(n)}function pp(){}var wa=!1;function fp(e,n,s){if(wa)return e(n,s);wa=!0;try{return up(e,n,s)}finally{wa=!1,(xl!==null||ml!==null)&&(pp(),cp())}}function ur(e,n){var s=e.stateNode;if(s===null)return null;var l=Xi(s);if(l===null)return null;s=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(G(231,n,typeof s));return s}var ao=!1;if(Tn)try{var $l={};Object.defineProperty($l,"passive",{get:function(){ao=!0}}),window.addEventListener("test",$l,$l),window.removeEventListener("test",$l,$l)}catch{ao=!1}function cx(e,n,s,l,r,i,o,d,u){var c=Array.prototype.slice.call(arguments,3);try{n.apply(s,c)}catch(_){this.onError(_)}}var tr=!1,ji=null,bi=!1,oo=null,ux={onError:function(e){tr=!0,ji=e}};function px(e,n,s,l,r,i,o,d,u){tr=!1,ji=null,cx.apply(ux,arguments)}function fx(e,n,s,l,r,i,o,d,u){if(px.apply(this,arguments),tr){if(tr){var c=ji;tr=!1,ji=null}else throw Error(G(198));bi||(bi=!0,oo=c)}}function Ds(e){var n=e,s=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,n.flags&4098&&(s=n.return),e=n.return;while(e)}return n.tag===3?s:null}function hp(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function bc(e){if(Ds(e)!==e)throw Error(G(188))}function hx(e){var n=e.alternate;if(!n){if(n=Ds(e),n===null)throw Error(G(188));return n!==e?null:e}for(var s=e,l=n;;){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 bc(r),e;if(i===l)return bc(r),n;i=i.sibling}throw Error(G(188))}if(s.return!==l.return)s=r,l=i;else{for(var o=!1,d=r.child;d;){if(d===s){o=!0,s=r,l=i;break}if(d===l){o=!0,l=r,s=i;break}d=d.sibling}if(!o){for(d=i.child;d;){if(d===s){o=!0,s=i,l=r;break}if(d===l){o=!0,l=i,s=r;break}d=d.sibling}if(!o)throw Error(G(189))}}if(s.alternate!==l)throw Error(G(190))}if(s.tag!==3)throw Error(G(188));return s.stateNode.current===s?e:n}function gp(e){return e=hx(e),e!==null?xp(e):null}function xp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=xp(e);if(n!==null)return n;e=e.sibling}return null}var mp=Ot.unstable_scheduleCallback,Sc=Ot.unstable_cancelCallback,gx=Ot.unstable_shouldYield,xx=Ot.unstable_requestPaint,Xe=Ot.unstable_now,mx=Ot.unstable_getCurrentPriorityLevel,ed=Ot.unstable_ImmediatePriority,yp=Ot.unstable_UserBlockingPriority,Si=Ot.unstable_NormalPriority,yx=Ot.unstable_LowPriority,vp=Ot.unstable_IdlePriority,Gi=null,fn=null;function vx(e){if(fn&&typeof fn.onCommitFiberRoot=="function")try{fn.onCommitFiberRoot(Gi,e,void 0,(e.current.flags&128)===128)}catch{}}var Vt=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 Mr=64,Hr=4194304;function Jl(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 wi(e,n){var s=e.pendingLanes;if(s===0)return 0;var l=0,r=e.suspendedLanes,i=e.pingedLanes,o=s&268435455;if(o!==0){var d=o&~r;d!==0?l=Jl(d):(i&=o,i!==0&&(l=Jl(i)))}else o=s&~r,o!==0?l=Jl(o):i!==0&&(l=Jl(i));if(l===0)return 0;if(n!==0&&n!==l&&!(n&r)&&(r=l&-l,i=n&-n,r>=i||r===16&&(i&4194240)!==0))return n;if(l&4&&(l|=s&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)s=31-Vt(n),r=1<<s,l|=e[s],n&=~r;return l}function wx(e,n){switch(e){case 1:case 2:case 4:return n+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _x(e,n){for(var s=e.suspendedLanes,l=e.pingedLanes,r=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Vt(i),d=1<<o,u=r[o];u===-1?(!(d&s)||d&l)&&(r[o]=wx(d,n)):u<=n&&(e.expiredLanes|=d),i&=~d}}function co(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function jp(){var e=Mr;return Mr<<=1,!(Mr&4194240)&&(Mr=64),e}function _a(e){for(var n=[],s=0;31>s;s++)n.push(e);return n}function Tr(e,n,s){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Vt(n),e[n]=s}function kx(e,n){var s=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<s;){var r=31-Vt(s),i=1<<r;n[r]=0,l[r]=-1,e[r]=-1,s&=~i}}function td(e,n){var s=e.entangledLanes|=n;for(e=e.entanglements;s;){var l=31-Vt(s),r=1<<l;r&n|e[l]&n&&(e[l]|=n),s&=~r}}var je=0;function bp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Sp,nd,wp,_p,kp,uo=!1,Gr=[],Kn=null,Qn=null,Yn=null,pr=new Map,fr=new Map,$n=[],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 wc(e,n){switch(e){case"focusin":case"focusout":Kn=null;break;case"dragenter":case"dragleave":Qn=null;break;case"mouseover":case"mouseout":Yn=null;break;case"pointerover":case"pointerout":pr.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":fr.delete(n.pointerId)}}function Ul(e,n,s,l,r,i){return e===null||e.nativeEvent!==i?(e={blockedOn:n,domEventName:s,eventSystemFlags:l,nativeEvent:i,targetContainers:[r]},n!==null&&(n=Ar(n),n!==null&&nd(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,r!==null&&n.indexOf(r)===-1&&n.push(r),e)}function zx(e,n,s,l,r){switch(n){case"focusin":return Kn=Ul(Kn,e,n,s,l,r),!0;case"dragenter":return Qn=Ul(Qn,e,n,s,l,r),!0;case"mouseover":return Yn=Ul(Yn,e,n,s,l,r),!0;case"pointerover":var i=r.pointerId;return pr.set(i,Ul(pr.get(i)||null,e,n,s,l,r)),!0;case"gotpointercapture":return i=r.pointerId,fr.set(i,Ul(fr.get(i)||null,e,n,s,l,r)),!0}return!1}function Cp(e){var n=Ss(e.target);if(n!==null){var s=Ds(n);if(s!==null){if(n=s.tag,n===13){if(n=hp(s),n!==null){e.blockedOn=n,kp(e.priority,function(){wp(s)});return}}else if(n===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function oi(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var s=po(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var l=new s.constructor(s.type,s);ro=l,s.target.dispatchEvent(l),ro=null}else return n=Ar(s),n!==null&&nd(n),e.blockedOn=s,!1;n.shift()}return!0}function _c(e,n,s){oi(e)&&s.delete(n)}function Ix(){uo=!1,Kn!==null&&oi(Kn)&&(Kn=null),Qn!==null&&oi(Qn)&&(Qn=null),Yn!==null&&oi(Yn)&&(Yn=null),pr.forEach(_c),fr.forEach(_c)}function Fl(e,n){e.blockedOn===n&&(e.blockedOn=null,uo||(uo=!0,Ot.unstable_scheduleCallback(Ot.unstable_NormalPriority,Ix)))}function hr(e){function n(r){return Fl(r,e)}if(0<Gr.length){Fl(Gr[0],e);for(var s=1;s<Gr.length;s++){var l=Gr[s];l.blockedOn===e&&(l.blockedOn=null)}}for(Kn!==null&&Fl(Kn,e),Qn!==null&&Fl(Qn,e),Yn!==null&&Fl(Yn,e),pr.forEach(n),fr.forEach(n),s=0;s<$n.length;s++)l=$n[s],l.blockedOn===e&&(l.blockedOn=null);for(;0<$n.length&&(s=$n[0],s.blockedOn===null);)Cp(s),s.blockedOn===null&&$n.shift()}var yl=Rn.ReactCurrentBatchConfig,_i=!0;function Tx(e,n,s,l){var r=je,i=yl.transition;yl.transition=null;try{je=1,sd(e,n,s,l)}finally{je=r,yl.transition=i}}function Ex(e,n,s,l){var r=je,i=yl.transition;yl.transition=null;try{je=4,sd(e,n,s,l)}finally{je=r,yl.transition=i}}function sd(e,n,s,l){if(_i){var r=po(e,n,s,l);if(r===null)Da(e,n,l,ki,s),wc(e,l);else if(zx(r,e,n,s,l))l.stopPropagation();else if(wc(e,l),n&4&&-1<Cx.indexOf(e)){for(;r!==null;){var i=Ar(r);if(i!==null&&Sp(i),i=po(e,n,s,l),i===null&&Da(e,n,l,ki,s),i===r)break;r=i}r!==null&&l.stopPropagation()}else Da(e,n,l,null,s)}}var ki=null;function po(e,n,s,l){if(ki=null,e=Zo(l),e=Ss(e),e!==null)if(n=Ds(e),n===null)e=null;else if(s=n.tag,s===13){if(e=hp(n),e!==null)return e;e=null}else if(s===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return ki=e,null}function zp(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 ed:return 1;case yp:return 4;case Si:case yx:return 16;case vp:return 536870912;default:return 16}default:return 16}}var Fn=null,ld=null,di=null;function Ip(){if(di)return di;var e,n=ld,s=n.length,l,r="value"in Fn?Fn.value:Fn.textContent,i=r.length;for(e=0;e<s&&n[e]===r[e];e++);var o=s-e;for(l=1;l<=o&&n[s-l]===r[i-l];l++);return di=r.slice(e,1<l?1-l:void 0)}function ci(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function Kr(){return!0}function kc(){return!1}function Wt(e){function n(s,l,r,i,o){this._reactName=s,this._targetInst=r,this.type=l,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var d in e)e.hasOwnProperty(d)&&(s=e[d],this[d]=s?s(i):i[d]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Kr:kc,this.isPropagationStopped=kc,this}return Le(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Kr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Kr)},persist:function(){},isPersistent:Kr}),n}var Al={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rd=Wt(Al),Er=Le({},Al,{view:0,detail:0}),Ax=Wt(Er),ka,Ca,Ml,Ki=Le({},Er,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:id,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!==Ml&&(Ml&&e.type==="mousemove"?(ka=e.screenX-Ml.screenX,Ca=e.screenY-Ml.screenY):Ca=ka=0,Ml=e),ka)},movementY:function(e){return"movementY"in e?e.movementY:Ca}}),Cc=Wt(Ki),Px=Le({},Ki,{dataTransfer:0}),Rx=Wt(Px),Dx=Le({},Er,{relatedTarget:0}),za=Wt(Dx),Ox=Le({},Al,{animationName:0,elapsedTime:0,pseudoElement:0}),Lx=Wt(Ox),Wx=Le({},Al,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Nx=Wt(Wx),Bx=Le({},Al,{data:0}),zc=Wt(Bx),$x={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ux={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Fx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mx(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Fx[e])?!!n[e]:!1}function id(){return Mx}var Hx=Le({},Er,{key:function(e){if(e.key){var n=$x[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ci(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:id,charCode:function(e){return e.type==="keypress"?ci(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ci(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Gx=Wt(Hx),Kx=Le({},Ki,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ic=Wt(Kx),Qx=Le({},Er,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:id}),Yx=Wt(Qx),Xx=Le({},Al,{propertyName:0,elapsedTime:0,pseudoElement:0}),qx=Wt(Xx),Jx=Le({},Ki,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Vx=Wt(Jx),Zx=[9,13,27,32],ad=Tn&&"CompositionEvent"in window,nr=null;Tn&&"documentMode"in document&&(nr=document.documentMode);var em=Tn&&"TextEvent"in window&&!nr,Tp=Tn&&(!ad||nr&&8<nr&&11>=nr),Tc=" ",Ec=!1;function Ep(e,n){switch(e){case"keyup":return Zx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ap(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ll=!1;function tm(e,n){switch(e){case"compositionend":return Ap(n);case"keypress":return n.which!==32?null:(Ec=!0,Tc);case"textInput":return e=n.data,e===Tc&&Ec?null:e;default:return null}}function nm(e,n){if(ll)return e==="compositionend"||!ad&&Ep(e,n)?(e=Ip(),di=ld=Fn=null,ll=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Tp&&n.locale!=="ko"?null:n.data;default:return null}}var sm={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ac(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!sm[e.type]:n==="textarea"}function Pp(e,n,s,l){dp(l),n=Ci(n,"onChange"),0<n.length&&(s=new rd("onChange","change",null,s,l),e.push({event:s,listeners:n}))}var sr=null,gr=null;function lm(e){Mp(e,0)}function Qi(e){var n=al(e);if(np(n))return e}function rm(e,n){if(e==="change")return n}var Rp=!1;if(Tn){var Ia;if(Tn){var Ta="oninput"in document;if(!Ta){var Pc=document.createElement("div");Pc.setAttribute("oninput","return;"),Ta=typeof Pc.oninput=="function"}Ia=Ta}else Ia=!1;Rp=Ia&&(!document.documentMode||9<document.documentMode)}function Rc(){sr&&(sr.detachEvent("onpropertychange",Dp),gr=sr=null)}function Dp(e){if(e.propertyName==="value"&&Qi(gr)){var n=[];Pp(n,gr,e,Zo(e)),fp(lm,n)}}function im(e,n,s){e==="focusin"?(Rc(),sr=n,gr=s,sr.attachEvent("onpropertychange",Dp)):e==="focusout"&&Rc()}function am(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Qi(gr)}function om(e,n){if(e==="click")return Qi(n)}function dm(e,n){if(e==="input"||e==="change")return Qi(n)}function cm(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var en=typeof Object.is=="function"?Object.is:cm;function xr(e,n){if(en(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var s=Object.keys(e),l=Object.keys(n);if(s.length!==l.length)return!1;for(l=0;l<s.length;l++){var r=s[l];if(!Qa.call(n,r)||!en(e[r],n[r]))return!1}return!0}function Dc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Oc(e,n){var s=Dc(e);e=0;for(var l;s;){if(s.nodeType===3){if(l=e+s.textContent.length,e<=n&&l>=n)return{node:s,offset:n-e};e=l}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Dc(s)}}function Op(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Op(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Lp(){for(var e=window,n=vi();n instanceof e.HTMLIFrameElement;){try{var s=typeof n.contentWindow.location.href=="string"}catch{s=!1}if(s)e=n.contentWindow;else break;n=vi(e.document)}return n}function od(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function um(e){var n=Lp(),s=e.focusedElem,l=e.selectionRange;if(n!==s&&s&&s.ownerDocument&&Op(s.ownerDocument.documentElement,s)){if(l!==null&&od(s)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in s)s.selectionStart=n,s.selectionEnd=Math.min(e,s.value.length);else if(e=(n=s.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var r=s.textContent.length,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=Oc(s,i);var o=Oc(s,l);r&&o&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(n=n.createRange(),n.setStart(r.node,r.offset),e.removeAllRanges(),i>l?(e.addRange(n),e.extend(o.node,o.offset)):(n.setEnd(o.node,o.offset),e.addRange(n)))}}for(n=[],e=s;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<n.length;s++)e=n[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var pm=Tn&&"documentMode"in document&&11>=document.documentMode,rl=null,fo=null,lr=null,ho=!1;function Lc(e,n,s){var l=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;ho||rl==null||rl!==vi(l)||(l=rl,"selectionStart"in l&&od(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}),lr&&xr(lr,l)||(lr=l,l=Ci(fo,"onSelect"),0<l.length&&(n=new rd("onSelect","select",null,n,s),e.push({event:n,listeners:l}),n.target=rl)))}function Qr(e,n){var s={};return s[e.toLowerCase()]=n.toLowerCase(),s["Webkit"+e]="webkit"+n,s["Moz"+e]="moz"+n,s}var il={animationend:Qr("Animation","AnimationEnd"),animationiteration:Qr("Animation","AnimationIteration"),animationstart:Qr("Animation","AnimationStart"),transitionend:Qr("Transition","TransitionEnd")},Ea={},Wp={};Tn&&(Wp=document.createElement("div").style,"AnimationEvent"in window||(delete il.animationend.animation,delete il.animationiteration.animation,delete il.animationstart.animation),"TransitionEvent"in window||delete il.transitionend.transition);function Yi(e){if(Ea[e])return Ea[e];if(!il[e])return e;var n=il[e],s;for(s in n)if(n.hasOwnProperty(s)&&s in Wp)return Ea[e]=n[s];return e}var Np=Yi("animationend"),Bp=Yi("animationiteration"),$p=Yi("animationstart"),Up=Yi("transitionend"),Fp=new Map,Wc="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 ss(e,n){Fp.set(e,n),Rs(n,[e])}for(var Aa=0;Aa<Wc.length;Aa++){var Pa=Wc[Aa],fm=Pa.toLowerCase(),hm=Pa[0].toUpperCase()+Pa.slice(1);ss(fm,"on"+hm)}ss(Np,"onAnimationEnd");ss(Bp,"onAnimationIteration");ss($p,"onAnimationStart");ss("dblclick","onDoubleClick");ss("focusin","onFocus");ss("focusout","onBlur");ss(Up,"onTransitionEnd");bl("onMouseEnter",["mouseout","mouseover"]);bl("onMouseLeave",["mouseout","mouseover"]);bl("onPointerEnter",["pointerout","pointerover"]);bl("onPointerLeave",["pointerout","pointerover"]);Rs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Rs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Rs("onBeforeInput",["compositionend","keypress","textInput","paste"]);Rs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Rs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Rs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vl="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(Vl));function Nc(e,n,s){var l=e.type||"unknown-event";e.currentTarget=s,fx(l,n,void 0,e),e.currentTarget=null}function Mp(e,n){n=(n&4)!==0;for(var s=0;s<e.length;s++){var l=e[s],r=l.event;l=l.listeners;e:{var i=void 0;if(n)for(var o=l.length-1;0<=o;o--){var d=l[o],u=d.instance,c=d.currentTarget;if(d=d.listener,u!==i&&r.isPropagationStopped())break e;Nc(r,d,c),i=u}else for(o=0;o<l.length;o++){if(d=l[o],u=d.instance,c=d.currentTarget,d=d.listener,u!==i&&r.isPropagationStopped())break e;Nc(r,d,c),i=u}}}if(bi)throw e=oo,bi=!1,oo=null,e}function Ce(e,n){var s=n[vo];s===void 0&&(s=n[vo]=new Set);var l=e+"__bubble";s.has(l)||(Hp(n,e,2,!1),s.add(l))}function Ra(e,n,s){var l=0;n&&(l|=4),Hp(s,e,l,n)}var Yr="_reactListening"+Math.random().toString(36).slice(2);function mr(e){if(!e[Yr]){e[Yr]=!0,Ju.forEach(function(s){s!=="selectionchange"&&(gm.has(s)||Ra(s,!1,e),Ra(s,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Yr]||(n[Yr]=!0,Ra("selectionchange",!1,n))}}function Hp(e,n,s,l){switch(zp(n)){case 1:var r=Tx;break;case 4:r=Ex;break;default:r=sd}s=r.bind(null,n,s,e),r=void 0,!ao||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(r=!0),l?r!==void 0?e.addEventListener(n,s,{capture:!0,passive:r}):e.addEventListener(n,s,!0):r!==void 0?e.addEventListener(n,s,{passive:r}):e.addEventListener(n,s,!1)}function Da(e,n,s,l,r){var i=l;if(!(n&1)&&!(n&2)&&l!==null)e:for(;;){if(l===null)return;var o=l.tag;if(o===3||o===4){var d=l.stateNode.containerInfo;if(d===r||d.nodeType===8&&d.parentNode===r)break;if(o===4)for(o=l.return;o!==null;){var u=o.tag;if((u===3||u===4)&&(u=o.stateNode.containerInfo,u===r||u.nodeType===8&&u.parentNode===r))return;o=o.return}for(;d!==null;){if(o=Ss(d),o===null)return;if(u=o.tag,u===5||u===6){l=i=o;continue e}d=d.parentNode}}l=l.return}fp(function(){var c=i,_=Zo(s),m=[];e:{var y=Fp.get(e);if(y!==void 0){var h=rd,b=e;switch(e){case"keypress":if(ci(s)===0)break e;case"keydown":case"keyup":h=Gx;break;case"focusin":b="focus",h=za;break;case"focusout":b="blur",h=za;break;case"beforeblur":case"afterblur":h=za;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=Cc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=Rx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=Yx;break;case Np:case Bp:case $p:h=Lx;break;case Up:h=qx;break;case"scroll":h=Ax;break;case"wheel":h=Vx;break;case"copy":case"cut":case"paste":h=Nx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Ic}var z=(n&4)!==0,j=!z&&e==="scroll",f=z?y!==null?y+"Capture":null:y;z=[];for(var a=c,x;a!==null;){x=a;var g=x.stateNode;if(x.tag===5&&g!==null&&(x=g,f!==null&&(g=ur(a,f),g!=null&&z.push(yr(a,g,x)))),j)break;a=a.return}0<z.length&&(y=new h(y,b,null,s,_),m.push({event:y,listeners:z}))}}if(!(n&7)){e:{if(y=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",y&&s!==ro&&(b=s.relatedTarget||s.fromElement)&&(Ss(b)||b[En]))break e;if((h||y)&&(y=_.window===_?_:(y=_.ownerDocument)?y.defaultView||y.parentWindow:window,h?(b=s.relatedTarget||s.toElement,h=c,b=b?Ss(b):null,b!==null&&(j=Ds(b),b!==j||b.tag!==5&&b.tag!==6)&&(b=null)):(h=null,b=c),h!==b)){if(z=Cc,g="onMouseLeave",f="onMouseEnter",a="mouse",(e==="pointerout"||e==="pointerover")&&(z=Ic,g="onPointerLeave",f="onPointerEnter",a="pointer"),j=h==null?y:al(h),x=b==null?y:al(b),y=new z(g,a+"leave",h,s,_),y.target=j,y.relatedTarget=x,g=null,Ss(_)===c&&(z=new z(f,a+"enter",b,s,_),z.target=x,z.relatedTarget=j,g=z),j=g,h&&b)t:{for(z=h,f=b,a=0,x=z;x;x=Ks(x))a++;for(x=0,g=f;g;g=Ks(g))x++;for(;0<a-x;)z=Ks(z),a--;for(;0<x-a;)f=Ks(f),x--;for(;a--;){if(z===f||f!==null&&z===f.alternate)break t;z=Ks(z),f=Ks(f)}z=null}else z=null;h!==null&&Bc(m,y,h,z,!1),b!==null&&j!==null&&Bc(m,j,b,z,!0)}}e:{if(y=c?al(c):window,h=y.nodeName&&y.nodeName.toLowerCase(),h==="select"||h==="input"&&y.type==="file")var C=rm;else if(Ac(y))if(Rp)C=dm;else{C=am;var w=im}else(h=y.nodeName)&&h.toLowerCase()==="input"&&(y.type==="checkbox"||y.type==="radio")&&(C=om);if(C&&(C=C(e,c))){Pp(m,C,s,_);break e}w&&w(e,y,c),e==="focusout"&&(w=y._wrapperState)&&w.controlled&&y.type==="number"&&eo(y,"number",y.value)}switch(w=c?al(c):window,e){case"focusin":(Ac(w)||w.contentEditable==="true")&&(rl=w,fo=c,lr=null);break;case"focusout":lr=fo=rl=null;break;case"mousedown":ho=!0;break;case"contextmenu":case"mouseup":case"dragend":ho=!1,Lc(m,s,_);break;case"selectionchange":if(pm)break;case"keydown":case"keyup":Lc(m,s,_)}var p;if(ad)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else ll?Ep(e,s)&&(k="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(k="onCompositionStart");k&&(Tp&&s.locale!=="ko"&&(ll||k!=="onCompositionStart"?k==="onCompositionEnd"&&ll&&(p=Ip()):(Fn=_,ld="value"in Fn?Fn.value:Fn.textContent,ll=!0)),w=Ci(c,k),0<w.length&&(k=new zc(k,e,null,s,_),m.push({event:k,listeners:w}),p?k.data=p:(p=Ap(s),p!==null&&(k.data=p)))),(p=em?tm(e,s):nm(e,s))&&(c=Ci(c,"onBeforeInput"),0<c.length&&(_=new zc("onBeforeInput","beforeinput",null,s,_),m.push({event:_,listeners:c}),_.data=p))}Mp(m,n)})}function yr(e,n,s){return{instance:e,listener:n,currentTarget:s}}function Ci(e,n){for(var s=n+"Capture",l=[];e!==null;){var r=e,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=ur(e,s),i!=null&&l.unshift(yr(e,i,r)),i=ur(e,n),i!=null&&l.push(yr(e,i,r))),e=e.return}return l}function Ks(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Bc(e,n,s,l,r){for(var i=n._reactName,o=[];s!==null&&s!==l;){var d=s,u=d.alternate,c=d.stateNode;if(u!==null&&u===l)break;d.tag===5&&c!==null&&(d=c,r?(u=ur(s,i),u!=null&&o.unshift(yr(s,u,d))):r||(u=ur(s,i),u!=null&&o.push(yr(s,u,d)))),s=s.return}o.length!==0&&e.push({event:n,listeners:o})}var xm=/\r\n?/g,mm=/\u0000|\uFFFD/g;function $c(e){return(typeof e=="string"?e:""+e).replace(xm,`
`).replace(mm,"")}function Xr(e,n,s){if(n=$c(n),$c(e)!==n&&s)throw Error(G(425))}function zi(){}var go=null,xo=null;function mo(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var yo=typeof setTimeout=="function"?setTimeout:void 0,ym=typeof clearTimeout=="function"?clearTimeout:void 0,Uc=typeof Promise=="function"?Promise:void 0,vm=typeof queueMicrotask=="function"?queueMicrotask:typeof Uc<"u"?function(e){return Uc.resolve(null).then(e).catch(jm)}:yo;function jm(e){setTimeout(function(){throw e})}function Oa(e,n){var s=n,l=0;do{var r=s.nextSibling;if(e.removeChild(s),r&&r.nodeType===8)if(s=r.data,s==="/$"){if(l===0){e.removeChild(r),hr(n);return}l--}else s!=="$"&&s!=="$?"&&s!=="$!"||l++;s=r}while(s);hr(n)}function Xn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function Fc(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(n===0)return e;n--}else s==="/$"&&n++}e=e.previousSibling}return null}var Pl=Math.random().toString(36).slice(2),pn="__reactFiber$"+Pl,vr="__reactProps$"+Pl,En="__reactContainer$"+Pl,vo="__reactEvents$"+Pl,bm="__reactListeners$"+Pl,Sm="__reactHandles$"+Pl;function Ss(e){var n=e[pn];if(n)return n;for(var s=e.parentNode;s;){if(n=s[En]||s[pn]){if(s=n.alternate,n.child!==null||s!==null&&s.child!==null)for(e=Fc(e);e!==null;){if(s=e[pn])return s;e=Fc(e)}return n}e=s,s=e.parentNode}return null}function Ar(e){return e=e[pn]||e[En],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function al(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(G(33))}function Xi(e){return e[vr]||null}var jo=[],ol=-1;function ls(e){return{current:e}}function ze(e){0>ol||(e.current=jo[ol],jo[ol]=null,ol--)}function we(e,n){ol++,jo[ol]=e.current,e.current=n}var ts={},yt=ls(ts),Ct=ls(!1),zs=ts;function Sl(e,n){var s=e.type.contextTypes;if(!s)return ts;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var r={},i;for(i in s)r[i]=n[i];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=r),r}function zt(e){return e=e.childContextTypes,e!=null}function Ii(){ze(Ct),ze(yt)}function Mc(e,n,s){if(yt.current!==ts)throw Error(G(168));we(yt,n),we(Ct,s)}function Gp(e,n,s){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return s;l=l.getChildContext();for(var r in l)if(!(r in n))throw Error(G(108,ix(e)||"Unknown",r));return Le({},s,l)}function Ti(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ts,zs=yt.current,we(yt,e),we(Ct,Ct.current),!0}function Hc(e,n,s){var l=e.stateNode;if(!l)throw Error(G(169));s?(e=Gp(e,n,zs),l.__reactInternalMemoizedMergedChildContext=e,ze(Ct),ze(yt),we(yt,e)):ze(Ct),we(Ct,s)}var kn=null,qi=!1,La=!1;function Kp(e){kn===null?kn=[e]:kn.push(e)}function wm(e){qi=!0,Kp(e)}function rs(){if(!La&&kn!==null){La=!0;var e=0,n=je;try{var s=kn;for(je=1;e<s.length;e++){var l=s[e];do l=l(!0);while(l!==null)}kn=null,qi=!1}catch(r){throw kn!==null&&(kn=kn.slice(e+1)),mp(ed,rs),r}finally{je=n,La=!1}}return null}var dl=[],cl=0,Ei=null,Ai=0,Bt=[],$t=0,Is=null,Cn=1,zn="";function js(e,n){dl[cl++]=Ai,dl[cl++]=Ei,Ei=e,Ai=n}function Qp(e,n,s){Bt[$t++]=Cn,Bt[$t++]=zn,Bt[$t++]=Is,Is=e;var l=Cn;e=zn;var r=32-Vt(l)-1;l&=~(1<<r),s+=1;var i=32-Vt(n)+r;if(30<i){var o=r-r%5;i=(l&(1<<o)-1).toString(32),l>>=o,r-=o,Cn=1<<32-Vt(n)+r|s<<r|l,zn=i+e}else Cn=1<<i|s<<r|l,zn=e}function dd(e){e.return!==null&&(js(e,1),Qp(e,1,0))}function cd(e){for(;e===Ei;)Ei=dl[--cl],dl[cl]=null,Ai=dl[--cl],dl[cl]=null;for(;e===Is;)Is=Bt[--$t],Bt[$t]=null,zn=Bt[--$t],Bt[$t]=null,Cn=Bt[--$t],Bt[$t]=null}var Dt=null,Rt=null,Ae=!1,Jt=null;function Yp(e,n){var s=Ut(5,null,null,0);s.elementType="DELETED",s.stateNode=n,s.return=e,n=e.deletions,n===null?(e.deletions=[s],e.flags|=16):n.push(s)}function Gc(e,n){switch(e.tag){case 5:var s=e.type;return n=n.nodeType!==1||s.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,Dt=e,Rt=Xn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Dt=e,Rt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(s=Is!==null?{id:Cn,overflow:zn}:null,e.memoizedState={dehydrated:n,treeContext:s,retryLane:1073741824},s=Ut(18,null,null,0),s.stateNode=n,s.return=e,e.child=s,Dt=e,Rt=null,!0):!1;default:return!1}}function bo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function So(e){if(Ae){var n=Rt;if(n){var s=n;if(!Gc(e,n)){if(bo(e))throw Error(G(418));n=Xn(s.nextSibling);var l=Dt;n&&Gc(e,n)?Yp(l,s):(e.flags=e.flags&-4097|2,Ae=!1,Dt=e)}}else{if(bo(e))throw Error(G(418));e.flags=e.flags&-4097|2,Ae=!1,Dt=e}}}function Kc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Dt=e}function qr(e){if(e!==Dt)return!1;if(!Ae)return Kc(e),Ae=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!mo(e.type,e.memoizedProps)),n&&(n=Rt)){if(bo(e))throw Xp(),Error(G(418));for(;n;)Yp(e,n),n=Xn(n.nextSibling)}if(Kc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(G(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(n===0){Rt=Xn(e.nextSibling);break e}n--}else s!=="$"&&s!=="$!"&&s!=="$?"||n++}e=e.nextSibling}Rt=null}}else Rt=Dt?Xn(e.stateNode.nextSibling):null;return!0}function Xp(){for(var e=Rt;e;)e=Xn(e.nextSibling)}function wl(){Rt=Dt=null,Ae=!1}function ud(e){Jt===null?Jt=[e]:Jt.push(e)}var _m=Rn.ReactCurrentBatchConfig;function Hl(e,n,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(G(309));var l=s.stateNode}if(!l)throw Error(G(147,e));var r=l,i=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===i?n.ref:(n=function(o){var d=r.refs;o===null?delete d[i]:d[i]=o},n._stringRef=i,n)}if(typeof e!="string")throw Error(G(284));if(!s._owner)throw Error(G(290,e))}return e}function Jr(e,n){throw e=Object.prototype.toString.call(n),Error(G(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function Qc(e){var n=e._init;return n(e._payload)}function qp(e){function n(f,a){if(e){var x=f.deletions;x===null?(f.deletions=[a],f.flags|=16):x.push(a)}}function s(f,a){if(!e)return null;for(;a!==null;)n(f,a),a=a.sibling;return null}function l(f,a){for(f=new Map;a!==null;)a.key!==null?f.set(a.key,a):f.set(a.index,a),a=a.sibling;return f}function r(f,a){return f=Zn(f,a),f.index=0,f.sibling=null,f}function i(f,a,x){return f.index=x,e?(x=f.alternate,x!==null?(x=x.index,x<a?(f.flags|=2,a):x):(f.flags|=2,a)):(f.flags|=1048576,a)}function o(f){return e&&f.alternate===null&&(f.flags|=2),f}function d(f,a,x,g){return a===null||a.tag!==6?(a=Ma(x,f.mode,g),a.return=f,a):(a=r(a,x),a.return=f,a)}function u(f,a,x,g){var C=x.type;return C===sl?_(f,a,x.props.children,g,x.key):a!==null&&(a.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Nn&&Qc(C)===a.type)?(g=r(a,x.props),g.ref=Hl(f,a,x),g.return=f,g):(g=mi(x.type,x.key,x.props,null,f.mode,g),g.ref=Hl(f,a,x),g.return=f,g)}function c(f,a,x,g){return a===null||a.tag!==4||a.stateNode.containerInfo!==x.containerInfo||a.stateNode.implementation!==x.implementation?(a=Ha(x,f.mode,g),a.return=f,a):(a=r(a,x.children||[]),a.return=f,a)}function _(f,a,x,g,C){return a===null||a.tag!==7?(a=Cs(x,f.mode,g,C),a.return=f,a):(a=r(a,x),a.return=f,a)}function m(f,a,x){if(typeof a=="string"&&a!==""||typeof a=="number")return a=Ma(""+a,f.mode,x),a.return=f,a;if(typeof a=="object"&&a!==null){switch(a.$$typeof){case $r:return x=mi(a.type,a.key,a.props,null,f.mode,x),x.ref=Hl(f,null,a),x.return=f,x;case nl:return a=Ha(a,f.mode,x),a.return=f,a;case Nn:var g=a._init;return m(f,g(a._payload),x)}if(ql(a)||Bl(a))return a=Cs(a,f.mode,x,null),a.return=f,a;Jr(f,a)}return null}function y(f,a,x,g){var C=a!==null?a.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return C!==null?null:d(f,a,""+x,g);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case $r:return x.key===C?u(f,a,x,g):null;case nl:return x.key===C?c(f,a,x,g):null;case Nn:return C=x._init,y(f,a,C(x._payload),g)}if(ql(x)||Bl(x))return C!==null?null:_(f,a,x,g,null);Jr(f,x)}return null}function h(f,a,x,g,C){if(typeof g=="string"&&g!==""||typeof g=="number")return f=f.get(x)||null,d(a,f,""+g,C);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case $r:return f=f.get(g.key===null?x:g.key)||null,u(a,f,g,C);case nl:return f=f.get(g.key===null?x:g.key)||null,c(a,f,g,C);case Nn:var w=g._init;return h(f,a,x,w(g._payload),C)}if(ql(g)||Bl(g))return f=f.get(x)||null,_(a,f,g,C,null);Jr(a,g)}return null}function b(f,a,x,g){for(var C=null,w=null,p=a,k=a=0,T=null;p!==null&&k<x.length;k++){p.index>k?(T=p,p=null):T=p.sibling;var A=y(f,p,x[k],g);if(A===null){p===null&&(p=T);break}e&&p&&A.alternate===null&&n(f,p),a=i(A,a,k),w===null?C=A:w.sibling=A,w=A,p=T}if(k===x.length)return s(f,p),Ae&&js(f,k),C;if(p===null){for(;k<x.length;k++)p=m(f,x[k],g),p!==null&&(a=i(p,a,k),w===null?C=p:w.sibling=p,w=p);return Ae&&js(f,k),C}for(p=l(f,p);k<x.length;k++)T=h(p,f,k,x[k],g),T!==null&&(e&&T.alternate!==null&&p.delete(T.key===null?k:T.key),a=i(T,a,k),w===null?C=T:w.sibling=T,w=T);return e&&p.forEach(function(Q){return n(f,Q)}),Ae&&js(f,k),C}function z(f,a,x,g){var C=Bl(x);if(typeof C!="function")throw Error(G(150));if(x=C.call(x),x==null)throw Error(G(151));for(var w=C=null,p=a,k=a=0,T=null,A=x.next();p!==null&&!A.done;k++,A=x.next()){p.index>k?(T=p,p=null):T=p.sibling;var Q=y(f,p,A.value,g);if(Q===null){p===null&&(p=T);break}e&&p&&Q.alternate===null&&n(f,p),a=i(Q,a,k),w===null?C=Q:w.sibling=Q,w=Q,p=T}if(A.done)return s(f,p),Ae&&js(f,k),C;if(p===null){for(;!A.done;k++,A=x.next())A=m(f,A.value,g),A!==null&&(a=i(A,a,k),w===null?C=A:w.sibling=A,w=A);return Ae&&js(f,k),C}for(p=l(f,p);!A.done;k++,A=x.next())A=h(p,f,k,A.value,g),A!==null&&(e&&A.alternate!==null&&p.delete(A.key===null?k:A.key),a=i(A,a,k),w===null?C=A:w.sibling=A,w=A);return e&&p.forEach(function(J){return n(f,J)}),Ae&&js(f,k),C}function j(f,a,x,g){if(typeof x=="object"&&x!==null&&x.type===sl&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case $r:e:{for(var C=x.key,w=a;w!==null;){if(w.key===C){if(C=x.type,C===sl){if(w.tag===7){s(f,w.sibling),a=r(w,x.props.children),a.return=f,f=a;break e}}else if(w.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Nn&&Qc(C)===w.type){s(f,w.sibling),a=r(w,x.props),a.ref=Hl(f,w,x),a.return=f,f=a;break e}s(f,w);break}else n(f,w);w=w.sibling}x.type===sl?(a=Cs(x.props.children,f.mode,g,x.key),a.return=f,f=a):(g=mi(x.type,x.key,x.props,null,f.mode,g),g.ref=Hl(f,a,x),g.return=f,f=g)}return o(f);case nl:e:{for(w=x.key;a!==null;){if(a.key===w)if(a.tag===4&&a.stateNode.containerInfo===x.containerInfo&&a.stateNode.implementation===x.implementation){s(f,a.sibling),a=r(a,x.children||[]),a.return=f,f=a;break e}else{s(f,a);break}else n(f,a);a=a.sibling}a=Ha(x,f.mode,g),a.return=f,f=a}return o(f);case Nn:return w=x._init,j(f,a,w(x._payload),g)}if(ql(x))return b(f,a,x,g);if(Bl(x))return z(f,a,x,g);Jr(f,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,a!==null&&a.tag===6?(s(f,a.sibling),a=r(a,x),a.return=f,f=a):(s(f,a),a=Ma(x,f.mode,g),a.return=f,f=a),o(f)):s(f,a)}return j}var _l=qp(!0),Jp=qp(!1),Pi=ls(null),Ri=null,ul=null,pd=null;function fd(){pd=ul=Ri=null}function hd(e){var n=Pi.current;ze(Pi),e._currentValue=n}function wo(e,n,s){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===s)break;e=e.return}}function vl(e,n){Ri=e,pd=ul=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&n&&(kt=!0),e.firstContext=null)}function Mt(e){var n=e._currentValue;if(pd!==e)if(e={context:e,memoizedValue:n,next:null},ul===null){if(Ri===null)throw Error(G(308));ul=e,Ri.dependencies={lanes:0,firstContext:e}}else ul=ul.next=e;return n}var ws=null;function gd(e){ws===null?ws=[e]:ws.push(e)}function Vp(e,n,s,l){var r=n.interleaved;return r===null?(s.next=s,gd(n)):(s.next=r.next,r.next=s),n.interleaved=s,An(e,l)}function An(e,n){e.lanes|=n;var s=e.alternate;for(s!==null&&(s.lanes|=n),s=e,e=e.return;e!==null;)e.childLanes|=n,s=e.alternate,s!==null&&(s.childLanes|=n),s=e,e=e.return;return s.tag===3?s.stateNode:null}var Bn=!1;function xd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Zp(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function In(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function qn(e,n,s){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,ge&2){var r=l.pending;return r===null?n.next=n:(n.next=r.next,r.next=n),l.pending=n,An(e,s)}return r=l.interleaved,r===null?(n.next=n,gd(l)):(n.next=r.next,r.next=n),l.interleaved=n,An(e,s)}function ui(e,n,s){if(n=n.updateQueue,n!==null&&(n=n.shared,(s&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,td(e,s)}}function Yc(e,n){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 o={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};i===null?r=i=o:i=i.next=o,s=s.next}while(s!==null);i===null?r=i=n:i=i.next=n}else r=i=n;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=n:e.next=n,s.lastBaseUpdate=n}function Di(e,n,s,l){var r=e.updateQueue;Bn=!1;var i=r.firstBaseUpdate,o=r.lastBaseUpdate,d=r.shared.pending;if(d!==null){r.shared.pending=null;var u=d,c=u.next;u.next=null,o===null?i=c:o.next=c,o=u;var _=e.alternate;_!==null&&(_=_.updateQueue,d=_.lastBaseUpdate,d!==o&&(d===null?_.firstBaseUpdate=c:d.next=c,_.lastBaseUpdate=u))}if(i!==null){var m=r.baseState;o=0,_=c=u=null,d=i;do{var y=d.lane,h=d.eventTime;if((l&y)===y){_!==null&&(_=_.next={eventTime:h,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var b=e,z=d;switch(y=n,h=s,z.tag){case 1:if(b=z.payload,typeof b=="function"){m=b.call(h,m,y);break e}m=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=z.payload,y=typeof b=="function"?b.call(h,m,y):b,y==null)break e;m=Le({},m,y);break e;case 2:Bn=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,y=r.effects,y===null?r.effects=[d]:y.push(d))}else h={eventTime:h,lane:y,tag:d.tag,payload:d.payload,callback:d.callback,next:null},_===null?(c=_=h,u=m):_=_.next=h,o|=y;if(d=d.next,d===null){if(d=r.shared.pending,d===null)break;y=d,d=y.next,y.next=null,r.lastBaseUpdate=y,r.shared.pending=null}}while(!0);if(_===null&&(u=m),r.baseState=u,r.firstBaseUpdate=c,r.lastBaseUpdate=_,n=r.shared.interleaved,n!==null){r=n;do o|=r.lane,r=r.next;while(r!==n)}else i===null&&(r.shared.lanes=0);Es|=o,e.lanes=o,e.memoizedState=m}}function Xc(e,n,s){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],r=l.callback;if(r!==null){if(l.callback=null,l=s,typeof r!="function")throw Error(G(191,r));r.call(l)}}}var Pr={},hn=ls(Pr),jr=ls(Pr),br=ls(Pr);function _s(e){if(e===Pr)throw Error(G(174));return e}function md(e,n){switch(we(br,n),we(jr,e),we(hn,Pr),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:no(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=no(n,e)}ze(hn),we(hn,n)}function kl(){ze(hn),ze(jr),ze(br)}function ef(e){_s(br.current);var n=_s(hn.current),s=no(n,e.type);n!==s&&(we(jr,e),we(hn,s))}function yd(e){jr.current===e&&(ze(hn),ze(jr))}var De=ls(0);function Oi(e){for(var n=e;n!==null;){if(n.tag===13){var s=n.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if(n.flags&128)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Wa=[];function vd(){for(var e=0;e<Wa.length;e++)Wa[e]._workInProgressVersionPrimary=null;Wa.length=0}var pi=Rn.ReactCurrentDispatcher,Na=Rn.ReactCurrentBatchConfig,Ts=0,Oe=null,lt=null,at=null,Li=!1,rr=!1,Sr=0,km=0;function gt(){throw Error(G(321))}function jd(e,n){if(n===null)return!1;for(var s=0;s<n.length&&s<e.length;s++)if(!en(e[s],n[s]))return!1;return!0}function bd(e,n,s,l,r,i){if(Ts=i,Oe=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,pi.current=e===null||e.memoizedState===null?Tm:Em,e=s(l,r),rr){i=0;do{if(rr=!1,Sr=0,25<=i)throw Error(G(301));i+=1,at=lt=null,n.updateQueue=null,pi.current=Am,e=s(l,r)}while(rr)}if(pi.current=Wi,n=lt!==null&&lt.next!==null,Ts=0,at=lt=Oe=null,Li=!1,n)throw Error(G(300));return e}function Sd(){var e=Sr!==0;return Sr=0,e}function un(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return at===null?Oe.memoizedState=at=e:at=at.next=e,at}function Ht(){if(lt===null){var e=Oe.alternate;e=e!==null?e.memoizedState:null}else e=lt.next;var n=at===null?Oe.memoizedState:at.next;if(n!==null)at=n,lt=e;else{if(e===null)throw Error(G(310));lt=e,e={memoizedState:lt.memoizedState,baseState:lt.baseState,baseQueue:lt.baseQueue,queue:lt.queue,next:null},at===null?Oe.memoizedState=at=e:at=at.next=e}return at}function wr(e,n){return typeof n=="function"?n(e):n}function Ba(e){var n=Ht(),s=n.queue;if(s===null)throw Error(G(311));s.lastRenderedReducer=e;var l=lt,r=l.baseQueue,i=s.pending;if(i!==null){if(r!==null){var o=r.next;r.next=i.next,i.next=o}l.baseQueue=r=i,s.pending=null}if(r!==null){i=r.next,l=l.baseState;var d=o=null,u=null,c=i;do{var _=c.lane;if((Ts&_)===_)u!==null&&(u=u.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),l=c.hasEagerState?c.eagerState:e(l,c.action);else{var m={lane:_,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};u===null?(d=u=m,o=l):u=u.next=m,Oe.lanes|=_,Es|=_}c=c.next}while(c!==null&&c!==i);u===null?o=l:u.next=d,en(l,n.memoizedState)||(kt=!0),n.memoizedState=l,n.baseState=o,n.baseQueue=u,s.lastRenderedState=l}if(e=s.interleaved,e!==null){r=e;do i=r.lane,Oe.lanes|=i,Es|=i,r=r.next;while(r!==e)}else r===null&&(s.lanes=0);return[n.memoizedState,s.dispatch]}function $a(e){var n=Ht(),s=n.queue;if(s===null)throw Error(G(311));s.lastRenderedReducer=e;var l=s.dispatch,r=s.pending,i=n.memoizedState;if(r!==null){s.pending=null;var o=r=r.next;do i=e(i,o.action),o=o.next;while(o!==r);en(i,n.memoizedState)||(kt=!0),n.memoizedState=i,n.baseQueue===null&&(n.baseState=i),s.lastRenderedState=i}return[i,l]}function tf(){}function nf(e,n){var s=Oe,l=Ht(),r=n(),i=!en(l.memoizedState,r);if(i&&(l.memoizedState=r,kt=!0),l=l.queue,wd(rf.bind(null,s,l,e),[e]),l.getSnapshot!==n||i||at!==null&&at.memoizedState.tag&1){if(s.flags|=2048,_r(9,lf.bind(null,s,l,r,n),void 0,null),ot===null)throw Error(G(349));Ts&30||sf(s,n,r)}return r}function sf(e,n,s){e.flags|=16384,e={getSnapshot:n,value:s},n=Oe.updateQueue,n===null?(n={lastEffect:null,stores:null},Oe.updateQueue=n,n.stores=[e]):(s=n.stores,s===null?n.stores=[e]:s.push(e))}function lf(e,n,s,l){n.value=s,n.getSnapshot=l,af(n)&&of(e)}function rf(e,n,s){return s(function(){af(n)&&of(e)})}function af(e){var n=e.getSnapshot;e=e.value;try{var s=n();return!en(e,s)}catch{return!0}}function of(e){var n=An(e,1);n!==null&&Zt(n,e,1,-1)}function qc(e){var n=un();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:e},n.queue=e,e=e.dispatch=Im.bind(null,Oe,e),[n.memoizedState,e]}function _r(e,n,s,l){return e={tag:e,create:n,destroy:s,deps:l,next:null},n=Oe.updateQueue,n===null?(n={lastEffect:null,stores:null},Oe.updateQueue=n,n.lastEffect=e.next=e):(s=n.lastEffect,s===null?n.lastEffect=e.next=e:(l=s.next,s.next=e,e.next=l,n.lastEffect=e)),e}function df(){return Ht().memoizedState}function fi(e,n,s,l){var r=un();Oe.flags|=e,r.memoizedState=_r(1|n,s,void 0,l===void 0?null:l)}function Ji(e,n,s,l){var r=Ht();l=l===void 0?null:l;var i=void 0;if(lt!==null){var o=lt.memoizedState;if(i=o.destroy,l!==null&&jd(l,o.deps)){r.memoizedState=_r(n,s,i,l);return}}Oe.flags|=e,r.memoizedState=_r(1|n,s,i,l)}function Jc(e,n){return fi(8390656,8,e,n)}function wd(e,n){return Ji(2048,8,e,n)}function cf(e,n){return Ji(4,2,e,n)}function uf(e,n){return Ji(4,4,e,n)}function pf(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function ff(e,n,s){return s=s!=null?s.concat([e]):null,Ji(4,4,pf.bind(null,n,e),s)}function _d(){}function hf(e,n){var s=Ht();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&jd(n,l[1])?l[0]:(s.memoizedState=[e,n],e)}function gf(e,n){var s=Ht();n=n===void 0?null:n;var l=s.memoizedState;return l!==null&&n!==null&&jd(n,l[1])?l[0]:(e=e(),s.memoizedState=[e,n],e)}function xf(e,n,s){return Ts&21?(en(s,n)||(s=jp(),Oe.lanes|=s,Es|=s,e.baseState=!0),n):(e.baseState&&(e.baseState=!1,kt=!0),e.memoizedState=s)}function Cm(e,n){var s=je;je=s!==0&&4>s?s:4,e(!0);var l=Na.transition;Na.transition={};try{e(!1),n()}finally{je=s,Na.transition=l}}function mf(){return Ht().memoizedState}function zm(e,n,s){var l=Vn(e);if(s={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null},yf(e))vf(n,s);else if(s=Vp(e,n,s,l),s!==null){var r=bt();Zt(s,e,l,r),jf(s,n,l)}}function Im(e,n,s){var l=Vn(e),r={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null};if(yf(e))vf(n,r);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=n.lastRenderedReducer,i!==null))try{var o=n.lastRenderedState,d=i(o,s);if(r.hasEagerState=!0,r.eagerState=d,en(d,o)){var u=n.interleaved;u===null?(r.next=r,gd(n)):(r.next=u.next,u.next=r),n.interleaved=r;return}}catch{}finally{}s=Vp(e,n,r,l),s!==null&&(r=bt(),Zt(s,e,l,r),jf(s,n,l))}}function yf(e){var n=e.alternate;return e===Oe||n!==null&&n===Oe}function vf(e,n){rr=Li=!0;var s=e.pending;s===null?n.next=n:(n.next=s.next,s.next=n),e.pending=n}function jf(e,n,s){if(s&4194240){var l=n.lanes;l&=e.pendingLanes,s|=l,n.lanes=s,td(e,s)}}var Wi={readContext:Mt,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},Tm={readContext:Mt,useCallback:function(e,n){return un().memoizedState=[e,n===void 0?null:n],e},useContext:Mt,useEffect:Jc,useImperativeHandle:function(e,n,s){return s=s!=null?s.concat([e]):null,fi(4194308,4,pf.bind(null,n,e),s)},useLayoutEffect:function(e,n){return fi(4194308,4,e,n)},useInsertionEffect:function(e,n){return fi(4,2,e,n)},useMemo:function(e,n){var s=un();return n=n===void 0?null:n,e=e(),s.memoizedState=[e,n],e},useReducer:function(e,n,s){var l=un();return n=s!==void 0?s(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=zm.bind(null,Oe,e),[l.memoizedState,e]},useRef:function(e){var n=un();return e={current:e},n.memoizedState=e},useState:qc,useDebugValue:_d,useDeferredValue:function(e){return un().memoizedState=e},useTransition:function(){var e=qc(!1),n=e[0];return e=Cm.bind(null,e[1]),un().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,s){var l=Oe,r=un();if(Ae){if(s===void 0)throw Error(G(407));s=s()}else{if(s=n(),ot===null)throw Error(G(349));Ts&30||sf(l,n,s)}r.memoizedState=s;var i={value:s,getSnapshot:n};return r.queue=i,Jc(rf.bind(null,l,i,e),[e]),l.flags|=2048,_r(9,lf.bind(null,l,i,s,n),void 0,null),s},useId:function(){var e=un(),n=ot.identifierPrefix;if(Ae){var s=zn,l=Cn;s=(l&~(1<<32-Vt(l)-1)).toString(32)+s,n=":"+n+"R"+s,s=Sr++,0<s&&(n+="H"+s.toString(32)),n+=":"}else s=km++,n=":"+n+"r"+s.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Em={readContext:Mt,useCallback:hf,useContext:Mt,useEffect:wd,useImperativeHandle:ff,useInsertionEffect:cf,useLayoutEffect:uf,useMemo:gf,useReducer:Ba,useRef:df,useState:function(){return Ba(wr)},useDebugValue:_d,useDeferredValue:function(e){var n=Ht();return xf(n,lt.memoizedState,e)},useTransition:function(){var e=Ba(wr)[0],n=Ht().memoizedState;return[e,n]},useMutableSource:tf,useSyncExternalStore:nf,useId:mf,unstable_isNewReconciler:!1},Am={readContext:Mt,useCallback:hf,useContext:Mt,useEffect:wd,useImperativeHandle:ff,useInsertionEffect:cf,useLayoutEffect:uf,useMemo:gf,useReducer:$a,useRef:df,useState:function(){return $a(wr)},useDebugValue:_d,useDeferredValue:function(e){var n=Ht();return lt===null?n.memoizedState=e:xf(n,lt.memoizedState,e)},useTransition:function(){var e=$a(wr)[0],n=Ht().memoizedState;return[e,n]},useMutableSource:tf,useSyncExternalStore:nf,useId:mf,unstable_isNewReconciler:!1};function Xt(e,n){if(e&&e.defaultProps){n=Le({},n),e=e.defaultProps;for(var s in e)n[s]===void 0&&(n[s]=e[s]);return n}return n}function _o(e,n,s,l){n=e.memoizedState,s=s(l,n),s=s==null?n:Le({},n,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Vi={isMounted:function(e){return(e=e._reactInternals)?Ds(e)===e:!1},enqueueSetState:function(e,n,s){e=e._reactInternals;var l=bt(),r=Vn(e),i=In(l,r);i.payload=n,s!=null&&(i.callback=s),n=qn(e,i,r),n!==null&&(Zt(n,e,r,l),ui(n,e,r))},enqueueReplaceState:function(e,n,s){e=e._reactInternals;var l=bt(),r=Vn(e),i=In(l,r);i.tag=1,i.payload=n,s!=null&&(i.callback=s),n=qn(e,i,r),n!==null&&(Zt(n,e,r,l),ui(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var s=bt(),l=Vn(e),r=In(s,l);r.tag=2,n!=null&&(r.callback=n),n=qn(e,r,l),n!==null&&(Zt(n,e,l,s),ui(n,e,l))}};function Vc(e,n,s,l,r,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,i,o):n.prototype&&n.prototype.isPureReactComponent?!xr(s,l)||!xr(r,i):!0}function bf(e,n,s){var l=!1,r=ts,i=n.contextType;return typeof i=="object"&&i!==null?i=Mt(i):(r=zt(n)?zs:yt.current,l=n.contextTypes,i=(l=l!=null)?Sl(e,r):ts),n=new n(s,i),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Vi,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=i),n}function Zc(e,n,s,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(s,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(s,l),n.state!==e&&Vi.enqueueReplaceState(n,n.state,null)}function ko(e,n,s,l){var r=e.stateNode;r.props=s,r.state=e.memoizedState,r.refs={},xd(e);var i=n.contextType;typeof i=="object"&&i!==null?r.context=Mt(i):(i=zt(n)?zs:yt.current,r.context=Sl(e,i)),r.state=e.memoizedState,i=n.getDerivedStateFromProps,typeof i=="function"&&(_o(e,n,i,s),r.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(n=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),n!==r.state&&Vi.enqueueReplaceState(r,r.state,null),Di(e,s,r,l),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function Cl(e,n){try{var s="",l=n;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:n,stack:r,digest:null}}function Ua(e,n,s){return{value:e,source:null,stack:s??null,digest:n??null}}function Co(e,n){try{console.error(n.value)}catch(s){setTimeout(function(){throw s})}}var Pm=typeof WeakMap=="function"?WeakMap:Map;function Sf(e,n,s){s=In(-1,s),s.tag=3,s.payload={element:null};var l=n.value;return s.callback=function(){Bi||(Bi=!0,Lo=l),Co(e,n)},s}function wf(e,n,s){s=In(-1,s),s.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var r=n.value;s.payload=function(){return l(r)},s.callback=function(){Co(e,n)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(s.callback=function(){Co(e,n),typeof l!="function"&&(Jn===null?Jn=new Set([this]):Jn.add(this));var o=n.stack;this.componentDidCatch(n.value,{componentStack:o!==null?o:""})}),s}function eu(e,n,s){var l=e.pingCache;if(l===null){l=e.pingCache=new Pm;var r=new Set;l.set(n,r)}else r=l.get(n),r===void 0&&(r=new Set,l.set(n,r));r.has(s)||(r.add(s),e=Km.bind(null,e,n,s),n.then(e,e))}function tu(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function nu(e,n,s,l,r){return e.mode&1?(e.flags|=65536,e.lanes=r,e):(e===n?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(n=In(-1,1),n.tag=2,qn(s,n,1))),s.lanes|=1),e)}var Rm=Rn.ReactCurrentOwner,kt=!1;function jt(e,n,s,l){n.child=e===null?Jp(n,null,s,l):_l(n,e.child,s,l)}function su(e,n,s,l,r){s=s.render;var i=n.ref;return vl(n,r),l=bd(e,n,s,l,i,r),s=Sd(),e!==null&&!kt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r,Pn(e,n,r)):(Ae&&s&&dd(n),n.flags|=1,jt(e,n,l,r),n.child)}function lu(e,n,s,l,r){if(e===null){var i=s.type;return typeof i=="function"&&!Pd(i)&&i.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(n.tag=15,n.type=i,_f(e,n,i,l,r)):(e=mi(s.type,null,l,n,n.mode,r),e.ref=n.ref,e.return=n,n.child=e)}if(i=e.child,!(e.lanes&r)){var o=i.memoizedProps;if(s=s.compare,s=s!==null?s:xr,s(o,l)&&e.ref===n.ref)return Pn(e,n,r)}return n.flags|=1,e=Zn(i,l),e.ref=n.ref,e.return=n,n.child=e}function _f(e,n,s,l,r){if(e!==null){var i=e.memoizedProps;if(xr(i,l)&&e.ref===n.ref)if(kt=!1,n.pendingProps=l=i,(e.lanes&r)!==0)e.flags&131072&&(kt=!0);else return n.lanes=e.lanes,Pn(e,n,r)}return zo(e,n,s,l,r)}function kf(e,n,s){var l=n.pendingProps,r=l.children,i=e!==null?e.memoizedState:null;if(l.mode==="hidden")if(!(n.mode&1))n.memoizedState={baseLanes:0,cachePool:null,transitions:null},we(fl,Pt),Pt|=s;else{if(!(s&1073741824))return e=i!==null?i.baseLanes|s:s,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,we(fl,Pt),Pt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=i!==null?i.baseLanes:s,we(fl,Pt),Pt|=l}else i!==null?(l=i.baseLanes|s,n.memoizedState=null):l=s,we(fl,Pt),Pt|=l;return jt(e,n,r,s),n.child}function Cf(e,n){var s=n.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(n.flags|=512,n.flags|=2097152)}function zo(e,n,s,l,r){var i=zt(s)?zs:yt.current;return i=Sl(n,i),vl(n,r),s=bd(e,n,s,l,i,r),l=Sd(),e!==null&&!kt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r,Pn(e,n,r)):(Ae&&l&&dd(n),n.flags|=1,jt(e,n,s,r),n.child)}function ru(e,n,s,l,r){if(zt(s)){var i=!0;Ti(n)}else i=!1;if(vl(n,r),n.stateNode===null)hi(e,n),bf(n,s,l),ko(n,s,l,r),l=!0;else if(e===null){var o=n.stateNode,d=n.memoizedProps;o.props=d;var u=o.context,c=s.contextType;typeof c=="object"&&c!==null?c=Mt(c):(c=zt(s)?zs:yt.current,c=Sl(n,c));var _=s.getDerivedStateFromProps,m=typeof _=="function"||typeof o.getSnapshotBeforeUpdate=="function";m||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(d!==l||u!==c)&&Zc(n,o,l,c),Bn=!1;var y=n.memoizedState;o.state=y,Di(n,l,o,r),u=n.memoizedState,d!==l||y!==u||Ct.current||Bn?(typeof _=="function"&&(_o(n,s,_,l),u=n.memoizedState),(d=Bn||Vc(n,s,d,l,y,u,c))?(m||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(n.flags|=4194308)):(typeof o.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=u),o.props=l,o.state=u,o.context=c,l=d):(typeof o.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{o=n.stateNode,Zp(e,n),d=n.memoizedProps,c=n.type===n.elementType?d:Xt(n.type,d),o.props=c,m=n.pendingProps,y=o.context,u=s.contextType,typeof u=="object"&&u!==null?u=Mt(u):(u=zt(s)?zs:yt.current,u=Sl(n,u));var h=s.getDerivedStateFromProps;(_=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(d!==m||y!==u)&&Zc(n,o,l,u),Bn=!1,y=n.memoizedState,o.state=y,Di(n,l,o,r);var b=n.memoizedState;d!==m||y!==b||Ct.current||Bn?(typeof h=="function"&&(_o(n,s,h,l),b=n.memoizedState),(c=Bn||Vc(n,s,c,l,y,b,u)||!1)?(_||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(l,b,u),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(l,b,u)),typeof o.componentDidUpdate=="function"&&(n.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof o.componentDidUpdate!="function"||d===e.memoizedProps&&y===e.memoizedState||(n.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&y===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=b),o.props=l,o.state=b,o.context=u,l=c):(typeof o.componentDidUpdate!="function"||d===e.memoizedProps&&y===e.memoizedState||(n.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&y===e.memoizedState||(n.flags|=1024),l=!1)}return Io(e,n,s,l,i,r)}function Io(e,n,s,l,r,i){Cf(e,n);var o=(n.flags&128)!==0;if(!l&&!o)return r&&Hc(n,s,!1),Pn(e,n,i);l=n.stateNode,Rm.current=n;var d=o&&typeof s.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&o?(n.child=_l(n,e.child,null,i),n.child=_l(n,null,d,i)):jt(e,n,d,i),n.memoizedState=l.state,r&&Hc(n,s,!0),n.child}function zf(e){var n=e.stateNode;n.pendingContext?Mc(e,n.pendingContext,n.pendingContext!==n.context):n.context&&Mc(e,n.context,!1),md(e,n.containerInfo)}function iu(e,n,s,l,r){return wl(),ud(r),n.flags|=256,jt(e,n,s,l),n.child}var To={dehydrated:null,treeContext:null,retryLane:0};function Eo(e){return{baseLanes:e,cachePool:null,transitions:null}}function If(e,n,s){var l=n.pendingProps,r=De.current,i=!1,o=(n.flags&128)!==0,d;if((d=o)||(d=e!==null&&e.memoizedState===null?!1:(r&2)!==0),d?(i=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(r|=1),we(De,r&1),e===null)return So(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(n.mode&1?e.data==="$!"?n.lanes=8:n.lanes=1073741824:n.lanes=1,null):(o=l.children,e=l.fallback,i?(l=n.mode,i=n.child,o={mode:"hidden",children:o},!(l&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=ta(o,l,0,null),e=Cs(e,l,s,null),i.return=n,e.return=n,i.sibling=e,n.child=i,n.child.memoizedState=Eo(s),n.memoizedState=To,e):kd(n,o));if(r=e.memoizedState,r!==null&&(d=r.dehydrated,d!==null))return Dm(e,n,o,l,d,r,s);if(i){i=l.fallback,o=n.mode,r=e.child,d=r.sibling;var u={mode:"hidden",children:l.children};return!(o&1)&&n.child!==r?(l=n.child,l.childLanes=0,l.pendingProps=u,n.deletions=null):(l=Zn(r,u),l.subtreeFlags=r.subtreeFlags&14680064),d!==null?i=Zn(d,i):(i=Cs(i,o,s,null),i.flags|=2),i.return=n,l.return=n,l.sibling=i,n.child=l,l=i,i=n.child,o=e.child.memoizedState,o=o===null?Eo(s):{baseLanes:o.baseLanes|s,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~s,n.memoizedState=To,l}return i=e.child,e=i.sibling,l=Zn(i,{mode:"visible",children:l.children}),!(n.mode&1)&&(l.lanes=s),l.return=n,l.sibling=null,e!==null&&(s=n.deletions,s===null?(n.deletions=[e],n.flags|=16):s.push(e)),n.child=l,n.memoizedState=null,l}function kd(e,n){return n=ta({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Vr(e,n,s,l){return l!==null&&ud(l),_l(n,e.child,null,s),e=kd(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Dm(e,n,s,l,r,i,o){if(s)return n.flags&256?(n.flags&=-257,l=Ua(Error(G(422))),Vr(e,n,o,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(i=l.fallback,r=n.mode,l=ta({mode:"visible",children:l.children},r,0,null),i=Cs(i,r,o,null),i.flags|=2,l.return=n,i.return=n,l.sibling=i,n.child=l,n.mode&1&&_l(n,e.child,null,o),n.child.memoizedState=Eo(o),n.memoizedState=To,i);if(!(n.mode&1))return Vr(e,n,o,null);if(r.data==="$!"){if(l=r.nextSibling&&r.nextSibling.dataset,l)var d=l.dgst;return l=d,i=Error(G(419)),l=Ua(i,l,void 0),Vr(e,n,o,l)}if(d=(o&e.childLanes)!==0,kt||d){if(l=ot,l!==null){switch(o&-o){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|o)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,An(e,r),Zt(l,e,r,-1))}return Ad(),l=Ua(Error(G(421))),Vr(e,n,o,l)}return r.data==="$?"?(n.flags|=128,n.child=e.child,n=Qm.bind(null,e),r._reactRetry=n,null):(e=i.treeContext,Rt=Xn(r.nextSibling),Dt=n,Ae=!0,Jt=null,e!==null&&(Bt[$t++]=Cn,Bt[$t++]=zn,Bt[$t++]=Is,Cn=e.id,zn=e.overflow,Is=n),n=kd(n,l.children),n.flags|=4096,n)}function au(e,n,s){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),wo(e.return,n,s)}function Fa(e,n,s,l,r){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:s,tailMode:r}:(i.isBackwards=n,i.rendering=null,i.renderingStartTime=0,i.last=l,i.tail=s,i.tailMode=r)}function Tf(e,n,s){var l=n.pendingProps,r=l.revealOrder,i=l.tail;if(jt(e,n,l.children,s),l=De.current,l&2)l=l&1|2,n.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&au(e,s,n);else if(e.tag===19)au(e,s,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(we(De,l),!(n.mode&1))n.memoizedState=null;else switch(r){case"forwards":for(s=n.child,r=null;s!==null;)e=s.alternate,e!==null&&Oi(e)===null&&(r=s),s=s.sibling;s=r,s===null?(r=n.child,n.child=null):(r=s.sibling,s.sibling=null),Fa(n,!1,r,s,i);break;case"backwards":for(s=null,r=n.child,n.child=null;r!==null;){if(e=r.alternate,e!==null&&Oi(e)===null){n.child=r;break}e=r.sibling,r.sibling=s,s=r,r=e}Fa(n,!0,s,null,i);break;case"together":Fa(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function hi(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function Pn(e,n,s){if(e!==null&&(n.dependencies=e.dependencies),Es|=n.lanes,!(s&n.childLanes))return null;if(e!==null&&n.child!==e.child)throw Error(G(153));if(n.child!==null){for(e=n.child,s=Zn(e,e.pendingProps),n.child=s,s.return=n;e.sibling!==null;)e=e.sibling,s=s.sibling=Zn(e,e.pendingProps),s.return=n;s.sibling=null}return n.child}function Om(e,n,s){switch(n.tag){case 3:zf(n),wl();break;case 5:ef(n);break;case 1:zt(n.type)&&Ti(n);break;case 4:md(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,r=n.memoizedProps.value;we(Pi,l._currentValue),l._currentValue=r;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(we(De,De.current&1),n.flags|=128,null):s&n.child.childLanes?If(e,n,s):(we(De,De.current&1),e=Pn(e,n,s),e!==null?e.sibling:null);we(De,De.current&1);break;case 19:if(l=(s&n.childLanes)!==0,e.flags&128){if(l)return Tf(e,n,s);n.flags|=128}if(r=n.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),we(De,De.current),l)break;return null;case 22:case 23:return n.lanes=0,kf(e,n,s)}return Pn(e,n,s)}var Ef,Ao,Af,Pf;Ef=function(e,n){for(var s=n.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};Ao=function(){};Af=function(e,n,s,l){var r=e.memoizedProps;if(r!==l){e=n.stateNode,_s(hn.current);var i=null;switch(s){case"input":r=Va(e,r),l=Va(e,l),i=[];break;case"select":r=Le({},r,{value:void 0}),l=Le({},l,{value:void 0}),i=[];break;case"textarea":r=to(e,r),l=to(e,l),i=[];break;default:typeof r.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=zi)}so(s,l);var o;s=null;for(c in r)if(!l.hasOwnProperty(c)&&r.hasOwnProperty(c)&&r[c]!=null)if(c==="style"){var d=r[c];for(o in d)d.hasOwnProperty(o)&&(s||(s={}),s[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(dr.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in l){var u=l[c];if(d=r!=null?r[c]:void 0,l.hasOwnProperty(c)&&u!==d&&(u!=null||d!=null))if(c==="style")if(d){for(o in d)!d.hasOwnProperty(o)||u&&u.hasOwnProperty(o)||(s||(s={}),s[o]="");for(o in u)u.hasOwnProperty(o)&&d[o]!==u[o]&&(s||(s={}),s[o]=u[o])}else s||(i||(i=[]),i.push(c,s)),s=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,d=d?d.__html:void 0,u!=null&&d!==u&&(i=i||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(dr.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&Ce("scroll",e),i||d===u||(i=[])):(i=i||[]).push(c,u))}s&&(i=i||[]).push("style",s);var c=i;(n.updateQueue=c)&&(n.flags|=4)}};Pf=function(e,n,s,l){s!==l&&(n.flags|=4)};function Gl(e,n){if(!Ae)switch(e.tailMode){case"hidden":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var l=null;s!==null;)s.alternate!==null&&(l=s),s=s.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function xt(e){var n=e.alternate!==null&&e.alternate.child===e.child,s=0,l=0;if(n)for(var r=e.child;r!==null;)s|=r.lanes|r.childLanes,l|=r.subtreeFlags&14680064,l|=r.flags&14680064,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)s|=r.lanes|r.childLanes,l|=r.subtreeFlags,l|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=l,e.childLanes=s,n}function Lm(e,n,s){var l=n.pendingProps;switch(cd(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xt(n),null;case 1:return zt(n.type)&&Ii(),xt(n),null;case 3:return l=n.stateNode,kl(),ze(Ct),ze(yt),vd(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(qr(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&!(n.flags&256)||(n.flags|=1024,Jt!==null&&(Bo(Jt),Jt=null))),Ao(e,n),xt(n),null;case 5:yd(n);var r=_s(br.current);if(s=n.type,e!==null&&n.stateNode!=null)Af(e,n,s,l,r),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(G(166));return xt(n),null}if(e=_s(hn.current),qr(n)){l=n.stateNode,s=n.type;var i=n.memoizedProps;switch(l[pn]=n,l[vr]=i,e=(n.mode&1)!==0,s){case"dialog":Ce("cancel",l),Ce("close",l);break;case"iframe":case"object":case"embed":Ce("load",l);break;case"video":case"audio":for(r=0;r<Vl.length;r++)Ce(Vl[r],l);break;case"source":Ce("error",l);break;case"img":case"image":case"link":Ce("error",l),Ce("load",l);break;case"details":Ce("toggle",l);break;case"input":xc(l,i),Ce("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!i.multiple},Ce("invalid",l);break;case"textarea":yc(l,i),Ce("invalid",l)}so(s,i),r=null;for(var o in i)if(i.hasOwnProperty(o)){var d=i[o];o==="children"?typeof d=="string"?l.textContent!==d&&(i.suppressHydrationWarning!==!0&&Xr(l.textContent,d,e),r=["children",d]):typeof d=="number"&&l.textContent!==""+d&&(i.suppressHydrationWarning!==!0&&Xr(l.textContent,d,e),r=["children",""+d]):dr.hasOwnProperty(o)&&d!=null&&o==="onScroll"&&Ce("scroll",l)}switch(s){case"input":Ur(l),mc(l,i,!0);break;case"textarea":Ur(l),vc(l);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(l.onclick=zi)}l=r,n.updateQueue=l,l!==null&&(n.flags|=4)}else{o=r.nodeType===9?r:r.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=rp(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=o.createElement(s,{is:l.is}):(e=o.createElement(s),s==="select"&&(o=e,l.multiple?o.multiple=!0:l.size&&(o.size=l.size))):e=o.createElementNS(e,s),e[pn]=n,e[vr]=l,Ef(e,n,!1,!1),n.stateNode=e;e:{switch(o=lo(s,l),s){case"dialog":Ce("cancel",e),Ce("close",e),r=l;break;case"iframe":case"object":case"embed":Ce("load",e),r=l;break;case"video":case"audio":for(r=0;r<Vl.length;r++)Ce(Vl[r],e);r=l;break;case"source":Ce("error",e),r=l;break;case"img":case"image":case"link":Ce("error",e),Ce("load",e),r=l;break;case"details":Ce("toggle",e),r=l;break;case"input":xc(e,l),r=Va(e,l),Ce("invalid",e);break;case"option":r=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},r=Le({},l,{value:void 0}),Ce("invalid",e);break;case"textarea":yc(e,l),r=to(e,l),Ce("invalid",e);break;default:r=l}so(s,r),d=r;for(i in d)if(d.hasOwnProperty(i)){var u=d[i];i==="style"?op(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&ip(e,u)):i==="children"?typeof u=="string"?(s!=="textarea"||u!=="")&&cr(e,u):typeof u=="number"&&cr(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(dr.hasOwnProperty(i)?u!=null&&i==="onScroll"&&Ce("scroll",e):u!=null&&Xo(e,i,u,o))}switch(s){case"input":Ur(e),mc(e,l,!1);break;case"textarea":Ur(e),vc(e);break;case"option":l.value!=null&&e.setAttribute("value",""+es(l.value));break;case"select":e.multiple=!!l.multiple,i=l.value,i!=null?gl(e,!!l.multiple,i,!1):l.defaultValue!=null&&gl(e,!!l.multiple,l.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=zi)}switch(s){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return xt(n),null;case 6:if(e&&n.stateNode!=null)Pf(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(G(166));if(s=_s(br.current),_s(hn.current),qr(n)){if(l=n.stateNode,s=n.memoizedProps,l[pn]=n,(i=l.nodeValue!==s)&&(e=Dt,e!==null))switch(e.tag){case 3:Xr(l.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Xr(l.nodeValue,s,(e.mode&1)!==0)}i&&(n.flags|=4)}else l=(s.nodeType===9?s:s.ownerDocument).createTextNode(l),l[pn]=n,n.stateNode=l}return xt(n),null;case 13:if(ze(De),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ae&&Rt!==null&&n.mode&1&&!(n.flags&128))Xp(),wl(),n.flags|=98560,i=!1;else if(i=qr(n),l!==null&&l.dehydrated!==null){if(e===null){if(!i)throw Error(G(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(G(317));i[pn]=n}else wl(),!(n.flags&128)&&(n.memoizedState=null),n.flags|=4;xt(n),i=!1}else Jt!==null&&(Bo(Jt),Jt=null),i=!0;if(!i)return n.flags&65536?n:null}return n.flags&128?(n.lanes=s,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,n.mode&1&&(e===null||De.current&1?rt===0&&(rt=3):Ad())),n.updateQueue!==null&&(n.flags|=4),xt(n),null);case 4:return kl(),Ao(e,n),e===null&&mr(n.stateNode.containerInfo),xt(n),null;case 10:return hd(n.type._context),xt(n),null;case 17:return zt(n.type)&&Ii(),xt(n),null;case 19:if(ze(De),i=n.memoizedState,i===null)return xt(n),null;if(l=(n.flags&128)!==0,o=i.rendering,o===null)if(l)Gl(i,!1);else{if(rt!==0||e!==null&&e.flags&128)for(e=n.child;e!==null;){if(o=Oi(e),o!==null){for(n.flags|=128,Gl(i,!1),l=o.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=s,s=n.child;s!==null;)i=s,e=l,i.flags&=14680066,o=i.alternate,o===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=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return we(De,De.current&1|2),n.child}e=e.sibling}i.tail!==null&&Xe()>zl&&(n.flags|=128,l=!0,Gl(i,!1),n.lanes=4194304)}else{if(!l)if(e=Oi(o),e!==null){if(n.flags|=128,l=!0,s=e.updateQueue,s!==null&&(n.updateQueue=s,n.flags|=4),Gl(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ae)return xt(n),null}else 2*Xe()-i.renderingStartTime>zl&&s!==1073741824&&(n.flags|=128,l=!0,Gl(i,!1),n.lanes=4194304);i.isBackwards?(o.sibling=n.child,n.child=o):(s=i.last,s!==null?s.sibling=o:n.child=o,i.last=o)}return i.tail!==null?(n=i.tail,i.rendering=n,i.tail=n.sibling,i.renderingStartTime=Xe(),n.sibling=null,s=De.current,we(De,l?s&1|2:s&1),n):(xt(n),null);case 22:case 23:return Ed(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&n.mode&1?Pt&1073741824&&(xt(n),n.subtreeFlags&6&&(n.flags|=8192)):xt(n),null;case 24:return null;case 25:return null}throw Error(G(156,n.tag))}function Wm(e,n){switch(cd(n),n.tag){case 1:return zt(n.type)&&Ii(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return kl(),ze(Ct),ze(yt),vd(),e=n.flags,e&65536&&!(e&128)?(n.flags=e&-65537|128,n):null;case 5:return yd(n),null;case 13:if(ze(De),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(G(340));wl()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return ze(De),null;case 4:return kl(),null;case 10:return hd(n.type._context),null;case 22:case 23:return Ed(),null;case 24:return null;default:return null}}var Zr=!1,mt=!1,Nm=typeof WeakSet=="function"?WeakSet:Set,V=null;function pl(e,n){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(l){He(e,n,l)}else s.current=null}function Po(e,n,s){try{s()}catch(l){He(e,n,l)}}var ou=!1;function Bm(e,n){if(go=_i,e=Lp(),od(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 o=0,d=-1,u=-1,c=0,_=0,m=e,y=null;t:for(;;){for(var h;m!==s||r!==0&&m.nodeType!==3||(d=o+r),m!==i||l!==0&&m.nodeType!==3||(u=o+l),m.nodeType===3&&(o+=m.nodeValue.length),(h=m.firstChild)!==null;)y=m,m=h;for(;;){if(m===e)break t;if(y===s&&++c===r&&(d=o),y===i&&++_===l&&(u=o),(h=m.nextSibling)!==null)break;m=y,y=m.parentNode}m=h}s=d===-1||u===-1?null:{start:d,end:u}}else s=null}s=s||{start:0,end:0}}else s=null;for(xo={focusedElem:e,selectionRange:s},_i=!1,V=n;V!==null;)if(n=V,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,V=e;else for(;V!==null;){n=V;try{var b=n.alternate;if(n.flags&1024)switch(n.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var z=b.memoizedProps,j=b.memoizedState,f=n.stateNode,a=f.getSnapshotBeforeUpdate(n.elementType===n.type?z:Xt(n.type,z),j);f.__reactInternalSnapshotBeforeUpdate=a}break;case 3:var x=n.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(g){He(n,n.return,g)}if(e=n.sibling,e!==null){e.return=n.return,V=e;break}V=n.return}return b=ou,ou=!1,b}function ir(e,n,s){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var r=l=l.next;do{if((r.tag&e)===e){var i=r.destroy;r.destroy=void 0,i!==void 0&&Po(n,s,i)}r=r.next}while(r!==l)}}function Zi(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&e)===e){var l=s.create;s.destroy=l()}s=s.next}while(s!==n)}}function Ro(e){var n=e.ref;if(n!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof n=="function"?n(e):n.current=e}}function Rf(e){var n=e.alternate;n!==null&&(e.alternate=null,Rf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[pn],delete n[vr],delete n[vo],delete n[bm],delete n[Sm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Df(e){return e.tag===5||e.tag===3||e.tag===4}function du(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Df(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 Do(e,n,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?s.nodeType===8?s.parentNode.insertBefore(e,n):s.insertBefore(e,n):(s.nodeType===8?(n=s.parentNode,n.insertBefore(e,s)):(n=s,n.appendChild(e)),s=s._reactRootContainer,s!=null||n.onclick!==null||(n.onclick=zi));else if(l!==4&&(e=e.child,e!==null))for(Do(e,n,s),e=e.sibling;e!==null;)Do(e,n,s),e=e.sibling}function Oo(e,n,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?s.insertBefore(e,n):s.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Oo(e,n,s),e=e.sibling;e!==null;)Oo(e,n,s),e=e.sibling}var ut=null,qt=!1;function Ln(e,n,s){for(s=s.child;s!==null;)Of(e,n,s),s=s.sibling}function Of(e,n,s){if(fn&&typeof fn.onCommitFiberUnmount=="function")try{fn.onCommitFiberUnmount(Gi,s)}catch{}switch(s.tag){case 5:mt||pl(s,n);case 6:var l=ut,r=qt;ut=null,Ln(e,n,s),ut=l,qt=r,ut!==null&&(qt?(e=ut,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):ut.removeChild(s.stateNode));break;case 18:ut!==null&&(qt?(e=ut,s=s.stateNode,e.nodeType===8?Oa(e.parentNode,s):e.nodeType===1&&Oa(e,s),hr(e)):Oa(ut,s.stateNode));break;case 4:l=ut,r=qt,ut=s.stateNode.containerInfo,qt=!0,Ln(e,n,s),ut=l,qt=r;break;case 0:case 11:case 14:case 15:if(!mt&&(l=s.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){r=l=l.next;do{var i=r,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Po(s,n,o),r=r.next}while(r!==l)}Ln(e,n,s);break;case 1:if(!mt&&(pl(s,n),l=s.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=s.memoizedProps,l.state=s.memoizedState,l.componentWillUnmount()}catch(d){He(s,n,d)}Ln(e,n,s);break;case 21:Ln(e,n,s);break;case 22:s.mode&1?(mt=(l=mt)||s.memoizedState!==null,Ln(e,n,s),mt=l):Ln(e,n,s);break;default:Ln(e,n,s)}}function cu(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Nm),n.forEach(function(l){var r=Ym.bind(null,e,l);s.has(l)||(s.add(l),l.then(r,r))})}}function Qt(e,n){var s=n.deletions;if(s!==null)for(var l=0;l<s.length;l++){var r=s[l];try{var i=e,o=n,d=o;e:for(;d!==null;){switch(d.tag){case 5:ut=d.stateNode,qt=!1;break e;case 3:ut=d.stateNode.containerInfo,qt=!0;break e;case 4:ut=d.stateNode.containerInfo,qt=!0;break e}d=d.return}if(ut===null)throw Error(G(160));Of(i,o,r),ut=null,qt=!1;var u=r.alternate;u!==null&&(u.return=null),r.return=null}catch(c){He(r,n,c)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Lf(n,e),n=n.sibling}function Lf(e,n){var s=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Qt(n,e),an(e),l&4){try{ir(3,e,e.return),Zi(3,e)}catch(z){He(e,e.return,z)}try{ir(5,e,e.return)}catch(z){He(e,e.return,z)}}break;case 1:Qt(n,e),an(e),l&512&&s!==null&&pl(s,s.return);break;case 5:if(Qt(n,e),an(e),l&512&&s!==null&&pl(s,s.return),e.flags&32){var r=e.stateNode;try{cr(r,"")}catch(z){He(e,e.return,z)}}if(l&4&&(r=e.stateNode,r!=null)){var i=e.memoizedProps,o=s!==null?s.memoizedProps:i,d=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{d==="input"&&i.type==="radio"&&i.name!=null&&sp(r,i),lo(d,o);var c=lo(d,i);for(o=0;o<u.length;o+=2){var _=u[o],m=u[o+1];_==="style"?op(r,m):_==="dangerouslySetInnerHTML"?ip(r,m):_==="children"?cr(r,m):Xo(r,_,m,c)}switch(d){case"input":Za(r,i);break;case"textarea":lp(r,i);break;case"select":var y=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?gl(r,!!i.multiple,h,!1):y!==!!i.multiple&&(i.defaultValue!=null?gl(r,!!i.multiple,i.defaultValue,!0):gl(r,!!i.multiple,i.multiple?[]:"",!1))}r[vr]=i}catch(z){He(e,e.return,z)}}break;case 6:if(Qt(n,e),an(e),l&4){if(e.stateNode===null)throw Error(G(162));r=e.stateNode,i=e.memoizedProps;try{r.nodeValue=i}catch(z){He(e,e.return,z)}}break;case 3:if(Qt(n,e),an(e),l&4&&s!==null&&s.memoizedState.isDehydrated)try{hr(n.containerInfo)}catch(z){He(e,e.return,z)}break;case 4:Qt(n,e),an(e);break;case 13:Qt(n,e),an(e),r=e.child,r.flags&8192&&(i=r.memoizedState!==null,r.stateNode.isHidden=i,!i||r.alternate!==null&&r.alternate.memoizedState!==null||(Id=Xe())),l&4&&cu(e);break;case 22:if(_=s!==null&&s.memoizedState!==null,e.mode&1?(mt=(c=mt)||_,Qt(n,e),mt=c):Qt(n,e),an(e),l&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!_&&e.mode&1)for(V=e,_=e.child;_!==null;){for(m=V=_;V!==null;){switch(y=V,h=y.child,y.tag){case 0:case 11:case 14:case 15:ir(4,y,y.return);break;case 1:pl(y,y.return);var b=y.stateNode;if(typeof b.componentWillUnmount=="function"){l=y,s=y.return;try{n=l,b.props=n.memoizedProps,b.state=n.memoizedState,b.componentWillUnmount()}catch(z){He(l,s,z)}}break;case 5:pl(y,y.return);break;case 22:if(y.memoizedState!==null){pu(m);continue}}h!==null?(h.return=y,V=h):pu(m)}_=_.sibling}e:for(_=null,m=e;;){if(m.tag===5){if(_===null){_=m;try{r=m.stateNode,c?(i=r.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(d=m.stateNode,u=m.memoizedProps.style,o=u!=null&&u.hasOwnProperty("display")?u.display:null,d.style.display=ap("display",o))}catch(z){He(e,e.return,z)}}}else if(m.tag===6){if(_===null)try{m.stateNode.nodeValue=c?"":m.memoizedProps}catch(z){He(e,e.return,z)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;_===m&&(_=null),m=m.return}_===m&&(_=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:Qt(n,e),an(e),l&4&&cu(e);break;case 21:break;default:Qt(n,e),an(e)}}function an(e){var n=e.flags;if(n&2){try{e:{for(var s=e.return;s!==null;){if(Df(s)){var l=s;break e}s=s.return}throw Error(G(160))}switch(l.tag){case 5:var r=l.stateNode;l.flags&32&&(cr(r,""),l.flags&=-33);var i=du(e);Oo(e,i,r);break;case 3:case 4:var o=l.stateNode.containerInfo,d=du(e);Do(e,d,o);break;default:throw Error(G(161))}}catch(u){He(e,e.return,u)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function $m(e,n,s){V=e,Wf(e)}function Wf(e,n,s){for(var l=(e.mode&1)!==0;V!==null;){var r=V,i=r.child;if(r.tag===22&&l){var o=r.memoizedState!==null||Zr;if(!o){var d=r.alternate,u=d!==null&&d.memoizedState!==null||mt;d=Zr;var c=mt;if(Zr=o,(mt=u)&&!c)for(V=r;V!==null;)o=V,u=o.child,o.tag===22&&o.memoizedState!==null?fu(r):u!==null?(u.return=o,V=u):fu(r);for(;i!==null;)V=i,Wf(i),i=i.sibling;V=r,Zr=d,mt=c}uu(e)}else r.subtreeFlags&8772&&i!==null?(i.return=r,V=i):uu(e)}}function uu(e){for(;V!==null;){var n=V;if(n.flags&8772){var s=n.alternate;try{if(n.flags&8772)switch(n.tag){case 0:case 11:case 15:mt||Zi(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!mt)if(s===null)l.componentDidMount();else{var r=n.elementType===n.type?s.memoizedProps:Xt(n.type,s.memoizedProps);l.componentDidUpdate(r,s.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var i=n.updateQueue;i!==null&&Xc(n,i,l);break;case 3:var o=n.updateQueue;if(o!==null){if(s=null,n.child!==null)switch(n.child.tag){case 5:s=n.child.stateNode;break;case 1:s=n.child.stateNode}Xc(n,o,s)}break;case 5:var d=n.stateNode;if(s===null&&n.flags&4){s=d;var u=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&s.focus();break;case"img":u.src&&(s.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var c=n.alternate;if(c!==null){var _=c.memoizedState;if(_!==null){var m=_.dehydrated;m!==null&&hr(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(G(163))}mt||n.flags&512&&Ro(n)}catch(y){He(n,n.return,y)}}if(n===e){V=null;break}if(s=n.sibling,s!==null){s.return=n.return,V=s;break}V=n.return}}function pu(e){for(;V!==null;){var n=V;if(n===e){V=null;break}var s=n.sibling;if(s!==null){s.return=n.return,V=s;break}V=n.return}}function fu(e){for(;V!==null;){var n=V;try{switch(n.tag){case 0:case 11:case 15:var s=n.return;try{Zi(4,n)}catch(u){He(n,s,u)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var r=n.return;try{l.componentDidMount()}catch(u){He(n,r,u)}}var i=n.return;try{Ro(n)}catch(u){He(n,i,u)}break;case 5:var o=n.return;try{Ro(n)}catch(u){He(n,o,u)}}}catch(u){He(n,n.return,u)}if(n===e){V=null;break}var d=n.sibling;if(d!==null){d.return=n.return,V=d;break}V=n.return}}var Um=Math.ceil,Ni=Rn.ReactCurrentDispatcher,Cd=Rn.ReactCurrentOwner,Ft=Rn.ReactCurrentBatchConfig,ge=0,ot=null,et=null,pt=0,Pt=0,fl=ls(0),rt=0,kr=null,Es=0,ea=0,zd=0,ar=null,_t=null,Id=0,zl=1/0,_n=null,Bi=!1,Lo=null,Jn=null,ei=!1,Mn=null,$i=0,or=0,Wo=null,gi=-1,xi=0;function bt(){return ge&6?Xe():gi!==-1?gi:gi=Xe()}function Vn(e){return e.mode&1?ge&2&&pt!==0?pt&-pt:_m.transition!==null?(xi===0&&(xi=jp()),xi):(e=je,e!==0||(e=window.event,e=e===void 0?16:zp(e.type)),e):1}function Zt(e,n,s,l){if(50<or)throw or=0,Wo=null,Error(G(185));Tr(e,s,l),(!(ge&2)||e!==ot)&&(e===ot&&(!(ge&2)&&(ea|=s),rt===4&&Un(e,pt)),It(e,l),s===1&&ge===0&&!(n.mode&1)&&(zl=Xe()+500,qi&&rs()))}function It(e,n){var s=e.callbackNode;_x(e,n);var l=wi(e,e===ot?pt:0);if(l===0)s!==null&&Sc(s),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(s!=null&&Sc(s),n===1)e.tag===0?wm(hu.bind(null,e)):Kp(hu.bind(null,e)),vm(function(){!(ge&6)&&rs()}),s=null;else{switch(bp(l)){case 1:s=ed;break;case 4:s=yp;break;case 16:s=Si;break;case 536870912:s=vp;break;default:s=Si}s=Gf(s,Nf.bind(null,e))}e.callbackPriority=n,e.callbackNode=s}}function Nf(e,n){if(gi=-1,xi=0,ge&6)throw Error(G(327));var s=e.callbackNode;if(jl()&&e.callbackNode!==s)return null;var l=wi(e,e===ot?pt:0);if(l===0)return null;if(l&30||l&e.expiredLanes||n)n=Ui(e,l);else{n=l;var r=ge;ge|=2;var i=$f();(ot!==e||pt!==n)&&(_n=null,zl=Xe()+500,ks(e,n));do try{Hm();break}catch(d){Bf(e,d)}while(!0);fd(),Ni.current=i,ge=r,et!==null?n=0:(ot=null,pt=0,n=rt)}if(n!==0){if(n===2&&(r=co(e),r!==0&&(l=r,n=No(e,r))),n===1)throw s=kr,ks(e,0),Un(e,l),It(e,Xe()),s;if(n===6)Un(e,l);else{if(r=e.current.alternate,!(l&30)&&!Fm(r)&&(n=Ui(e,l),n===2&&(i=co(e),i!==0&&(l=i,n=No(e,i))),n===1))throw s=kr,ks(e,0),Un(e,l),It(e,Xe()),s;switch(e.finishedWork=r,e.finishedLanes=l,n){case 0:case 1:throw Error(G(345));case 2:bs(e,_t,_n);break;case 3:if(Un(e,l),(l&130023424)===l&&(n=Id+500-Xe(),10<n)){if(wi(e,0)!==0)break;if(r=e.suspendedLanes,(r&l)!==l){bt(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=yo(bs.bind(null,e,_t,_n),n);break}bs(e,_t,_n);break;case 4:if(Un(e,l),(l&4194240)===l)break;for(n=e.eventTimes,r=-1;0<l;){var o=31-Vt(l);i=1<<o,o=n[o],o>r&&(r=o),l&=~i}if(l=r,l=Xe()-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=yo(bs.bind(null,e,_t,_n),l);break}bs(e,_t,_n);break;case 5:bs(e,_t,_n);break;default:throw Error(G(329))}}}return It(e,Xe()),e.callbackNode===s?Nf.bind(null,e):null}function No(e,n){var s=ar;return e.current.memoizedState.isDehydrated&&(ks(e,n).flags|=256),e=Ui(e,n),e!==2&&(n=_t,_t=s,n!==null&&Bo(n)),e}function Bo(e){_t===null?_t=e:_t.push.apply(_t,e)}function Fm(e){for(var n=e;;){if(n.flags&16384){var s=n.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var l=0;l<s.length;l++){var r=s[l],i=r.getSnapshot;r=r.value;try{if(!en(i(),r))return!1}catch{return!1}}}if(s=n.child,n.subtreeFlags&16384&&s!==null)s.return=n,n=s;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Un(e,n){for(n&=~zd,n&=~ea,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var s=31-Vt(n),l=1<<s;e[s]=-1,n&=~l}}function hu(e){if(ge&6)throw Error(G(327));jl();var n=wi(e,0);if(!(n&1))return It(e,Xe()),null;var s=Ui(e,n);if(e.tag!==0&&s===2){var l=co(e);l!==0&&(n=l,s=No(e,l))}if(s===1)throw s=kr,ks(e,0),Un(e,n),It(e,Xe()),s;if(s===6)throw Error(G(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,bs(e,_t,_n),It(e,Xe()),null}function Td(e,n){var s=ge;ge|=1;try{return e(n)}finally{ge=s,ge===0&&(zl=Xe()+500,qi&&rs())}}function As(e){Mn!==null&&Mn.tag===0&&!(ge&6)&&jl();var n=ge;ge|=1;var s=Ft.transition,l=je;try{if(Ft.transition=null,je=1,e)return e()}finally{je=l,Ft.transition=s,ge=n,!(ge&6)&&rs()}}function Ed(){Pt=fl.current,ze(fl)}function ks(e,n){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,ym(s)),et!==null)for(s=et.return;s!==null;){var l=s;switch(cd(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&Ii();break;case 3:kl(),ze(Ct),ze(yt),vd();break;case 5:yd(l);break;case 4:kl();break;case 13:ze(De);break;case 19:ze(De);break;case 10:hd(l.type._context);break;case 22:case 23:Ed()}s=s.return}if(ot=e,et=e=Zn(e.current,null),pt=Pt=n,rt=0,kr=null,zd=ea=Es=0,_t=ar=null,ws!==null){for(n=0;n<ws.length;n++)if(s=ws[n],l=s.interleaved,l!==null){s.interleaved=null;var r=l.next,i=s.pending;if(i!==null){var o=i.next;i.next=r,l.next=o}s.pending=l}ws=null}return e}function Bf(e,n){do{var s=et;try{if(fd(),pi.current=Wi,Li){for(var l=Oe.memoizedState;l!==null;){var r=l.queue;r!==null&&(r.pending=null),l=l.next}Li=!1}if(Ts=0,at=lt=Oe=null,rr=!1,Sr=0,Cd.current=null,s===null||s.return===null){rt=1,kr=n,et=null;break}e:{var i=e,o=s.return,d=s,u=n;if(n=pt,d.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var c=u,_=d,m=_.tag;if(!(_.mode&1)&&(m===0||m===11||m===15)){var y=_.alternate;y?(_.updateQueue=y.updateQueue,_.memoizedState=y.memoizedState,_.lanes=y.lanes):(_.updateQueue=null,_.memoizedState=null)}var h=tu(o);if(h!==null){h.flags&=-257,nu(h,o,d,i,n),h.mode&1&&eu(i,c,n),n=h,u=c;var b=n.updateQueue;if(b===null){var z=new Set;z.add(u),n.updateQueue=z}else b.add(u);break e}else{if(!(n&1)){eu(i,c,n),Ad();break e}u=Error(G(426))}}else if(Ae&&d.mode&1){var j=tu(o);if(j!==null){!(j.flags&65536)&&(j.flags|=256),nu(j,o,d,i,n),ud(Cl(u,d));break e}}i=u=Cl(u,d),rt!==4&&(rt=2),ar===null?ar=[i]:ar.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,n&=-n,i.lanes|=n;var f=Sf(i,u,n);Yc(i,f);break e;case 1:d=u;var a=i.type,x=i.stateNode;if(!(i.flags&128)&&(typeof a.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Jn===null||!Jn.has(x)))){i.flags|=65536,n&=-n,i.lanes|=n;var g=wf(i,d,n);Yc(i,g);break e}}i=i.return}while(i!==null)}Ff(s)}catch(C){n=C,et===s&&s!==null&&(et=s=s.return);continue}break}while(!0)}function $f(){var e=Ni.current;return Ni.current=Wi,e===null?Wi:e}function Ad(){(rt===0||rt===3||rt===2)&&(rt=4),ot===null||!(Es&268435455)&&!(ea&268435455)||Un(ot,pt)}function Ui(e,n){var s=ge;ge|=2;var l=$f();(ot!==e||pt!==n)&&(_n=null,ks(e,n));do try{Mm();break}catch(r){Bf(e,r)}while(!0);if(fd(),ge=s,Ni.current=l,et!==null)throw Error(G(261));return ot=null,pt=0,rt}function Mm(){for(;et!==null;)Uf(et)}function Hm(){for(;et!==null&&!gx();)Uf(et)}function Uf(e){var n=Hf(e.alternate,e,Pt);e.memoizedProps=e.pendingProps,n===null?Ff(e):et=n,Cd.current=null}function Ff(e){var n=e;do{var s=n.alternate;if(e=n.return,n.flags&32768){if(s=Wm(s,n),s!==null){s.flags&=32767,et=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{rt=6,et=null;return}}else if(s=Lm(s,n,Pt),s!==null){et=s;return}if(n=n.sibling,n!==null){et=n;return}et=n=e}while(n!==null);rt===0&&(rt=5)}function bs(e,n,s){var l=je,r=Ft.transition;try{Ft.transition=null,je=1,Gm(e,n,s,l)}finally{Ft.transition=r,je=l}return null}function Gm(e,n,s,l){do jl();while(Mn!==null);if(ge&6)throw Error(G(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(G(177));e.callbackNode=null,e.callbackPriority=0;var i=s.lanes|s.childLanes;if(kx(e,i),e===ot&&(et=ot=null,pt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||ei||(ei=!0,Gf(Si,function(){return jl(),null})),i=(s.flags&15990)!==0,s.subtreeFlags&15990||i){i=Ft.transition,Ft.transition=null;var o=je;je=1;var d=ge;ge|=4,Cd.current=null,Bm(e,s),Lf(s,e),um(xo),_i=!!go,xo=go=null,e.current=s,$m(s),xx(),ge=d,je=o,Ft.transition=i}else e.current=s;if(ei&&(ei=!1,Mn=e,$i=r),i=e.pendingLanes,i===0&&(Jn=null),vx(s.stateNode),It(e,Xe()),n!==null)for(l=e.onRecoverableError,s=0;s<n.length;s++)r=n[s],l(r.value,{componentStack:r.stack,digest:r.digest});if(Bi)throw Bi=!1,e=Lo,Lo=null,e;return $i&1&&e.tag!==0&&jl(),i=e.pendingLanes,i&1?e===Wo?or++:(or=0,Wo=e):or=0,rs(),null}function jl(){if(Mn!==null){var e=bp($i),n=Ft.transition,s=je;try{if(Ft.transition=null,je=16>e?16:e,Mn===null)var l=!1;else{if(e=Mn,Mn=null,$i=0,ge&6)throw Error(G(331));var r=ge;for(ge|=4,V=e.current;V!==null;){var i=V,o=i.child;if(V.flags&16){var d=i.deletions;if(d!==null){for(var u=0;u<d.length;u++){var c=d[u];for(V=c;V!==null;){var _=V;switch(_.tag){case 0:case 11:case 15:ir(8,_,i)}var m=_.child;if(m!==null)m.return=_,V=m;else for(;V!==null;){_=V;var y=_.sibling,h=_.return;if(Rf(_),_===c){V=null;break}if(y!==null){y.return=h,V=y;break}V=h}}}var b=i.alternate;if(b!==null){var z=b.child;if(z!==null){b.child=null;do{var j=z.sibling;z.sibling=null,z=j}while(z!==null)}}V=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,V=o;else e:for(;V!==null;){if(i=V,i.flags&2048)switch(i.tag){case 0:case 11:case 15:ir(9,i,i.return)}var f=i.sibling;if(f!==null){f.return=i.return,V=f;break e}V=i.return}}var a=e.current;for(V=a;V!==null;){o=V;var x=o.child;if(o.subtreeFlags&2064&&x!==null)x.return=o,V=x;else e:for(o=a;V!==null;){if(d=V,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:Zi(9,d)}}catch(C){He(d,d.return,C)}if(d===o){V=null;break e}var g=d.sibling;if(g!==null){g.return=d.return,V=g;break e}V=d.return}}if(ge=r,rs(),fn&&typeof fn.onPostCommitFiberRoot=="function")try{fn.onPostCommitFiberRoot(Gi,e)}catch{}l=!0}return l}finally{je=s,Ft.transition=n}}return!1}function gu(e,n,s){n=Cl(s,n),n=Sf(e,n,1),e=qn(e,n,1),n=bt(),e!==null&&(Tr(e,1,n),It(e,n))}function He(e,n,s){if(e.tag===3)gu(e,e,s);else for(;n!==null;){if(n.tag===3){gu(n,e,s);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Jn===null||!Jn.has(l))){e=Cl(s,e),e=wf(n,e,1),n=qn(n,e,1),e=bt(),n!==null&&(Tr(n,1,e),It(n,e));break}}n=n.return}}function Km(e,n,s){var l=e.pingCache;l!==null&&l.delete(n),n=bt(),e.pingedLanes|=e.suspendedLanes&s,ot===e&&(pt&s)===s&&(rt===4||rt===3&&(pt&130023424)===pt&&500>Xe()-Id?ks(e,0):zd|=s),It(e,n)}function Mf(e,n){n===0&&(e.mode&1?(n=Hr,Hr<<=1,!(Hr&130023424)&&(Hr=4194304)):n=1);var s=bt();e=An(e,n),e!==null&&(Tr(e,n,s),It(e,s))}function Qm(e){var n=e.memoizedState,s=0;n!==null&&(s=n.retryLane),Mf(e,s)}function Ym(e,n){var s=0;switch(e.tag){case 13:var l=e.stateNode,r=e.memoizedState;r!==null&&(s=r.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(G(314))}l!==null&&l.delete(n),Mf(e,s)}var Hf;Hf=function(e,n,s){if(e!==null)if(e.memoizedProps!==n.pendingProps||Ct.current)kt=!0;else{if(!(e.lanes&s)&&!(n.flags&128))return kt=!1,Om(e,n,s);kt=!!(e.flags&131072)}else kt=!1,Ae&&n.flags&1048576&&Qp(n,Ai,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;hi(e,n),e=n.pendingProps;var r=Sl(n,yt.current);vl(n,s),r=bd(null,n,l,e,r,s);var i=Sd();return n.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,zt(l)?(i=!0,Ti(n)):i=!1,n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,xd(n),r.updater=Vi,n.stateNode=r,r._reactInternals=n,ko(n,l,e,s),n=Io(null,n,l,!0,i,s)):(n.tag=0,Ae&&i&&dd(n),jt(null,n,r,s),n=n.child),n;case 16:l=n.elementType;e:{switch(hi(e,n),e=n.pendingProps,r=l._init,l=r(l._payload),n.type=l,r=n.tag=qm(l),e=Xt(l,e),r){case 0:n=zo(null,n,l,e,s);break e;case 1:n=ru(null,n,l,e,s);break e;case 11:n=su(null,n,l,e,s);break e;case 14:n=lu(null,n,l,Xt(l.type,e),s);break e}throw Error(G(306,l,""))}return n;case 0:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Xt(l,r),zo(e,n,l,r,s);case 1:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Xt(l,r),ru(e,n,l,r,s);case 3:e:{if(zf(n),e===null)throw Error(G(387));l=n.pendingProps,i=n.memoizedState,r=i.element,Zp(e,n),Di(n,l,null,s);var o=n.memoizedState;if(l=o.element,i.isDehydrated)if(i={element:l,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},n.updateQueue.baseState=i,n.memoizedState=i,n.flags&256){r=Cl(Error(G(423)),n),n=iu(e,n,l,s,r);break e}else if(l!==r){r=Cl(Error(G(424)),n),n=iu(e,n,l,s,r);break e}else for(Rt=Xn(n.stateNode.containerInfo.firstChild),Dt=n,Ae=!0,Jt=null,s=Jp(n,null,l,s),n.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(wl(),l===r){n=Pn(e,n,s);break e}jt(e,n,l,s)}n=n.child}return n;case 5:return ef(n),e===null&&So(n),l=n.type,r=n.pendingProps,i=e!==null?e.memoizedProps:null,o=r.children,mo(l,r)?o=null:i!==null&&mo(l,i)&&(n.flags|=32),Cf(e,n),jt(e,n,o,s),n.child;case 6:return e===null&&So(n),null;case 13:return If(e,n,s);case 4:return md(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=_l(n,null,l,s):jt(e,n,l,s),n.child;case 11:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Xt(l,r),su(e,n,l,r,s);case 7:return jt(e,n,n.pendingProps,s),n.child;case 8:return jt(e,n,n.pendingProps.children,s),n.child;case 12:return jt(e,n,n.pendingProps.children,s),n.child;case 10:e:{if(l=n.type._context,r=n.pendingProps,i=n.memoizedProps,o=r.value,we(Pi,l._currentValue),l._currentValue=o,i!==null)if(en(i.value,o)){if(i.children===r.children&&!Ct.current){n=Pn(e,n,s);break e}}else for(i=n.child,i!==null&&(i.return=n);i!==null;){var d=i.dependencies;if(d!==null){o=i.child;for(var u=d.firstContext;u!==null;){if(u.context===l){if(i.tag===1){u=In(-1,s&-s),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var _=c.pending;_===null?u.next=u:(u.next=_.next,_.next=u),c.pending=u}}i.lanes|=s,u=i.alternate,u!==null&&(u.lanes|=s),wo(i.return,s,n),d.lanes|=s;break}u=u.next}}else if(i.tag===10)o=i.type===n.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(G(341));o.lanes|=s,d=o.alternate,d!==null&&(d.lanes|=s),wo(o,s,n),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===n){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}jt(e,n,r.children,s),n=n.child}return n;case 9:return r=n.type,l=n.pendingProps.children,vl(n,s),r=Mt(r),l=l(r),n.flags|=1,jt(e,n,l,s),n.child;case 14:return l=n.type,r=Xt(l,n.pendingProps),r=Xt(l.type,r),lu(e,n,l,r,s);case 15:return _f(e,n,n.type,n.pendingProps,s);case 17:return l=n.type,r=n.pendingProps,r=n.elementType===l?r:Xt(l,r),hi(e,n),n.tag=1,zt(l)?(e=!0,Ti(n)):e=!1,vl(n,s),bf(n,l,r),ko(n,l,r,s),Io(null,n,l,!0,e,s);case 19:return Tf(e,n,s);case 22:return kf(e,n,s)}throw Error(G(156,n.tag))};function Gf(e,n){return mp(e,n)}function Xm(e,n,s,l){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ut(e,n,s,l){return new Xm(e,n,s,l)}function Pd(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qm(e){if(typeof e=="function")return Pd(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Jo)return 11;if(e===Vo)return 14}return 2}function Zn(e,n){var s=e.alternate;return s===null?(s=Ut(e.tag,n,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=n,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,n=e.dependencies,s.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function mi(e,n,s,l,r,i){var o=2;if(l=e,typeof e=="function")Pd(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case sl:return Cs(s.children,r,i,n);case qo:o=8,r|=8;break;case Ya:return e=Ut(12,s,n,r|2),e.elementType=Ya,e.lanes=i,e;case Xa:return e=Ut(13,s,n,r),e.elementType=Xa,e.lanes=i,e;case qa:return e=Ut(19,s,n,r),e.elementType=qa,e.lanes=i,e;case ep:return ta(s,r,i,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Vu:o=10;break e;case Zu:o=9;break e;case Jo:o=11;break e;case Vo:o=14;break e;case Nn:o=16,l=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return n=Ut(o,s,n,r),n.elementType=e,n.type=l,n.lanes=i,n}function Cs(e,n,s,l){return e=Ut(7,e,l,n),e.lanes=s,e}function ta(e,n,s,l){return e=Ut(22,e,l,n),e.elementType=ep,e.lanes=s,e.stateNode={isHidden:!1},e}function Ma(e,n,s){return e=Ut(6,e,null,n),e.lanes=s,e}function Ha(e,n,s){return n=Ut(4,e.children!==null?e.children:[],e.key,n),n.lanes=s,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Jm(e,n,s,l,r){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=_a(0),this.expirationTimes=_a(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_a(0),this.identifierPrefix=l,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Rd(e,n,s,l,r,i,o,d,u){return e=new Jm(e,n,s,d,u),n===1?(n=1,i===!0&&(n|=8)):n=0,i=Ut(3,null,null,n),e.current=i,i.stateNode=e,i.memoizedState={element:l,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},xd(i),e}function Vm(e,n,s){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:nl,key:l==null?null:""+l,children:e,containerInfo:n,implementation:s}}function Kf(e){if(!e)return ts;e=e._reactInternals;e:{if(Ds(e)!==e||e.tag!==1)throw Error(G(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(zt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(G(171))}if(e.tag===1){var s=e.type;if(zt(s))return Gp(e,s,n)}return n}function Qf(e,n,s,l,r,i,o,d,u){return e=Rd(s,l,!0,e,r,i,o,d,u),e.context=Kf(null),s=e.current,l=bt(),r=Vn(s),i=In(l,r),i.callback=n??null,qn(s,i,r),e.current.lanes=r,Tr(e,r,l),It(e,l),e}function na(e,n,s,l){var r=n.current,i=bt(),o=Vn(r);return s=Kf(s),n.context===null?n.context=s:n.pendingContext=s,n=In(i,o),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=qn(r,n,o),e!==null&&(Zt(e,r,o,i),ui(e,r,o)),o}function Fi(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 xu(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<n?s:n}}function Dd(e,n){xu(e,n),(e=e.alternate)&&xu(e,n)}function Zm(){return null}var Yf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Od(e){this._internalRoot=e}sa.prototype.render=Od.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(G(409));na(e,n,null,null)};sa.prototype.unmount=Od.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;As(function(){na(null,e,null,null)}),n[En]=null}};function sa(e){this._internalRoot=e}sa.prototype.unstable_scheduleHydration=function(e){if(e){var n=_p();e={blockedOn:null,target:e,priority:n};for(var s=0;s<$n.length&&n!==0&&n<$n[s].priority;s++);$n.splice(s,0,e),s===0&&Cp(e)}};function Ld(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function la(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function mu(){}function ey(e,n,s,l,r){if(r){if(typeof l=="function"){var i=l;l=function(){var c=Fi(o);i.call(c)}}var o=Qf(n,l,e,0,null,!1,!1,"",mu);return e._reactRootContainer=o,e[En]=o.current,mr(e.nodeType===8?e.parentNode:e),As(),o}for(;r=e.lastChild;)e.removeChild(r);if(typeof l=="function"){var d=l;l=function(){var c=Fi(u);d.call(c)}}var u=Rd(e,0,!1,null,null,!1,!1,"",mu);return e._reactRootContainer=u,e[En]=u.current,mr(e.nodeType===8?e.parentNode:e),As(function(){na(n,u,s,l)}),u}function ra(e,n,s,l,r){var i=s._reactRootContainer;if(i){var o=i;if(typeof r=="function"){var d=r;r=function(){var u=Fi(o);d.call(u)}}na(n,o,e,r)}else o=ey(s,n,e,r,l);return Fi(o)}Sp=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var s=Jl(n.pendingLanes);s!==0&&(td(n,s|1),It(n,Xe()),!(ge&6)&&(zl=Xe()+500,rs()))}break;case 13:As(function(){var l=An(e,1);if(l!==null){var r=bt();Zt(l,e,1,r)}}),Dd(e,1)}};nd=function(e){if(e.tag===13){var n=An(e,134217728);if(n!==null){var s=bt();Zt(n,e,134217728,s)}Dd(e,134217728)}};wp=function(e){if(e.tag===13){var n=Vn(e),s=An(e,n);if(s!==null){var l=bt();Zt(s,e,n,l)}Dd(e,n)}};_p=function(){return je};kp=function(e,n){var s=je;try{return je=e,n()}finally{je=s}};io=function(e,n,s){switch(n){case"input":if(Za(e,s),n=s.name,s.type==="radio"&&n!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<s.length;n++){var l=s[n];if(l!==e&&l.form===e.form){var r=Xi(l);if(!r)throw Error(G(90));np(l),Za(l,r)}}}break;case"textarea":lp(e,s);break;case"select":n=s.value,n!=null&&gl(e,!!s.multiple,n,!1)}};up=Td;pp=As;var ty={usingClientEntryPoint:!1,Events:[Ar,al,Xi,dp,cp,Td]},Kl={findFiberByHostInstance:Ss,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ny={bundleType:Kl.bundleType,version:Kl.version,rendererPackageName:Kl.rendererPackageName,rendererConfig:Kl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Rn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=gp(e),e===null?null:e.stateNode},findFiberByHostInstance:Kl.findFiberByHostInstance||Zm,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ti=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ti.isDisabled&&ti.supportsFiber)try{Gi=ti.inject(ny),fn=ti}catch{}}Lt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ty;Lt.createPortal=function(e,n){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ld(n))throw Error(G(200));return Vm(e,n,null,s)};Lt.createRoot=function(e,n){if(!Ld(e))throw Error(G(299));var s=!1,l="",r=Yf;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(r=n.onRecoverableError)),n=Rd(e,1,!1,null,null,s,!1,l,r),e[En]=n.current,mr(e.nodeType===8?e.parentNode:e),new Od(n)};Lt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(G(188)):(e=Object.keys(e).join(","),Error(G(268,e)));return e=gp(n),e=e===null?null:e.stateNode,e};Lt.flushSync=function(e){return As(e)};Lt.hydrate=function(e,n,s){if(!la(n))throw Error(G(200));return ra(null,e,n,!0,s)};Lt.hydrateRoot=function(e,n,s){if(!Ld(e))throw Error(G(405));var l=s!=null&&s.hydratedSources||null,r=!1,i="",o=Yf;if(s!=null&&(s.unstable_strictMode===!0&&(r=!0),s.identifierPrefix!==void 0&&(i=s.identifierPrefix),s.onRecoverableError!==void 0&&(o=s.onRecoverableError)),n=Qf(n,null,e,1,s??null,r,!1,i,o),e[En]=n.current,mr(e),l)for(e=0;e<l.length;e++)s=l[e],r=s._getVersion,r=r(s._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[s,r]:n.mutableSourceEagerHydrationData.push(s,r);return new sa(n)};Lt.render=function(e,n,s){if(!la(n))throw Error(G(200));return ra(null,e,n,!1,s)};Lt.unmountComponentAtNode=function(e){if(!la(e))throw Error(G(40));return e._reactRootContainer?(As(function(){ra(null,null,e,!1,function(){e._reactRootContainer=null,e[En]=null})}),!0):!1};Lt.unstable_batchedUpdates=Td;Lt.unstable_renderSubtreeIntoContainer=function(e,n,s,l){if(!la(s))throw Error(G(200));if(e==null||e._reactInternals===void 0)throw Error(G(38));return ra(e,n,s,!1,l)};Lt.version="18.3.1-next-f1338f8080-20240426";function Xf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Xf)}catch(e){console.error(e)}}Xf(),Yu.exports=Lt;var sy=Yu.exports,qf,yu=sy;qf=yu.createRoot,yu.hydrateRoot;const de="",D={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"},X={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"}],Jf=[{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"?[]:Jf.filter(({id:n})=>e==="Admin"||!ry.has(n))}const Wn=(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:Wn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:Wn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:Wn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:Wn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:Wn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:Wn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:Wn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:Wn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},users:{label:"Users",orgField:"custom_organization",columns:[{key:"full_name",label:"Full Name"},{key:"email",label:"Email"},{key:"username",label:"Username"},{key:"mobile_no",label:"Phone"},{key:"custom_category",label:"Category"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_department",label:"Department"},{key:"custom_branch",label:"Branch"},{key:"custom_number",label:"User ID No"},{key:"enabled",label:"Active"},{key:"creation",label:"Created On"}],defaultColumns:["full_name","email","custom_category","custom_organization","enabled"]},delegations:{label:"Delegations",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"auditor",label:"Delegator"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"incident_initial_evaluation",label:"Incident Initial Evaluation"},{key:"idea_initial_evaluation",label:"Idea Initial Evaluation"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","incident_initial_evaluation","idea_initial_evaluation","status","requested_on"]},"group-companies":{label:"Group Companies",columns:[{key:"company_name",label:"Company Name"},{key:"code",label:"Code"},{key:"acronym",label:"Acronym"},{key:"owner_user",label:"Group Co Owner"},{key:"status",label:"Status"}],defaultColumns:["company_name","code","acronym","owner_user","status"]}},oy=()=>t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),dy=()=>t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),cy=()=>t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v6M14 11v6"}),t.jsx("path",{d:"M9 6V4h6v2"})]});function it({onView:e,onEdit:n,onDelete:s}){const l=(r,i,o,d,u,c)=>d?t.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),d()},title:c,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:r,color:o,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:_=>{_.currentTarget.style.background=i,_.currentTarget.style.transform="scale(1.08)"},onMouseLeave:_=>{_.currentTarget.style.background=r,_.currentTarget.style.transform="scale(1)"},children:u},c):null;return t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l("#f0f9ff","#e0f2fe","#0284c7",e,t.jsx(oy,{}),"View"),l("#f0fdf4","#dcfce7","#16a34a",n,t.jsx(dy,{}),"Edit"),s&&l("#fff1f2","#fee2e2","#e11d48",s,t.jsx(cy,{}),"Delete")]})}const 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"},E={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 ye(e,n){return e.filter(s=>uy(s)||s.name===n)}const py={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function Hn(e,n){return!!n&&py[e].includes(n)}function Il(e,n,s,l){return e.filter(r=>{const i=n[r.name]||[];return!(i.includes("SB Admin")||i.includes("System Manager")||!i.includes(s)||l&&r.custom_organization&&r.custom_organization!==l)})}const Tl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function yi(e){const n=(e||"").trim().toLowerCase();return n==="new"||n==="initial evaluation"||n==="draft"?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:n.includes("progress")||n.includes("review")||n.includes("proposal")||n.includes("resolution")?{bg:"#fefce8",color:"#a16207",border:"#fef08a"}:n.includes("executed")||n.includes("approved")||n.includes("active")||n.includes("closed")||n.includes("completed")?{bg:"#f0fdf4",color:"#15803d",border:"#bbf7d0"}:n.includes("rejected")||n.includes("overdue")||n.includes("fail")||n.includes("inactive")?{bg:"#fef2f2",color:"#b91c1c",border:"#fecaca"}:n.includes("deleted")?{bg:"#fff1f2",color:"#e11d48",border:"#fecdd3"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}function fy(e){const n=(e||"").trim().toLowerCase();return n.includes("incident")?{bg:"#f1f5f9",color:"#334155",border:"#cbd5e1"}:n.includes("complaint")?{bg:"#fff7ed",color:"#c2410c",border:"#fed7aa"}:n.includes("violation")?{bg:"#faf5ff",color:"#7e22ce",border:"#e9d5ff"}:n.includes("process")?{bg:"#f0fdfa",color:"#0f766e",border:"#99f6e4"}:n.includes("asset")?{bg:"#ecfeff",color:"#0e7490",border:"#a5f3fc"}:n.includes("human")?{bg:"#f5f3ff",color:"#6d28d9",border:"#ddd6fe"}:n.includes("idea")?{bg:"#ecfdf5",color:"#047857",border:"#a7f3d0"}:n.includes("study")?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}const Cr=(e,n)=>{let s;return typeof n=="object"&&n!==null?s=n:typeof n=="string"&&n.startsWith("#")?s=yi(e):typeof n=="string"?s=yi(n):s=yi(e),t.jsx("span",{className:"status-badge",style:{background:s.bg,color:s.color,border:`1px solid ${s.border}`,padding:"2px 8px",borderRadius:9999,fontSize:11,fontWeight:600,letterSpacing:"0.2px",display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:1.3,whiteSpace:"nowrap",boxSizing:"border-box",transition:"all 0.15s ease"},children:e})},ns=e=>Cr(e,yi(e)),Wd=e=>Cr(e,fy(e));function qe({deletedBy:e,deletedOn:n,reason:s,onRestore:l,isRestoring:r}){return t.jsxs("div",{style:{background:"#fff1f2",border:"1px solid #fecdd3",borderRadius:8,padding:"7px 14px",marginBottom:12,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,color:"#9f1239",fontSize:12,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsxs("div",{style:{fontWeight:700,fontSize:12,display:"flex",alignItems:"center",gap:5,color:"#be123c",whiteSpace:"nowrap"},children:[t.jsx("span",{style:{fontSize:13},children:"⚠️"}),t.jsx("span",{children:"DELETED RECORD / سجل محذوف"})]}),t.jsxs("div",{style:{fontSize:11,color:"#881337",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e&&t.jsxs("span",{children:[t.jsx("strong",{children:"Deleted By:"})," ",e]}),n&&t.jsxs("span",{children:["| ",t.jsx("strong",{children:"Deleted On:"})," ",n]}),s&&t.jsxs("span",{children:["| ",t.jsx("strong",{children:"Reason:"})," ",s]})]})]}),l&&t.jsxs("button",{type:"button",onClick:l,disabled:r,style:{background:"#e11d48",color:"white",border:"none",borderRadius:6,padding:"5px 12px",fontSize:11,fontWeight:700,cursor:r?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:5,whiteSpace:"nowrap",transition:"all 0.15s ease"},onMouseEnter:i=>{r||(i.currentTarget.style.background="#be123c")},onMouseLeave:i=>{r||(i.currentTarget.style.background="#e11d48")},children:[t.jsx("span",{children:"↺"}),t.jsx("span",{children:r?"Restoring...":"Restore Record / استعادة"})]})]})}function ia({onDelete:e,disabled:n,title:s="Delete Request",btnText:l="Delete"}){return t.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #fee2e2",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:s}),t.jsxs("button",{type:"button",onClick:e,disabled:n,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:"#dc2626",color:"#ffffff",fontWeight:700,fontSize:12,cursor:n?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,boxShadow:"0 1px 3px rgba(220, 38, 38, 0.25)",transition:"all 0.15s ease"},onMouseEnter:r=>{n||(r.currentTarget.style.background="#b91c1c")},onMouseLeave:r=>{n||(r.currentTarget.style.background="#dc2626")},children:[t.jsx("span",{children:"🗑️"}),t.jsx("span",{children:l})]})]})}function le({title:e,children:n,style:s}){return t.jsxs("div",{className:"form-card",style:{background:"#ffffff",borderRadius:10,border:"1px solid #e2e8f0",padding:"16px 20px",marginBottom:16,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.03)",...s},children:[t.jsx("div",{className:"form-card-title",style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:t.jsx("span",{children:e})}),n]})}function aa({title:e="Status Summary",priority:n,createdDate:s,modifiedDate:l,assignedTo:r,status:i}){const o=d=>{if(!d)return"—";try{const u=new Date(d);return isNaN(u.getTime())?d:u.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return d}};return t.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:12},children:e}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[n&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Priority"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:n==="High"||n==="Urgent"?"#dc2626":"#1e293b"},children:n})]}),i&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Status"}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#334155"},children:i})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Assigned To"}),t.jsx("div",{style:{fontSize:12,fontWeight:600,color:r?"#334155":"#94a3b8",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r||"—"})]}),s&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Created"}),t.jsx("div",{style:{fontSize:11,color:"#64748b"},children:o(s)})]}),l&&t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Last Modified"}),t.jsx("div",{style:{fontSize:11,color:"#64748b"},children:o(l)})]})]})]})}const hy="modulepreload",gy=function(e){return"/"+e},vu={},xy=function(n,s,l){let r=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),d=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=Promise.allSettled(s.map(u=>{if(u=gy(u),u in vu)return;vu[u]=!0;const c=u.endsWith(".css"),_=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${_}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":hy,c||(m.as="script"),m.crossOrigin="",m.href=u,d&&m.setAttribute("nonce",d),document.head.appendChild(m),c)return new Promise((y,h)=>{m.addEventListener("load",y),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=o,window.dispatchEvent(d),!d.defaultPrevented)throw o}return r.then(o=>{for(const d of o||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function Vf(e,n){const s=e[n.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function my(e,n){const s=URL.createObjectURL(e),l=document.createElement("a");l.href=s,l.download=n,l.click(),URL.revokeObjectURL(s)}function yy(e,n,s){const l=e.map(o=>`"${o.label.replace(/"/g,'""')}"`).join(","),r=n.map(o=>e.map(d=>`"${Vf(o,d).replace(/"/g,'""')}"`).join(",")).join(`
`),i=new Blob([l+`
`+r],{type:"text/csv;charset=utf-8;"});my(i,`${s}.csv`)}async function vy(e,n,s){const l=await xy(()=>import("./xlsx-D_0l8YDs.js"),[]),r=n.map(d=>{const u={};for(const c of e)u[c.label]=Vf(d,c);return u}),i=l.utils.json_to_sheet(r,{header:e.map(d=>d.label)}),o=l.utils.book_new();l.utils.book_append_sheet(o,i,"Export"),l.writeFile(o,`${s}.xlsx`)}const on="#16a34a";function jy({title:e,rows:n,selectedRows:s=[],pageRows:l=[],columns:r,defaultColumnKeys:i,filenameBase:o,onClose:d}){const[u,c]=S.useState(s.length>0?"selected":"all"),[_,m]=S.useState("csv"),[y,h]=S.useState(new Set(i)),[b,z]=S.useState("");S.useEffect(()=>{s&&s.length>0&&c("selected")},[s]);const j=u==="selected"?s:u==="page"?l:n,f=r.filter(k=>y.has(k.key)),a=b?r.filter(k=>k.label.toLowerCase().includes(b.toLowerCase())):r,x=k=>{h(T=>{const A=new Set(T);return A.has(k)?A.delete(k):A.add(k),A})},g=async()=>{f.length===0||j.length===0||(_==="csv"?yy(f,j,o):await vy(f,j,o),d())},C={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},w={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"},p=[{id:"selected",label:"Selected rows",sub:`${s.length} row${s.length!==1?"s":""} selected`,count:s.length,disabled:s.length===0},{id:"page",label:"Current page",sub:`${l.length} row${l.length!==1?"s":""} on this page`,count:l.length},{id:"all",label:"All records (current filters)",sub:`${n.length} total matching records`,count:n.length}];return t.jsx("div",{onClick:d,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:t.jsxs("div",{onClick:k=>k.stopPropagation(),style:{width:580,maxWidth:"92vw",maxHeight:"90vh",background:"white",borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.3)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{background:on,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[t.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e,t.jsxs("span",{style:{fontSize:12,fontWeight:400,opacity:.8},children:[r.length," fields available · ",y.size," selected"]})]}),t.jsx("button",{onClick:d,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"white",width:28,height:28,borderRadius:8,cursor:"pointer",fontSize:15,lineHeight:1},children:"✕"})]}),t.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1,display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{children:[t.jsx("div",{style:C,children:"What to export"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:p.map(k=>t.jsxs("label",{onClick:()=>!k.disabled&&c(k.id),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderRadius:10,cursor:k.disabled?"not-allowed":"pointer",border:`2px solid ${u===k.id?on:"#e5e7eb"}`,background:u===k.id?"#f0fdf4":k.disabled?"#fafafa":"white",opacity:k.disabled?.5:1,transition:"border-color 0.15s, background 0.15s"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${u===k.id?on:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:u===k.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:on}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#111827"},children:k.label}),t.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:1},children:k.sub})]})]}),t.jsx("span",{style:{background:u===k.id?on:"#e5e7eb",color:u===k.id?"white":"#374151",fontSize:12,fontWeight:700,padding:"2px 10px",borderRadius:9999},children:k.count})]},k.id))})]}),t.jsxs("div",{children:[t.jsx("div",{style:C,children:"File Format"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Universal, works everywhere",icon:"📄"},{id:"xlsx",label:"Excel (.xlsx)",desc:"Native Excel workbook",icon:"📊"}].map(k=>t.jsxs("div",{onClick:()=>m(k.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${_===k.id?on:"#e5e7eb"}`,background:_===k.id?"#f0fdf4":"white"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",border:`2px solid ${_===k.id?on:"#d1d5db"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:_===k.id&&t.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:on}})}),t.jsx("span",{style:{fontSize:20},children:k.icon}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:k.label}),t.jsx("div",{style:{fontSize:11,color:"#888"},children:k.desc})]})]},k.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[t.jsx("div",{style:{...C,marginBottom:0},children:"Columns to Export"}),t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsx("button",{onClick:()=>h(new Set(r.map(k=>k.key))),style:w,children:"All"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>h(new Set(i)),style:w,children:"Default"}),t.jsx("span",{style:{color:"#d1d5db"},children:"|"}),t.jsx("button",{onClick:()=>h(new Set),style:{...w,color:"#ef4444"},children:"None"})]})]}),t.jsx("div",{style:{marginBottom:8},children:t.jsx("input",{type:"text",placeholder:"Search fields...",value:b,onChange:k=>z(k.target.value),style:{width:"100%",padding:"7px 10px",borderRadius:8,border:"1px solid #e5e7eb",fontSize:12,boxSizing:"border-box",background:"#f9fafb"}})}),t.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:"10px 12px"},children:a.map(k=>t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer",padding:"3px 5px",borderRadius:5,background:y.has(k.key)?"#f0fdf4":"transparent"},children:[t.jsx("input",{type:"checkbox",checked:y.has(k.key),onChange:()=>x(k.key),style:{accentColor:on,cursor:"pointer"}}),k.label]},k.key))})}),t.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[y.size," of ",r.length," fields selected"]})]})]}),t.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[t.jsxs("span",{style:{fontSize:12,color:"#888"},children:["Exporting ",j.length," ",u==="selected"?"selected":u==="page"?"page":""," row",j.length!==1?"s":""]}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsx("button",{onClick:d,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),t.jsx("button",{onClick:g,disabled:f.length===0||j.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:on,color:"white",fontWeight:700,fontSize:13,cursor:f.length===0||j.length===0?"not-allowed":"pointer",opacity:f.length===0||j.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const Zf="sidrah_rtl",$o="sidrah-lang-change";function hl(){try{return localStorage.getItem(Zf)==="1"}catch{return!1}}function eh(){const e=!hl();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($o))}function ne(){const[e,n]=S.useState(hl);return S.useEffect(()=>{const s=()=>n(hl());return window.addEventListener($o,s),document.documentElement.setAttribute("dir",hl()?"rtl":"ltr"),document.documentElement.setAttribute("lang",hl()?"ar":"en-GB"),()=>window.removeEventListener($o,s)},[]),e?Sy:by}const by={rtl:!1,nav:{dashboard:"Dashboard",inbox:"Inbox",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",reports:"Reports",users:"Users",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",settings:"Settings"},pages:{dashboard:"Dashboard",inbox:"Inbox",reports:"Reports",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",users:"Users"},new:"+ New",save:"Save",cancel:"Cancel",edit:"Edit",delete:"Delete",deletedBadge:"DELETED",restore:"Restore",restoring:"Restoring...",restoredOk:"Record restored successfully!",deletedBanner:"⚠️ This record has been deleted",deletedBy:"Deleted by",deletedOn:"Deleted on",deletedReason:"Reason",deleteModal:{title:"Confirm Deletion",subtitle:"Are you sure you want to delete this record?",softDeleteTitle:"Delete",softDeleteDesc:"Moves the record to deleted state. It can be restored later by an Administrator.",permanentDeleteTitle:"Permanent Delete",permanentDeleteDesc:"Permanently removes this record from the database. This action cannot be undone.",reasonLabel:"Reason for deletion (optional):",reasonPlaceholder:"Enter deletion reason…",softDeleteBtn:"Delete",permanentDeleteBtn:"Permanent Delete",cancelBtn:"Cancel",deleting:"Deleting…"},view:"View",back:"← Back",clear:"Clear",search:"Search",loading:"Loading...",saving:"Saving...",savedOk:"Saved successfully!",home:"Home",noRecords:"No records found",login:{subtitle:"Sign in to continue",username:"USERNAME",password:"PASSWORD",usernamePlaceholder:"Enter username",passwordPlaceholder:"Enter password",signIn:"Sign In",signingIn:"Signing in...",invalidCreds:"Invalid username or password",emptyFields:"Please enter username and password",connError:"Connection error: "},myProfile:"My Profile",signOut:"Sign Out",switchLang:"العربية (RTL)",filter:{numberTitle:"Number / Title",searchPlaceholder:"Search...",organization:"Organization",department:"Department",branch:"Branch",status:"Status",allOrgs:"All Organizations",allDepts:"All Departments",allBranches:"All Branches",allStatuses:"All Statuses",allTypes:"All Types"},col:{number:"Number",title:"Title",organization:"Organization",type:"Type",status:"Status",actions:"Actions",name:"Name",department:"Department",branch:"Branch",city:"City",email:"Email",management:"Management",organization_type:"Type",frequency:"Frequency",period:"Period",startDate:"Start Date",endDate:"End Date",auditor:"Auditor",manager:"Manager",functions:"Functions",requestedOn:"Requested On"},field:{number:"Number",title:"Title",organization:"Organization",management:"Management",department:"Department",section:"Section",branch:"Branch",type:"Type",date:"Date",time:"Time",status:"Status",description:"Description",assignedTo:"Assigned To",hsesField:"HSES Field",priority:"Priority",economyClass:"Economy Class",entityScope:"Entity Scope",productRelation:"Product Relation",repeatedEvent:"Repeated Event",solution:"Solution / Action Plan",actualCost:"Actual Cost",summary:"Resolution Summary",auditorComment:"Auditor Comment",incidentClass:"Incident Class",incidentField:"Incident Field",currentCondition:"Current Condition",proposedCondition:"Proposed Condition",ideaClass:"Idea Class",startingDate:"Starting Date",endingDate:"Ending Date",budget:"Budget",currency:"Currency",notes:"Notes",cycle:"Cycle",stage:"Stage",completionPct:"Completion %",actor:"Actor",escalationLevel:"Escalation Level",dateStart:"Start Date",dateEnd:"End Date",cycleType:"Cycle Type",progressIndicators:"Progress Indicators",impactLevel:"Impact Level",kpiName:"KPI Name",kpiType:"KPI Type",kpiMeasure:"KPI Measure",costPerCycle:"Cost per Cycle",chainLocation:"Chain Location",notifyManager:"Notify Manager",creationDate:"Creation Date",statusActive:"Active",statusInactive:"Inactive",name1:"Name",fullName:"Full Name",username:"Username",emailAddress:"Email Address",phoneNumber:"Phone Number",category:"Category",since:"Since",active:"Active",inactive:"Inactive",enabled:"Enabled",selectMgr:"-- Select manager --",select:"-- Select --",eventCategory:"Event Category",selectType:"-- Select type --",selectClass:"-- Select class --",selectField:"-- Select field --",selectStatus:"-- Select status --",solutionPlaceholder:"Describe the solution or action taken…",commentPlaceholder:"Optional comment…",high:"High",normal:"Normal",expenses:"Expenses",capital:"Capital",earn:"Earn",payLoss:"Pay/Loss",upstream:"Upstream",onstream:"On-stream",downstream:"Downstream",government:"Government",private:"Private",linkedOrder:"Linked Order",linkedIdea:"Linked Idea",convertedToOrder:"Converted to Order",originatingIdea:"Originating Idea",viewOrder:"View Order",viewIdea:"View Idea",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",cycleActive:"Active",cycleCompleted:"Completed",cyclePaused:"Paused",updateWindowDays:"Update Window (days)",incidentTriageWindowDays:"Triage Window (days)",incidentResolutionWindowDays:"Resolution Window (days)",orgAcronym:"Acronym",contactEmail:"Contact Email",orgCity:"City",orgName:"Organization Name",organizationType:"Organization Type",revenue_growth:"Revenue Growth (%)",net_profit:"Net Profit",cash_flow:"Cash Flow",strategic_goal_pct:"Strategic Goal (%)",customer_satisfaction:"Customer Satisfaction",employee_turnover_pct:"Employee Turnover (%)",open_safety_incidents:"Open Safety Incidents",compliance_score:"Compliance Score"},wf:{workflow:"Workflow",noActions:"No actions available for your role in this state.",applying:"Applying…",submit:"Submit",assignToManager:"Assign to Manager",reject:"Reject",submitSolution:"Submit Solution",resolutionComplete:"Resolution complete",moveToOutsourcing:"Move to Outsourcing",closeIdea:"Close Idea"},steps:{auditorTriage:"Auditor Triage (Step 2)",managerSolution:"Manager Solution (Step 3)",ownerComment:"Owner / Auditor Comment (Step 4)",auditorEval:"Auditor Evaluation (Step 2)",managerReview:"Manager Review (Step 3)"},formTitle:{newIncident:"New Incident",editIncident:"Edit Incident",viewIncident:"Incident: ",newIdea:"New Idea",editIdea:"Edit Idea",viewIdea:"Idea: ",newOrder:"New Order",editOrder:"Edit Order",viewOrder:"Order: ",newProcess:"New Process",editProcess:"Edit Process",viewProcess:"Process: ",newOrg:"New Organization",editOrg:"Edit Organization",newMgmt:"New Management",editMgmt:"Edit Management",newDept:"New Department",editDept:"Edit Department",newBranch:"New Branch",editBranch:"Edit Branch",newUser:"New User",editUser:"Edit User",viewUser:"User Profile",newCycle:"New Cycle",editCycle:"Edit Cycle",newKpi:"New KPI Input",editKpi:"Edit KPI Input",newDelegation:"New Delegation",viewDelegation:"Delegation: "},saveIncident:"Save Incident",saveIdea:"Save Idea",saveOrder:"Save Order",saveProcess:"Save Process",saveOrg:"Save Organization",saveMgmt:"Save Management",saveDept:"Save Department",saveBranch:"Save Branch",saveUser:"Save User",saveCycle:"Save Cycle",saveKpi:"Save KPI Input",saveDelegation:"Send Delegation",saveName:"Save",dash:{allOrgs:"All organizations",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",level2:"Level 2 — Critical Escalation",level1:"Level 1 — Auditor Review Needed",overduePrefix:"Overdue for Triage — ",overdueSuffix:" incident(s) past 3-day window",untriaged:"Untriaged Incidents",recentKpi:"Recent KPI Inputs",manageKpi:"Manage KPI Inputs",escalatedProcesses:"Escalated Processes",escalatedOrders:"Escalated Orders",level:"Level",revenueGrowth:"Revenue Growth",netProfit:"Net Profit",strategicGoal:"Strategic Goal",customerSat:"Customer Sat.",compliance:"Compliance",safetyInc:"Safety Incidents",total:"Total"},noIncidents:"No incidents found",noIdeas:"No ideas found",noOrders:"No orders found",noProcesses:"No processes found",noUsers:"No users found",noData:"No data found",users:{category:"Category",number:"Number",fullName:"Full Name",username:"Username",email:"Email Address",phone:"Phone Number",organization:"Organization",management:"Management",department:"Department",branch:"Branch",since:"Since",status:"Status",tools:"Tools",active:"Active",inactive:"Inactive",setPassword:"Set Password",newPassword:"New password",passwordUpdated:"Password updated!",passwordFailed:"Failed. Please try again.",disableConfirm:"Delete user? They will no longer appear in the list.",password:"Password"},inbox:{title:"Inbox",noMessages:"No messages"},reports:{title:"Reports",selectOrg:"Select Organization",generate:"Generate Report"},comments:{title:"Comments",placeholder:"Write a comment…",post:"Post",noComments:"No comments yet."},activity:{title:"Activity Log",created:"Created",by:"by"}},Sy={rtl:!0,nav:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",reports:"التقارير",users:"المستخدمون",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",settings:"الإعدادات"},pages:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",reports:"التقارير",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",users:"المستخدمون"},new:"+ جديد",save:"حفظ",cancel:"إلغاء",edit:"تعديل",delete:"حذف",deletedBadge:"محذوف",restore:"استعادة",restoring:"جارٍ الاستعادة...",restoredOk:"تمت استعادة السجل بنجاح!",deletedBanner:"⚠️ هذا السجل محذوف",deletedBy:"تم الحذف بواسطة",deletedOn:"تاريخ الحذف",deletedReason:"السبب",deleteModal:{title:"تأكيد الحذف",subtitle:"هل أنت متأكد من رغبتك في حذف هذا السجل؟",softDeleteTitle:"حذف",softDeleteDesc:"يتم نقل السجل إلى سلة المحذوفات. يمكن للمسؤول استعادته لاحقاً.",permanentDeleteTitle:"حذف نهائي",permanentDeleteDesc:"حذف السجل نهائياً من قاعدة البيانات. لا يمكن التراجع عن هذا الإجراء.",reasonLabel:"سبب الحذف (اختياري):",reasonPlaceholder:"أدخل سبب الحذف…",softDeleteBtn:"حذف",permanentDeleteBtn:"حذف نهائي",cancelBtn:"إلغاء",deleting:"جارٍ الحذف…"},view:"عرض",back:"رجوع →",clear:"مسح",search:"بحث",loading:"جارٍ التحميل...",saving:"جارٍ الحفظ...",savedOk:"تم الحفظ بنجاح!",home:"الرئيسية",noRecords:"لا توجد سجلات",login:{subtitle:"تسجيل الدخول للمتابعة",username:"اسم المستخدم",password:"كلمة المرور",usernamePlaceholder:"أدخل اسم المستخدم",passwordPlaceholder:"أدخل كلمة المرور",signIn:"تسجيل الدخول",signingIn:"جارٍ تسجيل الدخول...",invalidCreds:"اسم المستخدم أو كلمة المرور غير صحيحة",emptyFields:"الرجاء إدخال اسم المستخدم وكلمة المرور",connError:"خطأ في الاتصال: "},myProfile:"ملفي الشخصي",signOut:"تسجيل الخروج",switchLang:"English (LTR)",filter:{numberTitle:"الرقم / العنوان",searchPlaceholder:"بحث...",organization:"المؤسسة",department:"القسم",branch:"الفرع",status:"الحالة",allOrgs:"جميع المؤسسات",allDepts:"جميع الأقسام",allBranches:"جميع الفروع",allStatuses:"جميع الحالات",allTypes:"جميع الأنواع"},col:{number:"الرقم",title:"العنوان",organization:"المؤسسة",type:"النوع",status:"الحالة",actions:"الإجراءات",name:"الاسم",department:"القسم",branch:"الفرع",city:"المدينة",email:"البريد الإلكتروني",management:"الإدارة",organization_type:"النوع",frequency:"التكرار",period:"الفترة",startDate:"تاريخ البدء",endDate:"تاريخ الانتهاء",auditor:"المدقق",manager:"المدير",functions:"الوظائف",requestedOn:"تاريخ الطلب"},field:{number:"الرقم",title:"العنوان",organization:"المؤسسة",management:"الإدارة",department:"القسم",section:"القطاع",branch:"الفرع",type:"النوع",date:"التاريخ",time:"الوقت",status:"الحالة",description:"الوصف",assignedTo:"مُسند إلى",hsesField:"مجال السلامة والصحة",priority:"الأولوية",economyClass:"التصنيف الاقتصادي",entityScope:"نطاق الكيان",productRelation:"علاقة المنتج",repeatedEvent:"حدث متكرر",solution:"الحل / خطة العمل",actualCost:"التكلفة الفعلية",summary:"ملخص الحل",auditorComment:"تعليق المدقق",incidentClass:"تصنيف الحادث",incidentField:"مجال الحادث",currentCondition:"الوضع الراهن",proposedCondition:"الوضع المقترح",ideaClass:"تصنيف الفكرة",startingDate:"تاريخ البدء",endingDate:"تاريخ الانتهاء",budget:"الميزانية",currency:"العملة",notes:"الملاحظات",cycle:"الدورة",stage:"المرحلة",completionPct:"نسبة الاكتمال",actor:"المنفذ",escalationLevel:"مستوى التصعيد",dateStart:"تاريخ البدء",dateEnd:"تاريخ الانتهاء",cycleType:"نوع الدورة",progressIndicators:"مؤشرات التقدم",impactLevel:"مستوى التأثير",kpiName:"اسم المؤشر",kpiType:"نوع المؤشر",kpiMeasure:"قياس المؤشر",costPerCycle:"التكلفة لكل دورة",chainLocation:"موقع السلسلة",notifyManager:"إشعار المدير",creationDate:"تاريخ الإنشاء",statusActive:"نشط",statusInactive:"غير نشط",name1:"الاسم",fullName:"الاسم الكامل",username:"اسم المستخدم",emailAddress:"البريد الإلكتروني",phoneNumber:"رقم الهاتف",category:"الفئة",since:"منذ",active:"نشط",inactive:"غير نشط",enabled:"مفعّل",selectMgr:"-- اختر المدير --",select:"-- اختر --",eventCategory:"فئة الحدث",selectType:"-- اختر النوع --",selectClass:"-- اختر التصنيف --",selectField:"-- اختر المجال --",selectStatus:"-- اختر الحالة --",solutionPlaceholder:"صف الحل أو الإجراء المتخذ…",commentPlaceholder:"تعليق اختياري…",high:"عالي",normal:"عادي",expenses:"مصروفات",capital:"رأس مال",earn:"إيرادات",payLoss:"دفع/خسارة",upstream:"مرحلة المنبع",onstream:"على الخط",downstream:"مرحلة المصب",government:"حكومي",private:"خاص",linkedOrder:"الأمر المرتبط",linkedIdea:"الفكرة المرتبطة",convertedToOrder:"تم التحويل إلى أمر",originatingIdea:"الفكرة الأصلية",viewOrder:"عرض الأمر",viewIdea:"عرض الفكرة",monthly:"شهري",quarterly:"ربع سنوي",yearly:"سنوي",cycleActive:"نشط",cycleCompleted:"مكتمل",cyclePaused:"موقوف",updateWindowDays:"نافذة التحديث (أيام)",incidentTriageWindowDays:"نافذة الفرز (أيام)",incidentResolutionWindowDays:"نافذة الحل (أيام)",orgAcronym:"الاختصار",contactEmail:"البريد الإلكتروني للتواصل",orgCity:"المدينة",orgName:"اسم المؤسسة",organizationType:"نوع المؤسسة",revenue_growth:"نمو الإيرادات (%)",net_profit:"صافي الربح",cash_flow:"التدفق النقدي",strategic_goal_pct:"الهدف الاستراتيجي (%)",customer_satisfaction:"رضا العملاء",employee_turnover_pct:"معدل دوران الموظفين (%)",open_safety_incidents:"حوادث السلامة المفتوحة",compliance_score:"درجة الامتثال"},wf:{workflow:"سير العمل",noActions:"لا توجد إجراءات متاحة لدورك في هذه الحالة.",applying:"جارٍ التطبيق...",submit:"إرسال",assignToManager:"تعيين للمدير",reject:"رفض",submitSolution:"إرسال الحل",resolutionComplete:"اكتمال الحل",moveToOutsourcing:"نقل للاستعانة بمصادر خارجية",closeIdea:"إغلاق الفكرة"},steps:{auditorTriage:"فرز المدقق (الخطوة 2)",managerSolution:"حل المدير (الخطوة 3)",ownerComment:"تعليق المالك / المدقق (الخطوة 4)",auditorEval:"تقييم المدقق (الخطوة 2)",managerReview:"مراجعة المدير (الخطوة 3)"},formTitle:{newIncident:"حادث جديد",editIncident:"تعديل الحادث",viewIncident:"الحادث: ",newIdea:"فكرة جديدة",editIdea:"تعديل الفكرة",viewIdea:"الفكرة: ",newOrder:"طلب جديد",editOrder:"تعديل الطلب",viewOrder:"الطلب: ",newProcess:"عملية جديدة",editProcess:"تعديل العملية",viewProcess:"العملية: ",newOrg:"مؤسسة جديدة",editOrg:"تعديل المؤسسة",newMgmt:"إدارة جديدة",editMgmt:"تعديل الإدارة",newDept:"قسم جديد",editDept:"تعديل القسم",newBranch:"فرع جديد",editBranch:"تعديل الفرع",newUser:"مستخدم جديد",editUser:"تعديل المستخدم",viewUser:"ملف المستخدم",newCycle:"دورة جديدة",editCycle:"تعديل الدورة",newKpi:"مؤشر أداء جديد",editKpi:"تعديل مؤشر الأداء",newDelegation:"تفويض جديد",viewDelegation:"التفويض: "},saveIncident:"حفظ الحادث",saveIdea:"حفظ الفكرة",saveOrder:"حفظ الطلب",saveProcess:"حفظ العملية",saveOrg:"حفظ المؤسسة",saveMgmt:"حفظ الإدارة",saveDept:"حفظ القسم",saveBranch:"حفظ الفرع",saveUser:"حفظ المستخدم",saveCycle:"حفظ الدورة",saveKpi:"حفظ مؤشر الأداء",saveDelegation:"إرسال التفويض",saveName:"حفظ",dash:{allOrgs:"جميع المؤسسات",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",level2:"المستوى 2 — تصعيد حرج",level1:"المستوى 1 — مراجعة المدقق مطلوبة",overduePrefix:"متأخر للفرز — ",overdueSuffix:" حادث(ة) تجاوز نافذة 3 أيام",untriaged:"حوادث غير مفرزة",recentKpi:"مؤشرات الأداء الأخيرة",manageKpi:"إدارة مؤشرات الأداء",escalatedProcesses:"عمليات متصاعدة",escalatedOrders:"طلبات متصاعدة",level:"المستوى",revenueGrowth:"نمو الإيرادات",netProfit:"صافي الربح",strategicGoal:"الهدف الاستراتيجي",customerSat:"رضا العملاء",compliance:"الامتثال",safetyInc:"حوادث السلامة",total:"الإجمالي"},noIncidents:"لا توجد حوادث",noIdeas:"لا توجد أفكار",noOrders:"لا توجد طلبات",noProcesses:"لا توجد عمليات",noUsers:"لا يوجد مستخدمون",noData:"لا توجد بيانات",users:{category:"الفئة",number:"الرقم",fullName:"الاسم الكامل",username:"اسم المستخدم",email:"البريد الإلكتروني",phone:"رقم الهاتف",organization:"المؤسسة",management:"الإدارة",department:"القسم",branch:"الفرع",since:"منذ",status:"الحالة",tools:"الأدوات",active:"نشط",inactive:"غير نشط",setPassword:"تعيين كلمة المرور",newPassword:"كلمة مرور جديدة",passwordUpdated:"تم تحديث كلمة المرور!",passwordFailed:"فشل. الرجاء المحاولة مرة أخرى.",disableConfirm:"حذف المستخدم؟ لن يظهر في القائمة بعد الآن.",password:"كلمة المرور"},inbox:{title:"البريد الوارد",noMessages:"لا توجد رسائل"},reports:{title:"التقارير",selectOrg:"اختر المؤسسة",generate:"إنشاء التقرير"},comments:{title:"التعليقات",placeholder:"اكتب تعليقاً…",post:"نشر",noComments:"لا توجد تعليقات بعد."},activity:{title:"سجل النشاط",created:"أُنشئ",by:"بواسطة"}};function ju({isOpen:e,doctype:n,docname:s,docTitle:l,isAdmin:r,isDeleting:i,onClose:o,onConfirmSoftDelete:d,onConfirmPermanentDelete:u}){const c=ne(),[_,m]=S.useState("");if(S.useEffect(()=>{e&&m("")},[e]),S.useEffect(()=>{const h=b=>{b.key==="Escape"&&e&&!i&&o()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,i,o]),!e)return null;const y=n.replace(/^SB\s+/,"");return t.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:"rgba(15, 23, 42, 0.6)",backdropFilter:"blur(3px)",animation:"fadeIn 0.15s ease"},onClick:h=>{h.target===h.currentTarget&&!i&&o()},children:t.jsxs("div",{className:"delete-modal-card",style:{background:"white",borderRadius:12,boxShadow:"0 20px 35px -10px rgba(0, 0, 0, 0.22)",maxWidth:390,width:"100%",padding:"16px 18px",boxSizing:"border-box",position:"relative",animation:"scaleIn 0.15s ease",border:"1px solid rgba(226, 232, 240, 0.9)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#ef4444"},children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3 6h18m-2 0v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6m3 0V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),t.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),t.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("h3",{style:{margin:0,fontSize:14,fontWeight:700,color:"#1e293b"},children:c.deleteModal.title}),t.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:c.deleteModal.subtitle})]}),t.jsx("button",{type:"button",onClick:o,disabled:i,style:{background:"transparent",border:"none",color:"#94a3b8",cursor:"pointer",padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"6px 10px",marginBottom:12,display:"flex",alignItems:"center",gap:6},children:[t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.4px",flexShrink:0},children:[y,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l?`${l} (${s})`:s})]}),t.jsxs("div",{style:{marginBottom:14},children:[t.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#475569",marginBottom:4},children:c.deleteModal.reasonLabel}),t.jsx("input",{type:"text",value:_,onChange:h=>m(h.target.value),placeholder:c.deleteModal.reasonPlaceholder,disabled:i,style:{width:"100%",height:30,padding:"4px 8px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,boxSizing:"border-box",outline:"none"},onFocus:h=>{h.target.style.borderColor="#6366f1",h.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:h=>{h.target.style.borderColor="#cbd5e1",h.target.style.boxShadow="none"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button",onClick:o,disabled:i,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#475569",fontSize:12,fontWeight:600,cursor:i?"not-allowed":"pointer",transition:"background 0.15s"},children:c.deleteModal.cancelBtn}),t.jsxs("button",{type:"button",onClick:()=>d(_),disabled:i,title:c.deleteModal.softDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"1px solid #fca5a5",background:"#fff1f2",color:"#b91c1c",fontSize:12,fontWeight:600,cursor:i?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s"},onMouseEnter:h=>{i||(h.currentTarget.style.background="#fee2e2")},onMouseLeave:h=>{i||(h.currentTarget.style.background="#fff1f2")},children:[t.jsx("span",{children:"🗑️"}),i?c.deleteModal.deleting:c.deleteModal.softDeleteBtn]}),r&&t.jsxs("button",{type:"button",onClick:()=>u(_),disabled:i,title:c.deleteModal.permanentDeleteDesc,style:{padding:"5px 12px",borderRadius:6,border:"none",background:"#ef4444",color:"#ffffff",fontSize:12,fontWeight:600,cursor:i?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,boxShadow:"0 1px 3px rgba(239, 68, 68, 0.25)",transition:"all 0.15s"},onMouseEnter:h=>{i||(h.currentTarget.style.background="#dc2626")},onMouseLeave:h=>{i||(h.currentTarget.style.background="#ef4444")},children:[t.jsx("span",{children:"💥"}),i?c.deleteModal.deleting:c.deleteModal.permanentDeleteBtn]})]})]})})}const th="/assets/logo-BlYgMyx5.png";function nh({collapsed:e,onToggleCollapsed:n,activePage:s,onNavigate:l,hasDashboard:r,hasReports:i,hasDelegations:o,role:d,hideSettings:u,rtl:c,navLabels:_,settingsLabel:m}){const y=u?[]:iy(d);return t.jsxs("div",{style:{width:e?60:230,background:"linear-gradient(180deg, #0f172a 0%, #1e1b4b 60%, #0b0f19 100%)",color:"white",flexShrink:0,display:"flex",flexDirection:"column",position:"sticky",top:0,height:"100vh",transition:"width 0.22s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.15)",borderRight:"1px solid rgba(255, 255, 255, 0.06)",zIndex:40},children:[t.jsxs("div",{style:{padding:e?"16px 0":"16px 16px 14px",borderBottom:"1px solid rgba(255, 255, 255, 0.08)",display:"flex",alignItems:"center",justifyContent:e?"center":"space-between",gap:8,flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"white",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",padding:3,boxSizing:"border-box",overflow:"hidden"},children:t.jsx("img",{src:th,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:h=>{h.currentTarget.style.display="none"}})}),!e&&t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.jsx("span",{style:{fontSize:14,fontWeight:800,whiteSpace:"nowrap",color:"#ffffff",letterSpacing:"-0.2px"},children:c?"صدرة للأعمال":"Sidrah"})})]}),t.jsx("button",{type:"button",onClick:n,title:e?c?"توسيع":"Expand":c?"طي":"Collapse",style:{background:"rgba(255, 255, 255, 0.06)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:6,color:"rgba(255, 255, 255, 0.75)",cursor:"pointer",fontSize:11,padding:"4px 7px",flexShrink:0,lineHeight:1,transition:"all 0.15s ease"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(255, 255, 255, 0.15)",h.currentTarget.style.color="#ffffff"},onMouseLeave:h=>{h.currentTarget.style.background="rgba(255, 255, 255, 0.06)",h.currentTarget.style.color="rgba(255, 255, 255, 0.75)"},children:e?"▶":"✕"})]}),t.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[ly.filter(({id:h})=>(h!=="dashboard"||r)&&(h!=="reports"||i)&&(h!=="delegations"||o)).map(({id:h,icon:b})=>{const z=_[h]||h,j=h===s;return t.jsxs("div",{onClick:()=>l(h),title:e?z:void 0,className:"sidebar-nav-item",style:{padding:e?"8px 0":"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:10,background:j?"rgba(99, 102, 241, 0.28)":"transparent",border:j?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:j?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:j?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2,position:"relative"},onMouseEnter:f=>{j||(f.currentTarget.style.background="rgba(255, 255, 255, 0.08)",f.currentTarget.style.color="#ffffff")},onMouseLeave:f=>{j||(f.currentTarget.style.background="transparent",f.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:b}),!e&&t.jsx("span",{children:z})]},h)}),y.length>0&&t.jsxs(t.Fragment,{children:[!e&&t.jsx("div",{style:{padding:"12px 12px 4px",fontSize:10,color:"rgba(255, 255, 255, 0.45)",fontWeight:700,letterSpacing:"0.8px",textTransform:"uppercase",marginTop:8},children:m}),e&&t.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),y.map(({id:h,icon:b})=>{const z=_[h]||h,j=h===s;return t.jsxs("div",{onClick:()=>l(h),title:e?z:void 0,className:"sidebar-nav-item",style:{padding:e?"8px 0":"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:10,background:j?"rgba(99, 102, 241, 0.28)":"transparent",border:j?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:j?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:j?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2},onMouseEnter:f=>{j||(f.currentTarget.style.background="rgba(255, 255, 255, 0.08)",f.currentTarget.style.color="#ffffff")},onMouseLeave:f=>{j||(f.currentTarget.style.background="transparent",f.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[t.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:b}),!e&&t.jsx("span",{children:z})]},h)})]})]})]})}const Rl=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 Ps="";async function Nd(){try{const e=await fetch(`${de}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const s=(await e.json()).message||"";if(s)return Ps=s,s}}catch(e){console.error("CSRF fetch error:",e)}return Ps}async function tn(){return Ps||await Nd(),Ps}function zr(e,n){try{if(e!=null&&e._server_messages){const l=JSON.parse(e._server_messages);if(l.length){const r=JSON.parse(l[0]);if(r!=null&&r.message)return r.message.replace(/<[^>]+>/g,"").trim()}}}catch{}let s=(e==null?void 0:e.message)||(e==null?void 0:e.exception)||(e==null?void 0:e.exc)||n;if(typeof s=="string"&&s.includes("frappe.exceptions.")){const l=s.split(`
`).map(i=>i.trim()).filter(i=>i&&!i.startsWith("Traceback")&&!i.startsWith("File "));s=(l[l.length-1]||s).replace(/^frappe\.exceptions\.\w+:\s*/,"").trim()}return s||n}async function At(e,n,s=[]){if(Rl.has(e)){const o=`${de}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(n)}`,d=await fetch(o,{credentials:"include",headers:{Accept:"application/json"}});if(!d.ok)throw new Error(`API Error: ${d.status}`);return(await d.json()).message}const l=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",r=await fetch(`${de}/api/v1/resource/${e}/${encodeURIComponent(n)}${l}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`API Error: ${r.status}`);return(await r.json()).data}async function Uo(e,n,s="",l=!1){const r=await tn();if(Rl.has(e)){const d=new URLSearchParams({doctype:e,name:n});s&&d.append("reason",s),l&&d.append("permanent","1");const u=await fetch(`${de}/api/method/sidrah_business.api.delete_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:d.toString()});if(!u.ok){const c=await u.json().catch(()=>({}));throw new Error(zr(c,`Error deleting ${n}`))}return}const i=new URLSearchParams({doctype:e,name:n});s&&i.append("reason",s),l&&i.append("permanent","1");const o=await fetch(`${de}/api/method/sidrah_business.soft_delete.soft_delete`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:i.toString()});if(!o.ok){const d=await o.json().catch(()=>({}));throw new Error(zr(d,`Error deleting ${n}`))}return await o.json()}async function wy(e,n){const s=await tn();if(Rl.has(e)){const i=new URLSearchParams({doctype:e,name:n}),o=await fetch(`${de}/api/method/sidrah_business.api.restore_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:i.toString()});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(zr(u,`Error restoring ${n}`))}return(await o.json()).message||{success:!0}}const l=new URLSearchParams({doctype:e,name:n}),r=await fetch(`${de}/api/method/sidrah_business.soft_delete.restore_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:l.toString()});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(zr(i,`Error restoring ${n}`))}return await r.json()}async function Ee(e){if(Rl.has(e))try{const l=`${de}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,r=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}const n=encodeURIComponent('["*"]'),s=`${de}/api/v1/resource/${e}?limit_page_length=500&fields=${n}`;try{const l=await fetch(s,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return l.status===401||l.status===403?[]:l.ok?(await l.json()).data||[]:[]}catch(l){return console.error("Get error:",l),[]}}async function bu(e,n){const s=await tn();if(Rl.has(e)){const r=new URLSearchParams({doctype:e,data_json:JSON.stringify(n)}),i=await fetch(`${de}/api/method/sidrah_business.api.create_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const l=`${de}/api/v1/resource/${e}`;try{const r=await fetch(l,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(n)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const 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 Mi(e,n,s){const l=await tn();if(Rl.has(e)){const i=new URLSearchParams({doctype:e,name:n,data_json:JSON.stringify(s)}),o=await fetch(`${de}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:i.toString()});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.message||u.exc||`Error updating ${e}`)}return{data:(await o.json()).message}}const r=`${de}/api/v1/resource/${e}/${encodeURIComponent(n)}`;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 o=await i.json();throw new Error(o.message||"Update Error")}return await i.json()}catch(i){throw console.error("Update error:",i),i}}async function _y(){const e=`${de}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return n.status===401||n.status===403?[]:n.ok?(await n.json()).data||[]:[]}catch(n){return console.error("Get users error:",n),[]}}async function ky(e,n){const s=new FormData;s.append("usr",e),s.append("pwd",n);const r=await(await fetch(`${de}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return r.csrf_token?Ps=r.csrf_token:await Nd(),r}async function Cy(){const e=await tn();try{await fetch(`${de}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Ps=""}function zy(){return Ps}async function sh(){try{const e=await fetch(`${de}/api/method/frappe.auth.get_logged_user`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return e.ok&&(await e.json()).message||""}catch{return""}}async function Iy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),n=`${de}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).data||[]:[]}catch{return[]}}async function Ty(){const e=`${de}/api/method/sidrah_business.api.get_user_role_map`;try{const n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||{}:{}}catch{return{}}}async function lh(e,n){await Mi("User",e,{new_password:n})}async function Ey(e=20){try{const n=`${de}/api/method/sidrah_business.api.get_notifications?limit=${e}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Ay(){const e=await tn();try{await fetch(`${de}/api/method/sidrah_business.api.mark_notifications_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":e}})}catch{}}async function Py(e){const n=await tn();try{await fetch(`${de}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":n},body:new URLSearchParams({name:e}).toString()})}catch{}}async function Ry(e){const n=await tn(),s=new URLSearchParams({name:e});await fetch(`${de}/api/method/sidrah_business.api.disable_user`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":n},body:s.toString()})}async function Dy(e,n){try{const s=`${de}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function Oy(e,n,s){const l=await tn(),r=new URLSearchParams({doctype:e,docname:n,content:s}),i=await fetch(`${de}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function Ly(e,n){try{const s=`${de}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(n)}`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function rh(e){try{const n=`${de}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,s=await fetch(n,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Wy(){try{const e=`${de}/api/method/sidrah_business.api.get_my_organization`,n=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return n.ok&&(await n.json()).message||""}catch{return""}}async function Os(e,n={}){const s=await tn(),l=new URLSearchParams(n),r=await fetch(`${de}/api/method/sidrah_business.api.${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:l.toString()});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(zr(o,`Error calling ${e}`))}return(await r.json()).message}async function Ny(e,n,s="",l,r,i){const o={name:e,action:n,comment:s};return l!==void 0&&(o.stage=l),i!==void 0&&(o.cycle_status=i),Os("apply_order_workflow",o)}async function By(e,n,s=""){return Os("apply_incident_workflow",{name:e,action:n,fields_json:s})}async function $y(e,n,s=""){return Os("apply_idea_workflow",{name:e,action:n,fields_json:s})}async function Uy(e=""){const n=`${de}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function Fy(e,n={}){return Os("get_report_data",{report_name:e,filters_json:JSON.stringify(n)})}async function My(){try{const e=`${de}/api/method/sidrah_business.api.get_inbox_items`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Hy(e,n,s="",l="",r="",i=""){return Os("create_delegation",{manager:e,functions_json:JSON.stringify(n),organization:s,remarks:l,incident_name:r,idea_name:i})}async function Gy(e,n,s=""){return Os("respond_to_delegation",{name:e,response:n,remarks:s})}async function Ky(e,n=""){return Os("revoke_delegation",{name:e,remarks:n})}async function Qy(){try{const e=`${de}/api/method/sidrah_business.api.get_delegations`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Yy(e){const n=`${de}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,s=await fetch(n,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error("Failed to load delegation");return(await s.json()).message}async function Xy(){try{const e=`${de}/api/method/sidrah_business.api.get_my_delegated_functions`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function qy(){try{const e=`${de}/api/method/sidrah_business.api.get_my_delegated_organizations`,n=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return n.ok?(await n.json()).message||{}:{}}catch{return{}}}async function Jy(){try{const e=await tn(),n=await fetch(`${de}/api/method/sidrah_business.api.get_group_companies`,{method:"GET",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":e}});return n.ok?(await n.json()).message||[]:[]}catch{return[]}}async function Vy(){const e=zy();return e||Nd()}async function Zl(e){const n=await fetch(`${de}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.message||`Failed to load process (${n.status})`)}const s=await n.json();return s.message||s.data}async function Zy(e,n,s={}){const l=await Vy(),r=new URLSearchParams({name:e,action:n});s.actor_status&&r.set("actor_status",String(s.actor_status)),s.actor_comment&&r.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&r.set("progress_indicators",JSON.stringify(s.progress_indicators));const i=await fetch(`${de}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({})),u=d.message||(d.exception?String(d.exception).split(`
`).pop():"")||d.exc_type||`Workflow action "${n}" failed (${i.status})`;throw new Error(u)}const o=await i.json();return o.message||o.data}const e0=["dashboard","incidents","incidents-form","ideas","ideas-form","orders","orders-form","processes","processes-form","processes-workflow","organizations","organizations-form","managements","managements-form","departments","departments-form","branches","branches-form","incident-types","incident-types-form","idea-types","idea-types-form","order-types","order-types-form","process-types","process-types-form","incident-statuses","incident-statuses-form","idea-statuses","idea-statuses-form","order-statuses","order-statuses-form","process-statuses","process-statuses-form","users","users-form","cycles","cycles-form","kpi-input","kpi-input-form","delegations","delegations-form","inbox","reports","profile"],Su=new Set(e0),t0={"incidents-form":"incidents","ideas-form":"ideas","orders-form":"orders","processes-form":"processes","processes-workflow":"processes","organizations-form":"organizations","managements-form":"managements","departments-form":"departments","branches-form":"branches","incident-types-form":"incident-types","idea-types-form":"idea-types","order-types-form":"order-types","process-types-form":"process-types","incident-statuses-form":"incident-statuses","idea-statuses-form":"idea-statuses","order-statuses-form":"order-statuses","process-statuses-form":"process-statuses","users-form":"users","cycles-form":"cycles","kpi-input-form":"kpi-input","delegations-form":"delegations",profile:"dashboard"};function wu(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return Su.has(e)?e:null;const n=window.location.pathname.split("/").filter(Boolean).pop()||"";return Su.has(n)?n:null}function n0(e){return e?t0[e]??e:null}function s0(e){return`#/${e}`}function l0({onLogin:e}){const n=ne(),[s,l]=S.useState(""),[r,i]=S.useState(""),[o,d]=S.useState(""),[u,c]=S.useState(!1),[_,m]=S.useState(!1),[y,h]=S.useState(!1),b=async()=>{if(!s||!r){d(n.login.emptyFields);return}c(!0),d("");try{const j=await ky(s,r);if(j.message==="Logged In"){const a=await sh()||s,x=await rh(a),g=x.some(C=>["SB Admin","System Manager"].includes(C))?"Admin":x.includes("SB Auditor")?"Auditor":x.includes("SB Owner")?"Owner":x.includes("SB X-Auditor")?"XAuditor":x.includes("SB Manager")?"Manager":"Employee";e({name:a,full_name:j.full_name||s,role:g})}else d(n.login.invalidCreds)}catch(j){d(n.login.connError+(j instanceof Error?j.message:"Unknown"))}c(!1)},z=j=>({width:"100%",padding:"11px 16px",border:`1.5px solid ${j?"#6366f1":"#e2e8f0"}`,borderRadius:8,fontSize:14,background:j?"#f8faff":"#ffffff",color:"#1e293b",outline:"none",transition:"all 0.18s ease",boxSizing:"border-box",boxShadow:j?"0 0 0 3px rgba(99, 102, 241, 0.15)":"none"});return t.jsx("div",{style:{minHeight:"100vh",background:"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif",padding:"20px"},children:t.jsxs("div",{style:{width:380,maxWidth:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:[t.jsx("div",{style:{width:72,height:72,borderRadius:18,background:"white",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:20,boxShadow:"0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04)",border:"1px solid #f1f5f9",overflow:"hidden",padding:10},children:t.jsx("img",{src:th,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:j=>{j.currentTarget.style.display="none"}})}),t.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[t.jsx("h1",{style:{fontSize:22,fontWeight:800,color:"#0f172a",letterSpacing:"-0.3px",margin:0},children:n.rtl?"صدرة للأعمال":"Sidrah"}),t.jsx("div",{style:{fontSize:13,color:"#6366f1",fontWeight:600,marginTop:4},children:n.rtl?"نظام إدارة العمليات والأعمال":"Asset Management System"}),t.jsx("div",{style:{fontSize:12,color:"#94a3b8",marginTop:6},children:n.login.subtitle})]}),t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:12},children:[t.jsx("div",{children:t.jsx("input",{value:s,onChange:j=>l(j.target.value),onKeyDown:j=>j.key==="Enter"&&b(),onFocus:()=>m(!0),onBlur:()=>m(!1),style:z(_),placeholder:n.login.usernamePlaceholder,autoComplete:"username"})}),t.jsx("div",{children:t.jsx("input",{type:"password",value:r,onChange:j=>i(j.target.value),onKeyDown:j=>j.key==="Enter"&&b(),onFocus:()=>h(!0),onBlur:()=>h(!1),style:z(y),placeholder:n.login.passwordPlaceholder,autoComplete:"current-password"})}),o&&t.jsx("div",{style:{padding:"9px 12px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:12,textAlign:"center"},children:o}),t.jsx("button",{type:"button",onClick:b,disabled:u,style:{background:u?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:u?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:j=>{u||(j.currentTarget.style.background="#4338ca")},onMouseLeave:j=>{u||(j.currentTarget.style.background="#4f46e5")},children:u?n.login.signingIn:n.login.signIn}),t.jsx("div",{style:{textAlign:"center",marginTop:8},children:t.jsx("button",{type:"button",onClick:eh,style:{fontSize:12,color:"#94a3b8",background:"none",border:"none",cursor:"pointer"},onMouseEnter:j=>j.currentTarget.style.color="#475569",onMouseLeave:j=>j.currentTarget.style.color="#94a3b8",children:n.switchLang})})]})]})})}function r0(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,i=s&255,o=d=>Math.round(d+(255-d)*n);return`rgb(${o(l)}, ${o(r)}, ${o(i)})`}function Ql(e,n){const s=parseInt(e.replace("#",""),16),l=s>>16&255,r=s>>8&255,i=s&255;return`rgba(${l}, ${r}, ${i}, ${n})`}function ni({title:e,data:n,color:s,onSelect:l}){const[,r]=n[0]??["Total",0,""],i=n.slice(1),o=i.map((u,c)=>r0(s,Math.min(c*.16,.7))),d=i.map(([u,c,_],m)=>[u,c,_,o[m]]).filter(([,u])=>u>0);return t.jsxs("div",{className:"status-card",style:{borderRadius:18,padding:"16px 18px 18px",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${Ql(s,.09)} 0%, transparent 55%)`}}),t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${Ql(s,.35)})`}}),t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[t.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),t.jsx("span",{style:{fontSize:14,fontWeight:800,color:"white",background:s,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${Ql(s,.35)}`},children:r})]}),r>0&&t.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:Ql(s,.1),marginBottom:13},children:d.map(([u,c,_,m],y)=>t.jsx("div",{title:`${u}: ${c}`,onClick:h=>{h.stopPropagation(),l==null||l(_)},style:{flex:`${c} 0 0`,background:m,borderRight:y<d.length-1?"2px solid white":"none",cursor:l?"pointer":"default"}},u))}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:i.map(([u,c,_],m)=>t.jsxs("div",{className:"status-card-row",onClick:c>0?y=>{y.stopPropagation(),l==null||l(_)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:c>0&&l?"pointer":"default",transition:"background 0.12s"},children:[t.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:o[m],flexShrink:0,boxShadow:`0 0 0 3px ${Ql(o[m],.18)}`}}),t.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),t.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:c})]},u))})]})}function Gt({value:e,onChange:n,organizations:s,placeholder:l="-- Choose organization --",disabled:r=!1,small:i=!1}){var m;const[o,d]=S.useState(!1),u=S.useRef(null);S.useEffect(()=>{const y=h=>{u.current&&!u.current.contains(h.target)&&d(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const c=e?((m=s.find(y=>y.organization_name===e||y.name===e))==null?void 0:m.organization_name)??e:l,_=s.filter(y=>!!y.is_active||y.organization_name===e||y.name===e);return t.jsxs("div",{ref:u,className:`custom-select-container ${r?"disabled":""} ${o?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${i?"small":""} ${r?"disabled":""} ${o?"open":""} ${e?"":"is-placeholder"}`,onClick:()=>!r&&d(y=>!y),children:[t.jsx("span",{className:"trigger-text",children:c}),t.jsx("span",{className:"trigger-arrow",children:"▼"})]}),o&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[t.jsx(_u,{label:l,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{n(""),d(!1)}}),_.length===0&&t.jsx("div",{className:"custom-select-empty",children:"No organizations"}),_.map(y=>t.jsx(_u,{label:y.organization_name,selected:e===y.organization_name||e===y.name,active:!!y.is_active,isPlaceholder:!1,small:i,onClick:()=>{n(y.organization_name),d(!1)}},y.name))]})})]})}function _u({label:e,selected:n,active:s,isPlaceholder:l,small:r,onClick:i}){const[o,d]=S.useState(!1);return t.jsx("div",{onClick:i,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:`custom-select-option ${n?"selected":""} ${o?"hovered":""} ${l?"placeholder-option":""} ${s?"":"inactive-option"} ${r?"small":""}`,children:e})}function Yt({label:e,icon:n,onClick:s}){return t.jsxs("button",{onClick:s,className:"hero-quicklink-btn",style:{display:"flex",alignItems:"center",gap:8,padding:"7px 14px",background:"rgba(255, 255, 255, 0.12)",border:"1px solid rgba(255, 255, 255, 0.22)",borderRadius:10,cursor:"pointer",backdropFilter:"blur(8px)",color:"white",fontSize:13,fontWeight:700,boxShadow:"0 2px 6px rgba(0,0,0,0.12)",transition:"all 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[t.jsx("span",{style:{fontSize:15,display:"flex",alignItems:"center"},children:n}),t.jsx("span",{style:{whiteSpace:"nowrap"},children:e})]})}function Gn({items:e,type:n,onNavigate:s}){const l=ne();if(!e.length)return null;const r=n==="process"?"processes-form":"orders-form",i=n==="process"?l.dash.escalatedProcesses:l.dash.escalatedOrders,o=e.some(d=>d.escalation_level===2||d.escalation_level==="2");return t.jsxs("div",{children:[t.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:o?"#ef4444":"#f59e0b",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{children:o?"🚨":"⚠️"}),t.jsxs("span",{children:[i," (",e.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.map(d=>t.jsxs("div",{onClick:()=>s(r,d.name),className:"dashboard-alert-item",style:{padding:"10px 14px",background:o?"#fef2f2":"#fffbeb",borderRadius:10,border:`1px solid ${o?"#fecaca":"#fed7aa"}`,cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.15s ease"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:o?"#991b1b":"#92400e",whiteSpace:"nowrap"},children:d.number||d.name}),t.jsx("span",{style:{fontSize:12,color:"#475569",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.title})]}),t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:o?"#b91c1c":"#b45309",background:o?"#fee2e2":"#fef3c7",border:`1px solid ${o?"#fca5a5":"#fde68a"}`,padding:"2px 8px",borderRadius:9999,flexShrink:0},children:[l.dash.level," ",d.escalation_level]})]},d.name))})]})}function i0({kpi:e}){const n=ne();return t.jsxs("div",{className:"dashboard-kpi-card",style:{borderRadius:14,padding:"16px 18px",border:"1px solid #e2e8f0",background:"white",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",transition:"all 0.2s ease",display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("div",{style:{fontWeight:800,fontSize:14,color:"#1e293b"},children:e.organization}),t.jsx("span",{style:{fontSize:11,fontWeight:700,color:"#4f46e5",background:"#eff6ff",border:"1px solid #c7d2fe",padding:"2px 9px",borderRadius:9999},children:e.period})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[{label:n.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—",color:"#10b981"},{label:n.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—",color:"#3b82f6"},{label:n.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—",color:"#8b5cf6"},{label:n.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—",color:"#f59e0b"},{label:n.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—",color:"#06b6d4"},{label:n.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—",color:"#ef4444"}].map(({label:s,val:l,color:r})=>t.jsxs("div",{style:{background:"#f8fafc",padding:"8px 10px",borderRadius:8,border:"1px solid #f1f5f9"},children:[t.jsx("div",{style:{fontSize:10,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px"},children:s}),t.jsxs("div",{style:{fontSize:14,fontWeight:800,color:"#1e293b",marginTop:2,display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:r}}),l]})]},s))})]})}function a0({data:e}){if(!e.length)return t.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"No cycle data available for trend chart."});const n=Math.max(...e.map(s=>s.pass+s.fail+s.unknown),1);return t.jsxs("div",{children:[t.jsx("div",{style:{display:"flex",gap:14,alignItems:"flex-end",overflowX:"auto",paddingBottom:8,paddingTop:10},children:e.map(s=>{const l=s.pass+s.fail+s.unknown||1,r=100;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,minWidth:54},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:2,height:r,width:36,background:"#f1f5f9",borderRadius:6,padding:2,boxSizing:"border-box"},children:[t.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/n*(r-4)),background:"linear-gradient(180deg, #34d399 0%, #10b981 100%)",borderRadius:"4px 4px 0 0",minHeight:s.pass?4:0}}),t.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/n*(r-4)),background:"linear-gradient(180deg, #f87171 0%, #ef4444 100%)",borderRadius:"4px 4px 0 0",minHeight:s.fail?4:0}}),t.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/n*(r-4)),background:"#94a3b8",borderRadius:"4px 4px 0 0",minHeight:s.unknown?4:0}})]}),t.jsx("div",{style:{fontSize:10,fontWeight:600,color:"#64748b",textAlign:"center",lineHeight:1.2},children:s.month.replace(/^(\d{4})-(\d{2})$/,(i,o,d)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+d-1]} '${o.slice(2)}`)}),t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#10b981",textAlign:"center"},children:l>1?Math.round(s.pass/l*100)+"%":"—"})]},s.month)})}),t.jsx("div",{style:{display:"flex",gap:20,marginTop:12,borderTop:"1px solid #f1f5f9",paddingTop:10},children:[["#10b981","Pass (Verified)"],["#ef4444","Fail (Action Required)"],["#94a3b8","Unknown / Unrecorded"]].map(([s,l])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,fontWeight:600},children:[t.jsx("div",{style:{width:10,height:10,background:s,borderRadius:3}}),t.jsx("span",{style:{color:"#64748b"},children:l})]},l))})]})}function o0({dashData:e,fi:n,fid:s,fo:l,fp:r,incidentStatuses:i,ideaStatuses:o,orderStatuses:d,processStatuses:u,onNavigate:c,onNavigateStatus:_}){const m=ne(),y=(e==null?void 0:e.escalated_processes)||[],h=(e==null?void 0:e.escalated_orders)||[],b=(e==null?void 0:e.attention_processes)||[],z=(e==null?void 0:e.attention_orders)||[],j=(e==null?void 0:e.untriaged_incidents)||[],f=(e==null?void 0:e.overdue_triage)||[],a=y.length>0||h.length>0,x=b.length>0||z.length>0,g=[["Total",n.length,""],...i.map(k=>[k.name1||k.name,n.filter(T=>T.status===k.name).length,k.name])],C=[["Total",s.length,""],...o.map(k=>[k.name1||k.name,s.filter(T=>T.status===k.name).length,k.name])],w=[["Total",l.length,""],...d.map(k=>[k.name1||k.name,l.filter(T=>T.status===k.name).length,k.name])],p=[["Total",r.length,""],...u.map(k=>[k.name1||k.name,r.filter(T=>T.status===k.name).length,k.name])];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsx("div",{onClick:()=>c("incidents"),style:{cursor:"pointer"},children:t.jsx(ni,{title:m.dash.incidents,color:"#ef4444",data:g,onSelect:k=>_("incidents",k)})}),t.jsx("div",{onClick:()=>c("ideas"),style:{cursor:"pointer"},children:t.jsx(ni,{title:m.dash.ideas,color:"#10b981",data:C,onSelect:k=>_("ideas",k)})}),t.jsx("div",{onClick:()=>c("orders"),style:{cursor:"pointer"},children:t.jsx(ni,{title:m.dash.orders,color:"#8b5cf6",data:w,onSelect:k=>_("orders",k)})}),t.jsx("div",{onClick:()=>c("processes"),style:{cursor:"pointer"},children:t.jsx(ni,{title:m.dash.processes,color:"#3b82f6",data:p,onSelect:k=>_("processes",k)})})]}),(a||x)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[a&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #ef4444"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#ef4444",margin:0},children:m.dash.level2}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fef2f2",color:"#ef4444",padding:"2px 8px",borderRadius:9999},children:[y.length+h.length," Critical"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Gn,{items:y,type:"process",onNavigate:c}),t.jsx(Gn,{items:h,type:"order",onNavigate:c})]})]}),x&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fef3c7",borderLeft:"5px solid #f59e0b"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#b45309",margin:0},children:m.dash.level1}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,background:"#fffbeb",color:"#b45309",padding:"2px 8px",borderRadius:9999},children:[b.length+z.length," Action Needed"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Gn,{items:b,type:"process",onNavigate:c}),t.jsx(Gn,{items:z,type:"order",onNavigate:c})]})]})]}),(f.length>0||j.length>0)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[f.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #dc2626"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#dc2626",marginBottom:10},children:[m.dash.overduePrefix,f.length,m.dash.overdueSuffix]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:f.map(k=>t.jsxs("div",{onClick:()=>c("incidents-form",k.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:"#991b1b"},children:k.number||k.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:k.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:k.date})]},k.name))})]}),j.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #ffedd5",borderLeft:"5px solid #f97316"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#ea580c",marginBottom:10},children:[m.dash.untriaged," (",j.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:j.map(k=>t.jsxs("div",{onClick:()=>c("incidents-form",k.name),style:{padding:"8px 12px",background:"#fff7ed",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,fontSize:12,color:"#9a3412"},children:k.number||k.name}),t.jsx("span",{style:{fontSize:12,color:"#475569"},children:k.title}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:k.date})]},k.name))})]})]})]})}function d0({dashData:e,selectedOrg:n,onNavigate:s}){const l=ne(),[r,i]=S.useState([]),[o,d]=S.useState([]),[u,c]=S.useState(!1),_=(e==null?void 0:e.escalated_processes)||[],m=(e==null?void 0:e.escalated_orders)||[],y=(e==null?void 0:e.attention_processes)||[],h=(e==null?void 0:e.attention_orders)||[],b=(e==null?void 0:e.kpi_inputs)||[];S.useEffect(()=>{c(!0);const f=new URLSearchParams({months:"6"});n&&f.append("organization",n),fetch(`/api/method/sidrah_business.api.get_process_trend?${f}`,{credentials:"include",headers:{Accept:"application/json"}}).then(a=>a.json()).then(a=>{const x=a.message||[],g={};for(const C of x)g[C.month]||(g[C.month]={pass:0,fail:0,unknown:0}),C.status==="Pass"?g[C.month].pass=C.count:C.status==="Fail"?g[C.month].fail=C.count:C.status==="Unknown"&&(g[C.month].unknown=C.count);i(Object.entries(g).map(([C,w])=>({month:C,...w})))}).catch(()=>{}).finally(()=>c(!1))},[n]),S.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(f=>f.json()).then(f=>{var a;d((((a=f.message)==null?void 0:a.rows)||[]).slice(0,50))}).catch(()=>{})},[n]);const z=_.length>0||m.length>0,j=y.length>0||h.length>0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[b.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",margin:0},children:l.dash.recentKpi}),t.jsxs("button",{onClick:()=>s("kpi-input"),style:{padding:"6px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#334155",fontWeight:600,fontSize:12,cursor:"pointer"},children:[l.dash.manageKpi," →"]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:14},children:b.map(f=>t.jsx(i0,{kpi:f},f.name))})]}),(z||j)&&t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:16},children:[z&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fee2e2",borderLeft:"5px solid #ef4444"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:14,color:"#ef4444",marginBottom:12},children:["Critical Escalations — Level 2 (",_.length+m.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Gn,{items:_,type:"process",onNavigate:s}),t.jsx(Gn,{items:m,type:"order",onNavigate:s})]})]}),j&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"16px 18px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #fef3c7",borderLeft:"5px solid #f59e0b"},children:[t.jsxs("h3",{style:{fontWeight:800,fontSize:14,color:"#b45309",marginBottom:12},children:["Needs Attention — Level 1 (",y.length+h.length,")"]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(Gn,{items:y,type:"process",onNavigate:s}),t.jsx(Gn,{items:h,type:"order",onNavigate:s})]})]})]}),t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",marginBottom:4},children:"Process Execution Trend — Last 6 Months"}),t.jsx("p",{style:{fontSize:12,color:"#64748b",marginBottom:12},children:"Pass / Fail verification metrics across all processes and review cycles."}),u?t.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"Loading trend analytics…"}):t.jsx(a0,{data:r})]}),o.length>0&&t.jsxs("div",{style:{background:"white",borderRadius:14,padding:"18px 20px",boxShadow:"0 2px 8px rgba(0,0,0,0.04)",border:"1px solid #e2e8f0"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[t.jsx("h3",{style:{fontWeight:800,fontSize:14,color:"#1e293b",margin:0},children:"Audit Log Book — Recent Activity"}),t.jsx("button",{onClick:()=>s("reports"),style:{padding:"6px 14px",borderRadius:8,border:"1px solid #cbd5e1",background:"#f8fafc",color:"#334155",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log →"})]}),t.jsx("div",{style:{overflowX:"auto",borderRadius:10,border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(f=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#64748b",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:f},f))})}),t.jsx("tbody",{children:o.map((f,a)=>t.jsxs("tr",{style:{borderTop:"1px solid #f1f5f9",background:a%2===0?"white":"#fafafa"},children:[t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",whiteSpace:"nowrap"},children:f.timestamp?String(f.timestamp).slice(0,16):"—"}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600,color:"#1e293b"},children:f.user||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#475569"},children:t.jsx("span",{style:{background:"#f1f5f9",padding:"2px 8px",borderRadius:6,fontWeight:600,fontSize:11},children:f.entity_type||"—"})}),t.jsx("td",{style:{padding:"10px 14px",color:"#1e293b",fontWeight:500},children:f.entity_name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#64748b",maxWidth:280,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.changes||"—"})]},a))})]})})]})]})}function c0({incidents:e,ideas:n,orders:s,processes:l,organizations:r,incidentStatuses:i,ideaStatuses:o,orderStatuses:d,processStatuses:u,selectedOrg:c,onOrgChange:_,onNavigate:m,onNavigateStatus:y,userRole:h}){const[b,z]=S.useState(null),[j,f]=S.useState(!1),a=()=>{f(!0),Uy(c).then(z).finally(()=>f(!1))};S.useEffect(()=>{a()},[c]);const x=S.useMemo(()=>c?e.filter(J=>J.organization===c):e,[e,c]),g=S.useMemo(()=>c?n.filter(J=>J.organization===c):n,[n,c]),C=S.useMemo(()=>c?s.filter(J=>J.organization===c):s,[s,c]),w=S.useMemo(()=>c?l.filter(J=>J.organization===c):l,[l,c]),p=h==="Admin",k=h==="Owner",[T,A]=S.useState("level1"),Q=k||p&&T==="level2";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #1e3a8a 100%)",borderRadius:16,padding:"22px 26px",color:"white",boxShadow:"0 8px 30px rgba(30, 27, 75, 0.25)",position:"relative",zIndex:20},children:[t.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:"inherit",overflow:"hidden",pointerEvents:"none"},children:[t.jsx("div",{style:{position:"absolute",top:-50,right:-50,width:220,height:220,borderRadius:"50%",background:"rgba(99, 102, 241, 0.25)",filter:"blur(50px)"}}),t.jsx("div",{style:{position:"absolute",bottom:-40,left:"35%",width:180,height:180,borderRadius:"50%",background:"rgba(59, 130, 246, 0.2)",filter:"blur(45px)"}})]}),t.jsxs("div",{style:{position:"relative",zIndex:1},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:16,marginBottom:20},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[t.jsx("span",{style:{fontSize:24},children:"⚡"}),t.jsx("h2",{style:{fontSize:22,fontWeight:800,color:"white",margin:0,letterSpacing:-.5},children:Q?"Executive Performance Dashboard":"Operational Activity Dashboard"})]}),t.jsx("p",{style:{fontSize:13,color:"#c7d2fe",margin:0,opacity:.9},children:c?`Real-time analytics for ${c}`:"Enterprise overview across all organizations & business units"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{style:{minWidth:190,maxWidth:260},children:t.jsx(Gt,{value:c,onChange:_,organizations:r,placeholder:"All Organizations",small:!0})}),p&&t.jsxs("div",{style:{display:"flex",background:"rgba(255, 255, 255, 0.12)",borderRadius:10,padding:3,gap:3,backdropFilter:"blur(8px)",border:"1px solid rgba(255, 255, 255, 0.15)"},children:[t.jsx("button",{onClick:()=>A("level1"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:T==="level1"?"white":"transparent",color:T==="level1"?"#1e1b4b":"#c7d2fe",boxShadow:T==="level1"?"0 2px 6px rgba(0,0,0,0.15)":"none",transition:"all 0.15s ease"},children:"Level 1 (Ops)"}),t.jsx("button",{onClick:()=>A("level2"),style:{padding:"5px 12px",borderRadius:7,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:T==="level2"?"#8b5cf6":"transparent",color:"white",boxShadow:T==="level2"?"0 2px 6px rgba(0,0,0,0.2)":"none",transition:"all 0.15s ease"},children:"Level 2 (Exec)"})]}),!p&&t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:Q?"#8b5cf6":"#3b82f6",padding:"5px 14px",borderRadius:9999,border:"1px solid rgba(255, 255, 255, 0.2)",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"},children:Q?"👑 Owner View":"💼 Operations View"}),t.jsx("button",{onClick:a,disabled:j,title:"Refresh Metrics",style:{width:32,height:32,borderRadius:10,background:"rgba(255, 255, 255, 0.15)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,transition:"all 0.15s"},children:t.jsx("span",{style:{display:"inline-block",transform:j?"rotate(180deg)":"none",transition:"transform 0.4s ease"},children:"🔄"})})]})]}),t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:Q?t.jsxs(t.Fragment,{children:[t.jsx(Yt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>m("users")}),t.jsx(Yt,{label:"Active Review Cycles",icon:"🔄",onClick:()=>m("cycles")}),t.jsx(Yt,{label:"Strategic KPI Inputs",icon:"📈",onClick:()=>m("kpi-input")}),t.jsx(Yt,{label:"Executive Reports",icon:"📊",onClick:()=>m("reports")}),t.jsx(Yt,{label:"Organizations Hierarchy",icon:"🏢",onClick:()=>m("organizations")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Yt,{label:"Incidents",icon:"⚠️",onClick:()=>m("incidents")}),t.jsx(Yt,{label:"Ideas",icon:"💡",onClick:()=>m("ideas")}),t.jsx(Yt,{label:"Orders",icon:"📦",onClick:()=>m("orders")}),t.jsx(Yt,{label:"Processes",icon:"⚙️",onClick:()=>m("processes")}),t.jsx(Yt,{label:"Inbox",icon:"📥",onClick:()=>m("inbox")}),t.jsx(Yt,{label:"Reports",icon:"📊",onClick:()=>m("reports")})]})})]})]}),Q?t.jsx(d0,{dashData:b,selectedOrg:c,onNavigate:m}):t.jsx(o0,{dashData:b,fi:x,fid:g,fo:C,fp:w,incidentStatuses:i,ideaStatuses:o,orderStatuses:d,processStatuses:u,onNavigate:m,onNavigateStatus:y})]})}const tt={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},nt={width:"100%",padding:"6px 10px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,background:"white",color:"#1e293b",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:32,outline:"none"};function oa({children:e}){const[n,s]=S.useState(!1);return t.jsxs("div",{style:{borderRadius:10,overflow:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",flexShrink:0,border:"1px solid #e2e8f0",marginBottom:14},children:[t.jsxs("div",{onClick:()=>s(l=>!l),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",color:"white",padding:"10px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none",fontWeight:600,fontSize:13},children:[t.jsx("span",{style:{fontSize:12,opacity:.9},children:n?"▲":"▼"}),t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{children:"Filters"})]}),n&&t.jsx("div",{style:{background:"#f8fafc",padding:"14px 18px",borderTop:"1px solid #e2e8f0"},children:e})]})}const re=20,ku=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 Je({page:e,pageSize:n=re,total:s,onPageChange:l}){if(s===0)return null;const r=Math.max(1,Math.ceil(s/n)),i=(e-1)*n+1,o=Math.min(e*n,s);return t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[t.jsxs("span",{children:["Showing ",i," to ",o," of ",s," results"]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{disabled:e<=1,onClick:()=>l(e-1),style:ku(e<=1),children:"Previous"}),t.jsx("button",{disabled:e>=r,onClick:()=>l(e+1),style:ku(e>=r),children:"Next"})]})]})}function u0({incidents:e,organizations:n,departments:s,branches:l,incidentStatuses:r,initialOrg:i,initialStatus:o,canModify:d,userRole:u,onView:c,onEdit:_,onDelete:m,onSelectionChange:y}){const h=ne(),[b,z]=S.useState(new Set),[j,f]=S.useState({search:"",organization:i||"",department:"",branch:"",status:o||""}),a=(p,k)=>f(T=>({...T,[p]:k})),[x,g]=S.useState(1),C=e.filter(p=>!(j.search&&!`${p.number} ${p.title}`.toLowerCase().includes(j.search.toLowerCase())||j.organization&&p.organization!==j.organization||j.department&&p.department!==j.department||j.branch&&p.branch!==j.branch||j.status&&p.status!==j.status));S.useEffect(()=>{g(1)},[j]);const w=C.slice((x-1)*re,x*re);return S.useEffect(()=>{if(y){const p=e.filter(k=>b.has(k.name));y(p,w)}},[b,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(oa,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.numberTitle}),t.jsx("input",{style:nt,value:j.search,onChange:p=>a("search",p.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.organization}),t.jsxs("select",{style:nt,value:j.organization,onChange:p=>a("organization",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(p=>t.jsx("option",{value:p.name,children:p.organization_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.department}),t.jsxs("select",{style:nt,value:j.department,onChange:p=>a("department",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(p=>t.jsx("option",{value:p.name,children:p.department_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.branch}),t.jsxs("select",{style:nt,value:j.branch,onChange:p=>a("branch",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(p=>t.jsx("option",{value:p.name,children:p.branch||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.status}),t.jsxs("select",{style:nt,value:j.status,onChange:p=>a("status",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(p=>t.jsx("option",{value:p.name,children:p.name1||p.name},p.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(p=>b.has(p.name)),onChange:p=>{if(p.target.checked)z(new Set([...b,...w.map(k=>k.name)]));else{const k=new Set(b);w.forEach(T=>k.delete(T.name)),z(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:C.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noIncidents})}):w.map((p,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>c==null?void 0:c(p),style:{borderTop:"1px solid #f1f5f9",background:b.has(p.name)?"#eff6ff":p.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(p.name),onChange:()=>{const T=new Set(b);T.has(p.name)?T.delete(p.name):T.add(p.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:p.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:p.title||p.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:p.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.type?Wd(p.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.custom_is_deleted?ns(h.deletedBadge):p.status?ns(p.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(it,{onView:()=>c==null?void 0:c(p),onEdit:d&&_&&!p.custom_is_deleted&&!Hn("incident",p.workflow_state)&&!(u==="Employee"&&p.workflow_state&&p.workflow_state!=="New")?()=>_(p):void 0,onDelete:d&&m&&!p.custom_is_deleted?()=>m(p.name):void 0})})]},p.name))})]})}),t.jsx(Je,{page:x,total:C.length,onPageChange:g})]})}function p0(e){if(!e)return"";const[n,s,l]=e.split("-");return!n||!s||!l?"":`${l}/${s}/${n}`}function me({value:e,onChange:n,disabled:s,style:l,min:r,max:i}){return t.jsxs("div",{style:{position:"relative",width:"100%"},children:[t.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:p0(e),placeholder:"DD/MM/YYYY",style:{...l,pointerEvents:"none",paddingRight:30}}),t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:s?"#bbb":"#666",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),t.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),t.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),t.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),t.jsx("input",{type:"date",value:e||"",disabled:s,min:r,max:i,onChange:o=>n(o.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:s?"default":"pointer",border:"none",padding:0,margin:0}})]})}const Cu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function f0(e){const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function ih({notifCount:e,darkMode:n,onCountChange:s,onToggleDark:l,onViewProfile:r,onLogout:i,onNavigate:o,userName:d,userRole:u}){const[c,_]=S.useState(!1),[m,y]=S.useState([]),[h,b]=S.useState(!1),z=S.useRef(null);S.useEffect(()=>{const A=Q=>{z.current&&!z.current.contains(Q.target)&&_(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[]);const j=async()=>{b(!0);const A=await Ey(30);y(A),b(!1)},f=()=>{const A=!c;_(A),A&&j()},a=async()=>{await Ay(),y(A=>A.map(Q=>({...Q,read:1}))),s(0)},x=A=>{A.read||(Py(A.name),y(J=>J.map(W=>W.name===A.name?{...W,read:1}:W)),s(Math.max(0,e-1)));const Q=A.document_type?Cu[A.document_type]:void 0;Q&&o&&(o(Q,A.document_type==="SB Delegation"?void 0:A.document_name),_(!1))},g=m.filter(A=>!A.read).length,C=A=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:n?"#2d3748":"#f3f4f6",color:n?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...A}),w=n,p=w?"#1a202c":"white",k=w?"#2d3748":"#e5e7eb",T=w?"#e2e8f0":"#1a2332";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[d&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginRight:4,lineHeight:1.25},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,color:w?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:d}),u&&t.jsx("span",{style:{fontSize:11,color:w?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:u})]}),t.jsx("button",{style:C({background:"#4f46e5",color:"white"}),onClick:r,title:"My Profile",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),t.jsxs("div",{ref:z,style:{position:"relative"},children:[t.jsxs("button",{style:C(),onClick:f,title:"Notifications",children:[t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&t.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),c&&t.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:p,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${k}`,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${k}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:p},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:T},children:["Notifications",g>0&&t.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[g," new"]})]}),g>0&&t.jsx("button",{onClick:a,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),t.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[h&&t.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!h&&m.length===0&&t.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[t.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),t.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!h&&m.map(A=>{const Q=!!(A.document_type&&Cu[A.document_type]&&o);return t.jsxs("div",{onClick:()=>x(A),style:{padding:"11px 16px",borderBottom:`1px solid ${w?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:A.read?p:w?"#1e3a5f":"#eff6ff",cursor:Q?"pointer":"default",transition:"background 0.12s"},onMouseEnter:J=>{Q&&(J.currentTarget.style.background=w?"#243244":"#e0ecfd")},onMouseLeave:J=>{J.currentTarget.style.background=A.read?p:w?"#1e3a5f":"#eff6ff"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:13,fontWeight:A.read?400:600,color:T,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A.subject||`${A.document_type}: ${A.document_name}`}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:A.document_type&&t.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:w?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[A.document_type.replace("SB ",""),A.document_name?` · ${A.document_name}`:""]})}),t.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:f0(A.creation)})]}),!A.read&&t.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},A.name)})]})]})]}),t.jsx("button",{style:C(),onClick:eh,title:hl()?"Switch to English":"Switch to Arabic",children:t.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),t.jsx("button",{style:C(),onClick:l,title:n?"Light mode":"Dark mode",children:n?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"5"}),t.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),t.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),t.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),t.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),t.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),t.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),t.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),t.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),t.jsx("button",{style:C({background:w?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:i,title:"Logout",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),t.jsx("polyline",{points:"16,17 21,12 16,7"}),t.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Ve({title:e,activePage:n,user:s,formStatus:l,buttonText:r,viewMode:i,statusBadge:o,onEdit:d,onCancel:u,hideSettings:c,rightPanel:_,darkMode:m,notifCount:y,onToggleDark:h,onCountChange:b,onViewProfile:z,onSubmit:j,onBack:f,onNavigate:a,onLogout:x,children:g}){const C=ne(),w=s.role,p=w==="Admin"||w==="Owner"||w==="Auditor"||w==="Manager",k=w==="Admin"||w==="Owner"||w==="Auditor"||w==="Manager",T=w==="Admin"||w==="Auditor"||w==="Manager",[A,Q]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),J=S.useRef(void 0),[W,U]=S.useState(!1);S.useEffect(()=>{if(J.current===!0&&i===!1){U(!0);const M=setTimeout(()=>{U(!1)},4e3);return()=>clearTimeout(M)}else U(!1);J.current=i},[i]);const I=()=>Q(M=>{const H=!M;return localStorage.setItem("sb_sidebar",H?"1":"0"),H}),O=u||f;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:m?"#0f172a":"#f8fafc"},children:[t.jsx(nh,{collapsed:A,onToggleCollapsed:I,activePage:n,onNavigate:a,hasDashboard:p,hasReports:k,hasDelegations:T,role:w,hideSettings:c,rtl:C.rtl,navLabels:C.nav,settingsLabel:C.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:m?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${m?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:m?"none":"0 1px 4px rgba(0,0,0,0.03)"},children:t.jsx(ih,{notifCount:y,darkMode:m,onCountChange:b,onToggleDark:h,onNavigate:a,onViewProfile:z,onLogout:x,userName:s.full_name||s.name,userRole:s.role})}),t.jsxs("div",{style:{background:m?"#1e293b":"#ffffff",padding:"12px 24px",borderBottom:`1px solid ${m?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,position:"relative"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsx("button",{onClick:f,title:C.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:`1px solid ${m?"#475569":"#e2e8f0"}`,background:m?"#334155":"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:M=>{M.currentTarget.style.background=m?"#475569":"#eff6ff",M.currentTarget.style.borderColor="#93c5fd"},onMouseLeave:M=>{M.currentTarget.style.background=m?"#334155":"#ffffff",M.currentTarget.style.borderColor=m?"#475569":"#e2e8f0"},children:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{style:{fontSize:17,fontWeight:700,color:m?"#f8fafc":"#0f172a"},children:e}),o&&(typeof o=="string"?t.jsx("span",{style:{padding:"3px 10px",borderRadius:16,fontSize:12,fontWeight:600,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:o}):o)]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i&&d&&t.jsxs("button",{type:"button",onClick:d,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:6,border:"none",background:"#2563eb",color:"#ffffff",cursor:"pointer",fontSize:13,fontWeight:600,boxShadow:"0 1px 3px rgba(37,99,235,0.25)",transition:"all 0.15s ease"},onMouseEnter:M=>M.currentTarget.style.background="#1d4ed8",onMouseLeave:M=>M.currentTarget.style.background="#2563eb",children:[t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),C.edit]}),!i&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button",onClick:O,style:{padding:"7px 16px",borderRadius:6,border:`1px solid ${m?"#475569":"#cbd5e1"}`,background:m?"#334155":"#ffffff",color:m?"#e2e8f0":"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:M=>{M.currentTarget.style.background=m?"#475569":"#f1f5f9"},onMouseLeave:M=>{M.currentTarget.style.background=m?"#334155":"#ffffff"},children:C.cancel}),t.jsxs("button",{type:"button",onClick:j,disabled:l==="loading",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 18px",borderRadius:6,border:"none",background:"#16a34a",color:"#ffffff",fontSize:13,fontWeight:600,cursor:l==="loading"?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(22, 163, 74, 0.3)",opacity:l==="loading"?.7:1,transition:"all 0.15s ease"},onMouseEnter:M=>{l!=="loading"&&(M.currentTarget.style.background="#15803d")},onMouseLeave:M=>{l!=="loading"&&(M.currentTarget.style.background="#16a34a")},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),t.jsx("polyline",{points:"7 3 7 8 15 8"})]}),t.jsx("span",{children:l==="loading"?C.saving:r||"Save Changes"})]})]})]}),!i&&W&&t.jsxs("div",{style:{position:"absolute",top:-34,right:24,background:"#0284c7",color:"#ffffff",padding:"4px 12px",borderRadius:6,fontSize:12,fontWeight:600,display:"flex",alignItems:"center",gap:8,boxShadow:"0 2px 8px rgba(2, 132, 199, 0.3)",zIndex:10},children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Edit mode enabled"]}),t.jsx("button",{type:"button",onClick:()=>U(!1),title:"Dismiss",style:{background:"transparent",border:"none",color:"white",cursor:"pointer",fontSize:14,padding:0,lineHeight:1,opacity:.85},children:"✕"})]})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:_?"1fr 240px":"1fr",gap:16,alignItems:"start"},children:[t.jsxs("div",{style:{minWidth:0},children:[g,l==="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:C.savedOk}),l!=="idle"&&l!=="loading"&&l!=="success"&&t.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:14},children:l})]}),_&&t.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:_})]})]})]})}function ue({value:e,onChange:n,items:s,placeholder:l="-- Select --",disabled:r=!1}){var m;const[i,o]=S.useState(!1),[d,u]=S.useState(""),c=S.useRef(null);S.useEffect(()=>{const y=h=>{c.current&&!c.current.contains(h.target)&&o(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const _=e?((m=s.find(y=>y.name===e))==null?void 0:m.label)??e:l;return t.jsxs("div",{ref:c,className:`custom-select-container ${r?"disabled":""} ${i?"open":""}`,style:{position:"relative",width:"100%"},children:[t.jsxs("div",{className:`custom-select-trigger ${r?"disabled":""} ${i?"open":""} ${e?"":"is-placeholder"}`,onClick:()=>!r&&o(y=>!y),children:[t.jsx("span",{className:"trigger-text",children:_}),t.jsx("span",{className:"trigger-arrow",children:"▼"})]}),i&&t.jsx("div",{className:"custom-select-dropdown",children:t.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[t.jsx("div",{className:`custom-select-option placeholder-option ${d==="__placeholder"?"hovered":""}`,onClick:()=>{n(""),o(!1)},onMouseEnter:()=>u("__placeholder"),onMouseLeave:()=>u(""),children:l}),s.length===0&&t.jsx("div",{className:"custom-select-empty",children:"No records found"}),s.map(y=>t.jsx("div",{className:`custom-select-option ${e===y.name?"selected":""} ${d===y.name?"hovered":""}`,onClick:()=>{n(y.name),o(!1)},onMouseEnter:()=>u(y.name),onMouseLeave:()=>u(""),children:y.label},y.name))]})})]})}function h0(e){const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*7?`${Math.floor(n/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function g0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function da({doctype:e,docname:n,currentUserName:s}){const l=ne(),[r,i]=S.useState([]),[o,d]=S.useState(!1),[u,c]=S.useState(""),[_,m]=S.useState(!1),[y,h]=S.useState(!1),[b,z]=S.useState(!1),[j,f]=S.useState(""),a=5,x=S.useCallback(async()=>{d(!0);const k=await Dy(e,n);i(k),d(!1)},[e,n]);S.useEffect(()=>{x()},[x]);const g=async()=>{const k=u.trim();if(!(!k||_)){m(!0),f("");try{await Oy(e,n,k),c(""),await x()}catch{f("Failed to post comment. Please try again.")}m(!1)}},C=async k=>{if(window.confirm("Delete this comment?"))try{await Uo("Comment",k),i(T=>T.filter(A=>A.name!==k))}catch{alert("Failed to delete comment.")}},w=b?r:r.slice(-a),p=Math.max(0,r.length-a);return t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>h(k=>!k),style:{padding:"12px 20px",borderBottom:y?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",l.comments.title,r.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:r.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("button",{onClick:k=>{k.stopPropagation(),x()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),t.jsx("span",{style:{color:"#ccc",fontSize:11},children:y?"▼":"▲"})]})]}),!y&&t.jsxs("div",{style:{padding:"16px 20px"},children:[!b&&p>0&&t.jsxs("button",{onClick:()=>z(!0),style:{width:"100%",padding:"8px",marginBottom:12,border:"none",background:"#f8f9fa",borderRadius:6,cursor:"pointer",fontSize:12,color:"#3498db",fontFamily:"Segoe UI"},children:["Show ",p," older comment",p!==1?"s":""]}),o&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!o&&r.length===0&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:l.comments.noComments}),!o&&w.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:w.map(k=>{const T=k.comment_by||k.comment_email||k.owner||"Unknown",A=k.owner===s||k.comment_by===s;return t.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[t.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,flexShrink:0},children:g0(T)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:T}),t.jsx("span",{style:{fontSize:11,color:"#aaa"},children:h0(k.creation)})]}),A&&t.jsx("button",{onClick:()=>C(k.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),t.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:k.content||""}})]})]},k.name)})}),t.jsxs("div",{style:{borderTop:r.length>0?"1px solid #f0f0f0":"none",paddingTop:r.length>0?14:0},children:[t.jsx("textarea",{value:u,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&g()},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"}}),j&&t.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:j}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:t.jsx("button",{onClick:g,disabled:!u.trim()||_,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!u.trim()||_?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!u.trim()||_?.6:1},children:_?l.saving:l.comments.post})})]})]})]})}function zu(e){if(!e)return"";const n=(Date.now()-new Date(e).getTime())/1e3;return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*7?`${Math.floor(n/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function x0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Iu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function Fo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Tu(e){return Fo(e).split(" ").filter(Boolean).slice(0,2).map(n=>n[0].toUpperCase()).join("")}function m0(e){let n={};try{n=JSON.parse(e.data||"{}")}catch{}const s=(n.changed||[]).map(l=>({field:l[0]||"",oldVal:Iu(l[1]),newVal:Iu(l[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:s,added:(n.added||[]).length,removed:(n.removed||[]).length,rowChanged:(n.row_changed||[]).length}}function ca({doctype:e,docname:n,docCreation:s,docOwner:l}){const r=ne(),[i,o]=S.useState([]),[d,u]=S.useState(!1),[c,_]=S.useState(!0),[m,y]=S.useState(!1),h=5,b=S.useCallback(async()=>{u(!0);const a=await Ly(e,n);o(a.map(m0)),u(!1)},[e,n]);S.useEffect(()=>{c||b()},[c,b]);const z=m?i:i.slice(0,h),j=i.length-h,f=(a,x=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:a,border:"2px solid white",boxShadow:x?`0 0 0 2px ${a}44`:"none"});return t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>_(a=>!a),style:{padding:"12px 20px",borderBottom:c?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",r.activity.title,!c&&i.length>0&&t.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:i.length})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!c&&t.jsx("button",{onClick:a=>{a.stopPropagation(),b()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),t.jsx("span",{style:{color:"#ccc",fontSize:11},children:c?"▼":"▲"})]})]}),!c&&t.jsxs("div",{style:{padding:"16px 20px"},children:[d&&t.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!d&&t.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[t.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[z.map((a,x)=>t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:f(x===0?"#3498db":"#d1d5db",x===0)}),t.jsxs("div",{style:{background:x===0?"#eff6ff":"#f9fafb",border:`1px solid ${x===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Tu(a.owner)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Fo(a.owner)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:zu(a.creation)})]}),a.changes.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:a.changes.map((g,C)=>t.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[t.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:x0(g.field)}),t.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),t.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:g.oldVal}),t.jsx("span",{style:{color:"#6b7280"},children:" → "}),t.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:g.newVal})]},C))}):t.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",a.added>0&&t.jsxs("span",{children:[" · +",a.added," row(s)"]}),a.removed>0&&t.jsxs("span",{children:[" · -",a.removed," row(s)"]}),a.rowChanged>0&&t.jsxs("span",{children:[" · ~",a.rowChanged," row(s) modified"]})]})]})]},a.name)),s&&l&&t.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[t.jsx("div",{style:f("#22c55e")}),t.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[t.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#22c55e",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Tu(l)}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Fo(l)}),t.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:zu(s)})]}),t.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",r.activity.created]})]})]}),i.length===0&&!s&&t.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!d&&j>0&&t.jsx("div",{style:{textAlign:"center",marginTop:12},children:t.jsx("button",{onClick:()=>y(a=>!a),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:m?"▲ Show less":`▼ Show all (${i.length})`})})]})]})}const y0={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on resolution":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function v0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...y0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function j0({incForm:e,setIncForm:n,organizations:s,managements:l,departments:r,branches:i,incidentTypes:o,incidentClasses:d,incidentFields:u,incidentStatuses:c,users:_,userRoleMap:m={},formStatus:y,viewMode:h,canModify:b,onEdit:z,onDelete:j,onRestore:f,darkMode:a,notifCount:x,onToggleDark:g,onCountChange:C,onViewProfile:w,userRole:p,delegatedFunctions:k=[],delegatedOrgs:T={},onSubmit:A,onBack:Q,onNavigate:J,onLogout:W,user:U,onRefresh:I}){var ct;const O=ne(),M=F=>n({...e,...F}),H=h?{background:"#f9f9f9"}:{},Y=Il(_,m,"SB Manager",e.organization),[q,$]=S.useState(""),[Z,pe]=S.useState(!1),be=e.name?h?`${O.formTitle.viewIncident}${e.number||e.name}`:O.formTitle.editIncident:O.formTitle.newIncident,ie=ye(l,e.management).map(F=>({name:F.name,label:F.name1||F.name})),Ze=ye(r,e.department).map(F=>({name:F.name,label:F.department_name||F.name})),dt=ye(i,e.branch).map(F=>({name:F.name,label:F.branch||F.name})),K=ye(o,e.type).map(F=>({name:F.name,label:F.name1||F.name})),ae=ye(d,e.incident_class).map(F=>({name:F.name,label:F.name1||F.name})),We=ye(u,e.incident_field).map(F=>({name:F.name,label:F.name1||F.name})),ve=e.workflow_state||"New",nn=p==="Employee",fe=p==="Auditor"||p==="Admin",xe=p==="Manager",Tt=xe&&k.includes("incident_initial_evaluation")&&(!T.incident_initial_evaluation||(T.incident_initial_evaluation||[]).includes(e.organization)),Ne=fe||Tt,L=e.name?ve==="New"?[{label:O.wf.submit,action:"Submit",color:"#2563eb"}]:ve==="Initial Evaluation"&&Ne?[{label:O.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:O.wf.reject,action:"Reject",color:"#dc2626"}]:ve==="Accept & Under Progress"&&(xe||fe)?[{label:O.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:ve==="working on resolution"&&(xe||fe)?[{label:O.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function se(F){if(e.name){pe(!0),$("");try{const Pe={};F==="Assign to Manager"&&(e.assigned_to&&(Pe.assigned_to=e.assigned_to),e.priority&&(Pe.priority=e.priority),e.economy_class&&(Pe.economy_class=e.economy_class),e.entity_scope&&(Pe.entity_scope=e.entity_scope),e.hses_field&&(Pe.hses_field=e.hses_field),Pe.product_relation=String(e.product_relation??0),Pe.repeated=String(e.repeated??0)),F==="Submit Solution"&&(e.solution&&(Pe.solution=e.solution),e.summary&&(Pe.summary=e.summary),e.cost&&(Pe.cost=String(e.cost))),(F==="Resolution complete"||F==="Submit Solution")&&e.auditor_comment&&(Pe.auditor_comment=e.auditor_comment),await By(e.name,F,JSON.stringify(Pe)),$("Done"),I==null||I()}catch(Pe){$(Pe.message||"Error")}finally{pe(!1)}}}const R=((ct=Y.find(F=>F.name===e.assigned_to))==null?void 0:ct.full_name)||e.assigned_to,Be=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:O.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:ve})]}),ve==="Initial Evaluation"&&Ne&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:O.wf.assignToManager}),t.jsxs("select",{style:P,value:e.assigned_to||"",onChange:F=>M({assigned_to:F.target.value}),children:[t.jsx("option",{value:"",children:O.field.selectMgr}),Y.map(F=>t.jsx("option",{value:F.name,children:F.full_name||F.name},F.name))]})]}),(ve==="Accept & Under Progress"||ve==="working on resolution")&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:O.field.solution}),t.jsx("textarea",{style:{...P,height:75,resize:"vertical"},value:e.solution||"",onChange:F=>M({solution:F.target.value}),placeholder:O.field.solutionPlaceholder}),t.jsx("label",{style:{...E,marginTop:6},children:O.field.actualCost}),t.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:F=>M({cost:parseFloat(F.target.value)||0}),placeholder:"0.00"})]}),ve==="working on resolution"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:O.field.auditorComment}),t.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:F=>M({auditor_comment:F.target.value}),placeholder:O.field.commentPlaceholder})]}),L.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:L.map(F=>t.jsx("button",{onClick:()=>se(F.action),disabled:Z,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:F.color,color:"white",fontWeight:600,fontSize:12,cursor:Z?"not-allowed":"pointer",opacity:Z?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:Z?O.wf.applying:F.label})},F.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:O.wf.noActions}),q&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:q==="Done"?X.green:X.red},children:q})]}),t.jsx(aa,{priority:e.priority,status:ve,assignedTo:R||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(da,{doctype:D.incidents,docname:e.name,currentUserName:U.name}),t.jsx(ca,{doctype:D.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),b&&j&&!e.custom_is_deleted&&t.jsx(ia,{title:"Delete Request",btnText:O.delete,onDelete:()=>j(e.name)})]}):null;return t.jsxs(Ve,{title:be,activePage:"incidents",user:U,formStatus:y,statusBadge:t.jsx("span",{style:v0(ve),children:ve}),buttonText:O.saveIncident,buttonColor:"#16a34a",viewMode:h,onEdit:z,darkMode:a,notifCount:x,onToggleDark:g,onCountChange:C,onViewProfile:w,rightPanel:Be,onSubmit:A,onBack:Q,onNavigate:J,onLogout:W,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:f?()=>f(e.name):void 0}),t.jsx(le,{title:"Incident Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.number}),t.jsx("input",{style:{...P,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[O.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:F=>M({organization:F}),organizations:s,disabled:h||!!U.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.title}),t.jsx("input",{style:{...P,...H},value:e.title,disabled:h,onChange:F=>M({title:F.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.management}),t.jsx(ue,{value:e.management,onChange:F=>M({management:F}),items:ie,placeholder:O.field.select,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.department}),t.jsx(ue,{value:e.department,onChange:F=>M({department:F}),items:Ze,placeholder:O.field.select,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.section}),t.jsx("input",{style:{...P,...H},value:e.section_field||"",disabled:h,onChange:F=>M({section_field:F.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.branch}),t.jsx(ue,{value:e.branch,onChange:F=>M({branch:F}),items:dt,placeholder:O.field.select,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.eventCategory}),t.jsxs("select",{style:{...P,...H},value:e.event_category||"",disabled:h,onChange:F=>M({event_category:F.target.value}),children:[t.jsx("option",{value:"",children:O.field.select}),e.event_category&&!["Operational","Technical","Administrative","Financial","Safety & Security","Environmental","Quality","Other"].includes(e.event_category)&&t.jsx("option",{value:e.event_category,children:e.event_category}),t.jsx("option",{value:"Operational",children:"Operational"}),t.jsx("option",{value:"Technical",children:"Technical"}),t.jsx("option",{value:"Administrative",children:"Administrative"}),t.jsx("option",{value:"Financial",children:"Financial"}),t.jsx("option",{value:"Safety & Security",children:"Safety & Security"}),t.jsx("option",{value:"Environmental",children:"Environmental"}),t.jsx("option",{value:"Quality",children:"Quality"}),t.jsx("option",{value:"Other",children:"Other"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.type}),t.jsx(ue,{value:e.type,onChange:F=>M({type:F}),items:K,placeholder:O.field.selectType,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.incidentClass}),t.jsx(ue,{value:e.incident_class,onChange:F=>M({incident_class:F}),items:ae,placeholder:O.field.selectClass,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.incidentField}),t.jsx(ue,{value:e.incident_field,onChange:F=>M({incident_field:F}),items:We,placeholder:O.field.selectField,disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.hsesField}),t.jsx("input",{style:{...P,...H},value:e.hses_field||"",disabled:h,onChange:F=>M({hses_field:F.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),t.jsxs(le,{title:"Incident Details & Timing",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.date}),t.jsx(me,{value:e.date,onChange:F=>M({date:F}),disabled:!0,style:{...P,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.time}),t.jsx("input",{type:"time",style:{...P,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.assignedTo}),h||p==="Employee"?t.jsx("input",{style:{...P,background:"#f8fafc",fontWeight:600,color:"#334155"},value:R||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.assigned_to||"",onChange:F=>M({assigned_to:F}),items:Y.map(F=>({name:F.name,label:F.full_name||F.name})),placeholder:O.field.select})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.description}),t.jsx("textarea",{style:{...P,...H,height:100,resize:"vertical"},value:e.description,disabled:h,onChange:F=>M({description:F.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!nn&&t.jsxs(le,{title:O.steps.auditorTriage,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.priority}),t.jsxs("select",{style:{...P,...h||!Ne?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:h||!Ne,onChange:F=>M({priority:F.target.value}),children:[t.jsx("option",{value:"",children:O.field.select}),t.jsx("option",{value:"High",children:O.field.high}),t.jsx("option",{value:"Normal",children:O.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.economyClass}),t.jsxs("select",{style:{...P,...h||!Ne?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:h||!Ne,onChange:F=>M({economy_class:F.target.value}),children:[t.jsx("option",{value:"",children:O.field.select}),t.jsx("option",{value:"Expenses",children:O.field.expenses}),t.jsx("option",{value:"Capital",children:O.field.capital}),t.jsx("option",{value:"Earn",children:O.field.earn}),t.jsx("option",{value:"Pay/Loss",children:O.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.entityScope}),t.jsxs("select",{style:{...P,...h||!Ne?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:h||!Ne,onChange:F=>M({entity_scope:F.target.value}),children:[t.jsx("option",{value:"",children:O.field.select}),t.jsx("option",{value:"Upstream",children:O.field.upstream}),t.jsx("option",{value:"On-stream",children:O.field.onstream}),t.jsx("option",{value:"Downstream",children:O.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:h||!Ne,onChange:F=>M({product_relation:F.target.checked?1:0})})," ",O.field.productRelation]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:h||!Ne,onChange:F=>M({repeated:F.target.checked?1:0})})," ",O.field.repeatedEvent]})]})]}),!nn&&t.jsxs(le,{title:O.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:E,children:O.field.solution}),t.jsx("textarea",{style:{...P,height:90,resize:"vertical",...h&&!xe&&!fe?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:h&&!xe&&!fe,onChange:F=>M({solution:F.target.value}),placeholder:O.field.solutionPlaceholder})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.actualCost}),t.jsx("input",{type:"number",style:{...P,...h&&!xe&&!fe?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:h&&!xe&&!fe,onChange:F=>M({cost:parseFloat(F.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.summary}),t.jsx("input",{style:{...P,...h&&!xe&&!fe?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:h&&!xe&&!fe,onChange:F=>M({summary:F.target.value}),placeholder:"Brief summary"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:O.field.auditorComment}),t.jsx("textarea",{style:{...P,height:70,resize:"vertical",...h&&!fe?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:h&&!fe,onChange:F=>M({auditor_comment:F.target.value}),placeholder:O.field.commentPlaceholder})]})]})]})}function b0({ideas:e,organizations:n,departments:s,branches:l,ideaStatuses:r,initialOrg:i,initialStatus:o,canModify:d,userRole:u,onView:c,onEdit:_,onDelete:m,onSelectionChange:y}){const h=ne(),[b,z]=S.useState(new Set),[j,f]=S.useState({search:"",organization:i||"",department:"",branch:"",status:o||""}),a=(p,k)=>f(T=>({...T,[p]:k})),[x,g]=S.useState(1),C=e.filter(p=>!(j.search&&!`${p.number} ${p.title}`.toLowerCase().includes(j.search.toLowerCase())||j.organization&&p.organization!==j.organization||j.department&&p.department!==j.department||j.branch&&p.branch!==j.branch||j.status&&p.status!==j.status));S.useEffect(()=>{g(1)},[j]);const w=C.slice((x-1)*re,x*re);return S.useEffect(()=>{if(y){const p=e.filter(k=>b.has(k.name));y(p,w)}},[b,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(oa,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.numberTitle}),t.jsx("input",{style:nt,value:j.search,onChange:p=>a("search",p.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.organization}),t.jsxs("select",{style:nt,value:j.organization,onChange:p=>a("organization",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(p=>t.jsx("option",{value:p.name,children:p.organization_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.department}),t.jsxs("select",{style:nt,value:j.department,onChange:p=>a("department",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(p=>t.jsx("option",{value:p.name,children:p.department_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.branch}),t.jsxs("select",{style:nt,value:j.branch,onChange:p=>a("branch",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(p=>t.jsx("option",{value:p.name,children:p.branch||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.status}),t.jsxs("select",{style:nt,value:j.status,onChange:p=>a("status",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(p=>t.jsx("option",{value:p.name,children:p.name1||p.name},p.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(p=>b.has(p.name)),onChange:p=>{if(p.target.checked)z(new Set([...b,...w.map(k=>k.name)]));else{const k=new Set(b);w.forEach(T=>k.delete(T.name)),z(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:C.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noIdeas})}):w.map((p,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>c==null?void 0:c(p),style:{borderTop:"1px solid #f1f5f9",background:b.has(p.name)?"#eff6ff":p.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(p.name),onChange:()=>{const T=new Set(b);T.has(p.name)?T.delete(p.name):T.add(p.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:p.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:p.title||"—"}),p.sb_order&&t.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",p.sb_order]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:p.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.custom_is_deleted?ns(h.deletedBadge):p.status?ns(p.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(it,{onView:()=>c==null?void 0:c(p),onEdit:d&&_&&!p.custom_is_deleted&&!Hn("idea",p.workflow_state)&&!(u==="Employee"&&p.workflow_state&&p.workflow_state!=="New")?()=>_(p):void 0,onDelete:d&&m&&!p.custom_is_deleted?()=>m(p.name):void 0})})]},p.name))})]})}),t.jsx(Je,{page:x,total:C.length,onPageChange:g})]})}const S0={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on proposal":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function w0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...S0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function _0({ideaForm:e,setIdeaForm:n,organizations:s,managements:l,departments:r,branches:i,ideaTypes:o,ideaStatuses:d,users:u=[],userRoleMap:c={},formStatus:_,viewMode:m,canModify:y,onEdit:h,onDelete:b,onRestore:z,onNavigateToOrder:j,darkMode:f,notifCount:a,onToggleDark:x,onCountChange:g,onViewProfile:C,userRole:w,delegatedFunctions:p=[],delegatedOrgs:k={},onSubmit:T,onBack:A,onNavigate:Q,onLogout:J,user:W,onRefresh:U}){var se;const I=ne(),O=R=>n({...e,...R}),M=m?{background:"#f9f9f9"}:{},H=Il(u,c,"SB Manager",e.organization),[Y,q]=S.useState(""),[$,Z]=S.useState(!1),pe=e.name?m?`${I.formTitle.viewIdea}${e.number||e.title||e.name}`:I.formTitle.editIdea:I.formTitle.newIdea,be=ye(l,e.management).map(R=>({name:R.name,label:R.name1||R.name})),ie=ye(r,e.department).map(R=>({name:R.name,label:R.department_name||R.name})),Ze=ye(i,e.branch).map(R=>({name:R.name,label:R.branch||R.name})),dt=ye(o,e.type).map(R=>({name:R.name,label:R.name1||R.name})),K=e.workflow_state||"New",ae=w==="Employee",We=w==="Auditor"||w==="Admin",ve=w==="Manager",nn=ve&&p.includes("idea_initial_evaluation")&&(!k.idea_initial_evaluation||(k.idea_initial_evaluation||[]).includes(e.organization)),fe=We||nn,xe=e.name?K==="New"?[{label:I.wf.submit,action:"Submit",color:"#2563eb"}]:K==="Initial Evaluation"&&fe?[{label:I.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:K==="Accept & Under Progress"&&(ve||We)?[{label:I.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:K==="working on proposal"&&We?[{label:I.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function Tt(R){if(e.name){Z(!0),q("");try{const Be={};R==="Assign to Manager"&&(e.assigned_to&&(Be.assigned_to=e.assigned_to),e.priority&&(Be.priority=e.priority),e.economy_class&&(Be.economy_class=e.economy_class),e.entity_scope&&(Be.entity_scope=e.entity_scope),e.hses_field&&(Be.hses_field=e.hses_field),Be.product_relation=String(e.product_relation??0),Be.repeated=String(e.repeated??0)),R==="Submit Proposal"&&(e.solution&&(Be.solution=e.solution),e.proposed_condition&&(Be.proposed_condition=e.proposed_condition),e.cost&&(Be.cost=String(e.cost))),e.auditor_comment&&(R==="Move to Outsourcing"||R==="Reject")&&(Be.auditor_comment=e.auditor_comment);const ct=await $y(e.name,R,JSON.stringify(Be));ct!=null&&ct.created_order&&O({sb_order:ct.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),q("Done"),U==null||U()}catch(Be){q(Be.message||"Error")}finally{Z(!1)}}}const Ne=((se=H.find(R=>R.name===e.assigned_to))==null?void 0:se.full_name)||e.assigned_to,L=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:I.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:K})]}),K==="Initial Evaluation"&&fe&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:I.wf.assignToManager}),t.jsxs("select",{style:P,value:e.assigned_to||"",onChange:R=>O({assigned_to:R.target.value}),children:[t.jsx("option",{value:"",children:I.field.selectMgr}),H.map(R=>t.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]}),K==="Accept & Under Progress"&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:I.field.solution}),t.jsx("textarea",{style:{...P,height:75,resize:"vertical"},value:e.solution||"",onChange:R=>O({solution:R.target.value}),placeholder:I.field.solutionPlaceholder}),t.jsx("label",{style:{...E,marginTop:6},children:I.field.actualCost}),t.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:R=>O({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),K==="working on proposal"&&We&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("label",{style:E,children:I.field.auditorComment}),t.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>O({auditor_comment:R.target.value}),placeholder:I.field.commentPlaceholder})]}),xe.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:xe.map(R=>t.jsx("button",{onClick:()=>Tt(R.action),disabled:$,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:R.color,color:"white",fontWeight:600,fontSize:12,cursor:$?"not-allowed":"pointer",opacity:$?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:$?I.wf.applying:R.label})},R.action))}):t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions}),Y&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:Y==="Done"?X.green:X.red},children:Y})]}),t.jsx(aa,{priority:e.priority,status:K,assignedTo:Ne||(e.assigned_to?e.assigned_to:void 0),createdDate:e.date,modifiedDate:e.modified}),t.jsx(da,{doctype:D.ideas,docname:e.name,currentUserName:W.name}),t.jsx(ca,{doctype:D.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),y&&b&&!e.custom_is_deleted&&t.jsx(ia,{title:"Delete Request",btnText:I.delete,onDelete:()=>b(e.name)})]}):null;return t.jsxs(Ve,{title:pe,activePage:"ideas",user:W,formStatus:_,statusBadge:t.jsx("span",{style:w0(K),children:K}),buttonText:I.saveIdea,buttonColor:"#16a34a",viewMode:m,onEdit:h,darkMode:f,notifCount:a,onToggleDark:x,onCountChange:g,onViewProfile:C,rightPanel:L,onSubmit:T,onBack:A,onNavigate:Q,onLogout:J,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:z?()=>z(e.name):void 0}),e.sb_order&&t.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"8px 14px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:"📦"}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#15803d",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[I.field.convertedToOrder,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),j&&t.jsxs("button",{type:"button",onClick:()=>j(e.sb_order),style:{background:"#16a34a",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:R=>R.currentTarget.style.background="#15803d",onMouseLeave:R=>R.currentTarget.style.background="#16a34a",children:[I.field.viewOrder," →"]})]}),t.jsx(le,{title:"Idea Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.number}),t.jsx("input",{style:{...P,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[I.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:R=>O({organization:R}),organizations:s,disabled:m||!!W.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.title}),t.jsx("input",{style:{...P,...M},value:e.title,disabled:m,onChange:R=>O({title:R.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.management}),t.jsx(ue,{value:e.management,onChange:R=>O({management:R}),items:be,placeholder:I.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.department}),t.jsx(ue,{value:e.department,onChange:R=>O({department:R}),items:ie,placeholder:I.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.section}),t.jsx("input",{style:{...P,...M},value:e.section_field||"",disabled:m,onChange:R=>O({section_field:R.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.branch}),t.jsx(ue,{value:e.branch,onChange:R=>O({branch:R}),items:Ze,placeholder:I.field.select,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.type}),t.jsx(ue,{value:e.type,onChange:R=>O({type:R}),items:dt,placeholder:I.field.selectType,disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.ideaClass}),t.jsxs("select",{style:{...P,...M},value:e.idea_class||"",disabled:m,onChange:R=>O({idea_class:R.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Safety",children:"Safety"}),t.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.hsesField}),t.jsx("input",{style:{...P,...M},value:e.hses_field||"",disabled:m,onChange:R=>O({hses_field:R.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.date}),t.jsx(me,{value:e.date||"",onChange:R=>O({date:R}),disabled:!0,style:{...P,background:"#f8fafc"}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.assignedTo}),m||w==="Employee"?t.jsx("input",{style:{...P,background:"#f8fafc",fontWeight:600,color:"#334155"},value:Ne||e.assigned_to||"—",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.assigned_to||"",onChange:R=>O({assigned_to:R}),items:H.map(R=>({name:R.name,label:R.full_name||R.name})),placeholder:I.field.select})]})]})}),t.jsx(le,{title:"Condition Details & Description",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.currentCondition}),t.jsx("textarea",{style:{...P,...M,height:100,resize:"vertical"},value:e.current_condition,disabled:m,onChange:R=>O({current_condition:R.target.value}),placeholder:"Describe the current condition or problem..."})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.proposedCondition}),t.jsx("textarea",{style:{...P,...M,height:100,resize:"vertical"},value:e.proposed_condition,disabled:m,onChange:R=>O({proposed_condition:R.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!ae&&t.jsxs(le,{title:I.steps.auditorEval,children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.priority}),t.jsxs("select",{style:{...P,...m||!fe?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:m||!fe,onChange:R=>O({priority:R.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"High",children:I.field.high}),t.jsx("option",{value:"Normal",children:I.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.economyClass}),t.jsxs("select",{style:{...P,...m||!fe?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:m||!fe,onChange:R=>O({economy_class:R.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Expenses",children:I.field.expenses}),t.jsx("option",{value:"Capital",children:I.field.capital}),t.jsx("option",{value:"Earn",children:I.field.earn}),t.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.entityScope}),t.jsxs("select",{style:{...P,...m||!fe?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:m||!fe,onChange:R=>O({entity_scope:R.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Upstream",children:I.field.upstream}),t.jsx("option",{value:"On-stream",children:I.field.onstream}),t.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:m||!fe,onChange:R=>O({product_relation:R.target.checked?1:0})})," ",I.field.productRelation]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:m||!fe,onChange:R=>O({repeated:R.target.checked?1:0})})," ",I.field.repeatedEvent]})]})]}),!ae&&t.jsxs(le,{title:I.steps.managerSolution,children:[t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("label",{style:E,children:I.field.solution}),t.jsx("textarea",{style:{...P,height:90,resize:"vertical",...m&&!ve&&!We?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:m&&!ve&&!We,onChange:R=>O({solution:R.target.value}),placeholder:I.field.solutionPlaceholder})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.actualCost}),t.jsx("input",{type:"number",style:{...P,...m&&!ve&&!We?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:m&&!ve&&!We,onChange:R=>O({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.auditorComment}),t.jsx("textarea",{style:{...P,height:60,resize:"vertical",...m&&!We?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:m&&!We,onChange:R=>O({auditor_comment:R.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})]})}function k0({orders:e,organizations:n,departments:s,branches:l,orderStatuses:r,initialOrg:i,initialStatus:o,canModify:d,userRole:u,onView:c,onEdit:_,onDelete:m,onSelectionChange:y}){const h=ne(),[b,z]=S.useState(new Set),[j,f]=S.useState({search:"",organization:i||"",department:"",branch:"",status:o||""}),a=(p,k)=>f(T=>({...T,[p]:k})),[x,g]=S.useState(1),C=e.filter(p=>!(j.search&&!`${p.number} ${p.title}`.toLowerCase().includes(j.search.toLowerCase())||j.organization&&p.organization!==j.organization||j.department&&p.department!==j.department||j.branch&&p.branch!==j.branch||j.status&&p.status!==j.status));S.useEffect(()=>{g(1)},[j]);const w=C.slice((x-1)*re,x*re);return S.useEffect(()=>{if(y){const p=e.filter(k=>b.has(k.name));y(p,w)}},[b,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(oa,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.numberTitle}),t.jsx("input",{style:nt,value:j.search,onChange:p=>a("search",p.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.organization}),t.jsxs("select",{style:nt,value:j.organization,onChange:p=>a("organization",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(p=>t.jsx("option",{value:p.name,children:p.organization_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.department}),t.jsxs("select",{style:nt,value:j.department,onChange:p=>a("department",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(p=>t.jsx("option",{value:p.name,children:p.department_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.branch}),t.jsxs("select",{style:nt,value:j.branch,onChange:p=>a("branch",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(p=>t.jsx("option",{value:p.name,children:p.branch||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.status}),t.jsxs("select",{style:nt,value:j.status,onChange:p=>a("status",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(p=>t.jsx("option",{value:p.name,children:p.name1||p.name},p.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(p=>b.has(p.name)),onChange:p=>{if(p.target.checked)z(new Set([...b,...w.map(k=>k.name)]));else{const k=new Set(b);w.forEach(T=>k.delete(T.name)),z(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.type}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:C.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noOrders})}):w.map((p,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>c==null?void 0:c(p),style:{borderTop:"1px solid #f1f5f9",background:b.has(p.name)?"#eff6ff":p.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(p.name),onChange:()=>{const T=new Set(b);T.has(p.name)?T.delete(p.name):T.add(p.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:p.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:p.title||p.name||"—"}),p.sb_idea&&t.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",p.sb_idea]})]})}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:p.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.type?Wd(p.type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.custom_is_deleted?ns(h.deletedBadge):p.status?ns(p.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(it,{onView:()=>c==null?void 0:c(p),onEdit:d&&_&&!p.custom_is_deleted&&!Hn("order",p.workflow_state)&&u!=="Employee"?()=>_(p):void 0,onDelete:d&&m&&!p.custom_is_deleted?()=>m(p.name):void 0})})]},p.name))})]})}),t.jsx(Je,{page:x,total:C.length,onPageChange:g})]})}const C0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},z0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},Review:{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"In Study":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Closed:{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function I0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...z0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function T0({orderForm:e,setOrderForm:n,organizations:s,managements:l,departments:r,branches:i,orderTypes:o,orderStatuses:d,cycles:u=[],users:c=[],userRoleMap:_={},formStatus:m,viewMode:y,canModify:h,onEdit:b,onDelete:z,onRestore:j,onNavigateToIdea:f,darkMode:a,notifCount:x,onToggleDark:g,onCountChange:C,onViewProfile:w,currentUser:p,userRole:k,onSubmit:T,onBack:A,onNavigate:Q,onLogout:J,user:W,onRefresh:U}){var is,Or;const I=ne(),O=N=>n({...e,...N}),M=y?{background:"#f9f9f9"}:{},H=Il(c,_,"SB Employee",e.organization),[Y,q]=S.useState(""),[$,Z]=S.useState(""),[pe,be]=S.useState(!1),[ie,Ze]=S.useState("Agree"),dt=e.name?y?`${I.formTitle.viewOrder}${e.number||e.title||e.name}`:I.formTitle.editOrder:I.formTitle.newOrder,K=ye(l,e.management).map(N=>({name:N.name,label:N.name1||N.name})),ae=ye(r,e.department).map(N=>({name:N.name,label:N.department_name||N.name})),We=ye(i,e.branch).map(N=>({name:N.name,label:N.branch||N.name})),ve=ye(o,e.type).map(N=>({name:N.name,label:N.name1||N.name})),nn=ye(u,e.cycle).map(N=>({name:N.name,label:N.name1||N.cycle_name||N.name})),fe=!!e.name,xe=e.workflow_state||"Draft",Tt=Math.min(5,(e.stage||0)+1),[Ne,L]=S.useState(Tt);S.useEffect(()=>{L(Math.min(5,(e.stage||0)+1))},[e.stage]);const se=k==="Auditor"||k==="Admin"||k==="Manager",R=se||k==="Owner",Be=!!(p&&(e.actor===p||e.assigned_to===p)),ct=e.stage===5||e.completion_pct===100||e.status==="Completion"||xe==="Completed"||xe==="Closed",F=e.order_cycle_log||[],Pe=F.length>0?F[F.length-1].status:ie,Dr=Pe==="Deviate"||Pe==="Deviated"||Pe==="Unknown",gn=(()=>{if(!fe)return[];if(xe==="Closed"||xe==="Completed")return[];if(xe==="Draft"&&se)return[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}];if(xe==="Pending Actor"&&(Be||se))return[{label:"Update Status",action:"Update Status",color:"#d97706"}];if(xe==="Review"&&R){const N=[{label:"Move to Study",action:"Move to Study",color:"#059669"}];return(!ct||Dr)&&N.push({label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}),ct&&N.push({label:"Close Order",action:"Close Order",color:"#475569"}),N}if(xe==="In Study"&&R){const N=[];return(!ct||Dr)&&N.push({label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}),N.push({label:"Close Order",action:"Close Order",color:"#475569"}),N}return[]})();async function ua(N){if(e.name){be(!0),q("");try{let Et;N==="Update Status"&&(Et=ie);const as=await Ny(e.name,N,$,N==="Update Status"?String(Ne):void 0,void 0,Et);if(Z(""),Ze("Agree"),q("Done"),as){const Dn=as;n({...e,...Dn,stage:Dn.stage??e.stage,completion_pct:Dn.completion_pct??e.completion_pct,workflow_state:Dn.workflow_state??e.workflow_state})}U==null||U()}catch(Et){q(Et.message||"Error")}finally{be(!1)}}}const xn=((is=H.find(N=>N.name===(e.actor||e.assigned_to)))==null?void 0:is.full_name)||e.actor||e.assigned_to,pa=fe?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:I.wf.workflow}),t.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),t.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:xe})]}),xe==="Pending Actor"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:["Stage (1–5) — ",Ne*20,"% complete"]}),t.jsx("input",{type:"number",min:1,max:5,style:{...P,width:"100%"},value:Ne,onChange:N=>L(Math.min(5,Math.max(1,parseInt(N.target.value)||1)))})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Cycle Status"}),t.jsxs("select",{style:P,value:ie,onChange:N=>Ze(N.target.value),children:[t.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),t.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),t.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsxs("label",{style:E,children:["Comment ",ie==="Deviate"&&xe==="Pending Actor"?t.jsx("span",{style:{color:X.red},children:" * required for Deviate"}):"(optional)"]}),t.jsx("textarea",{style:{...P,height:60,resize:"vertical",borderColor:ie==="Deviate"&&!$?"#fca5a5":void 0},value:$,onChange:N=>Z(N.target.value),placeholder:"Add a comment…"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:gn.map(N=>{const Et=N.action==="Update Status"&&ie==="Deviate"&&!$.trim();return t.jsx("button",{onClick:()=>ua(N.action),disabled:pe||Et,title:Et?"Comment required when status is Deviate":void 0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:N.color,color:"white",fontWeight:600,fontSize:12,cursor:pe||Et?"not-allowed":"pointer",opacity:pe||Et?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:t.jsx("span",{children:pe?I.wf.applying:N.label})},N.action)})}),Y&&t.jsx("p",{style:{marginTop:8,fontSize:12,color:Y==="Done"?X.green:X.red},children:Y}),gn.length===0&&t.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions})]}),t.jsx(aa,{priority:e.priority,status:xe,assignedTo:k!=="Employee"?xn:void 0,createdDate:e.starting_date,modifiedDate:e.modified}),t.jsx(da,{doctype:D.orders,docname:e.name,currentUserName:W.name}),t.jsx(ca,{doctype:D.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),h&&z&&!e.custom_is_deleted&&t.jsx(ia,{title:"Delete Request",btnText:I.delete,onDelete:()=>z(e.name)})]}):null;return t.jsxs(Ve,{title:dt,activePage:"orders",user:W,formStatus:m,statusBadge:t.jsx("span",{style:I0(xe),children:xe}),buttonText:I.saveOrder,buttonColor:"#16a34a",viewMode:y,onEdit:b,darkMode:a,notifCount:x,onToggleDark:g,onCountChange:C,onViewProfile:w,rightPanel:pa,onSubmit:T,onBack:A,onNavigate:Q,onLogout:J,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:j?()=>j(e.name):void 0}),e.sb_idea&&t.jsxs("div",{style:{background:"#f0f7ff",border:"1px solid #bfdbfe",borderRadius:8,padding:"8px 14px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[t.jsx("span",{style:{fontSize:14,flexShrink:0},children:"💡"}),t.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#1e40af",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[I.field.originatingIdea,":"]}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),f&&t.jsxs("button",{type:"button",onClick:()=>f(e.sb_idea),style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:N=>N.currentTarget.style.background="#1d4ed8",onMouseLeave:N=>N.currentTarget.style.background="#2563eb",children:[I.field.viewIdea," →"]})]}),t.jsx(le,{title:"Order Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.number}),t.jsx("input",{style:{...P,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[I.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:N=>O({organization:N}),organizations:s,disabled:y||!!W.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.title}),t.jsx("input",{style:{...P,...M},value:e.title,disabled:y,onChange:N=>O({title:N.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.management}),t.jsx(ue,{value:e.management,onChange:N=>O({management:N}),items:K,placeholder:I.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.department}),t.jsx(ue,{value:e.department,onChange:N=>O({department:N}),items:ae,placeholder:I.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.section}),t.jsx("input",{style:{...P,...M},value:e.section_field||"",disabled:y,onChange:N=>O({section_field:N.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.branch}),t.jsx(ue,{value:e.branch,onChange:N=>O({branch:N}),items:We,placeholder:I.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.type}),t.jsx(ue,{value:e.type,onChange:N=>O({type:N}),items:ve,placeholder:I.field.selectType,disabled:y})]})]})}),t.jsxs(le,{title:"Financial & Schedule",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.budget}),t.jsx("input",{type:"number",style:{...P,...M},value:e.budget||"",disabled:y,onChange:N=>O({budget:parseFloat(N.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.actualCost}),t.jsx("input",{type:"number",style:{...P,...M},value:e.actual_cost||"",disabled:y,onChange:N=>O({actual_cost:parseFloat(N.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Variance"}),(()=>{const N=(e.budget||0)-(e.actual_cost||0);return t.jsxs("div",{style:{padding:"7px 12px",borderRadius:6,fontWeight:700,fontSize:13,background:N>=0?"#f0fdf4":"#fef2f2",color:N>=0?"#166534":"#dc2626",border:`1px solid ${N>=0?"#bbf7d0":"#fecaca"}`,display:"inline-block",width:"100%",boxSizing:"border-box"},children:[N>=0?"+":"",N.toFixed(2)]})})()]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.currency}),t.jsxs("select",{style:{...P,...M},value:e.currency||"",disabled:y,onChange:N=>O({currency:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"SAR",children:"SAR"}),t.jsx("option",{value:"USD",children:"USD"}),t.jsx("option",{value:"EUR",children:"EUR"}),t.jsx("option",{value:"AED",children:"AED"}),t.jsx("option",{value:"GBP",children:"GBP"})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.startingDate}),t.jsx(me,{value:e.starting_date,onChange:N=>O({starting_date:N}),disabled:y,style:{...P,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.endingDate}),t.jsx(me,{value:e.ending_date,onChange:N=>O({ending_date:N}),disabled:y,style:{...P,...M}})]}),k!=="Employee"&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.actor}),y?t.jsx("input",{style:{...P,background:"#f8fafc",fontWeight:600,color:"#334155"},value:xn||"—",readOnly:!0,disabled:!0}):t.jsxs("select",{style:{...P,background:"#ffffff"},value:e.actor||e.assigned_to||"",onChange:N=>O({actor:N.target.value,assigned_to:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),H.map(N=>t.jsx("option",{value:N.name,children:N.full_name||N.name},N.name))]})]})]})]}),t.jsxs(le,{title:"Classification",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.priority}),t.jsxs("select",{style:{...P,...M},value:e.priority||"",disabled:y,onChange:N=>O({priority:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"High",children:I.field.high}),t.jsx("option",{value:"Normal",children:I.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.economyClass}),t.jsxs("select",{style:{...P,...M},value:e.economy_class||"",disabled:y,onChange:N=>O({economy_class:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Expenses",children:I.field.expenses}),t.jsx("option",{value:"Capital",children:I.field.capital}),t.jsx("option",{value:"Earn",children:I.field.earn}),t.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.entityScope}),t.jsxs("select",{style:{...P,...M},value:e.entity_scope||"",disabled:y,onChange:N=>O({entity_scope:N.target.value}),children:[t.jsx("option",{value:"",children:I.field.select}),t.jsx("option",{value:"Upstream",children:I.field.upstream}),t.jsx("option",{value:"On-stream",children:I.field.onstream}),t.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:y,onChange:N=>O({planned:N.target.checked?1:0})})," Planned"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:y,onChange:N=>O({product_relation:N.target.checked?1:0})})," ",I.field.productRelation]})]}),t.jsxs("div",{style:{marginTop:12},children:[t.jsx("label",{style:E,children:I.field.hsesField}),t.jsx("input",{style:{...P,...M},value:e.hses_field||"",disabled:y,onChange:N=>O({hses_field:N.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),t.jsxs(le,{title:"Cycle & Progress Tracking",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.cycle}),t.jsx(ue,{value:e.cycle||"",onChange:N=>O({cycle:N}),items:nn,placeholder:I.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.cycleType}),t.jsxs("select",{style:{...P,...M},value:e.cycle_type||"Normal",disabled:y,onChange:N=>O({cycle_type:N.target.value}),children:[t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Long",children:"Long"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.stage}),t.jsx("input",{type:"number",min:1,max:5,style:{...P,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Completion"}),t.jsx("input",{style:{...P,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Stage Description"}),t.jsx("span",{style:{display:"inline-block",padding:"7px 12px",borderRadius:6,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd",width:"100%",boxSizing:"border-box"},children:C0[e.stage||1]||"—"})]})]}),e.cycle_type==="Long"&&t.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginBottom:14},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 1"}),t.jsx(me,{value:e.long_cycle_date_1||"",onChange:N=>O({long_cycle_date_1:N}),disabled:y,style:{...P,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 2"}),t.jsx(me,{value:e.long_cycle_date_2||"",onChange:N=>O({long_cycle_date_2:N}),disabled:y,style:{...P,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 3"}),t.jsx(me,{value:e.long_cycle_date_3||"",onChange:N=>O({long_cycle_date_3:N}),disabled:y,style:{...P,...M}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 4"}),t.jsx(me,{value:e.long_cycle_date_4||"",onChange:N=>O({long_cycle_date_4:N}),disabled:y,style:{...P,...M}})]})]})]}),fe&&((Or=e.order_cycle_log)==null?void 0:Or.length)>0&&t.jsxs("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:14,marginTop:10},children:[t.jsx("p",{style:{fontWeight:700,color:"#334155",fontSize:13,marginBottom:10},children:"Cycle History"}),t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(N=>t.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:N},N))})}),t.jsx("tbody",{children:(e.order_cycle_log||[]).map((N,Et)=>{const as=N.status==="Agree"?"#166534":N.status==="Deviate"?"#c2410c":"#92400e",Dn=N.status==="Agree"?"#f0fdf4":N.status==="Deviate"?"#fff7ed":"#fefce8";return t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.cycle||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.cycle_date||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:N.stage||"—"}),t.jsx("td",{style:{padding:"6px 10px"},children:t.jsx("span",{style:{background:Dn,color:as,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:N.status||"—"})}),t.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:N.actor||"—"}),t.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:N.comment?"normal":"italic"},children:N.comment||"—"})]},Et)})})]})})]})]}),t.jsxs(le,{title:"Description & Notes",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.description}),t.jsx("textarea",{style:{...P,...M,height:90,resize:"vertical"},value:e.description,disabled:y,onChange:N=>O({description:N.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.notes}),t.jsx("textarea",{style:{...P,...M,height:90,resize:"vertical"},value:e.notes,disabled:y,onChange:N=>O({notes:N.target.value})})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:I.field.auditorComment}),t.jsx("textarea",{style:{...P,height:70,resize:"vertical",...y&&Be&&!se?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:y&&Be&&!se,onChange:N=>O({auditor_comment:N.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})}function E0({processes:e,organizations:n,departments:s,branches:l,processStatuses:r,initialOrg:i,initialStatus:o,canModify:d,userRole:u,onView:c,onEdit:_,onDelete:m,onSelectionChange:y}){const h=ne(),[b,z]=S.useState(new Set),[j,f]=S.useState({search:"",organization:i||"",department:"",branch:"",status:o||""}),a=(p,k)=>f(T=>({...T,[p]:k})),[x,g]=S.useState(1),C=e.filter(p=>!(j.search&&!`${p.number} ${p.title}`.toLowerCase().includes(j.search.toLowerCase())||j.organization&&p.organization!==j.organization||j.department&&p.department!==j.department||j.branch&&p.branch!==j.branch||j.status&&p.status!==j.status));S.useEffect(()=>{g(1)},[j]);const w=C.slice((x-1)*re,x*re);return S.useEffect(()=>{if(y){const p=e.filter(k=>b.has(k.name));y(p,w)}},[b,w,e]),t.jsxs(t.Fragment,{children:[t.jsx(oa,{children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"10px 14px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.numberTitle}),t.jsx("input",{style:nt,value:j.search,onChange:p=>a("search",p.target.value),placeholder:h.filter.searchPlaceholder})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.organization}),t.jsxs("select",{style:nt,value:j.organization,onChange:p=>a("organization",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allOrgs}),n.map(p=>t.jsx("option",{value:p.name,children:p.organization_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.department}),t.jsxs("select",{style:nt,value:j.department,onChange:p=>a("department",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allDepts}),s.map(p=>t.jsx("option",{value:p.name,children:p.department_name||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.branch}),t.jsxs("select",{style:nt,value:j.branch,onChange:p=>a("branch",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allBranches}),l.map(p=>t.jsx("option",{value:p.name,children:p.branch||p.name},p.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:tt,children:h.filter.status}),t.jsxs("select",{style:nt,value:j.status,onChange:p=>a("status",p.target.value),children:[t.jsx("option",{value:"",children:h.filter.allStatuses}),r.map(p=>t.jsx("option",{value:p.name,children:p.name1||p.name},p.name))]})]})]})}),t.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[t.jsx("th",{style:{width:44,padding:"12px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:w.length>0&&w.every(p=>b.has(p.name)),onChange:p=>{if(p.target.checked)z(new Set([...b,...w.map(k=>k.name)]));else{const k=new Set(b);w.forEach(T=>k.delete(T.name)),z(k)}},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.number}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.title}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.organization}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.field.cycleType}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.status}),t.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:h.col.actions})]})}),t.jsx("tbody",{children:C.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:h.noProcesses})}):w.map((p,k)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>c==null?void 0:c(p),style:{borderTop:"1px solid #f1f5f9",background:b.has(p.name)?"#eff6ff":p.custom_is_deleted?"#fff1f2":k%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:44,padding:"10px 14px",textAlign:"center"},onClick:T=>T.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:b.has(p.name),onChange:()=>{const T=new Set(b);T.has(p.name)?T.delete(p.name):T.add(p.name),z(T)},style:{width:16,height:16,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:p.number||"—"}),t.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:p.title||p.name||"—"}),t.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:p.organization||"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.cycle_type?Wd(p.cycle_type):"—"}),t.jsx("td",{style:{padding:"12px 16px"},children:p.custom_is_deleted?ns(h.deletedBadge):p.status?ns(p.status):"—"}),t.jsx("td",{style:{padding:"10px 16px"},onClick:T=>T.stopPropagation(),children:t.jsx(it,{onView:()=>c==null?void 0:c(p),onEdit:d&&_&&!p.custom_is_deleted&&!Hn("process",p.workflow_state)&&u!=="Employee"?()=>_(p):void 0,onDelete:d&&m&&!p.custom_is_deleted?()=>m(p.name):void 0})})]},p.name))})]})}),t.jsx(Je,{page:x,total:C.length,onPageChange:g})]})}const A0={Draft:[{action:"Submit for Review",next:"Pending Actor",allowedRoles:["Auditor","Manager"]}],"Pending Actor":[{action:"Update Status",next:"Pending Comment",allowedRoles:["Employee","Manager"]}],"Pending Comment":[{action:"Add Comment",next:"Review",allowedRoles:["Auditor","Manager"]}],Review:[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Move to Study",next:"In Study",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},P0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Pending Comment":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Completed:{background:"#ecfdf5",color:"#047857",border:"1px solid #a7f3d0"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function Eu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...P0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const si={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function R0({processName:e,userRole:n,onRefresh:s,canUpdateStatus:l=!0}){const[r,i]=S.useState(null),[o,d]=S.useState(!0),[u,c]=S.useState(""),[_,m]=S.useState(!1),[y,h]=S.useState(""),[b,z]=S.useState(""),[j,f]=S.useState("Pass"),[a,x]=S.useState(""),[g,C]=S.useState({}),w=S.useCallback(async()=>{if(!e){d(!1);return}d(!0),c("");try{const U=await Zl(e);i(U);const I={};for(const O of U.progress_indicators||[])I[O.name]=O.actual_value!=null?String(O.actual_value):"";C(I)}catch(U){c(U instanceof Error?U.message:"Failed to load process")}d(!1)},[e]);if(S.useEffect(()=>{w()},[w]),o)return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:24,color:"#aaa",fontSize:13,textAlign:"center"},children:"Loading…"})});if(u||!r)return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:t.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:u||"Could not load workflow"})})});const p=r.workflow_state||"Draft",k=A0[p]??[],T=n==="Employee"||n==="Manager",A=n!=="Manager"||l,Q=r.completion_pct===100||r.stage===5||r.status==="Completion"||r.status==="Completed"||p==="Completed"||p==="Closed",J=k.filter(U=>U.action==="Start New Cycle"&&Q?!1:(n==="Admin"||U.allowedRoles.includes(n))&&(U.action!=="Update Status"||A)),W=async U=>{m(!0),h(""),z("");try{const I={};if(U==="Update Status"){I.actor_status=j,I.actor_comment=a;const M=r.progress_indicators||[];M.length>0&&(I.progress_indicators=M.map(H=>({name:H.name,actual_value:g[H.name]??""})))}U==="Add Comment"&&a&&(I.actor_comment=a);const O=await Zy(r.name,U,I);i(O),x(""),z(`Done — now: ${O.workflow_state||"updated"}`),s==null||s()}catch(I){h(I instanceof Error?I.message:"Action failed")}m(!1)};return t.jsx("div",{style:{width:"100%",flexShrink:0},children:t.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[t.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),t.jsx("div",{style:Eu(p),children:p})]}),p==="Pending Actor"&&T&&A&&t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Update Status"}),Array.isArray(r.progress_indicators)&&r.progress_indicators.length>0&&t.jsxs("div",{style:{marginBottom:10},children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Actual Value"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.progress_indicators.map(U=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:11,color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:U.name1,children:U.name1||U.name}),t.jsx("input",{type:"number",value:g[U.name]??"",onChange:I=>C(O=>({...O,[U.name]:I.target.value})),style:{...si,width:70,flexShrink:0},placeholder:"0"})]},U.name))})]}),t.jsxs("div",{style:{marginBottom:8},children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),t.jsxs("select",{value:j,onChange:U=>f(U.target.value),style:si,children:[t.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),t.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),t.jsx("textarea",{value:a,onChange:U=>x(U.target.value),style:{...si,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(p==="Pending Comment"||p==="Review")&&!T&&t.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Auditor Comment"}),Array.isArray(r.cycle_logs)&&r.cycle_logs.length>0&&t.jsxs("div",{style:{marginBottom:8,padding:"6px 10px",background:"#f8fafc",borderRadius:6,border:"1px solid #e2e8f0"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",marginBottom:3},children:"Latest cycle status:"}),(()=>{const U=r.cycle_logs,I=U[U.length-1],O=I.status==="Pass"?"#16a34a":I.status==="Fail"?"#dc2626":"#9ca3af";return t.jsxs("div",{style:{fontSize:13,fontWeight:700,color:O},children:[I.status," ",I.comment?`— ${I.comment}`:""]})})()]}),t.jsx("textarea",{value:a,onChange:U=>x(U.target.value),style:{...si,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),t.jsxs("div",{style:{padding:"12px 14px",borderBottom:J.length>0?"1px solid #f0f0f0":"none"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),J.length===0&&t.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",t.jsx("strong",{children:n})," in ",t.jsx("strong",{children:p}),"."]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:J.map(U=>t.jsxs("button",{onClick:()=>W(U.action),disabled:_,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:U.action==="Close Process"?"#64748b":U.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:_?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:_?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:_?"Applying…":U.action}),t.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",U.next]})]},U.action))}),y&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:y}),b&&t.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:b})]}),k.length>0&&t.jsxs("div",{style:{padding:"12px 14px"},children:[t.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),k.map(U=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[t.jsx("span",{style:{color:"#555",flex:1},children:U.action}),t.jsx("span",{style:{color:"#bbb"},children:"→"}),t.jsx("span",{style:Eu(U.next),children:U.next})]},U.action))]})]})})}function D0({processForm:e,setProcessForm:n,organizations:s,managements:l,departments:r,branches:i,processTypes:o,processStatuses:d,cycles:u=[],users:c=[],userRoleMap:_={},formStatus:m,viewMode:y,canModify:h,onEdit:b,onDelete:z,onRestore:j,darkMode:f,notifCount:a,onToggleDark:x,onCountChange:g,onViewProfile:C,userRole:w,onRefreshProcess:p,onSubmit:k,onBack:T,onNavigate:A,onLogout:Q,user:J}){var Ne;const W=ne(),U=L=>n({...e,...L}),I=y?{background:"#f9f9f9"}:{},O=s,M=!!J.custom_organization,H=ye(l,e.management).map(L=>({name:L.name,label:L.name1||L.name})),Y=ye(r,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),q=ye(i,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),$=ye(o,e.type).map(L=>({name:L.name,label:L.name1||L.name})),Z=ye(u,e.cycle).map(L=>({name:L.name,label:L.name1||L.name})),pe=Il(c,_,"SB Employee",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),be=Il(c,_,"SB Manager",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),ie=(L,se)=>{const R=[...e.cycle_logs||[]];R[L]={...R[L],...se},U({cycle_logs:R})},Ze=()=>{U({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},dt=L=>{const se=[...e.cycle_logs||[]];se.splice(L,1),U({cycle_logs:se})},K=(L,se)=>{const R=[...e.progress_indicators||[]];R[L]={...R[L],...se},U({progress_indicators:R})},ae=()=>{U({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"Pass",cycle_date:"",cycle_comment:"",status:"Active"}]})},We=L=>{const se=[...e.progress_indicators||[]];se.splice(L,1),U({progress_indicators:se})},ve=e.name?y?`${W.formTitle.viewProcess}${e.title||e.name}`:W.formTitle.editProcess:W.formTitle.newProcess,nn=w!=="Manager"||e.actor===J.name,fe=((Ne=pe.find(L=>L.name===e.actor))==null?void 0:Ne.label)||e.actor,xe=e.workflow_state||"Draft",Tt=e.name?t.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[t.jsx(R0,{processName:e.name,userRole:w||J.role||"Employee",onRefresh:p,canUpdateStatus:nn}),t.jsx(aa,{priority:e.impact_level,status:xe,assignedTo:fe,createdDate:e.date_start,modifiedDate:e.modified}),t.jsx(da,{doctype:D.processes,docname:e.name,currentUserName:J.name}),t.jsx(ca,{doctype:D.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),h&&z&&!e.custom_is_deleted&&t.jsx(ia,{title:"Delete Request",btnText:W.delete,onDelete:()=>z(e.name)})]}):void 0;return t.jsxs(Ve,{title:ve,activePage:"processes",user:J,formStatus:m,statusBadge:t.jsx("span",{style:{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},children:xe}),buttonText:W.saveProcess,buttonColor:"#16a34a",viewMode:y,onEdit:b,darkMode:f,notifCount:a,onToggleDark:x,onCountChange:g,onViewProfile:C,rightPanel:Tt,onSubmit:k,onBack:T,onNavigate:A,onLogout:Q,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:j?()=>j(e.name):void 0}),t.jsx(le,{title:"Process Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.number}),t.jsx("input",{style:{...P,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[W.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:L=>U({organization:L}),organizations:O,disabled:y||M})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.title}),t.jsx("input",{style:{...P,...I},value:e.title,disabled:y,onChange:L=>U({title:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.type}),t.jsx(ue,{value:e.type,onChange:L=>U({type:L}),items:$,placeholder:W.field.selectType,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.management}),t.jsx(ue,{value:e.management,onChange:L=>U({management:L}),items:H,placeholder:W.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.department}),t.jsx(ue,{value:e.department,onChange:L=>U({department:L}),items:Y,placeholder:W.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.section}),t.jsx("input",{style:{...P,...I},value:e.section_field||"",disabled:y,onChange:L=>U({section_field:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.branch}),t.jsx(ue,{value:e.branch,onChange:L=>U({branch:L}),items:q,placeholder:W.field.select,disabled:y})]})]})}),t.jsxs(le,{title:"Classification",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.chainLocation}),t.jsxs("select",{style:{...P,...I},value:e.chain_location||"",disabled:y,onChange:L=>U({chain_location:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Upstream",children:"Upstream"}),t.jsx("option",{value:"On-stream",children:"On-stream"}),t.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.economyClass}),t.jsxs("select",{style:{...P,...I},value:e.economy_class||"",disabled:y,onChange:L=>U({economy_class:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Expenses",children:W.field.expenses}),t.jsx("option",{value:"Capital",children:W.field.capital}),t.jsx("option",{value:"Earn",children:W.field.earn}),t.jsx("option",{value:"Pay/Loss",children:W.field.payLoss})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.impactLevel}),t.jsxs("select",{style:{...P,...I},value:e.impact_level||"",disabled:y,onChange:L=>U({impact_level:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"High",children:W.field.high}),t.jsx("option",{value:"Normal",children:W.field.normal})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.entityScope}),t.jsxs("select",{style:{...P,...I},value:e.entity_scope||"",disabled:y,onChange:L=>U({entity_scope:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Upstream",children:W.field.upstream}),t.jsx("option",{value:"On-stream",children:W.field.onstream}),t.jsx("option",{value:"Downstream",children:W.field.downstream})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.hsesField}),t.jsx("input",{style:{...P,...I},value:e.hses_field||"",disabled:y,onChange:L=>U({hses_field:L.target.value}),placeholder:"Safety, Health, Environment…"})]}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:18},children:t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[t.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:y,onChange:L=>U({product_relation:L.target.checked?1:0})})," ",W.field.productRelation]})})]})]}),t.jsxs(le,{title:"KPI & Timeline",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.kpiName}),t.jsx("input",{style:{...P,...I},value:e.kpi_name||"",disabled:y,onChange:L=>U({kpi_name:L.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.kpiType}),t.jsxs("select",{style:{...P,...I},value:e.kpi_type||"",disabled:y,onChange:L=>U({kpi_type:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Human",children:"Human"}),t.jsx("option",{value:"Substantial",children:"Substantial"}),t.jsx("option",{value:"System",children:"System"}),t.jsx("option",{value:"Value",children:"Value"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.kpiMeasure}),t.jsx("input",{style:{...P,...I},value:e.kpi_measure||"",disabled:y,onChange:L=>U({kpi_measure:L.target.value}),placeholder:"Unit of measure"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.dateStart}),t.jsx(me,{value:e.date_start,onChange:L=>U({date_start:L}),disabled:y,style:{...P,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.dateEnd}),t.jsx(me,{value:e.date_end,onChange:L=>U({date_end:L}),disabled:y,style:{...P,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.cycleType}),t.jsxs("select",{style:{...P,...I},value:e.cycle_type||"",disabled:y,onChange:L=>U({cycle_type:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&t.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14,marginTop:14},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 1"}),t.jsx(me,{value:e.long_cycle_date_1||"",onChange:L=>U({long_cycle_date_1:L}),disabled:y,style:{...P,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 2"}),t.jsx(me,{value:e.long_cycle_date_2||"",onChange:L=>U({long_cycle_date_2:L}),disabled:y,style:{...P,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 3"}),t.jsx(me,{value:e.long_cycle_date_3||"",onChange:L=>U({long_cycle_date_3:L}),disabled:y,style:{...P,...I}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Milestone 4"}),t.jsx(me,{value:e.long_cycle_date_4||"",onChange:L=>U({long_cycle_date_4:L}),disabled:y,style:{...P,...I}})]})]})]})]}),t.jsxs(le,{title:"Progress Indicators",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!y&&t.jsx("button",{type:"button",onClick:ae,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),t.jsx("div",{style:{overflowX:"auto",minWidth:0},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Order"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Name"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Type"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Unit"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Target"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Min"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Max"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Manager"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actual Value"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Status"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Date"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Comment"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),!y&&t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),t.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:y?14:15,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((L,se)=>t.jsxs("tr",{style:{background:se%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I,width:60},value:L.order??"",disabled:y,onChange:R=>K(se,{order:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I},value:L.name1,disabled:y,onChange:R=>K(se,{name1:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I},value:L.type,disabled:y,onChange:R=>K(se,{type:R.target.value}),children:[t.jsx("option",{children:"Nominal"}),t.jsx("option",{children:"Ordinal"}),t.jsx("option",{children:"Interval"}),t.jsx("option",{children:"Ratio"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I,width:70},type:"text",value:L.unit??"",disabled:y,onChange:R=>K(se,{unit:R.target.value}),placeholder:"e.g. °C, kg, %"})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I,minWidth:120},value:L.cycle,disabled:y,onChange:R=>K(se,{cycle:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),Z.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name)),L.cycle&&!Z.some(R=>R.name===L.cycle)&&t.jsx("option",{value:L.cycle,children:L.cycle})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I,width:80},value:L.target,disabled:y,onChange:R=>K(se,{target:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I,width:80},value:L.minimum,disabled:y,onChange:R=>K(se,{minimum:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I,width:80},value:L.maximum,disabled:y,onChange:R=>K(se,{maximum:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I,minWidth:140},value:L.manager,disabled:y,onChange:R=>K(se,{manager:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),be.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name)),L.manager&&!be.some(R=>R.name===L.manager)&&t.jsx("option",{value:L.manager,children:L.manager})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I,width:90},type:"number",value:L.actual_value??"",disabled:y,onChange:R=>K(se,{actual_value:parseFloat(R.target.value)||""})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I},value:L.cycle_status??"",disabled:y,onChange:R=>K(se,{cycle_status:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),t.jsx("option",{children:"Normal"}),t.jsx("option",{children:"Below Min"}),t.jsx("option",{children:"Above Max"}),t.jsx("option",{children:"At Risk"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(me,{value:L.cycle_date||"",onChange:R=>K(se,{cycle_date:R}),disabled:y,style:{...P,...I,width:110}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I},value:L.cycle_comment??"",disabled:y,onChange:R=>K(se,{cycle_comment:R.target.value})})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I},value:L.status??"",disabled:y,onChange:R=>K(se,{status:R.target.value}),children:[t.jsx("option",{value:"",children:"--"}),t.jsx("option",{children:"Normal"}),t.jsx("option",{children:"Below Min"}),t.jsx("option",{children:"Above Max"}),t.jsx("option",{children:"At Risk"})]})}),!y&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>We(se),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},se))]})]})})]}),t.jsx(le,{title:"Cycle & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.cycle}),t.jsx(ue,{value:e.cycle||"",onChange:L=>U({cycle:L}),items:Z,placeholder:W.field.select,disabled:y})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.actor}),t.jsxs("select",{style:{...P,...I},value:e.actor||"",disabled:y,onChange:L=>U({actor:L.target.value}),children:[t.jsx("option",{value:"",children:W.field.select}),pe.map(L=>t.jsx("option",{value:L.name,children:L.label},L.name))]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.costPerCycle}),t.jsx("input",{style:{...P,...I},type:"number",value:e.cost_per_cycle||"",disabled:y,onChange:L=>U({cost_per_cycle:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:W.field.escalationLevel}),t.jsx("input",{style:{...P,...I},type:"number",value:e.escalation_level||"",disabled:y,onChange:L=>U({escalation_level:parseInt(L.target.value)||0})})]})]})}),t.jsxs(le,{title:"Cycle History",children:[t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!y&&t.jsx("button",{type:"button",onClick:Ze,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,cursor:"pointer"},children:"+ Add Row"})}),t.jsx("div",{style:{overflowX:"auto",minWidth:0},children:t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Date"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Comment"}),!y&&t.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actions"})]})}),t.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:y?5:6,style:{padding:18,textAlign:"center",color:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((L,se)=>t.jsxs("tr",{style:{background:se%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I},value:L.cycle||"",disabled:y,onChange:R=>ie(se,{cycle:R.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),Z.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx(me,{value:L.cycle_date||"",onChange:R=>ie(se,{cycle_date:R}),disabled:y,style:{...P,...I,width:130}})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I},value:L.status,disabled:y,onChange:R=>ie(se,{status:R.target.value}),children:[t.jsx("option",{value:"Pass",children:"Pass"}),t.jsx("option",{value:"Fail",children:"Fail"}),t.jsx("option",{value:"Unknown",children:"Unknown"})]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsxs("select",{style:{...P,...I},value:L.actor||"",disabled:y,onChange:R=>ie(se,{actor:R.target.value}),children:[t.jsx("option",{value:"",children:"-- Select --"}),pe.map(R=>t.jsx("option",{value:R.name,children:R.label},R.name))]})}),t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("input",{style:{...P,...I},value:L.comment||"",disabled:y,onChange:R=>ie(se,{comment:R.target.value})})}),!y&&t.jsx("td",{style:{padding:"8px 10px"},children:t.jsx("button",{type:"button",onClick:()=>dt(se),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},se))]})]})})]}),t.jsx(le,{title:W.field.auditorComment,children:t.jsx("textarea",{style:{...P,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:W.field.commentPlaceholder})})]})}const O0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function L0({user:e,profileUser:n,darkMode:s,canModify:l,onBack:r,organizations:i=[],managements:o=[],departments:d=[],branches:u=[]}){const c=n||{},_=!!l&&e.role==="Admin",[m,y]=S.useState({first_name:c.first_name||"",middle_name:c.middle_name||"",last_name:c.last_name||"",mobile_no:c.mobile_no||"",custom_organization:c.custom_organization||"",custom_management:c.custom_management||"",custom_department:c.custom_department||"",custom_branch:c.custom_branch||"",custom_number:c.custom_number||"",custom_category:c.custom_category||""}),[h,b]=S.useState(""),[z,j]=S.useState(!1),[f,a]=S.useState({new:"",confirm:""}),[x,g]=S.useState(""),C=c.email||c.name||"",w=[m.first_name,m.middle_name,m.last_name].filter(Boolean).join(" ")||c.full_name||"",p=c.username||c.name||"",k=m.custom_category||"",T=c.enabled===0?"Inactive":"Active",A=O0[e.role]||"#6b7280",Q=s,J=Q?"#0f172a":"#f0f2f5",W=Q?"#1e293b":"white",U=Q?"#2d3748":"#e5e7eb",I=Q?"#e2e8f0":"#1a2332",O=Q?"#94a3b8":"#6b7280",M=Q?"#374151":"white",H=Q?"#2d3748":"#f9fafb",Y={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${U}`,fontSize:13,background:M,color:I,fontFamily:"inherit",outline:"none"},q={...Y,background:H,color:O},$={...Y,cursor:"pointer"},Z={fontSize:12,fontWeight:600,color:O,marginBottom:5,display:"block"},pe={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},be={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},ie=async()=>{if(l){b("saving");try{await Mi("User",c.name,{first_name:m.first_name,middle_name:m.middle_name,last_name:m.last_name,mobile_no:m.mobile_no,custom_organization:m.custom_organization,custom_management:m.custom_management,custom_department:m.custom_department,custom_branch:m.custom_branch,custom_number:m.custom_number,custom_category:m.custom_category}),b("saved"),setTimeout(()=>b(""),2e3)}catch{b("error"),setTimeout(()=>b(""),3e3)}}},Ze=async()=>{if(!f.new){g("Enter a new password");return}if(f.new!==f.confirm){g("Passwords do not match");return}g("saving");try{await lh(c.name,f.new),g("done"),a({new:"",confirm:""}),setTimeout(()=>{g(""),j(!1)},2e3)}catch{g("error")}},dt=({title:K,icon:ae,children:We})=>t.jsxs("div",{style:{background:W,borderRadius:12,padding:22,border:`1px solid ${U}`,boxShadow:`0 1px 4px rgba(0,0,0,${Q?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${U}`},children:[ae,t.jsx("span",{style:{fontSize:14,fontWeight:700,color:I},children:K})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:We})]});return t.jsxs("div",{style:{background:J,minHeight:"100%",padding:"0 0 32px"},children:[t.jsxs("div",{style:{background:W,borderBottom:`1px solid ${U}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[t.jsxs("button",{onClick:r,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:I,fontFamily:"inherit"},children:[t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),l&&t.jsxs("button",{onClick:ie,style:{display:"flex",alignItems:"center",gap:8,background:h==="saved"?"#16a34a":h==="error"?"#dc2626":"#16a34a",color:"white",border:"none",borderRadius:8,padding:"9px 22px",fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17,21 17,13 7,13 7,21"}),t.jsx("polyline",{points:"7,3 7,8 15,8"})]}),h==="saving"?"Saving…":h==="saved"?"Saved!":h==="error"?"Error":"Save Changes"]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:22,padding:"0 28px"},children:[t.jsxs("div",{style:{borderRadius:14,overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.12)",alignSelf:"start"},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",padding:"32px 20px 28px",display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[t.jsx("div",{style:{width:78,height:78,borderRadius:"50%",background:"rgba(255,255,255,0.22)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:4,border:"3px solid rgba(255,255,255,0.3)"},children:t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"rgba(255,255,255,0.9)",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]})}),t.jsx("div",{style:{fontSize:17,fontWeight:700,color:"white",textAlign:"center",lineHeight:1.3},children:w||C}),t.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:C})]}),t.jsx("div",{style:{background:W},children:[{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:A,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),t.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),t.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),t.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),label:"Username",value:p},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:A,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:k||"—"},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:T==="Active"?"#16a34a":"#dc2626",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),label:"Status",value:T,valueColor:T==="Active"?"#16a34a":"#dc2626"},{icon:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:A,strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:C},{icon:t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:A,strokeWidth:"2",strokeLinecap:"round",children:t.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.69 13a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.6 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),label:"Phone",value:m.mobile_no||"—"}].map(({icon:K,label:ae,value:We,valueColor:ve})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${U}`},children:[t.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:K}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:11,color:O,marginBottom:1},children:ae}),t.jsx("div",{style:{fontSize:13,fontWeight:600,color:ve||I,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:We})]})]},ae))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[t.jsxs(dt,{title:"Basic Information",icon:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("circle",{cx:"12",cy:"8",r:"4"}),t.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]}),children:[t.jsxs("div",{style:pe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Email ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m2 7 10 7 10-7"})]})}),t.jsx("input",{style:{...q,paddingLeft:32},value:C,readOnly:!0})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Full Name ",t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),t.jsx("input",{style:q,value:w,readOnly:!0})]})]}),t.jsxs("div",{style:be,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["First Name ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{style:l?Y:q,value:m.first_name,readOnly:!l,onChange:K=>y(ae=>({...ae,first_name:K.target.value})),placeholder:"First name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Middle Name"}),t.jsx("input",{style:l?Y:q,value:m.middle_name,readOnly:!l,onChange:K=>y(ae=>({...ae,middle_name:K.target.value})),placeholder:"Middle name"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Last Name"}),t.jsx("input",{style:l?Y:q,value:m.last_name,readOnly:!l,onChange:K=>y(ae=>({...ae,last_name:K.target.value})),placeholder:"Last name"})]})]}),t.jsxs("div",{style:pe,children:[t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"Phone Number"}),t.jsx("input",{style:l?Y:q,value:m.mobile_no,readOnly:!l,onChange:K=>y(ae=>({...ae,mobile_no:K.target.value})),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsx("label",{style:Z,children:"User ID No"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{style:{...q,paddingRight:44},value:m.custom_number||c.name||"",readOnly:!0}),t.jsx("div",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",background:"#ef4444",borderRadius:5,padding:"3px 7px",cursor:"default",display:"flex",alignItems:"center"},children:t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"white",children:[t.jsx("circle",{cx:"5",cy:"12",r:"2"}),t.jsx("circle",{cx:"12",cy:"12",r:"2"}),t.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Category ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:$,value:m.custom_category,onChange:K=>y(ae=>({...ae,custom_category:K.target.value})),children:[t.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(K=>t.jsx("option",{value:K,children:K},K))]}):t.jsx("input",{style:q,value:k||"—",readOnly:!0})]})]}),t.jsxs(dt,{title:"Organization Information",icon:t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#8b5cf6",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),t.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),children:[t.jsxs("div",{style:pe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Organization ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:$,value:m.custom_organization,onChange:K=>y(ae=>({...ae,custom_organization:K.target.value})),children:[t.jsx("option",{value:"",children:"Select organization"}),ye(i,m.custom_organization).map(K=>t.jsx("option",{value:K.name,children:K.organization_name||K.name},K.name))]}):t.jsx("input",{style:q,value:m.custom_organization||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Management ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:$,value:m.custom_management,onChange:K=>y(ae=>({...ae,custom_management:K.target.value})),children:[t.jsx("option",{value:"",children:"Select management"}),ye(o,m.custom_management).map(K=>t.jsx("option",{value:K.name,children:K.name1||K.name},K.name))]}):t.jsx("input",{style:q,value:m.custom_management||"—",readOnly:!0})]})]}),t.jsxs("div",{style:pe,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Department ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:$,value:m.custom_department,onChange:K=>y(ae=>({...ae,custom_department:K.target.value})),children:[t.jsx("option",{value:"",children:"Select department"}),ye(d,m.custom_department).map(K=>t.jsx("option",{value:K.name,children:K.department_name||K.name},K.name))]}):t.jsx("input",{style:q,value:m.custom_department||"—",readOnly:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Branch ",!_&&t.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),_?t.jsxs("select",{style:$,value:m.custom_branch,onChange:K=>y(ae=>({...ae,custom_branch:K.target.value})),children:[t.jsx("option",{value:"",children:"Select branch"}),ye(u,m.custom_branch).map(K=>t.jsx("option",{value:K.name,children:K.branch||K.name},K.name))]}):t.jsx("input",{style:q,value:m.custom_branch||"—",readOnly:!0})]})]})]}),t.jsxs("div",{style:{background:W,borderRadius:12,padding:22,border:`1px solid ${U}`,boxShadow:`0 1px 4px rgba(0,0,0,${Q?.3:.06})`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{style:{fontSize:14,fontWeight:700,color:I},children:"Change Password"})]}),l&&t.jsx("button",{onClick:()=>{j(K=>!K),g("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:z?"Cancel":"Change Password"})]}),z&&t.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:be,children:[t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["New Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:Y,value:f.new,onChange:K=>a(ae=>({...ae,new:K.target.value})),placeholder:"New password"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:Z,children:["Confirm Password ",t.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),t.jsx("input",{type:"password",style:Y,value:f.confirm,onChange:K=>a(ae=>({...ae,confirm:K.target.value})),placeholder:"Confirm password"})]}),t.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:t.jsx("button",{onClick:Ze,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:x==="saving"?"Saving…":"Update Password"})})]}),x&&x!=="saving"&&t.jsx("div",{style:{fontSize:13,color:x==="done"?"#16a34a":"#dc2626",fontWeight:500},children:x==="done"?"Password updated successfully":x==="error"?"Failed to update password":x})]})]})]})]})]})}function Ie({label:e,val:n,color:s}){return t.jsxs("div",{style:{background:"white",borderRadius:8,padding:"8px 16px",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${s}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[t.jsx("div",{style:{fontSize:18,fontWeight:700,color:s},children:n}),t.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const ah={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},W0={...ah,cursor:"pointer"};function vt({filters:e,defaultOpen:n=!1}){const[s,l]=S.useState(n);return t.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[t.jsxs("div",{onClick:()=>l(r=>!r),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:s?t.jsx("polyline",{points:"18,15 12,9 6,15"}):t.jsx("polyline",{points:"6,9 12,15 18,9"})}),t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),s&&t.jsx("div",{style:{padding:"18px 20px"},children:t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((r,i)=>t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:r.label}),r.type==="search"?t.jsx("input",{style:ah,placeholder:r.placeholder,value:r.value,onChange:o=>r.onChange(o.target.value)}):t.jsx("select",{style:W0,value:r.value,onChange:o=>r.onChange(o.target.value),children:r.options.map(o=>t.jsx("option",{value:o.value,children:o.label},o.value))})]},i))})})]})}function N0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function B0({organizations:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),[h,b]=S.useState("all"),z={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},j=S.useMemo(()=>e.filter(g=>{const C=[g.organization_name,g.city].filter(Boolean).join(" ").toLowerCase();return!(c&&!C.includes(c.toLowerCase())||m!=="all"&&g.type!==m||h!=="all"&&(g.is_active?"Active":"Inactive")!==h)}),[e,c,m,h]),[f,a]=S.useState(1);S.useEffect(()=>{a(1)},[c,m,h]);const x=j.slice((f-1)*re,f*re);return S.useEffect(()=>{if(i){const g=e.filter(C=>d.has(C.name));i(g,x)}},[d,x]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:j.length,color:"#1a2332"}),t.jsx(Ie,{label:"Active",val:j.filter(g=>g.is_active).length,color:X.green}),t.jsx(Ie,{label:"Government",val:j.filter(g=>g.type==="Government").length,color:X.blue}),t.jsx(Ie,{label:"Private",val:j.filter(g=>g.type==="Private").length,color:X.orange})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Name or city…"},{type:"select",label:o.col.type,value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:h,onChange:b,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:x.length>0&&x.every(g=>d.has(g.name)),onChange:g=>{if(g.target.checked)u(new Set([...d,...x.map(C=>C.name)]));else{const C=new Set(d);x.forEach(w=>C.delete(w.name)),u(C)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:z,children:o.col.name}),t.jsx("th",{style:z,children:o.col.type}),t.jsx("th",{style:z,children:o.col.city}),t.jsx("th",{style:z,children:o.field.creationDate}),t.jsx("th",{style:z,children:o.col.status}),t.jsx("th",{style:z,children:o.col.actions})]})}),t.jsx("tbody",{children:j.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):x.map((g,C)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(g),style:{borderTop:"1px solid #f0f0f0",background:d.has(g.name)?"#eff6ff":g.custom_is_deleted?"#fff1f2":C%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:w=>w.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(g.name),onChange:()=>{const w=new Set(d);w.has(g.name)?w.delete(g.name):w.add(g.name),u(w)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.organization_name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:g.type||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:g.city||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N0(g.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:g.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):Cr(g.is_active?o.field.statusActive:o.field.statusInactive,g.is_active?X.green:X.gray)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:w=>w.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(g),onEdit:n&&l&&!g.custom_is_deleted?()=>l(g):void 0,onDelete:n&&r&&!g.custom_is_deleted?()=>r(g.name):void 0})})]},g.name))})]})}),t.jsx(Je,{page:f,total:j.length,onPageChange:a})]})}const Sn=e=>({background:e?"#f9f9f9":void 0});function $0({orgForm:e,setOrgForm:n,groupCompanies:s=[],formStatus:l,viewMode:r,onEdit:i,onRestore:o,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,user:j}){const f=ne(),a=e.name?r&&e.organization_name||f.formTitle.editOrg:f.formTitle.newOrg,x=s.map(g=>({name:g.name,label:g.company_name?`${g.company_name} (${g.name})`:g.name}));return t.jsxs(Ve,{title:a,activePage:"organizations",user:j,formStatus:l,buttonText:f.saveOrg,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o&&e.name?()=>o(e.name):void 0}),t.jsx(le,{title:"Organization Information",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.orgName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...P,...Sn(r||!!e.name)},value:e.organization_name,disabled:r||!!e.name,required:!0,onChange:g=>n({...e,organization_name:g.target.value})})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.orgAcronym," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{type:"text",style:{...P,...Sn(r||!!e.name)},value:e.acronym||"",disabled:r||!!e.name,required:!0,onChange:g=>n({...e,acronym:g.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Group Company (Tenant)"}),t.jsx(ue,{value:e.group_company||"",onChange:g=>n({...e,group_company:g}),items:x,placeholder:"Select Group Company",disabled:r||!!j.custom_group_company})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.organizationType}),t.jsxs("select",{style:{...P,...Sn(r)},value:e.type,disabled:r,onChange:g=>n({...e,type:g.target.value}),children:[t.jsx("option",{children:"Government"}),t.jsx("option",{children:"Private"}),t.jsx("option",{children:"Non-Profit"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.orgCity}),t.jsx("input",{type:"text",style:{...P,...Sn(r)},value:e.city,disabled:r,onChange:g=>n({...e,city:g.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.contactEmail}),t.jsx("input",{type:"email",style:{...P,...Sn(r)},value:e.contact_email,disabled:r,onChange:g=>n({...e,contact_email:g.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>n({...e,creation_date:g}),disabled:r,style:{...P,...Sn(r)}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.status}),t.jsxs("select",{style:{...P,...Sn(r)},value:e.is_active?"Active":"Inactive",disabled:r,onChange:g=>n({...e,is_active:g.target.value==="Active"?1:0}),children:[t.jsx("option",{value:"Active",children:f.field.statusActive}),t.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}),t.jsx(le,{title:"Incident SLA Windows",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.incidentTriageWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...P,...Sn(r)},value:e.incident_triage_window_days??3,disabled:r,onChange:g=>n({...e,incident_triage_window_days:parseInt(g.target.value)||3})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.incidentResolutionWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...P,...Sn(r)},value:e.incident_resolution_window_days??5,disabled:r,onChange:g=>n({...e,incident_resolution_window_days:parseInt(g.target.value)||5})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})})]})}function U0({groupCompanies:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=[a.company_name,a.acronym,a.code,a.owner_user].filter(Boolean).join(" ").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total Group Cos",val:b.length,color:"#1a2332"}),t.jsx(Ie,{label:"Active",val:b.filter(a=>(a.status||"Active")==="Active").length,color:X.green}),t.jsx(Ie,{label:"Inactive",val:b.filter(a=>a.status==="Inactive").length,color:X.orange})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Inactive",label:"Inactive"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:"#fafafa"},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:"Company Name"}),t.jsx("th",{style:h,children:"Code / Acronym"}),t.jsx("th",{style:h,children:"Group Co Owner"}),t.jsx("th",{style:h,children:"Status"}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsxs("tbody",{children:[f.map((a,x)=>{const g=a.custom_is_deleted===1;return t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderBottom:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":g?"#fef2f2":x%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:C=>C.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const C=new Set(d);C.has(a.name)?C.delete(a.name):C.add(a.name),u(C)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[a.company_name,g&&t.jsx("span",{style:{marginLeft:8},children:Cr(o.deletedBadge,"#ef4444")})]}),t.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:[a.code,a.acronym].filter(Boolean).join(" / ")||"—"}),t.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:a.owner_user||"—"}),t.jsx("td",{style:{padding:"12px 14px"},children:Cr(a.status||"Active",(a.status||"Active")==="Active"?X.green:X.orange)}),t.jsx("td",{style:{padding:"12px 14px"},onClick:C=>C.stopPropagation(),children:t.jsx(it,{onView:s?()=>s(a):void 0,onEdit:n&&l?()=>l(a):void 0,onDelete:n&&r?()=>r(a.name):void 0})})]},a.name)}),b.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:24,textAlign:"center",color:"#aaa"},children:"No Group Companies found"})})]})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function F0({form:e,setForm:n,users:s=[],formStatus:l,viewMode:r,onEdit:i,onRestore:o,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,user:j}){const f=C=>n({...e,...C}),a=r?{background:"#f8fafc"}:{},x=e.name?r?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",g=s.map(C=>({name:C.name,label:C.full_name?`${C.full_name} (${C.name})`:C.name}));return t.jsxs(Ve,{title:x,activePage:"group-companies",user:j,formStatus:l,buttonText:"Save Group Company",buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o?()=>o(e.name):void 0}),t.jsxs(le,{title:"Group Company Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:["Company Name ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.company_name||"",disabled:r||!!e.name,onChange:C=>f({company_name:C.target.value}),placeholder:"e.g. Company A Group"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Company Code"}),t.jsx("input",{style:{...P,...a},value:e.code||"",disabled:r,onChange:C=>f({code:C.target.value}),placeholder:"e.g. CO-A"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Acronym"}),t.jsx("input",{style:{...P,...a},value:e.acronym||"",disabled:r,onChange:C=>f({acronym:C.target.value}),placeholder:"e.g. CAG"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Status"}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:r,onChange:C=>f({status:C.target.value}),children:[t.jsx("option",{value:"Active",children:"Active"}),t.jsx("option",{value:"Inactive",children:"Inactive"})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Group Co Owner / Admin User"}),t.jsx(ue,{value:e.owner_user||"",onChange:C=>f({owner_user:C}),items:g,placeholder:"Select owner user",disabled:r})]})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Notes"}),t.jsx("textarea",{style:{...P,...a,height:75,resize:"vertical"},value:e.notes||"",disabled:r,onChange:C=>f({notes:C.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function M0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function H0({managements:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:M0(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function G0({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:i,onRestore:o,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,user:j}){const f=ne(),a=C=>n(w=>({...w,...C})),x=r?{background:"#f8fafc"}:{},g=e.name?r?`${f.formTitle.editMgmt}: ${e.name1||e.name}`:f.formTitle.editMgmt:f.formTitle.newMgmt;return t.jsxs(Ve,{title:g,activePage:"managements",user:j,formStatus:l,buttonText:f.saveMgmt,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o&&e.name?()=>o(e.name):void 0}),t.jsx(le,{title:"Management Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:C=>a({organization:C}),organizations:s,disabled:r||!!j.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...x},value:e.name1,disabled:r||!!e.name,onChange:C=>a({name1:C.target.value}),placeholder:"Management name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:C=>a({creation_date:C}),disabled:r,style:{...P,...x}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.status}),t.jsxs("select",{style:{...P,...x},value:e.status||"Active",disabled:r,onChange:C=>a({status:C.target.value}),children:[t.jsx("option",{value:"Active",children:f.field.statusActive}),t.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})})]})}function K0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function Q0({departments:e,managements:n,canModify:s,onView:l,onEdit:r,onDelete:i,onSelectionChange:o}){const d=ne(),[u,c]=S.useState(new Set),[_,m]=S.useState(""),[y,h]=S.useState(""),[b,z]=S.useState("all"),j=w=>{var p;return((p=n.find(k=>k.name===w))==null?void 0:p.name1)||w||"—"},f={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},a=S.useMemo(()=>e.filter(w=>{const p=(w.department_name||w.name||"").toLowerCase();return!(_&&!p.includes(_.toLowerCase())||y&&w.custom_management!==y||b!=="all"&&(w.custom_status||"Active")!==b)}),[e,_,y,b]),[x,g]=S.useState(1);S.useEffect(()=>{g(1)},[_,y,b]);const C=a.slice((x-1)*re,x*re);return S.useEffect(()=>{if(o){const w=e.filter(p=>u.has(p.name));o(w,C)}},[u,C]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:a.length,color:X.teal})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:_,onChange:m,placeholder:"Search by name…"},{type:"select",label:d.col.management,value:y,onChange:h,options:[{value:"",label:"All Managements"},...n.map(w=>({value:w.name,label:w.name1||w.name}))]},{type:"select",label:"Status",value:b,onChange:z,options:[{value:"all",label:"All"},{value:"Active",label:d.field.statusActive},{value:"Inactive",label:d.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:C.length>0&&C.every(w=>u.has(w.name)),onChange:w=>{if(w.target.checked)c(new Set([...u,...C.map(p=>p.name)]));else{const p=new Set(u);C.forEach(k=>p.delete(k.name)),c(p)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:f,children:d.col.name}),t.jsx("th",{style:f,children:d.col.management}),t.jsx("th",{style:f,children:d.field.creationDate}),t.jsx("th",{style:f,children:d.field.status}),t.jsx("th",{style:f,children:d.col.actions})]})}),t.jsx("tbody",{children:a.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):C.map((w,p)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>l==null?void 0:l(w),style:{borderTop:"1px solid #f0f0f0",background:u.has(w.name)?"#eff6ff":w.custom_is_deleted?"#fff1f2":p%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:k=>k.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:u.has(w.name),onChange:()=>{const k=new Set(u);k.has(w.name)?k.delete(w.name):k.add(w.name),c(k)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:w.department_name||w.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:j(w.custom_management)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:K0(w.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:w.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:d.deletedBadge}):t.jsx("span",{style:{color:w.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:w.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:k=>k.stopPropagation(),children:t.jsx(it,{onView:()=>l==null?void 0:l(w),onEdit:s&&r&&!w.custom_is_deleted?()=>r(w):void 0,onDelete:s&&i&&!w.custom_is_deleted?()=>i(w.name):void 0})})]},w.name))})]})}),t.jsx(Je,{page:x,total:a.length,onPageChange:g})]})}function Y0({form:e,setForm:n,organizations:s,managements:l,formStatus:r,viewMode:i,onEdit:o,onRestore:d,darkMode:u,notifCount:c,onToggleDark:_,onCountChange:m,onViewProfile:y,onSubmit:h,onBack:b,onNavigate:z,onLogout:j,user:f}){const a=ne(),x=p=>n(k=>({...k,...p})),g=i?{background:"#f8fafc"}:{},C=e.name?i?`${a.formTitle.editDept}: ${e.department_name||e.name}`:a.formTitle.editDept:a.formTitle.newDept,w=ye(l,e.custom_management).map(p=>({name:p.name,label:p.name1||p.name}));return t.jsxs(Ve,{title:C,activePage:"departments",user:f,formStatus:r,buttonText:a.saveDept,buttonColor:"#16a34a",viewMode:i,onEdit:o,darkMode:u,notifCount:c,onToggleDark:_,onCountChange:m,onViewProfile:y,onSubmit:h,onBack:b,onNavigate:z,onLogout:j,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:d&&e.name?()=>d(e.name):void 0}),t.jsx(le,{title:"Department Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[a.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.custom_organization,onChange:p=>x({custom_organization:p}),organizations:s,disabled:i||!!f.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[a.field.department," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...g},value:e.department_name,disabled:i||!!e.name,onChange:p=>x({department_name:p.target.value}),placeholder:"Department name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:a.field.management}),t.jsx(ue,{value:e.custom_management,onChange:p=>x({custom_management:p}),items:w,placeholder:a.field.select,disabled:i})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:a.field.creationDate}),t.jsx(me,{value:e.custom_creation_date||"",onChange:p=>x({custom_creation_date:p}),disabled:i,style:{...P,...g}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:a.field.status}),t.jsxs("select",{style:{...P,...g},value:e.custom_status||"Active",disabled:i,onChange:p=>x({custom_status:p.target.value}),children:[t.jsx("option",{value:"Active",children:a.field.statusActive}),t.jsx("option",{value:"Inactive",children:a.field.statusInactive})]})]})]})})]})}function X0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function q0({branches:e,managements:n,departments:s,canModify:l,onView:r,onEdit:i,onDelete:o,onSelectionChange:d}){const u=ne(),[c,_]=S.useState(new Set),[m,y]=S.useState(""),[h,b]=S.useState(""),[z,j]=S.useState(""),[f,a]=S.useState("all"),x=A=>{var Q;return((Q=n.find(J=>J.name===A))==null?void 0:Q.name1)||A||"—"},g=A=>{var Q;return((Q=s.find(J=>J.name===A))==null?void 0:Q.department_name)||A||"—"},C={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},w=S.useMemo(()=>e.filter(A=>{const Q=(A.branch||A.name||"").toLowerCase();return!(m&&!Q.includes(m.toLowerCase())||h&&A.management!==h||z&&A.department!==z||f!=="all"&&(A.custom_status||"Active")!==f)}),[e,m,h,z,f]),[p,k]=S.useState(1);S.useEffect(()=>{k(1)},[m,h,z,f]);const T=w.slice((p-1)*re,p*re);return S.useEffect(()=>{if(d){const A=e.filter(Q=>c.has(Q.name));d(A,T)}},[c,T]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:w.length,color:X.purple})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:m,onChange:y,placeholder:"Search by name…"},{type:"select",label:u.col.management,value:h,onChange:b,options:[{value:"",label:"All Managements"},...n.map(A=>({value:A.name,label:A.name1||A.name}))]},{type:"select",label:u.col.department,value:z,onChange:j,options:[{value:"",label:"All Departments"},...s.map(A=>({value:A.name,label:A.department_name||A.name}))]},{type:"select",label:"Status",value:f,onChange:a,options:[{value:"all",label:"All"},{value:"Active",label:u.field.statusActive},{value:"Inactive",label:u.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:T.length>0&&T.every(A=>c.has(A.name)),onChange:A=>{if(A.target.checked)_(new Set([...c,...T.map(Q=>Q.name)]));else{const Q=new Set(c);T.forEach(J=>Q.delete(J.name)),_(Q)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:C,children:u.col.branch}),t.jsx("th",{style:C,children:u.col.management}),t.jsx("th",{style:C,children:u.col.department}),t.jsx("th",{style:C,children:u.field.creationDate}),t.jsx("th",{style:C,children:u.field.status}),t.jsx("th",{style:C,children:u.col.actions})]})}),t.jsx("tbody",{children:w.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:u.noData})}):T.map((A,Q)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(A),style:{borderTop:"1px solid #f0f0f0",background:c.has(A.name)?"#eff6ff":A.custom_is_deleted?"#fff1f2":Q%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:J=>J.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:c.has(A.name),onChange:()=>{const J=new Set(c);J.has(A.name)?J.delete(A.name):J.add(A.name),_(J)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:A.branch||A.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:x(A.management)}),t.jsx("td",{style:{padding:"10px 14px"},children:g(A.department)}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:X0(A.custom_creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:A.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:u.deletedBadge}):t.jsx("span",{style:{color:A.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:A.custom_status==="Inactive"?u.field.statusInactive:u.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:J=>J.stopPropagation(),children:t.jsx(it,{onView:()=>r==null?void 0:r(A),onEdit:l&&i&&!A.custom_is_deleted?()=>i(A):void 0,onDelete:l&&o&&!A.custom_is_deleted?()=>o(A.name):void 0})})]},A.name))})]})}),t.jsx(Je,{page:p,total:w.length,onPageChange:k})]})}function J0({form:e,setForm:n,organizations:s,managements:l,departments:r,formStatus:i,viewMode:o,onEdit:d,onRestore:u,darkMode:c,notifCount:_,onToggleDark:m,onCountChange:y,onViewProfile:h,onSubmit:b,onBack:z,onNavigate:j,onLogout:f,user:a}){const x=ne(),g=T=>n(A=>({...A,...T})),C=o?{background:"#f8fafc"}:{},w=e.name?o?`${x.formTitle.editBranch}: ${e.branch||e.name}`:x.formTitle.editBranch:x.formTitle.newBranch,p=ye(l,e.management).map(T=>({name:T.name,label:T.name1||T.name})),k=ye(r,e.department).map(T=>({name:T.name,label:T.department_name||T.name}));return t.jsxs(Ve,{title:w,activePage:"branches",user:a,formStatus:i,buttonText:x.saveBranch,buttonColor:"#16a34a",viewMode:o,onEdit:d,darkMode:c,notifCount:_,onToggleDark:m,onCountChange:y,onViewProfile:h,onSubmit:b,onBack:z,onNavigate:j,onLogout:f,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:u&&e.name?()=>u(e.name):void 0}),t.jsx(le,{title:"Branch Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[x.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:T=>g({organization:T}),organizations:s,disabled:o||!!a.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[x.field.branch," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...C},value:e.branch,disabled:o||!!e.name,onChange:T=>g({branch:T.target.value}),placeholder:"Branch name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:x.field.management}),t.jsx(ue,{value:e.management,onChange:T=>g({management:T}),items:p,placeholder:x.field.select,disabled:o})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:x.field.department}),t.jsx(ue,{value:e.department,onChange:T=>g({department:T}),items:k,placeholder:x.field.select,disabled:o})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:x.field.creationDate}),t.jsx(me,{value:e.custom_creation_date||"",onChange:T=>g({custom_creation_date:T}),disabled:o,style:{...P,...C}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:x.field.status}),t.jsxs("select",{style:{...P,...C},value:e.custom_status||"Active",disabled:o,onChange:T=>g({custom_status:T.target.value}),children:[t.jsx("option",{value:"Active",children:x.field.statusActive}),t.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})})]})}function V0(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function Z0({incidentTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.red})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:V0(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function e1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return t.jsxs(Ve,{title:x,activePage:"incident-types",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsx(le,{title:"Incident Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Incident type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]})})]})}function t1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function n1({ideaTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.teal})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:t1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function s1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return t.jsxs(Ve,{title:x,activePage:"idea-types",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsx(le,{title:"Idea Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Idea type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]})})]})}function l1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function r1({orderTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.purple})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:l1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function i1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return t.jsxs(Ve,{title:x,activePage:"order-types",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsx(le,{title:"Order Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Order type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]})})]})}function a1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function o1({processTypes:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:a1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function d1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return t.jsxs(Ve,{title:x,activePage:"process-types",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsx(le,{title:"Process Type Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Process type name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]})})]})}function c1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function u1({incidentStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.red})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.notifyManager}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.notify_manager?o.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:c1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function p1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return t.jsxs(Ve,{title:x,activePage:"incident-statuses",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsxs(le,{title:"Incident Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Incident status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:g=>f({notify_manager:g.target.checked?1:0}),style:Tl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:j.field.notifyManager})]})]})]})}function f1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function h1({ideaStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.teal})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.notifyManager}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.notify_manager?o.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:f1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function g1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return t.jsxs(Ve,{title:x,activePage:"idea-statuses",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsxs(le,{title:"Idea Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Idea status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:g=>f({notify_manager:g.target.checked?1:0}),style:Tl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:j.field.notifyManager})]})]})]})}function x1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function m1({orderStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.purple})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.notifyManager}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.notify_manager?o.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:x1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function y1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return t.jsxs(Ve,{title:x,activePage:"order-statuses",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsxs(le,{title:"Order Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Order status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:g=>f({notify_manager:g.target.checked?1:0}),style:Tl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:j.field.notifyManager})]})]})]})}function v1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function j1({processStatuses:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState("all"),h={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=S.useMemo(()=>e.filter(a=>{const x=(a.name1||a.name||"").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m!=="all"&&(a.status||"Active")!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total",val:b.length,color:X.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:"Status",value:m,onChange:y,options:[{value:"all",label:"All"},{value:"Active",label:o.field.statusActive},{value:"Inactive",label:o.field.statusInactive}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:h,children:o.col.name}),t.jsx("th",{style:h,children:o.field.notifyManager}),t.jsx("th",{style:h,children:o.field.creationDate}),t.jsx("th",{style:h,children:o.field.status}),t.jsx("th",{style:h,children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.name1||a.name||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.notify_manager?o.field.statusActive:"—"}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:v1(a.creation_date)}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{color:a.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:a.status==="Inactive"?o.field.statusInactive:o.field.statusActive})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function b1({form:e,setForm:n,formStatus:s,viewMode:l,onEdit:r,onRestore:i,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,user:z}){const j=ne(),f=g=>n(C=>({...C,...g})),a=l?{background:"#f8fafc"}:{},x=e.name?l?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return t.jsxs(Ve,{title:x,activePage:"process-statuses",user:z,formStatus:s,buttonText:j.saveName,buttonColor:"#16a34a",viewMode:l,onEdit:r,darkMode:o,notifCount:d,onToggleDark:u,onCountChange:c,onViewProfile:_,onSubmit:m,onBack:y,onNavigate:h,onLogout:b,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:i&&e.name?()=>i(e.name):void 0}),t.jsxs(le,{title:"Process Status Details",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[j.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...a},value:e.name1,disabled:l||!!e.name,onChange:g=>f({name1:g.target.value}),placeholder:"Process status name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.creationDate}),t.jsx(me,{value:e.creation_date||"",onChange:g=>f({creation_date:g}),disabled:l,style:{...P,...a}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:j.field.status}),t.jsxs("select",{style:{...P,...a},value:e.status||"Active",disabled:l,onChange:g=>f({status:g.target.value}),children:[t.jsx("option",{value:"Active",children:j.field.statusActive}),t.jsx("option",{value:"Inactive",children:j.field.statusInactive})]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:l,onChange:g=>f({notify_manager:g.target.checked?1:0}),style:Tl}),t.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:l?"default":"pointer"},children:j.field.notifyManager})]})]})]})}const S1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function w1(e){if(!e)return"—";const n=new Date(e);return`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function _1({users:e,canModify:n,onView:s,onEdit:l,onDisable:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(!1),[m,y]=S.useState(""),[h,b]=S.useState(""),[z,j]=S.useState(""),[f,a]=S.useState("active"),[x,g]=S.useState(1),[C,w]=S.useState(null),[p,k]=S.useState(""),[T,A]=S.useState("idle"),[Q,J]=S.useState(null),W=async()=>{if(!(!C||!p.trim())){A("loading");try{await lh(C.name,p.trim()),A("success"),setTimeout(()=>{w(null),k(""),A("idle")},1200)}catch{A("error")}}},U=async $=>{if(window.confirm(o.users.disableConfirm)){J($);try{await(r==null?void 0:r($))}finally{J(null)}}},I=e.filter($=>{if(f==="active"&&($.enabled===0||$.enabled==="0")||f==="inactive"&&$.enabled!==0&&$.enabled!=="0")return!1;const Z=$.custom_category||"";if(z&&Z!==z)return!1;const pe=$.custom_organization||"";if(h&&!pe.toLowerCase().includes(h.toLowerCase()))return!1;if(m){const be=m.toLowerCase();if(![$.full_name,$.email,$.name,$.username,$.mobile_no].join(" ").toLowerCase().includes(be))return!1}return!0}),O=[...new Set(e.map($=>$.custom_organization).filter(Boolean))],M=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];S.useEffect(()=>{g(1)},[m,h,z,f]);const H=I.slice((x-1)*re,x*re);S.useEffect(()=>{if(i){const $=I.filter(Z=>d.has(Z.name));i($,H)}},[d,H]);const Y={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},q={...Y,cursor:"pointer"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[t.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[t.jsxs("div",{onClick:()=>_($=>!$),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:c?t.jsx("polyline",{points:"18,15 12,9 6,15"}):t.jsx("polyline",{points:"6,9 12,15 18,9"})}),t.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),t.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),c&&t.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),t.jsx("input",{style:Y,placeholder:"Name, email, username…",value:m,onChange:$=>{y($.target.value),g(1)}})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),t.jsxs("select",{style:q,value:h,onChange:$=>{b($.target.value),g(1)},children:[t.jsx("option",{value:"",children:"All Organizations"}),O.map($=>t.jsx("option",{value:$,children:$},$))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),t.jsxs("select",{style:q,value:z,onChange:$=>{j($.target.value),g(1)},children:[t.jsx("option",{value:"",children:"All Categories"}),M.map($=>t.jsx("option",{value:$,children:$},$))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),t.jsxs("select",{style:q,value:f,onChange:$=>{a($.target.value),g(1)},children:[t.jsx("option",{value:"all",children:"All"}),t.jsx("option",{value:"active",children:"Active"}),t.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),t.jsx("div",{style:{background:"white",borderRadius:10,border:"1px solid #e5e7eb",overflow:"auto",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.05)"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f9fafb",borderBottom:"2px solid #e5e7eb",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"11px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:H.length>0&&H.every($=>d.has($.name)),onChange:$=>{if($.target.checked)u(new Set([...d,...H.map(Z=>Z.name)]));else{const Z=new Set(d);H.forEach(pe=>Z.delete(pe.name)),u(Z)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),[{label:"Category",w:110},{label:"Number",w:90},{label:o.col.name,w:160},{label:"Username",w:130},{label:"Email",w:180},{label:"Phone",w:110},{label:o.col.organization,w:140},{label:o.col.management,w:120},{label:o.col.department,w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:$,w:Z})=>t.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:Z,letterSpacing:.3,textTransform:"uppercase"},children:$},$))]})}),t.jsx("tbody",{children:I.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:14,style:{padding:"48px 20px",textAlign:"center",color:"#aaa",fontSize:14},children:"No users found"})}):H.map(($,Z)=>{const pe=$.custom_category||"",be=S1[pe]||"#6b7280";return t.jsxs("tr",{onClick:()=>s==null?void 0:s($),style:{borderBottom:"1px solid #f3f4f6",background:d.has($.name)?"#eff6ff":Z%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"11px 14px",textAlign:"center"},onClick:ie=>ie.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has($.name),onChange:()=>{const ie=new Set(d);ie.has($.name)?ie.delete($.name):ie.add($.name),u(ie)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:pe?t.jsx("span",{style:{background:be+"18",color:be,border:`1px solid ${be}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:pe}):t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:$.custom_number||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:$.full_name||$.first_name||"—"}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:$.username||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:$.email||$.name}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:$.mobile_no||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:$.custom_organization||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:$.custom_management||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:$.custom_department||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:$.custom_branch||t.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),t.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:w1($.creation)}),t.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:t.jsx("span",{style:{color:$.enabled?"#16a34a":"#dc2626",fontWeight:600},children:$.enabled?o.users.active:o.users.inactive})}),t.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:ie=>ie.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{onClick:ie=>{ie.stopPropagation(),s==null||s($)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),n&&l&&t.jsx("button",{onClick:ie=>{ie.stopPropagation(),l($)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),n&&t.jsx("button",{onClick:ie=>{ie.stopPropagation(),w({name:$.name,email:$.email||$.name}),k(""),A("idle")},title:"Set Password",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fef3c7",color:"#d97706"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),n&&t.jsx("button",{onClick:ie=>{ie.stopPropagation(),U($.name)},disabled:Q===$.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:Q===$.name?.5:1},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14H6L5 6"}),t.jsx("path",{d:"M10 11v6M14 11v6"}),t.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},$.name)})})]})}),t.jsx(Je,{page:x,total:I.length,onPageChange:g}),C&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[t.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:o.users.setPassword}),t.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",t.jsx("strong",{children:C.email})]}),t.jsx("input",{type:"password",value:p,onChange:$=>k($.target.value),placeholder:o.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:$=>$.key==="Enter"&&W(),autoFocus:!0}),T==="success"&&t.jsx("div",{style:{color:"#166534",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Password updated successfully"}),T==="error"&&t.jsx("div",{style:{color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Failed to update password"}),t.jsxs("div",{style:{display:"flex",gap:10},children:[t.jsx("button",{onClick:W,disabled:T==="loading"||!p.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:p.trim()?1:.5},children:T==="loading"?"Saving…":o.users.setPassword}),t.jsx("button",{onClick:()=>{w(null),k(""),A("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:o.cancel})]})]})})]})}function k1({form:e,setForm:n,groupCompanies:s=[],organizations:l,managements:r,departments:i,branches:o,formStatus:d,viewMode:u,onEdit:c,onRestore:_,darkMode:m,notifCount:y,onToggleDark:h,onCountChange:b,onViewProfile:z,isSelfProfile:j,onSubmit:f,onBack:a,onNavigate:x,onLogout:g,user:C}){const w=ne(),p=I=>n(O=>({...O,...I})),k=u?{background:"#f8fafc"}:{},T=!e.name,A=j?"My Profile":T?"New User":u?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,Q=s.map(I=>({name:I.name,label:I.company_name?`${I.company_name} (${I.name})`:I.name})),J=ye(r,e.custom_management).map(I=>({name:I.name,label:I.name1||I.name})),W=ye(i,e.custom_department).map(I=>({name:I.name,label:I.department_name||I.name})),U=ye(o,e.custom_branch).map(I=>({name:I.name,label:I.branch||I.name}));return t.jsxs(Ve,{title:A,activePage:"users",user:C,formStatus:d,buttonText:w.saveUser,buttonColor:"#16a34a",viewMode:u,onEdit:c,darkMode:m,notifCount:y,onToggleDark:h,onCountChange:b,onViewProfile:z,hideSettings:j,onSubmit:f,onBack:a,onNavigate:x,onLogout:g,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:_&&e.name?()=>_(e.name):void 0}),t.jsx(le,{title:"User Organization & Assignment",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:"Group Company (Tenant)"}),t.jsx(ue,{value:e.custom_group_company||"",onChange:I=>p({custom_group_company:I}),items:Q,placeholder:"-- Select Group Company --",disabled:u||!!C.custom_group_company})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.organization}),t.jsx(Gt,{value:e.custom_organization,onChange:I=>p({custom_organization:I}),organizations:l,disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.management}),t.jsx(ue,{value:e.custom_management,onChange:I=>p({custom_management:I}),items:J,placeholder:"-- Select --",disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.department}),t.jsx(ue,{value:e.custom_department,onChange:I=>p({custom_department:I}),items:W,placeholder:"-- Select --",disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.branch}),t.jsx(ue,{value:e.custom_branch,onChange:I=>p({custom_branch:I}),items:U,placeholder:"-- Select --",disabled:u})]})]})}),t.jsx(le,{title:"User Profile Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.number}),t.jsx("input",{style:{...P,...k},value:e.custom_number,disabled:u,onChange:I=>p({custom_number:I.target.value}),placeholder:"e.g. 10001"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[w.field.fullName," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...k},value:e.first_name,disabled:u,onChange:I=>p({first_name:I.target.value}),placeholder:"Full name",required:!0})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.username}),t.jsx("input",{style:{...P,...k},value:e.username,disabled:u,onChange:I=>p({username:I.target.value}),placeholder:"Username"})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.phoneNumber}),t.jsx("input",{style:{...P,...k},value:e.mobile_no,disabled:u,onChange:I=>p({mobile_no:I.target.value}),placeholder:"Phone number"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[w.field.emailAddress," ",T&&t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...u||!T?{background:"#f8fafc"}:{}},value:e.email,disabled:u||!T,onChange:I=>p({email:I.target.value}),placeholder:"user@example.com",type:"email",required:T})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:w.field.category}),t.jsxs("select",{style:{...P,...k},value:e.custom_category,disabled:u,onChange:I=>p({custom_category:I.target.value}),children:[t.jsx("option",{value:"",children:w.field.select}),t.jsx("option",{children:"Admin"}),t.jsx("option",{children:"Chairman"}),t.jsx("option",{children:"Auditor"}),t.jsx("option",{children:"X-Auditor"}),t.jsx("option",{children:"Manager"}),t.jsx("option",{children:"Employee"})]})]})]})})]})}const Au={Active:X.green,Closed:X.gray};function C1({cycles:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState(""),[h,b]=S.useState("all"),z=S.useMemo(()=>[...new Set(e.map(w=>w.organization).filter(Boolean))],[e]),j=S.useMemo(()=>e.filter(w=>{const p=(w.name1||w.name||"").toLowerCase();return!(c&&!p.includes(c.toLowerCase())||m&&w.organization!==m||h!=="all"&&w.status!==h)}),[e,c,m,h]),[f,a]=S.useState(1);S.useEffect(()=>{a(1)},[c,m,h]);const x=j.slice((f-1)*re,f*re);S.useEffect(()=>{if(i){const w=e.filter(p=>d.has(p.name));i(w,x)}},[d,x]);const g=j.filter(w=>w.status==="Active").length,C=j.filter(w=>w.status==="Closed").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:j.length,color:X.teal}),t.jsx(Ie,{label:"Active",val:g,color:X.green}),t.jsx(Ie,{label:"Closed",val:C,color:X.gray})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Search by name…"},{type:"select",label:o.col.organization,value:m,onChange:y,options:[{value:"",label:"All Organizations"},...z.map(w=>({value:w,label:w}))]},{type:"select",label:"Status",value:h,onChange:b,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:x.length>0&&x.every(w=>d.has(w.name)),onChange:w=>{if(w.target.checked)u(new Set([...d,...x.map(p=>p.name)]));else{const p=new Set(d);x.forEach(k=>p.delete(k.name)),u(p)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.name}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.frequency}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.startDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.endDate}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.status}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.actions})]})}),t.jsx("tbody",{children:j.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):x.map((w,p)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(w),style:{borderTop:"1px solid #f0f0f0",background:d.has(w.name)?"#eff6ff":w.custom_is_deleted?"#fff1f2":p%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:k=>k.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(w.name),onChange:()=>{const k=new Set(d);k.has(w.name)?k.delete(w.name):k.add(w.name),u(k)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:w.name1||w.name}),t.jsx("td",{style:{padding:"10px 14px"},children:w.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.frequency||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.start_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.end_date||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:w.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:Au[w.status]+"22",color:Au[w.status]||"#666"},children:w.status})}),t.jsx("td",{style:{padding:"8px 14px"},onClick:k=>k.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(w),onEdit:n&&l&&!w.custom_is_deleted?()=>l(w):void 0,onDelete:n&&r&&!w.custom_is_deleted?()=>r(w.name):void 0})})]},w.name))})]})}),t.jsx(Je,{page:f,total:j.length,onPageChange:a})]})}const z1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],I1=["Active","Closed"];function T1({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:i,onRestore:o,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,user:j}){const f=ne(),a=C=>n(w=>({...w,...C})),x=r?{background:"#f8fafc"}:{},g=e.name?r?`${f.formTitle.editCycle}: ${e.name1||e.name}`:f.formTitle.editCycle:f.formTitle.newCycle;return t.jsxs(Ve,{title:g,activePage:"cycles",user:j,formStatus:l,buttonText:f.saveCycle,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o&&e.name?()=>o(e.name):void 0}),t.jsx(le,{title:"Cycle Details",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.name1," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...x},value:e.name1||"",disabled:r||!!e.name,onChange:C=>a({name1:C.target.value}),placeholder:"e.g. Q1-2026"})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:C=>a({organization:C}),organizations:s,disabled:r||!!j.custom_organization})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.col.frequency}),t.jsx(ue,{value:e.frequency,onChange:C=>a({frequency:C}),items:z1.map(C=>({name:C,label:C})),placeholder:"-- Select Frequency --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.status}),t.jsx(ue,{value:e.status,onChange:C=>a({status:C}),items:I1.map(C=>({name:C,label:C})),placeholder:"-- Select Status --",disabled:r})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.dateStart}),t.jsx(me,{value:e.start_date||"",onChange:C=>a({start_date:C}),disabled:r,style:{...P,...x}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.dateEnd}),t.jsx(me,{value:e.end_date||"",onChange:C=>a({end_date:C}),disabled:r,style:{...P,...x}})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.updateWindowDays}),t.jsx("input",{type:"number",min:1,max:30,style:{...P,...x},value:e.update_window_days??2,disabled:r,onChange:C=>a({update_window_days:parseInt(C.target.value)||2})}),t.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})]})}function E1({kpiInputs:e,canModify:n,onView:s,onEdit:l,onDelete:r,onSelectionChange:i}){const o=ne(),[d,u]=S.useState(new Set),[c,_]=S.useState(""),[m,y]=S.useState(""),h=S.useMemo(()=>[...new Set(e.map(a=>a.organization).filter(Boolean))],[e]),b=S.useMemo(()=>e.filter(a=>{const x=[a.organization,a.period].filter(Boolean).join(" ").toLowerCase();return!(c&&!x.includes(c.toLowerCase())||m&&a.organization!==m)}),[e,c,m]),[z,j]=S.useState(1);S.useEffect(()=>{j(1)},[c,m]);const f=b.slice((z-1)*re,z*re);return S.useEffect(()=>{if(i){const a=e.filter(x=>d.has(x.name));i(a,f)}},[d,f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",gap:16},children:t.jsx(Ie,{label:"Total Records",val:b.length,color:X.blue})}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:c,onChange:_,placeholder:"Organization or period…"},{type:"select",label:o.col.organization,value:m,onChange:y,options:[{value:"",label:"All Organizations"},...h.map(a=>({value:a,label:a}))]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:f.length>0&&f.every(a=>d.has(a.name)),onChange:a=>{if(a.target.checked)u(new Set([...d,...f.map(x=>x.name)]));else{const x=new Set(d);f.forEach(g=>x.delete(g.name)),u(x)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.organization}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.period}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.field.revenue_growth}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.field.net_profit}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.dash.customerSat}),t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:o.col.actions})]})}),t.jsx("tbody",{children:b.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:o.noData})}):f.map((a,x)=>t.jsxs("tr",{className:"app-table-row",onClick:()=>s==null?void 0:s(a),style:{borderTop:"1px solid #f0f0f0",background:d.has(a.name)?"#eff6ff":a.custom_is_deleted?"#fff1f2":x%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:g=>g.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:d.has(a.name),onChange:()=>{const g=new Set(d);g.has(a.name)?g.delete(a.name):g.add(a.name),u(g)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:a.organization||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.period||"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.revenue_growth!=null?`${a.revenue_growth}%`:"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.net_profit!=null?a.net_profit.toLocaleString():"—"}),t.jsx("td",{style:{padding:"10px 14px"},children:a.custom_is_deleted?t.jsx("span",{style:{background:"#fee2e2",color:"#991b1b",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700},children:o.deletedBadge}):a.customer_satisfaction!=null?a.customer_satisfaction:"—"}),t.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:t.jsx(it,{onView:()=>s==null?void 0:s(a),onEdit:n&&l&&!a.custom_is_deleted?()=>l(a):void 0,onDelete:n&&r&&!a.custom_is_deleted?()=>r(a.name):void 0})})]},a.name))})]})}),t.jsx(Je,{page:z,total:b.length,onPageChange:j})]})}function A1({form:e,setForm:n,organizations:s,formStatus:l,viewMode:r,onEdit:i,onRestore:o,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,user:j}){const f=ne(),a=w=>n(p=>({...p,...w})),x=r?{background:"#f8fafc"}:{},g=w=>p=>a({[w]:parseFloat(p.target.value)||0}),C=e.name?r?`${f.formTitle.editKpi}: ${e.period||e.name}`:f.formTitle.editKpi:f.formTitle.newKpi;return t.jsxs(Ve,{title:C,activePage:"kpi-input",user:j,formStatus:l,buttonText:f.saveKpi,buttonColor:"#16a34a",viewMode:r,onEdit:i,darkMode:d,notifCount:u,onToggleDark:c,onCountChange:_,onViewProfile:m,onSubmit:y,onBack:h,onNavigate:b,onLogout:z,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:o&&e.name?()=>o(e.name):void 0}),t.jsx(le,{title:"Period & Organization",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.field.organization," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(Gt,{value:e.organization,onChange:w=>a({organization:w}),organizations:s,disabled:r||!!j.custom_organization})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[f.col.period," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx("input",{style:{...P,...x},value:e.period||"",disabled:r,onChange:w=>a({period:w.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),t.jsx(le,{title:"Financial KPIs",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.revenue_growth}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.revenue_growth||"",disabled:r,onChange:g("revenue_growth")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.net_profit}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.net_profit||"",disabled:r,onChange:g("net_profit")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.cash_flow}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.cash_flow||"",disabled:r,onChange:g("cash_flow")})]})]})}),t.jsx(le,{title:"Operational KPIs",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.strategic_goal_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.strategic_goal_pct||"",disabled:r,onChange:g("strategic_goal_pct")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.customer_satisfaction}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.customer_satisfaction||"",disabled:r,onChange:g("customer_satisfaction")})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.employee_turnover_pct}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.employee_turnover_pct||"",disabled:r,onChange:g("employee_turnover_pct")})]})]})}),t.jsx(le,{title:"Safety & Compliance",children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.open_safety_incidents}),t.jsx("input",{type:"number",min:0,style:{...P,...x},value:e.open_safety_incidents||"",disabled:r,onChange:w=>a({open_safety_incidents:parseInt(w.target.value)||0})})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:f.field.compliance_score}),t.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.compliance_score||"",disabled:r,onChange:g("compliance_score")})]})]})})]})}const P1={incident_initial_evaluation:"Incident Initial Evaluation",idea_initial_evaluation:"Idea Initial Evaluation"},Pu={Pending:X.orange,Accepted:X.green,Rejected:X.red,Revoked:X.gray};function R1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":`${String(n.getDate()).padStart(2,"0")}/${String(n.getMonth()+1).padStart(2,"0")}/${n.getFullYear()}`}function D1(e){const n=[];return e.incident_initial_evaluation&&n.push("incident_initial_evaluation"),e.idea_initial_evaluation&&n.push("idea_initial_evaluation"),n}function O1({delegations:e,organizations:n,userRole:s,currentUser:l,onView:r,onRevoke:i,onSelectionChange:o}){const d=ne(),[u,c]=S.useState(new Set),[_,m]=S.useState(""),[y,h]=S.useState(""),[b,z]=S.useState("all"),j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=S.useMemo(()=>e.filter(p=>{const k=`${p.auditor} ${p.manager}`.toLowerCase();return!(_&&!k.includes(_.toLowerCase())||y&&p.organization!==y||b!=="all"&&p.status!==b)}),[e,_,y,b]),[a,x]=S.useState(1);S.useEffect(()=>{x(1)},[_,y,b]);const g=f.slice((a-1)*re,a*re);S.useEffect(()=>{if(o){const p=e.filter(k=>u.has(k.name));o(p,g)}},[u,g]);const C=f.filter(p=>p.status==="Pending").length,w=f.filter(p=>p.status==="Accepted").length;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Ie,{label:"Total",val:f.length,color:X.purple}),t.jsx(Ie,{label:"Pending",val:C,color:X.orange}),t.jsx(Ie,{label:"Accepted",val:w,color:X.green})]}),t.jsx(vt,{filters:[{type:"search",label:"Search",value:_,onChange:m,placeholder:"Auditor or Manager…"},{type:"select",label:d.col.organization,value:y,onChange:h,options:[{value:"",label:"All Organizations"},...n.map(p=>({value:p.organization_name||p.name,label:p.organization_name||p.name}))]},{type:"select",label:"Status",value:b,onChange:z,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),t.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[t.jsx("th",{style:{width:40,padding:"10px 14px",textAlign:"center"},children:t.jsx("input",{type:"checkbox",checked:g.length>0&&g.every(p=>u.has(p.name)),onChange:p=>{if(p.target.checked)c(new Set([...u,...g.map(k=>k.name)]));else{const k=new Set(u);g.forEach(T=>k.delete(T.name)),c(k)}},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("th",{style:j,children:d.col.number}),t.jsx("th",{style:j,children:d.col.auditor}),t.jsx("th",{style:j,children:d.col.manager}),t.jsx("th",{style:j,children:d.col.organization}),t.jsx("th",{style:j,children:d.col.functions}),t.jsx("th",{style:j,children:d.col.status}),t.jsx("th",{style:j,children:d.col.requestedOn}),t.jsx("th",{style:j,children:d.col.actions})]})}),t.jsx("tbody",{children:f.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:9,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):g.map((p,k)=>{const T=!!i&&(p.status==="Pending"||p.status==="Accepted")&&(s==="Admin"||p.auditor===l);return t.jsxs("tr",{className:"app-table-row",onClick:()=>r==null?void 0:r(p),style:{borderTop:"1px solid #f0f0f0",background:u.has(p.name)?"#eff6ff":k%2===0?"white":"#fafafa",cursor:"pointer"},children:[t.jsx("td",{style:{width:40,padding:"10px 14px",textAlign:"center"},onClick:A=>A.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:u.has(p.name),onChange:()=>{const A=new Set(u);A.has(p.name)?A.delete(p.name):A.add(p.name),c(A)},style:{width:15,height:15,cursor:"pointer",accentColor:"#2563eb"}})}),t.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:p.number||p.name}),t.jsx("td",{style:{padding:"10px 14px"},children:p.auditor}),t.jsx("td",{style:{padding:"10px 14px"},children:p.manager}),t.jsx("td",{style:{padding:"10px 14px"},children:p.organization||"All Organizations"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:D1(p).map(A=>t.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:P1[A]||A},A))})}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{background:(Pu[p.status]||X.gray)+"22",color:Pu[p.status]||X.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:p.status})}),t.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:R1(p.requested_on)}),t.jsx("td",{style:{padding:"8px 14px"},onClick:A=>A.stopPropagation(),children:t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>r==null?void 0:r(p),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:t.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),T&&t.jsx("button",{onClick:()=>i==null?void 0:i(p.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"})]})})]},p.name)})})]})}),t.jsx(Je,{page:a,total:f.length,onPageChange:x})]})}const Ru={Pending:X.orange,Accepted:X.green,Rejected:X.red,Revoked:X.gray};function L1(e){if(!e)return"—";const n=new Date(e);return isNaN(n.getTime())?"—":n.toLocaleString()}function W1({form:e,setForm:n,organizations:s,users:l,userRoleMap:r,incidents:i=[],ideas:o=[],formStatus:d,viewMode:u,onEdit:c,onRestore:_,darkMode:m,notifCount:y,onToggleDark:h,onCountChange:b,onViewProfile:z,onSubmit:j,onBack:f,onNavigate:a,onLogout:x,user:g}){var J;const C=ne(),w=W=>n(U=>({...U,...W})),p=u?{background:"#f8fafc"}:{},k=Il(l,r,"SB Manager",e.organization).filter(W=>W.name!==(e.auditor||g.name)).map(W=>({name:W.name,label:W.full_name||W.name})),T=i.filter(W=>(W.workflow_state==="Initial Evaluation"||W.status==="Initial Evaluation")&&(!e.organization||W.organization===e.organization)).map(W=>({name:W.name,label:`${W.number||W.name} — ${W.title||""}`.trim()})),A=o.filter(W=>(W.workflow_state==="Initial Evaluation"||W.status==="Initial Evaluation")&&(!e.organization||W.organization===e.organization)).map(W=>({name:W.name,label:`${W.number||W.name} — ${W.title||""}`.trim()})),Q=e.name?`${C.formTitle.viewDelegation}${e.number||e.name}`:C.formTitle.newDelegation;return t.jsxs(Ve,{title:Q,activePage:"delegations",user:g,formStatus:d,statusBadge:e.status?t.jsx("span",{style:{background:(Ru[e.status]||X.gray)+"22",color:Ru[e.status]||X.gray,padding:"4px 12px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status}):void 0,buttonText:C.saveDelegation,buttonColor:"#16a34a",viewMode:u,onEdit:c,darkMode:m,notifCount:y,onToggleDark:h,onCountChange:b,onViewProfile:z,onSubmit:j,onBack:f,onNavigate:a,onLogout:x,children:[e.custom_is_deleted===1&&t.jsx(qe,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:_&&e.name?()=>_(e.name):void 0}),e.status==="Revoked"&&t.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f8fafc",border:"1px solid #cbd5e1",color:"#475569",fontSize:13,fontWeight:600,marginBottom:14,display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:16},children:"🚫"})," This delegation has been Revoked and is closed for further edits or re-delegation."]}),t.jsxs(le,{title:"Delegation Information",children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[t.jsxs("div",{children:[t.jsx("label",{style:E,children:C.col.auditor}),t.jsx("input",{style:{...P,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||g.name,disabled:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[C.col.manager," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsx(ue,{value:e.manager,onChange:W=>w({manager:W}),items:k,placeholder:"-- Select Manager --",disabled:u})]}),t.jsxs("div",{children:[t.jsx("label",{style:E,children:C.col.organization}),t.jsx(Gt,{value:e.organization,onChange:W=>w({organization:W,incident_name:"",idea_name:""}),organizations:s,placeholder:"-- All Organizations --",disabled:u})]})]}),t.jsxs("div",{children:[t.jsxs("label",{style:E,children:[C.col.functions," ",t.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:6},children:[t.jsxs("div",{className:`delegation-func-box ${e.incident_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:u?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:Tl,checked:!!e.incident_initial_evaluation,disabled:u,onChange:W=>w({incident_initial_evaluation:W.target.checked?1:0,incident_name:W.target.checked?e.incident_name:""})}),t.jsx("span",{className:"func-title",children:"Initial Evaluation (Incidents)"})]}),!!e.incident_initial_evaluation&&t.jsxs("div",{style:{marginTop:10},children:[t.jsxs("label",{style:{...E,fontSize:11},className:"func-sublabel",children:["Specific Incident ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),u?t.jsx("input",{style:{...P,background:"#f8fafc"},value:e.incident_name||"— All Incidents in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.incident_name||"",onChange:W=>w({incident_name:W}),items:T,placeholder:`-- Any Incident in Initial Evaluation (${T.length} available) --`,disabled:u})]})]}),t.jsxs("div",{className:`delegation-func-box ${e.idea_initial_evaluation?"checked":""}`,children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:u?"default":"pointer",fontSize:13,fontWeight:600},children:[t.jsx("input",{type:"checkbox",style:Tl,checked:!!e.idea_initial_evaluation,disabled:u,onChange:W=>w({idea_initial_evaluation:W.target.checked?1:0,idea_name:W.target.checked?e.idea_name:""})}),t.jsx("span",{className:"func-title",children:"Initial Evaluation (Ideas)"})]}),!!e.idea_initial_evaluation&&t.jsxs("div",{style:{marginTop:10},children:[t.jsxs("label",{style:{...E,fontSize:11},className:"func-sublabel",children:["Specific Idea ",t.jsx("span",{style:{fontWeight:400},className:"func-hint",children:"(optional — leave blank to delegate all)"})]}),u?t.jsx("input",{style:{...P,background:"#f8fafc"},value:e.idea_name||"— All Ideas in Initial Evaluation",readOnly:!0,disabled:!0}):t.jsx(ue,{value:e.idea_name||"",onChange:W=>w({idea_name:W}),items:A,placeholder:`-- Any Idea in Initial Evaluation (${A.length} available) --`,disabled:u})]})]})]})]}),!u&&t.jsxs("div",{style:{marginTop:14},children:[t.jsx("label",{style:E,children:"Remarks"}),t.jsx("textarea",{style:{...P,...p,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:W=>w({remarks:W.target.value}),placeholder:"Optional note for the Manager…"})]})]}),u&&(((J=e.delegation_log)==null?void 0:J.length)??0)>0&&t.jsx(le,{title:"Audit Trail",children:t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"#f8fafc"},children:[t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Action"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Timestamp"}),t.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Remarks"})]})}),t.jsx("tbody",{children:(e.delegation_log||[]).map((W,U)=>t.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[t.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:W.action}),t.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:W.actor}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:L1(W.timestamp)}),t.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:W.remarks||"—"})]},W.name||U))})]})})})]})}const Du={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},N1={process:"#3b82f6",order:"#8b5cf6",incident:"#ef4444",idea:"#10b981",delegation:"#f59e0b"},B1={process:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",order:"linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%)",incident:"linear-gradient(135deg, #ef4444 0%, #b91c1c 100%)",idea:"linear-gradient(135deg, #10b981 0%, #047857 100%)",delegation:"linear-gradient(135deg, #f59e0b 0%, #b45309 100%)"},$1={process:"⚙️",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function U1({onNavigate:e,onRefresh:n}){const[s,l]=S.useState([]),[r,i]=S.useState(!0),[o,d]=S.useState(""),[u,c]=S.useState(""),[_,m]=S.useState(""),[y,h]=S.useState("all"),b=()=>{i(!0),My().then(a=>{l(a||[]),i(!1)}).catch(()=>i(!1))};S.useEffect(()=>{b()},[]);const z=S.useMemo(()=>{const a={all:s.length,action:0,info:0};for(const x of s)x.requires_action?a.action=(a.action||0)+1:a.info=(a.info||0)+1,a[x.type]=(a[x.type]||0)+1;return a},[s]),j=S.useMemo(()=>s.filter(a=>{if(y==="action"&&!a.requires_action||y==="info"&&a.requires_action||y!=="all"&&y!=="action"&&y!=="info"&&a.type!==y)return!1;if(_.trim()){const x=_.toLowerCase();if(![a.number,a.title,a.action,a.organization,a.type].filter(Boolean).join(" ").toLowerCase().includes(x))return!1}return!0}),[s,y,_]),f=async(a,x)=>{d(a),c("");try{await Gy(a,x),await b(),n==null||n()}catch{c(a)}finally{d("")}};return t.jsxs("div",{style:{maxWidth:1100,margin:"0 auto",display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{background:"linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e293b 100%)",borderRadius:16,padding:"24px 28px",color:"#ffffff",boxShadow:"0 10px 25px -5px rgba(30, 27, 75, 0.25), 0 8px 10px -6px rgba(30, 27, 75, 0.2)",display:"flex",flexDirection:"column",gap:18,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",top:-40,right:-40,width:180,height:180,borderRadius:"50%",background:"radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%)",pointerEvents:"none"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:14},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("span",{style:{fontSize:24},children:"📬"}),t.jsx("h2",{style:{fontSize:20,fontWeight:800,color:"#ffffff",margin:0,letterSpacing:"-0.3px"},children:"Unified Activity Inbox"})]}),t.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#c7d2fe",opacity:.9},children:"Real-time tasks, approvals, delegations, and workflow actions requiring your attention."})]}),t.jsxs("button",{type:"button",onClick:b,disabled:r,style:{background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(8px)",border:"1px solid rgba(255, 255, 255, 0.25)",color:"white",borderRadius:10,padding:"8px 16px",fontSize:13,fontWeight:600,cursor:r?"wait":"pointer",display:"flex",alignItems:"center",gap:8,transition:"all 0.15s ease"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.25)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{transform:r?"rotate(180deg)":"none",transition:"transform 0.5s",display:"inline-block"},children:"🔄"}),r?"Refreshing…":"Refresh"]})]}),t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[t.jsxs("div",{style:{background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(255, 255, 255, 0.15)"},children:[t.jsx("span",{style:{fontSize:12,color:"#e0e7ff",fontWeight:500},children:"Total Items"}),t.jsx("span",{style:{background:"white",color:"#1e1b4b",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:z.all||0})]}),t.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.2)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(239, 68, 68, 0.35)"},children:[t.jsx("span",{style:{fontSize:12,color:"#fecaca",fontWeight:600},children:"Action Required"}),t.jsx("span",{style:{background:"#ef4444",color:"white",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:z.action||0})]}),t.jsxs("div",{style:{background:"rgba(59, 130, 246, 0.2)",backdropFilter:"blur(6px)",borderRadius:10,padding:"8px 14px",display:"flex",alignItems:"center",gap:10,border:"1px solid rgba(59, 130, 246, 0.35)"},children:[t.jsx("span",{style:{fontSize:12,color:"#bfdbfe",fontWeight:500},children:"Informational"}),t.jsx("span",{style:{background:"#3b82f6",color:"white",fontWeight:800,fontSize:12,padding:"2px 8px",borderRadius:999},children:z.info||0})]})]})]}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:14,background:"white",padding:"12px 16px",borderRadius:12,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},className:"form-card",children:[t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[{id:"all",label:"All",icon:"📋",count:z.all},{id:"action",label:"Needs Action",icon:"🚨",count:z.action,badgeColor:"#ef4444"},{id:"info",label:"Info",icon:"ℹ️",count:z.info},{id:"incident",label:"Incidents",icon:"⚠️",count:z.incident},{id:"idea",label:"Ideas",icon:"💡",count:z.idea},{id:"order",label:"Orders",icon:"📦",count:z.order},{id:"process",label:"Processes",icon:"⚙️",count:z.process},{id:"delegation",label:"Delegations",icon:"🤝",count:z.delegation}].map(a=>{const x=y===a.id;return a.id!=="all"&&a.id!=="action"&&a.id!=="info"&&(!a.count||a.count===0)?null:t.jsxs("button",{type:"button",onClick:()=>h(a.id),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:999,border:x?"1px solid #4f46e5":"1px solid #e2e8f0",background:x?"#4f46e5":"#f8fafc",color:x?"#ffffff":"#475569",fontSize:12,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},children:[t.jsx("span",{children:a.icon}),t.jsx("span",{children:a.label}),a.count!=null&&a.count>0&&t.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:999,background:x?"rgba(255,255,255,0.25)":a.badgeColor||"#e2e8f0",color:x?"#ffffff":a.badgeColor?"white":"#475569"},children:a.count})]},a.id)})}),t.jsx("div",{style:{minWidth:200,flex:"1 1 200px",maxWidth:300},children:t.jsx("input",{type:"text",placeholder:"Search items, titles, IDs…",value:_,onChange:a=>m(a.target.value),style:{width:"100%",padding:"7px 12px",borderRadius:8,border:"1px solid #cbd5e1",fontSize:12,boxSizing:"border-box",background:"#f8fafc",color:"#334155"}})})]}),r?t.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",color:"#94a3b8",fontSize:14},children:[t.jsx("div",{style:{fontSize:28,marginBottom:8,animation:"spin 1s linear infinite"},children:"⏳"}),"Loading inbox updates…"]}):j.length===0?t.jsxs("div",{style:{background:"white",borderRadius:16,padding:"60px 24px",textAlign:"center",border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.03)"},className:"form-card",children:[t.jsx("div",{style:{fontSize:44,marginBottom:12},children:"✨"}),t.jsx("h3",{style:{fontSize:16,fontWeight:700,color:"#1e293b",margin:0},children:_||y!=="all"?"No matching inbox items":"You are all caught up!"}),t.jsx("p",{style:{fontSize:13,color:"#64748b",marginTop:6,maxWidth:420,margin:"6px auto 0"},children:_||y!=="all"?"Try changing your filter pills or searching for a different keyword.":"There are no active pending approvals or tasks requiring your action right now."}),(_||y!=="all")&&t.jsx("button",{type:"button",onClick:()=>{m(""),h("all")},style:{marginTop:16,padding:"7px 16px",borderRadius:8,background:"#4f46e5",color:"white",border:"none",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Reset Filters"})]}):t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(330px, 1fr))",gap:14},children:j.map((a,x)=>{const g=N1[a.type]||X.gray,C=B1[a.type]||"linear-gradient(135deg, #64748b 0%, #475569 100%)",w=a.type!=="delegation";return t.jsxs("div",{className:"inbox-card form-card",onClick:w?()=>e(Du[a.type],a.name):void 0,style:{background:"white",borderRadius:14,padding:"16px 18px",border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)",display:"flex",flexDirection:"column",justifyContent:"space-between",gap:14,cursor:w?"pointer":"default",position:"relative",overflow:"hidden",transition:"transform 0.15s ease, box-shadow 0.15s ease"},onMouseEnter:p=>{w&&(p.currentTarget.style.transform="translateY(-2px)",p.currentTarget.style.boxShadow="0 10px 20px -5px rgba(0,0,0,0.08)")},onMouseLeave:p=>{w&&(p.currentTarget.style.transform="none",p.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.04)")},children:[t.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:4,background:C}}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:8,background:C,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0,boxShadow:`0 3px 8px -1px ${g}66`},children:$1[a.type]||"📌"}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:g,letterSpacing:"0.3px"},children:a.number||a.name})]}),a.requires_action?t.jsxs("span",{style:{fontSize:10,fontWeight:800,color:"#ef4444",background:"#fef2f2",border:"1px solid #fecaca",padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:"0.4px",display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#ef4444"}}),"Action"]}):t.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",background:"#f1f5f9",padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:"0.3px"},children:a.type})]}),t.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:700,color:"#1e293b",lineHeight:1.35,marginBottom:6,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:a.title||a.action||"Untitled Item"}),t.jsx("div",{style:{fontSize:12,color:"#475569",lineHeight:1.4,marginBottom:8},children:a.action}),t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[a.organization&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6,display:"flex",alignItems:"center",gap:4},children:["🏢 ",a.organization]}),a.date&&t.jsxs("span",{style:{fontSize:11,color:"#64748b",background:"#f8fafc",border:"1px solid #e2e8f0",padding:"2px 7px",borderRadius:6},children:["📅 ",a.date]})]}),u===a.name&&t.jsx("div",{style:{marginTop:8,fontSize:11,color:"#ef4444",fontWeight:600},children:"⚠️ Failed to process response. Please try again."})]}),t.jsx("div",{children:a.type==="delegation"?t.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[t.jsx("button",{type:"button",onClick:()=>f(a.name,"Accepted"),disabled:o===a.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#16a34a",color:"white",fontWeight:700,fontSize:12,cursor:o===a.name?"wait":"pointer",opacity:o===a.name?.6:1,transition:"background 0.15s ease"},children:"✓ Accept"}),t.jsx("button",{type:"button",onClick:()=>f(a.name,"Rejected"),disabled:o===a.name,style:{flex:1,padding:"7px 0",borderRadius:8,border:"none",background:"#ef4444",color:"white",fontWeight:700,fontSize:12,cursor:o===a.name?"wait":"pointer",opacity:o===a.name?.6:1,transition:"background 0.15s ease"},children:"✕ Reject"})]}):t.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),e(Du[a.type],a.name)},style:{width:"100%",padding:"7px 12px",borderRadius:8,border:a.requires_action?"none":"1px solid #cbd5e1",background:a.requires_action?C:"#f8fafc",color:a.requires_action?"#ffffff":"#334155",fontWeight:700,fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"all 0.15s ease"},children:[t.jsx("span",{children:a.requires_action?"Review & Act Now":"View Details"}),t.jsx("span",{style:{fontSize:13},children:"→"})]})})]},a.name||x)})})]})}const F1=[{id:"process_status_history",label:"Process Status History",description:"Full cycle-by-cycle status for any process, with actor, date, and escalation level",roles:["Admin","Auditor","Owner"]},{id:"order_tracker",label:"Outsourcing Order Tracker",description:"Stage-by-stage progress for all orders, with cost variance",roles:["Admin","Auditor","Manager","Owner"]},{id:"incident_register",label:"Incident Register",description:"All incidents with type, status, assigned manager, and resolution timeline",roles:["Admin","Auditor","Manager","Owner"]},{id:"ideas_pipeline",label:"Ideas Pipeline",description:"All ideas by status and type, conversion rate to Study",roles:["Admin","Auditor","Manager","Owner"]},{id:"department_performance",label:"Department Performance",description:"Aggregate Pass/Fail/Unknown per department per cycle",roles:["Admin","Auditor","Owner"]},{id:"escalation_report",label:"Escalation Report",description:"All Level 2 escalations with entity type and current status",roles:["Admin","Owner"]},{id:"cost_summary",label:"Cost Summary",description:"Total cost per order, per department — budget vs actual",roles:["Admin","Owner"]},{id:"process_year_end",label:"Process Year-End Summary",description:"Full status history and accumulated cost per process for a given year (Rule 11.1-6)",roles:["Admin","Auditor","Owner"],extraFilter:"year"},{id:"user_activity_log",label:"User Activity Log",description:"All actions by user with timestamp and entity reference — Admin only",roles:["Admin"]}],Bd={number:"Number",title:"Title",organization:"Organization",department:"Department",status:"Status",actor:"Actor",cycle:"Cycle",date_start:"Start Date",date_end:"End Date",escalation_level:"Escalation",stage:"Stage",completion_pct:"Completion %",budget:"Budget",starting_date:"Start",ending_date:"End",date:"Date",assigned_to:"Assigned To",type:"Type",entity_type:"Entity",pass_count:"Pass",fail_count:"Fail",unknown_count:"Unknown",total:"Total",cycle_type:"Cycle Type",cost_per_cycle:"Cost/Cycle",total_cycles:"Total Cycles",total_cost:"Total Cost",timestamp:"Timestamp",user:"User",entity_name:"Entity",changes:"Fields Changed"};function M1(e,n){const s=e.map(r=>Bd[r]||r).join(","),l=n.map(r=>e.map(i=>`"${r[i]??""}"`).join(",")).join(`
`);return s+`
`+l}function H1(e,n){const s=new Blob([e],{type:"text/csv"}),l=URL.createObjectURL(s),r=document.createElement("a");r.href=l,r.download=n,r.click(),URL.revokeObjectURL(l)}const Ou=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function G1(e,n,s){const l=e.map(c=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Ou(Bd[c]||c)}</th>`).join(""),r=n.map(c=>`<tr>${e.map(_=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Ou(c[_])}</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>`,o=new Blob(["\uFEFF"+i],{type:"application/vnd.ms-excel"}),d=URL.createObjectURL(o),u=document.createElement("a");u.href=d,u.download=s,u.click(),URL.revokeObjectURL(d)}const oh="report-print-area",Ga="report-print-portal";function K1(){const e=document.getElementById(oh);if(!e)return;const n=document.createElement("div");n.id=Ga,n.innerHTML=e.innerHTML,document.body.appendChild(n);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
#${Ga} { display: none; }
@media print {
#root { display: none !important; }
#${Ga} { display: block !important; }
}
`,document.head.appendChild(s);const l=()=>{n.remove(),s.remove(),window.removeEventListener("afterprint",l)};window.addEventListener("afterprint",l),window.print()}const Lu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Ka={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function Q1({organizations:e,userRole:n}){const s=ne(),l=F1.filter(T=>T.roles.includes(n)),[r,i]=S.useState(""),[o,d]=S.useState(""),[u,c]=S.useState(""),[_,m]=S.useState(""),[y,h]=S.useState(String(new Date().getFullYear())),[b,z]=S.useState([]),[j,f]=S.useState([]),[a,x]=S.useState(!1),[g,C]=S.useState(""),w=l.find(T=>T.id===r);async function p(){if(r){x(!0),C(""),f([]),z([]);try{const T={};o&&(T.organization=o),u&&(T.from_date=u),_&&(T.to_date=_),(w==null?void 0:w.extraFilter)==="year"&&y&&(T.year=y);const A=await Fy(r,T);z(A.columns||[]),f(A.rows||[])}catch(T){C(T.message||"Error running report")}finally{x(!1)}}}const k=(w==null?void 0:w.label)||r;return t.jsxs("div",{children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:l.map(T=>t.jsxs("div",{onClick:()=>i(T.id),style:{background:r===T.id?"#ebf5fb":"white",border:r===T.id?`2px solid ${X.accent}`:"2px solid transparent",borderRadius:10,padding:"14px 16px",cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[t.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:T.label}),t.jsx("div",{style:{fontSize:12,color:"#888"},children:T.description})]},T.id))}),t.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),t.jsxs("select",{style:Lu,value:r,onChange:T=>i(T.target.value),children:[t.jsx("option",{value:"",children:"-- Select Report --"}),l.map(T=>t.jsx("option",{value:T.id,children:T.label},T.id))]})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),t.jsxs("select",{style:Lu,value:o,onChange:T=>d(T.target.value),children:[t.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(T=>t.jsx("option",{value:T.name,children:T.organization_name||T.name},T.name))]})]}),(w==null?void 0:w.extraFilter)==="year"?t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),t.jsx("input",{type:"number",style:{...Ka,width:90},value:y,onChange:T=>h(T.target.value),min:2020,max:2099})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),t.jsx(me,{value:u,onChange:c,style:Ka})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),t.jsx(me,{value:_,onChange:m,style:Ka})]})]}),t.jsx("button",{onClick:p,disabled:!r||a,style:{padding:"9px 20px",borderRadius:8,border:"none",background:X.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:a?s.loading:s.reports.generate}),j.length>0&&t.jsx("button",{onClick:()=>H1(M1(b,j),`${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"}),j.length>0&&t.jsx("button",{onClick:()=>G1(b,j,`${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"}),j.length>0&&t.jsx("button",{onClick:K1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),g&&t.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:g}),j.length>0&&t.jsxs("div",{id:oh,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[t.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontWeight:700,color:"#333"},children:k}),t.jsxs("span",{style:{fontSize:12,color:"#888"},children:[j.length," rows"]})]}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"#f8f9fa"},children:b.map(T=>t.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Bd[T]||T.replace(/_/g," ").toUpperCase()},T))})}),t.jsx("tbody",{children:j.map((T,A)=>t.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:A%2===0?"white":"#fafafa"},children:b.map(Q=>t.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:T[Q]!=null?String(T[Q]):"—"},Q))},A))})]})]}),!a&&j.length===0&&r&&!g&&t.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),l.length===0&&t.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const Rr=()=>new Date().toISOString().split("T")[0],$d=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Y1=()=>new Date().toTimeString().slice(0,5),wn=()=>({name:"",number:"",title:"",organization:"",event_category:"",type:"",incident_class:"",incident_field:"",date:Rr(),time:Y1(),management:"",department:"",section_field:"",branch:"",assigned_to:"",status:"",description:"",summary:"",workflow_state:"New",hses_field:"",priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),dn=()=>({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:Rr(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),cn=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Rr(),ending_date:$d(),assigned_to:"",actor:"",status:"",budget:0,actual_cost:0,currency:"SAR",description:"",notes:"",cycle:"",stage:1,completion_pct:0,escalation_level:0,workflow_state:"Draft",planned:0,priority:"",product_relation:0,entity_scope:"",economy_class:"",hses_field:"",auditor_comment:"",sb_idea:"",cycle_type:"Normal",long_cycle_date_1:"",long_cycle_date_2:"",long_cycle_date_3:"",long_cycle_date_4:""}),li=()=>({name:"",title:"",date_start:Rr(),date_end:$d(),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:""}),Qs=()=>({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}),gs=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),xs=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),ms=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Ys=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Xs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),qs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Js=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Vs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Zs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),el=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),tl=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ri=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),ys=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:Rr(),end_date:$d(),update_window_days:2}),vs=()=>({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}),Yl=()=>({name:"",number:"",auditor:"",manager:"",organization:"",incident_initial_evaluation:0,idea_initial_evaluation:0,status:"Pending",requested_on:"",remarks:""}),X1=new Set(["incidents","incidents-form","ideas","ideas-form"]),q1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),J1=new Set(Jf.flatMap(({id:e})=>[e,`${e}-form`])),V1=new Set(["Admin","Owner","Auditor","Manager"]),Z1=new Set(["Admin","Owner","Auditor","Manager"]),ev=new Set(["Admin","Auditor","Manager"]);function tv({user:e,onLogout:n,darkMode:s,onToggleDark:l}){const r=ne(),i=e.role,o=V1.has(i),d=Z1.has(i),u=ev.has(i),c=v=>v==="users"||v==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!q1.has(v):X1.has(v),_=v=>i==="Employee"&&!!v&&v!=="New",m=o?"dashboard":"inbox",y=v=>v==="dashboard"?o:v==="reports"?d:v==="delegations"||v==="delegations-form"?u:v==="users"||v==="users-form"?i==="Admin":J1.has(v)?i==="Admin"||i==="Auditor":!0,[h,b]=S.useState(()=>{const v=n0(wu());return v&&y(v)?v:m});S.useEffect(()=>{const v=s0(h);window.location.hash!==v&&window.history.pushState(null,"",v)},[h]),S.useEffect(()=>{const v=()=>{const B=wu();b(B&&y(B)?B:m)};return window.addEventListener("popstate",v),()=>window.removeEventListener("popstate",v)},[]);const z=e.custom_organization||"",[j,f]=S.useState(""),[a,x]=S.useState("");S.useEffect(()=>{if(!a)return;const v=setTimeout(()=>x(""),0);return()=>clearTimeout(v)},[a]);const g=(v,B)=>{x(B),b(v)},[C,w]=S.useState(0),[p,k]=S.useState([]),[T,A]=S.useState([]),[Q,J]=S.useState([]),[W,U]=S.useState([]),[I,O]=S.useState([]),[M,H]=S.useState([]),[Y,q]=S.useState([]),[$,Z]=S.useState([]),[pe,be]=S.useState([]),[ie,Ze]=S.useState([]),[dt,K]=S.useState([]),[ae,We]=S.useState([]),[ve,nn]=S.useState([]),[fe,xe]=S.useState([]),[Tt,Ne]=S.useState([]),[L,se]=S.useState([]),[R,Be]=S.useState([]),[ct,F]=S.useState([]),[Pe,Dr]=S.useState([]),[gn,ua]=S.useState({}),[xn,pa]=S.useState([]),[is,Or]=S.useState([]),[N,Et]=S.useState([]),[as,Dn]=S.useState([]),[Ud,dh]=S.useState([]),[fa,ch]=S.useState({}),[ha,uh]=S.useState([]),Lr=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[Fd,Ls]=S.useState(Lr()),[_e,he]=S.useState(!0),[Ge,oe]=S.useState("idle"),[Ke,te]=S.useState(!1),[Md,Hd]=S.useState(!1),[Wr,Gd]=S.useState(null),[ph,fh]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),hh=()=>fh(v=>{const B=!v;return localStorage.setItem("sb_sidebar",B?"1":"0"),B}),[gh,ga]=S.useState(!1),[xh,$e]=S.useState([]),[mh,Ue]=S.useState([]);S.useEffect(()=>{ga(!1),$e([]),Ue([])},[h]);const[mn,yn]=S.useState(wn()),[vn,sn]=S.useState(dn()),[os,ln]=S.useState(cn()),[ds,rn]=S.useState(li()),[Kd,Ws]=S.useState(Qs()),[Qd,cs]=S.useState(gs()),[Yd,us]=S.useState(xs()),[Xd,ps]=S.useState(ms()),[qd,Ns]=S.useState(Ys()),[Jd,Bs]=S.useState(Xs()),[Vd,$s]=S.useState(qs()),[Zd,Us]=S.useState(Js()),[ec,Fs]=S.useState(Vs()),[tc,Ms]=S.useState(Zs()),[nc,Hs]=S.useState(el()),[sc,Gs]=S.useState(tl()),[Dl,Nr]=S.useState(ri()),[lc,fs]=S.useState(ys()),[rc,hs]=S.useState(vs()),[Kt,Ol]=S.useState(Yl()),Nt=async()=>{he(!0);try{const[v,B,ke,bn,On,Re,Nl,pg,fg,hg,gg,xg,mg,yg,vg,jg,bg,Sg,wg,_g,kg,Cg,zg,Ig,Tg,Eg,Ag]=await Promise.all([Ee(D.incidents),Ee(D.organizations),Ee(D.ideas),Ee(D.orders),Ee(D.processes),_y(),Ee(D.managements),Ee(D.departments),Ee(D.branches),Ee(D.incidentTypes),Ee(D.incidentClass),Ee(D.incidentField),Ee(D.ideaTypes),Ee(D.orderTypes),Ee(D.processTypes),Ee(D.incidentStatuses),Ee(D.ideaStatuses),Ee(D.orderStatuses),Ee(D.processStatuses),Iy(),Ty(),Ee(D.cycles),Ee(D.kpiInput),Qy(),Xy(),qy(),Jy()]);k(v||[]),A(B||[]),J(ke||[]),U(bn||[]),O(On||[]),pa(Re||[]),H(Nl||[]),q(pg||[]),Z(fg||[]),be(hg||[]),Ze(gg||[]),K(xg||[]),We(mg||[]),nn(yg||[]),xe(vg||[]),Ne(jg||[]),se(bg||[]),Be(Sg||[]),F(wg||[]),Dr(_g||[]),ua(kg||{}),Or(Cg||[]),Et(zg||[]),Dn(Ig||[]),dh(Tg||[]),ch(Eg||{}),uh(Ag||[])}catch(v){console.error("Error loading data:",v)}he(!1)},ic=async()=>{try{const v=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(v.ok){const B=await v.json();w(Number(B.message)||0)}}catch{}};S.useEffect(()=>{Nt(),ic();const v=setInterval(ic,6e4);return()=>clearInterval(v)},[e.name]);const[ht,jn]=S.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),Te=(v,B,ke)=>{jn({isOpen:!0,doctype:v,name:B,title:ke||B,isDeleting:!1})},ac=v=>{const ke={[D.incidents]:"incidents",[D.ideas]:"ideas",[D.orders]:"orders",[D.processes]:"processes",[D.organizations]:"organizations",[D.managements]:"managements",[D.departments]:"departments",[D.branches]:"branches",[D.cycles]:"cycles",[D.kpiInput]:"kpi-input",[D.incidentTypes]:"incident-types",[D.ideaTypes]:"idea-types",[D.orderTypes]:"order-types",[D.processTypes]:"process-types",[D.incidentStatuses]:"incident-statuses",[D.ideaStatuses]:"idea-statuses",[D.orderStatuses]:"order-statuses",[D.processStatuses]:"process-statuses",[D.groupCompanies]:"group-companies"}[v];ke&&b(ke)},oc=async v=>{jn(B=>({...B,isDeleting:!0}));try{const B=ht.doctype;await Uo(ht.doctype,ht.name,v,!1),jn(ke=>({...ke,isOpen:!1,isDeleting:!1})),alert(r.rtl?"تم نقل السجل إلى المحذوفات بنجاح!":"Record moved to Deleted successfully!"),await Nt(),h.endsWith("-form")&&ac(B)}catch(B){console.error("Delete error:",B),alert((B==null?void 0:B.message)||"Delete failed. Please try again."),jn(ke=>({...ke,isDeleting:!1}))}},dc=async v=>{jn(B=>({...B,isDeleting:!0}));try{const B=ht.doctype;await Uo(ht.doctype,ht.name,v,!0),jn(ke=>({...ke,isOpen:!1,isDeleting:!1})),alert(r.rtl?"تم حذف السجل نهائياً بنجاح!":"Record permanently deleted successfully!"),await Nt(),h.endsWith("-form")&&ac(B)}catch(B){console.error("Permanent delete error:",B),alert((B==null?void 0:B.message)||"Permanent delete failed. Please try again."),jn(ke=>({...ke,isDeleting:!1}))}},Qe=async(v,B)=>{if(window.confirm(r.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){he(!0);try{await wy(v,B),alert(r.restoredOk||"Record restored successfully!"),await Nt()}catch(ke){console.error("Restore error:",ke),alert((ke==null?void 0:ke.message)||"Restore failed. Please try again.")}he(!1)}},yh=async v=>{try{await Ry(v),await Nt()}catch(B){console.error("Disable user error:",B)}},vh=async v=>{te(!0),he(!0);try{const B=await At(D.incidents,v.name);yn({...wn(),...B})}catch{yn({...wn(),...v})}b("incidents-form"),he(!1)},jh=async v=>{te(!0),he(!0);try{const B=await At(D.ideas,v.name);sn({...dn(),...B})}catch{sn({...dn(),...v})}b("ideas-form"),he(!1)},bh=async v=>{te(!0),he(!0);try{const B=await At(D.orders,v.name);ln({...cn(),...B})}catch{ln({...cn(),...v})}b("orders-form"),he(!1)},Sh=async v=>{te(!0),he(!0);try{const B=await Zl(v.name);rn({...B,progress_indicators:B.progress_indicators||[],cycle_logs:B.cycle_logs||[]}),b("processes-form")}catch{rn({...v,progress_indicators:v.progress_indicators||[]}),b("processes-form")}he(!1)},wh=v=>Se(D.organizations,v,Ws,Qs(),"organizations-form",!0),_h=v=>{te(!0),Ls(v),b("group-companies-form")},kh=v=>{te(!1),Ls(v),b("group-companies-form")},Ch=async v=>{te(!0),he(!0);try{const B=await At(D.managements,v.name);cs({...gs(),...B})}catch{cs({...gs(),...v})}b("managements-form"),he(!1)},zh=async v=>{te(!0),he(!0);try{const B=await At(D.departments,v.name);us({...xs(),...B})}catch{us({...xs(),...v})}b("departments-form"),he(!1)},Ih=async v=>{te(!0),he(!0);try{const B=await At(D.branches,v.name);ps({...ms(),...B})}catch{ps({...ms(),...v})}b("branches-form"),he(!1)},Th=async v=>{te(!0),he(!0);try{const B=await At(D.cycles,v.name);fs({...ys(),...B})}catch{fs({...ys(),...v})}b("cycles-form"),he(!1)},Eh=async v=>{te(!0),he(!0);try{const B=await At(D.kpiInput,v.name);hs({...vs(),...B})}catch{hs({...vs(),...v})}b("kpi-input-form"),he(!1)},st=async(v,B,ke,bn,On)=>{oe("loading");try{if(B.name)await Mi(v,B.name,B),oe("success"),Nt(),setTimeout(()=>oe("idle"),1500);else{const Re=await bu(v,B),Nl=(Re==null?void 0:Re.data)??Re;On&&On(Nl),oe("success"),Nt(),setTimeout(()=>oe("idle"),1500)}}catch(Re){console.error("Submit error:",Re),oe(Re instanceof Error?Re.message:"Error saving. Please try again.")}},Fe=async()=>{await Cy(),n()},Se=async(v,B,ke,bn,On,Re)=>{te(Re),he(!0);try{const Nl=await At(v,B.name);ke({...bn,...Nl})}catch{ke({...bn,...B})}b(On),he(!1)},Ah=v=>Se(D.incidents,v,yn,wn(),"incidents-form",!1),Ph=v=>Se(D.ideas,v,sn,dn(),"ideas-form",!1),Rh=v=>Se(D.orders,v,ln,cn(),"orders-form",!1),Dh=v=>{te(!1),he(!0),Zl(v.name).then(B=>{rn({...B,progress_indicators:B.progress_indicators||[],cycle_logs:B.cycle_logs||[]})}).catch(()=>{rn({...v,progress_indicators:v.progress_indicators||[]})}).finally(()=>{b("processes-form"),he(!1)})},Oh=v=>Se(D.organizations,v,Ws,Qs(),"organizations-form",!1),Lh=v=>Se(D.managements,v,cs,gs(),"managements-form",!1),Wh=v=>Se(D.departments,v,us,xs(),"departments-form",!1),Nh=v=>Se(D.branches,v,ps,ms(),"branches-form",!1),Bh=v=>Se(D.cycles,v,fs,ys(),"cycles-form",!1),$h=v=>Se(D.kpiInput,v,hs,vs(),"kpi-input-form",!1),Uh=async v=>{te(!0),he(!0);try{const B=await Yy(v.name);Ol({...Yl(),...B})}catch{Ol({...Yl(),...v})}b("delegations-form"),he(!1)},Fh=async()=>{oe("loading");try{const v=[];Kt.incident_initial_evaluation&&v.push("incident_initial_evaluation"),Kt.idea_initial_evaluation&&v.push("idea_initial_evaluation"),await Hy(Kt.manager,v,Kt.organization,Kt.remarks||"",Kt.incident_name||"",Kt.idea_name||""),Ol(Yl()),oe("success"),Nt(),setTimeout(()=>{oe("idle"),b("delegations")},1500)}catch(v){console.error("Delegation submit error:",v),oe(v instanceof Error?v.message:"Error saving. Please try again.")}},Mh=async v=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){he(!0);try{await Ky(v),await Nt()}catch(B){console.error("Revoke delegation error:",B),alert(B instanceof Error?B.message:"Revoke failed. Please try again.")}he(!1)}},Hh=v=>Se(D.incidentTypes,v,Ns,Ys(),"incident-types-form",!0),Gh=v=>Se(D.incidentTypes,v,Ns,Ys(),"incident-types-form",!1),Kh=v=>Se(D.ideaTypes,v,Bs,Xs(),"idea-types-form",!0),Qh=v=>Se(D.ideaTypes,v,Bs,Xs(),"idea-types-form",!1),Yh=v=>Se(D.orderTypes,v,$s,qs(),"order-types-form",!0),Xh=v=>Se(D.orderTypes,v,$s,qs(),"order-types-form",!1),qh=v=>Se(D.processTypes,v,Us,Js(),"process-types-form",!0),Jh=v=>Se(D.processTypes,v,Us,Js(),"process-types-form",!1),Vh=v=>Se(D.incidentStatuses,v,Fs,Vs(),"incident-statuses-form",!0),Zh=v=>Se(D.incidentStatuses,v,Fs,Vs(),"incident-statuses-form",!1),eg=v=>Se(D.ideaStatuses,v,Ms,Zs(),"idea-statuses-form",!0),tg=v=>Se(D.ideaStatuses,v,Ms,Zs(),"idea-statuses-form",!1),ng=v=>Se(D.orderStatuses,v,Hs,el(),"order-statuses-form",!0),sg=v=>Se(D.orderStatuses,v,Hs,el(),"order-statuses-form",!1),lg=v=>Se(D.processStatuses,v,Gs,tl(),"process-statuses-form",!0),rg=v=>Se(D.processStatuses,v,Gs,tl(),"process-statuses-form",!1),ig=async v=>{Gd(v),b("profile")},ag=v=>{te(!1),Hd(!1),Nr({...ri(),...v}),b("users-form")},og=async()=>{oe("loading");try{if(!Dl.name){const B=await bu("User",{...Dl,send_welcome_email:0,user_type:"System User"});Nr({...ri(),...Dl,...(B==null?void 0:B.data)??B}),te(!0),oe("success"),Nt(),setTimeout(()=>oe("idle"),1500)}else{const{name:B,email:ke,creation:bn,full_name:On,...Re}=Dl;await Mi("User",B,Re),oe("success"),Nt(),setTimeout(()=>oe("idle"),1500)}}catch(v){console.error("User submit error:",v),oe(v instanceof Error?v.message:"Error saving. Please try again.")}},Me=()=>{const v=Pe.find(B=>B.name===e.name||B.username===e.name);Gd(v||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),b("profile")},xa=(v,B)=>{if(B){const bn={"processes-form":D.processes,"orders-form":D.orders,"incidents-form":D.incidents,"ideas-form":D.ideas}[v];if(bn){te(!0),he(!0),(v==="processes-form"?Zl(B).then(Re=>({...Re,progress_indicators:Re.progress_indicators||[],cycle_logs:Re.cycle_logs||[]})):At(bn,B)).then(Re=>{v==="processes-form"?rn(Re):v==="orders-form"?ln({...cn(),...Re}):v==="incidents-form"?yn({...wn(),...Re}):v==="ideas-form"&&sn({...dn(),...Re}),b(v),he(!1)}).catch(()=>{b(v),he(!1)});return}}b(v)},Ye=v=>t.jsxs(t.Fragment,{children:[v,t.jsx(ju,{isOpen:ht.isOpen,doctype:ht.doctype,docname:ht.name,docTitle:ht.title,isAdmin:i==="Admin"||e.name==="Administrator",isDeleting:ht.isDeleting,onClose:()=>jn(B=>({...B,isOpen:!1})),onConfirmSoftDelete:oc,onConfirmPermanentDelete:dc})]});if(h==="incidents-form")return Ye(t.jsx(j0,{incForm:mn,setIncForm:yn,organizations:T,managements:M,departments:Y,branches:$,incidentTypes:pe,incidentClasses:ie,incidentFields:dt,incidentStatuses:Tt,users:xn,userRoleMap:gn,formStatus:Ge,viewMode:Ke||!c("incidents-form")||_(mn.workflow_state),canModify:c("incidents-form"),onEdit:c("incidents-form")&&!_(mn.workflow_state)&&!Hn("incident",mn.workflow_state)?()=>te(!1):void 0,onDelete:c("incidents-form")?v=>Te(D.incidents,v,mn.title||mn.number):void 0,onRestore:i==="Admin"||i==="Auditor"?v=>Qe(D.incidents,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,userRole:i,delegatedFunctions:Ud,delegatedOrgs:fa,onSubmit:()=>st(D.incidents,mn,()=>yn(wn()),"incidents",v=>yn({...wn(),...v})),onBack:()=>{b("incidents"),oe("idle")},onNavigate:b,onLogout:Fe,user:e,onRefresh:async()=>{if(mn.name){const v=await At(D.incidents,mn.name).catch(()=>null);v&&yn({...wn(),...v})}Ee(D.incidents).then(v=>k(v||[])).catch(()=>{})}}));if(h==="ideas-form")return Ye(t.jsx(_0,{ideaForm:vn,setIdeaForm:sn,organizations:T,managements:M,departments:Y,branches:$,ideaTypes:ae,ideaStatuses:L,users:xn,userRoleMap:gn,formStatus:Ge,viewMode:Ke||!c("ideas-form")||_(vn.workflow_state),canModify:c("ideas-form"),onEdit:c("ideas-form")&&!_(vn.workflow_state)&&!Hn("idea",vn.workflow_state)?()=>te(!1):void 0,onDelete:c("ideas-form")?v=>Te(D.ideas,v,vn.title||vn.number):void 0,onRestore:i==="Admin"||i==="Auditor"?v=>Qe(D.ideas,v):void 0,onNavigateToOrder:v=>Se(D.orders,{name:v},ln,cn(),"orders-form",!0),darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,userRole:i,delegatedFunctions:Ud,delegatedOrgs:fa,onSubmit:()=>st(D.ideas,vn,()=>sn(dn()),"ideas",v=>sn({...dn(),...v})),onBack:()=>{b("ideas"),oe("idle")},onNavigate:b,onLogout:Fe,user:e,onRefresh:async()=>{if(vn.name){const v=await At(D.ideas,vn.name).catch(()=>null);v&&sn({...dn(),...v})}Ee(D.ideas).then(v=>J(v||[])).catch(()=>{})}}));if(h==="orders-form")return Ye(t.jsx(T0,{orderForm:os,setOrderForm:ln,organizations:T,managements:M,departments:Y,branches:$,orderTypes:ve,orderStatuses:R,cycles:is,users:xn,userRoleMap:gn,formStatus:Ge,viewMode:Ke||!c("orders-form"),canModify:c("orders-form"),onEdit:c("orders-form")&&!Hn("order",os.workflow_state)?()=>te(!1):void 0,onDelete:c("orders-form")?v=>Te(D.orders,v,os.title||os.number):void 0,onRestore:i==="Admin"||i==="Auditor"?v=>Qe(D.orders,v):void 0,onNavigateToIdea:v=>Se(D.ideas,{name:v},sn,dn(),"ideas-form",!0),darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,currentUser:e.name,userRole:i,onSubmit:()=>st(D.orders,os,()=>ln(cn()),"orders",v=>ln({...cn(),...v})),onBack:()=>{b("orders"),oe("idle")},onNavigate:b,onLogout:Fe,user:e,onRefresh:async()=>{if(os.name){const v=await At(D.orders,os.name).catch(()=>null);v&&ln({...cn(),...v})}Ee(D.orders).then(v=>U(v||[])).catch(()=>{})}}));if(h==="processes-form")return Ye(t.jsx(D0,{processForm:ds,setProcessForm:rn,organizations:T,managements:M,departments:Y,branches:$,processTypes:fe,processStatuses:ct,cycles:is,users:xn,userRoleMap:gn,formStatus:Ge,viewMode:Ke||!c("processes-form"),canModify:c("processes-form"),onEdit:c("processes-form")&&!Hn("process",ds.workflow_state)?()=>te(!1):void 0,onDelete:c("processes-form")?v=>Te(D.processes,v,ds.title||ds.number):void 0,onRestore:i==="Admin"||i==="Auditor"?v=>Qe(D.processes,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,userRole:e.role,onRefreshProcess:async()=>{if(ds.name)try{const v=await Zl(ds.name);rn({...v,progress_indicators:v.progress_indicators||[],cycle_logs:v.cycle_logs||[]})}catch{}Ee(D.processes).then(v=>O(v||[])).catch(()=>{})},onSubmit:()=>st(D.processes,ds,()=>rn(li()),"processes",v=>rn({...li(),...v,progress_indicators:v.progress_indicators||[],cycle_logs:v.cycle_logs||[]})),onBack:()=>{b("processes"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="organizations-form")return Ye(t.jsx($0,{orgForm:Kd,setOrgForm:Ws,groupCompanies:ha,formStatus:Ge,viewMode:Ke||!c("organizations-form"),onEdit:c("organizations-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.organizations,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.organizations,Kd,()=>Ws(Qs()),"organizations",v=>{Ws({...Qs(),...v}),te(!0)}),onBack:()=>{b("organizations"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="managements-form")return Ye(t.jsx(G0,{form:Qd,setForm:cs,organizations:T,formStatus:Ge,viewMode:Ke||!c("managements-form"),onEdit:c("managements-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.managements,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.managements,Qd,()=>cs(gs()),"managements",v=>{cs({...gs(),...v}),te(!0)}),onBack:()=>{b("managements"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="departments-form")return Ye(t.jsx(Y0,{form:Yd,setForm:us,organizations:T,managements:M,formStatus:Ge,viewMode:Ke||!c("departments-form"),onEdit:c("departments-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.departments,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.departments,Yd,()=>us(xs()),"departments",v=>{us({...xs(),...v}),te(!0)}),onBack:()=>{b("departments"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="branches-form")return Ye(t.jsx(J0,{form:Xd,setForm:ps,organizations:T,managements:M,departments:Y,formStatus:Ge,viewMode:Ke||!c("branches-form"),onEdit:c("branches-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.branches,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.branches,Xd,()=>ps(ms()),"branches",v=>{ps({...ms(),...v}),te(!0)}),onBack:()=>{b("branches"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="cycles-form")return Ye(t.jsx(T1,{form:lc,setForm:fs,organizations:T,formStatus:Ge,viewMode:Ke||!c("cycles-form"),onEdit:c("cycles-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.cycles,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.cycles,lc,()=>fs(ys()),"cycles",v=>{fs({...ys(),...v}),te(!0)}),onBack:()=>{b("cycles"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="kpi-input-form")return Ye(t.jsx(A1,{form:rc,setForm:hs,organizations:T,formStatus:Ge,viewMode:Ke||!c("kpi-input-form"),onEdit:c("kpi-input-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.kpiInput,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.kpiInput,rc,()=>hs(vs()),"kpi-input",v=>{hs({...vs(),...v}),te(!0)}),onBack:()=>{b("kpi-input"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="incident-types-form")return Ye(t.jsx(e1,{form:qd,setForm:Ns,formStatus:Ge,viewMode:Ke||!c("incident-types-form"),onEdit:c("incident-types-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.incidentTypes,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.incidentTypes,qd,()=>Ns(Ys()),"incident-types",v=>{Ns({...Ys(),...v}),te(!0)}),onBack:()=>{b("incident-types"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="idea-types-form")return Ye(t.jsx(s1,{form:Jd,setForm:Bs,formStatus:Ge,viewMode:Ke||!c("idea-types-form"),onEdit:c("idea-types-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.ideaTypes,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.ideaTypes,Jd,()=>Bs(Xs()),"idea-types",v=>{Bs({...Xs(),...v}),te(!0)}),onBack:()=>{b("idea-types"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="order-types-form")return Ye(t.jsx(i1,{form:Vd,setForm:$s,formStatus:Ge,viewMode:Ke||!c("order-types-form"),onEdit:c("order-types-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.orderTypes,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.orderTypes,Vd,()=>$s(qs()),"order-types",v=>{$s({...qs(),...v}),te(!0)}),onBack:()=>{b("order-types"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="process-types-form")return Ye(t.jsx(d1,{form:Zd,setForm:Us,formStatus:Ge,viewMode:Ke||!c("process-types-form"),onEdit:c("process-types-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.processTypes,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.processTypes,Zd,()=>Us(Js()),"process-types",v=>{Us({...Js(),...v}),te(!0)}),onBack:()=>{b("process-types"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="incident-statuses-form")return Ye(t.jsx(p1,{form:ec,setForm:Fs,formStatus:Ge,viewMode:Ke||!c("incident-statuses-form"),onEdit:c("incident-statuses-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.incidentStatuses,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.incidentStatuses,ec,()=>Fs(Vs()),"incident-statuses",v=>{Fs({...Vs(),...v}),te(!0)}),onBack:()=>{b("incident-statuses"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="idea-statuses-form")return Ye(t.jsx(g1,{form:tc,setForm:Ms,formStatus:Ge,viewMode:Ke||!c("idea-statuses-form"),onEdit:c("idea-statuses-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.ideaStatuses,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.ideaStatuses,tc,()=>Ms(Zs()),"idea-statuses",v=>{Ms({...Zs(),...v}),te(!0)}),onBack:()=>{b("idea-statuses"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="order-statuses-form")return Ye(t.jsx(y1,{form:nc,setForm:Hs,formStatus:Ge,viewMode:Ke||!c("order-statuses-form"),onEdit:c("order-statuses-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.orderStatuses,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.orderStatuses,nc,()=>Hs(el()),"order-statuses",v=>{Hs({...el(),...v}),te(!0)}),onBack:()=>{b("order-statuses"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="process-statuses-form")return Ye(t.jsx(b1,{form:sc,setForm:Gs,formStatus:Ge,viewMode:Ke||!c("process-statuses-form"),onEdit:c("process-statuses-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.processStatuses,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.processStatuses,sc,()=>Gs(tl()),"process-statuses",v=>{Gs({...tl(),...v}),te(!0)}),onBack:()=>{b("process-statuses"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="users-form")return Ye(t.jsx(k1,{form:Dl,setForm:Nr,groupCompanies:ha,organizations:T,managements:M,departments:Y,branches:$,formStatus:Ge,viewMode:Ke||!c("users-form"),onEdit:c("users-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.users,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,isSelfProfile:Md,onSubmit:og,onBack:()=>{b(Md?o?"dashboard":"inbox":"users"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));if(h==="delegations-form"){const v=Kt.status==="Revoked"||Kt.status==="Accepted"||Kt.status==="Rejected";return Ye(t.jsx(W1,{form:Kt,setForm:Ol,organizations:T,users:xn,userRoleMap:gn,incidents:p,ideas:Q,formStatus:Ge,viewMode:Ke||!c("delegations-form")||v,onEdit:c("delegations-form")&&!v?()=>te(!1):void 0,onRestore:i==="Admin"?B=>Qe(D.delegations,B):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:Fh,onBack:()=>{b("delegations"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}))}if(h==="group-companies-form")return Ye(t.jsx(F0,{form:Fd,setForm:Ls,users:xn,formStatus:Ge,viewMode:Ke||!c("group-companies-form"),onEdit:c("group-companies-form")?()=>te(!1):void 0,onRestore:i==="Admin"?v=>Qe(D.groupCompanies,v):void 0,darkMode:s,notifCount:C,onToggleDark:l,onCountChange:w,onViewProfile:Me,onSubmit:()=>st(D.groupCompanies,Fd,()=>Ls(Lr()),"group-companies",v=>{Ls({...Lr(),...v}),te(!0)}),onBack:()=>{b("group-companies"),oe("idle")},onNavigate:b,onLogout:Fe,user:e}));const ma={...r.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},dg={"group-companies":{color:X.purple,formPage:"group-companies-form",reset:()=>Ls(Lr())},incidents:{color:X.accent,formPage:"incidents-form",reset:()=>yn({...wn(),organization:z||j})},ideas:{color:X.teal,formPage:"ideas-form",reset:()=>sn({...dn(),organization:z||j})},orders:{color:X.purple,formPage:"orders-form",reset:()=>ln({...cn(),organization:z||j})},processes:{color:X.blue,formPage:"processes-form",reset:()=>{const v=fa.create_processes,B=z||(i==="Manager"&&v&&v.length===1?v[0]:j);rn({...li(),organization:B})}},organizations:{color:X.accent,formPage:"organizations-form",reset:()=>Ws(Qs())},managements:{color:X.blue,formPage:"managements-form",reset:()=>cs({...gs(),organization:z||j})},departments:{color:X.teal,formPage:"departments-form",reset:()=>us({...xs(),custom_organization:z||j})},branches:{color:X.purple,formPage:"branches-form",reset:()=>ps({...ms(),organization:z||j})},cycles:{color:X.teal,formPage:"cycles-form",reset:()=>fs({...ys(),organization:z||j})},"kpi-input":{color:X.blue,formPage:"kpi-input-form",reset:()=>hs({...vs(),organization:z||j})},"incident-types":{color:X.red,formPage:"incident-types-form",reset:()=>Ns(Ys())},"idea-types":{color:X.orange,formPage:"idea-types-form",reset:()=>Bs(Xs())},"order-types":{color:X.green,formPage:"order-types-form",reset:()=>$s(qs())},"process-types":{color:X.accent,formPage:"process-types-form",reset:()=>Us(Js())},"incident-statuses":{color:X.red,formPage:"incident-statuses-form",reset:()=>Fs(Vs())},"idea-statuses":{color:X.teal,formPage:"idea-statuses-form",reset:()=>Ms(Zs())},"order-statuses":{color:X.purple,formPage:"order-statuses-form",reset:()=>Hs(el())},"process-statuses":{color:X.blue,formPage:"process-statuses-form",reset:()=>Gs(tl())},users:{color:X.blue,formPage:"users-form",reset:()=>{Nr(ri()),Hd(!1)}},delegations:{color:X.purple,formPage:"delegations-form",reset:()=>Ol(Yl())}},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:p,ideas:Q,orders:W,processes:I,organizations:T,managements:M,departments:Y,branches:$,cycles:is,"kpi-input":N,"incident-types":pe,"idea-types":ae,"order-types":ve,"process-types":fe,"incident-statuses":Tt,"idea-statuses":L,"order-statuses":R,"process-statuses":ct,users:Pe,delegations:as},Ll=ay[h],Wl=ug[h],ee=c(h),ya=ee?dg[h]:null;return t.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":X.bg},children:[t.jsx(nh,{collapsed:ph,onToggleCollapsed:hh,activePage:h,onNavigate:v=>b(v),hasDashboard:o,hasReports:d,hasDelegations:u,role:i,rtl:r.rtl,navLabels:r.nav,settingsLabel:r.nav.settings}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("div",{style:{background:s?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${s?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:s?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:t.jsx(ih,{notifCount:C,darkMode:s,onCountChange:w,onToggleDark:l,onNavigate:xa,onViewProfile:Me,onLogout:Fe,userName:e.full_name||e.name,userRole:i})}),h!=="profile"&&t.jsxs("div",{style:{background:s?"#1e293b":"white",padding:"12px 24px",borderBottom:`1px solid ${s?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:18,fontWeight:700,color:s?"#e2e8f0":"#0f172a"},children:ma[h]||h}),Wl&&t.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Wl.length," ",ma[h]?ma[h].toLowerCase():"records"]})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[Ll&&Wl&&t.jsx("button",{onClick:()=>ga(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:"📊 Export"}),ya&&t.jsxs("button",{onClick:()=>{ya.reset(),te(!1),oe("idle"),b(ya.formPage)},style:{background:"#2563eb",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:["+ ",cg[h]||r.new]})]})]}),Ll&&Wl&&gh&&t.jsx(jy,{title:Ll.label,rows:Wl,selectedRows:xh,pageRows:mh,columns:Ll.columns,defaultColumnKeys:Ll.defaultColumns,filenameBase:h,onClose:()=>ga(!1)}),t.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:h==="profile"?0:"20px 24px",gap:h==="profile"?0:16},children:[_e&&t.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:r.loading}),!_e&&h==="dashboard"&&o&&t.jsx(c0,{incidents:p,ideas:Q,orders:W,processes:I,organizations:T,incidentStatuses:Tt,ideaStatuses:L,orderStatuses:R,processStatuses:ct,selectedOrg:j,onOrgChange:f,onNavigate:xa,onNavigateStatus:g,userRole:i}),!_e&&h==="inbox"&&t.jsx(U1,{onNavigate:xa,onRefresh:Nt}),!_e&&h==="reports"&&d&&t.jsx(Q1,{organizations:T,userRole:i}),!_e&&h==="incidents"&&t.jsx(u0,{incidents:p,organizations:T,departments:Y,branches:$,incidentStatuses:Tt,initialOrg:j,initialStatus:a,onView:vh,onEdit:ee?Ah:void 0,onDelete:ee?v=>Te(D.incidents,v):void 0,canModify:ee,userRole:i,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="ideas"&&t.jsx(b0,{ideas:Q,organizations:T,departments:Y,branches:$,ideaStatuses:L,initialOrg:j,initialStatus:a,onView:jh,onEdit:ee?Ph:void 0,onDelete:ee?v=>Te(D.ideas,v):void 0,canModify:ee,userRole:i,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="orders"&&t.jsx(k0,{orders:W,organizations:T,departments:Y,branches:$,orderStatuses:R,initialOrg:j,initialStatus:a,onView:bh,onEdit:ee?Rh:void 0,onDelete:ee?v=>Te(D.orders,v):void 0,canModify:ee,userRole:i,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="processes"&&t.jsx(E0,{processes:I,organizations:T,departments:Y,branches:$,processStatuses:ct,initialOrg:j,initialStatus:a,onView:Sh,onEdit:ee?Dh:void 0,onDelete:ee?v=>Te(D.processes,v):void 0,canModify:ee,userRole:i,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="organizations"&&t.jsx(B0,{organizations:T,onView:wh,onEdit:ee?Oh:void 0,onDelete:ee?v=>Te(D.organizations,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="group-companies"&&t.jsx(U0,{groupCompanies:ha,onView:_h,onEdit:ee?kh:void 0,onDelete:ee?v=>Te(D.groupCompanies,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="managements"&&t.jsx(H0,{managements:M,onView:Ch,onEdit:ee?Lh:void 0,onDelete:ee?v=>Te(D.managements,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="departments"&&t.jsx(Q0,{departments:Y,managements:M,onView:zh,onEdit:ee?Wh:void 0,onDelete:ee?v=>Te(D.departments,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="branches"&&t.jsx(q0,{branches:$,managements:M,departments:Y,onView:Ih,onEdit:ee?Nh:void 0,onDelete:ee?v=>Te(D.branches,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="cycles"&&t.jsx(C1,{cycles:is,canModify:ee,onView:Th,onEdit:ee?Bh:void 0,onDelete:ee?v=>Te(D.cycles,v):void 0,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="kpi-input"&&t.jsx(E1,{kpiInputs:N,canModify:ee,onView:Eh,onEdit:ee?$h:void 0,onDelete:ee?v=>Te(D.kpiInput,v):void 0,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="incident-types"&&t.jsx(Z0,{incidentTypes:pe,onView:Hh,onEdit:ee?Gh:void 0,onDelete:ee?v=>Te(D.incidentTypes,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="idea-types"&&t.jsx(n1,{ideaTypes:ae,onView:Kh,onEdit:ee?Qh:void 0,onDelete:ee?v=>Te(D.ideaTypes,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="order-types"&&t.jsx(r1,{orderTypes:ve,onView:Yh,onEdit:ee?Xh:void 0,onDelete:ee?v=>Te(D.orderTypes,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="process-types"&&t.jsx(o1,{processTypes:fe,onView:qh,onEdit:ee?Jh:void 0,onDelete:ee?v=>Te(D.processTypes,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="incident-statuses"&&t.jsx(u1,{incidentStatuses:Tt,onView:Vh,onEdit:ee?Zh:void 0,onDelete:ee?v=>Te(D.incidentStatuses,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="idea-statuses"&&t.jsx(h1,{ideaStatuses:L,onView:eg,onEdit:ee?tg:void 0,onDelete:ee?v=>Te(D.ideaStatuses,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="order-statuses"&&t.jsx(m1,{orderStatuses:R,onView:ng,onEdit:ee?sg:void 0,onDelete:ee?v=>Te(D.orderStatuses,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="process-statuses"&&t.jsx(j1,{processStatuses:ct,onView:lg,onEdit:ee?rg:void 0,onDelete:ee?v=>Te(D.processStatuses,v):void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="users"&&t.jsx(_1,{users:Pe,roleMap:gn,onView:ig,onEdit:ee?ag:void 0,onDelete:ee?v=>Te("User",v):void 0,onDisable:ee?yh:void 0,canModify:ee,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),!_e&&h==="delegations"&&u&&t.jsx(O1,{delegations:as,organizations:T,userRole:i,currentUser:e.name,onView:Uh,onRevoke:ee?Mh:void 0,onSelectionChange:(v,B)=>{$e(v),Ue(B)}}),h==="profile"&&(()=>{const v=!!Wr&&(Wr.name===e.name||Wr.email===e.name);return t.jsx(L0,{user:e,profileUser:Wr,sbUsers:Pe,organizations:T,managements:M,departments:Y,branches:$,darkMode:s,canModify:ee||v,onBack:()=>b(v?o?"dashboard":"inbox":"users"),onNavigate:b})})()]})]}),t.jsx(ju,{isOpen:ht.isOpen,doctype:ht.doctype,docname:ht.name,docTitle:ht.title,isAdmin:i==="Admin"||e.name==="Administrator",isDeleting:ht.isDeleting,onClose:()=>jn(v=>({...v,isOpen:!1})),onConfirmSoftDelete:oc,onConfirmPermanentDelete:dc})]})}function nv(e){return e.some(n=>["SB Admin","System Manager"].includes(n))?"Admin":e.includes("SB Manager")?"Manager":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":"Employee"}function sv(){const[e,n]=S.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[s,l]=S.useState(()=>localStorage.getItem("sb_dark")==="1"),r=()=>{const d=!s;l(d),localStorage.setItem("sb_dark",d?"1":"0"),document.documentElement.classList.toggle("dark",d)};S.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),S.useEffect(()=>{e&&sh().then(async d=>{const u=d||e.name,c=await rh(u);if(!c.length)return;const _=nv(c),m=await Wy();if(_!==e.role||u!==e.name||m!==(e.custom_organization||"")){const h={...e,name:u,role:_,custom_organization:m};n(h),localStorage.setItem("sidrah_user",JSON.stringify(h))}})},[e==null?void 0:e.name]);const i=d=>{n(d),localStorage.setItem("sidrah_user",JSON.stringify(d))},o=()=>{n(null),localStorage.removeItem("sidrah_user")};return e?t.jsx(tv,{user:e,onLogout:o,darkMode:s,onToggleDark:r}):t.jsx(l0,{onLogin:i})}qf(document.getElementById("root")).render(t.jsx(S.StrictMode,{children:t.jsx(sv,{})}));