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

53 lines
518 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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

(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function s(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=s(l);fetch(l.href,i)}})();var Uu={exports:{}},Mi={},Fu={exports:{}},de={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var jl=Symbol.for("react.element"),$g=Symbol.for("react.portal"),Ug=Symbol.for("react.fragment"),Fg=Symbol.for("react.strict_mode"),Mg=Symbol.for("react.profiler"),Hg=Symbol.for("react.provider"),Gg=Symbol.for("react.context"),Kg=Symbol.for("react.forward_ref"),Qg=Symbol.for("react.suspense"),Yg=Symbol.for("react.memo"),Xg=Symbol.for("react.lazy"),uc=Symbol.iterator;function qg(e){return e===null||typeof e!="object"?null:(e=uc&&e[uc]||e["@@iterator"],typeof e=="function"?e:null)}var Mu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hu=Object.assign,Gu={};function br(e,t,s){this.props=e,this.context=t,this.refs=Gu,this.updater=s||Mu}br.prototype.isReactComponent={};br.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};br.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Ku(){}Ku.prototype=br.prototype;function Ho(e,t,s){this.props=e,this.context=t,this.refs=Gu,this.updater=s||Mu}var Go=Ho.prototype=new Ku;Go.constructor=Ho;Hu(Go,br.prototype);Go.isPureReactComponent=!0;var pc=Array.isArray,Qu=Object.prototype.hasOwnProperty,Ko={current:null},Yu={key:!0,ref:!0,__self:!0,__source:!0};function Xu(e,t,s){var r,l={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)Qu.call(t,r)&&!Yu.hasOwnProperty(r)&&(l[r]=t[r]);var c=arguments.length-2;if(c===1)l.children=s;else if(1<c){for(var d=Array(c),p=0;p<c;p++)d[p]=arguments[p+2];l.children=d}if(e&&e.defaultProps)for(r in c=e.defaultProps,c)l[r]===void 0&&(l[r]=c[r]);return{$$typeof:jl,type:e,key:i,ref:a,props:l,_owner:Ko.current}}function Jg(e,t){return{$$typeof:jl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Qo(e){return typeof e=="object"&&e!==null&&e.$$typeof===jl}function Vg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var fc=/\/+/g;function xa(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Vg(""+e.key):t.toString(36)}function ri(e,t,s,r,l){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case jl:case $g:a=!0}}if(a)return a=e,l=l(a),e=r===""?"."+xa(a,0):r,pc(l)?(s="",e!=null&&(s=e.replace(fc,"$&/")+"/"),ri(l,t,s,"",function(p){return p})):l!=null&&(Qo(l)&&(l=Jg(l,s+(!l.key||a&&a.key===l.key?"":(""+l.key).replace(fc,"$&/")+"/")+e)),t.push(l)),1;if(a=0,r=r===""?".":r+":",pc(e))for(var c=0;c<e.length;c++){i=e[c];var d=r+xa(i,c);a+=ri(i,t,s,d,l)}else if(d=qg(e),typeof d=="function")for(e=d.call(e),c=0;!(i=e.next()).done;)i=i.value,d=r+xa(i,c++),a+=ri(i,t,s,d,l);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Al(e,t,s){if(e==null)return e;var r=[],l=0;return ri(e,r,"","",function(i){return t.call(s,i,l++)}),r}function Zg(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ht={current:null},li={transition:null},ex={ReactCurrentDispatcher:ht,ReactCurrentBatchConfig:li,ReactCurrentOwner:Ko};function qu(){throw Error("act(...) is not supported in production builds of React.")}de.Children={map:Al,forEach:function(e,t,s){Al(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return Al(e,function(){t++}),t},toArray:function(e){return Al(e,function(t){return t})||[]},only:function(e){if(!Qo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};de.Component=br;de.Fragment=Ug;de.Profiler=Mg;de.PureComponent=Ho;de.StrictMode=Fg;de.Suspense=Qg;de.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ex;de.act=qu;de.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Hu({},e.props),l=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Ko.current),t.key!==void 0&&(l=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(d in t)Qu.call(t,d)&&!Yu.hasOwnProperty(d)&&(r[d]=t[d]===void 0&&c!==void 0?c[d]:t[d])}var d=arguments.length-2;if(d===1)r.children=s;else if(1<d){c=Array(d);for(var p=0;p<d;p++)c[p]=arguments[p+2];r.children=c}return{$$typeof:jl,type:e.type,key:l,ref:i,props:r,_owner:a}};de.createContext=function(e){return e={$$typeof:Gg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Hg,_context:e},e.Consumer=e};de.createElement=Xu;de.createFactory=function(e){var t=Xu.bind(null,e);return t.type=e,t};de.createRef=function(){return{current:null}};de.forwardRef=function(e){return{$$typeof:Kg,render:e}};de.isValidElement=Qo;de.lazy=function(e){return{$$typeof:Xg,_payload:{_status:-1,_result:e},_init:Zg}};de.memo=function(e,t){return{$$typeof:Yg,type:e,compare:t===void 0?null:t}};de.startTransition=function(e){var t=li.transition;li.transition={};try{e()}finally{li.transition=t}};de.unstable_act=qu;de.useCallback=function(e,t){return ht.current.useCallback(e,t)};de.useContext=function(e){return ht.current.useContext(e)};de.useDebugValue=function(){};de.useDeferredValue=function(e){return ht.current.useDeferredValue(e)};de.useEffect=function(e,t){return ht.current.useEffect(e,t)};de.useId=function(){return ht.current.useId()};de.useImperativeHandle=function(e,t,s){return ht.current.useImperativeHandle(e,t,s)};de.useInsertionEffect=function(e,t){return ht.current.useInsertionEffect(e,t)};de.useLayoutEffect=function(e,t){return ht.current.useLayoutEffect(e,t)};de.useMemo=function(e,t){return ht.current.useMemo(e,t)};de.useReducer=function(e,t,s){return ht.current.useReducer(e,t,s)};de.useRef=function(e){return ht.current.useRef(e)};de.useState=function(e){return ht.current.useState(e)};de.useSyncExternalStore=function(e,t,s){return ht.current.useSyncExternalStore(e,t,s)};de.useTransition=function(){return ht.current.useTransition()};de.version="18.3.1";Fu.exports=de;var w=Fu.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 tx=w,nx=Symbol.for("react.element"),sx=Symbol.for("react.fragment"),rx=Object.prototype.hasOwnProperty,lx=tx.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ix={key:!0,ref:!0,__self:!0,__source:!0};function Ju(e,t,s){var r,l={},i=null,a=null;s!==void 0&&(i=""+s),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)rx.call(t,r)&&!ix.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)l[r]===void 0&&(l[r]=t[r]);return{$$typeof:nx,type:e,key:i,ref:a,props:l,_owner:lx.current}}Mi.Fragment=sx;Mi.jsx=Ju;Mi.jsxs=Ju;Uu.exports=Mi;var n=Uu.exports,Vu={exports:{}},zt={},Zu={exports:{}},ep={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(e){function t(L,M){var Y=L.length;L.push(M);e:for(;0<Y;){var Z=Y-1>>>1,V=L[Z];if(0<l(V,M))L[Z]=M,L[Y]=V,Y=Z;else break e}}function s(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var M=L[0],Y=L.pop();if(Y!==M){L[0]=Y;e:for(var Z=0,V=L.length,ke=V>>>1;Z<ke;){var De=2*(Z+1)-1,Ae=L[De],he=De+1,Fe=L[he];if(0>l(Ae,Y))he<V&&0>l(Fe,Ae)?(L[Z]=Fe,L[he]=Y,Z=he):(L[Z]=Ae,L[De]=Y,Z=De);else if(he<V&&0>l(Fe,Y))L[Z]=Fe,L[he]=Y,Z=he;else break e}}return M}function l(L,M){var Y=L.sortIndex-M.sortIndex;return Y!==0?Y:L.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,c=a.now();e.unstable_now=function(){return a.now()-c}}var d=[],p=[],v=1,f=null,u=3,m=!1,j=!1,h=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function o(L){for(var M=s(p);M!==null;){if(M.callback===null)r(p);else if(M.startTime<=L)r(p),M.sortIndex=M.expirationTime,t(d,M);else break;M=s(p)}}function y(L){if(h=!1,o(L),!j)if(s(d)!==null)j=!0,K(_);else{var M=s(p);M!==null&&G(y,M.startTime-L)}}function _(L,M){j=!1,h&&(h=!1,g(C),C=-1),m=!0;var Y=u;try{for(o(M),f=s(d);f!==null&&(!(f.expirationTime>M)||L&&!J());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,u=f.priorityLevel;var V=Z(f.expirationTime<=M);M=e.unstable_now(),typeof V=="function"?f.callback=V:f===s(d)&&r(d),o(M)}else r(d);f=s(d)}if(f!==null)var ke=!0;else{var De=s(p);De!==null&&G(y,De.startTime-M),ke=!1}return ke}finally{f=null,u=Y,m=!1}}var T=!1,A=null,C=-1,R=5,$=-1;function J(){return!(e.unstable_now()-$<R)}function ae(){if(A!==null){var L=e.unstable_now();$=L;var M=!0;try{M=A(!0,L)}finally{M?O():(T=!1,A=null)}}else T=!1}var O;if(typeof x=="function")O=function(){x(ae)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,E=I.port2;I.port1.onmessage=ae,O=function(){E.postMessage(null)}}else O=function(){S(ae,0)};function K(L){A=L,T||(T=!0,O())}function G(L,M){C=S(function(){L(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(L){L.callback=null},e.unstable_continueExecution=function(){j||m||(j=!0,K(_))},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return u},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(L){switch(u){case 1:case 2:case 3:var M=3;break;default:M=u}var Y=u;u=M;try{return L()}finally{u=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(L,M){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var Y=u;u=L;try{return M()}finally{u=Y}},e.unstable_scheduleCallback=function(L,M,Y){var Z=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?Z+Y:Z):Y=Z,L){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=Y+V,L={id:v++,callback:M,priorityLevel:L,startTime:Y,expirationTime:V,sortIndex:-1},Y>Z?(L.sortIndex=Y,t(p,L),s(d)===null&&L===s(p)&&(h?(g(C),C=-1):h=!0,G(y,Y-Z))):(L.sortIndex=V,t(d,L),j||m||(j=!0,K(_))),L},e.unstable_shouldYield=J,e.unstable_wrapCallback=function(L){var M=u;return function(){var Y=u;u=M;try{return L.apply(this,arguments)}finally{u=Y}}}})(ep);Zu.exports=ep;var ax=Zu.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 ox=w,Ct=ax;function U(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var tp=new Set,nl={};function bs(e,t){pr(e,t),pr(e+"Capture",t)}function pr(e,t){for(nl[e]=t,e=0;e<t.length;e++)tp.add(t[e])}var mn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ya=Object.prototype.hasOwnProperty,dx=/^[: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]*$/,hc={},gc={};function cx(e){return Ya.call(gc,e)?!0:Ya.call(hc,e)?!1:dx.test(e)?gc[e]=!0:(hc[e]=!0,!1)}function ux(e,t,s,r){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function px(e,t,s,r){if(t===null||typeof t>"u"||ux(e,t,s,r))return!0;if(r)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function gt(e,t,s,r,l,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var nt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){nt[e]=new gt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];nt[t]=new gt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){nt[e]=new gt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){nt[e]=new gt(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){nt[e]=new gt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){nt[e]=new gt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){nt[e]=new gt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){nt[e]=new gt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){nt[e]=new gt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yo=/[\-:]([a-z])/g;function Xo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);nt[t]=new gt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);nt[t]=new gt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Yo,Xo);nt[t]=new gt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){nt[e]=new gt(e,1,!1,e.toLowerCase(),null,!1,!1)});nt.xlinkHref=new gt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){nt[e]=new gt(e,1,!1,e.toLowerCase(),null,!0,!0)});function qo(e,t,s,r){var l=nt.hasOwnProperty(t)?nt[t]:null;(l!==null?l.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(px(t,s,l,r)&&(s=null),r||l===null?cx(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):l.mustUseProperty?e[l.propertyName]=s===null?l.type===3?!1:"":s:(t=l.attributeName,r=l.attributeNamespace,s===null?e.removeAttribute(t):(l=l.type,s=l===3||l===4&&s===!0?"":""+s,r?e.setAttributeNS(r,t,s):e.setAttribute(t,s))))}var bn=ox.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Rl=Symbol.for("react.element"),Qs=Symbol.for("react.portal"),Ys=Symbol.for("react.fragment"),Jo=Symbol.for("react.strict_mode"),Xa=Symbol.for("react.profiler"),np=Symbol.for("react.provider"),sp=Symbol.for("react.context"),Vo=Symbol.for("react.forward_ref"),qa=Symbol.for("react.suspense"),Ja=Symbol.for("react.suspense_list"),Zo=Symbol.for("react.memo"),Cn=Symbol.for("react.lazy"),rp=Symbol.for("react.offscreen"),xc=Symbol.iterator;function Tr(e){return e===null||typeof e!="object"?null:(e=xc&&e[xc]||e["@@iterator"],typeof e=="function"?e:null)}var Pe=Object.assign,ma;function Fr(e){if(ma===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);ma=t&&t[1]||""}return`
`+ma+e}var ya=!1;function va(e,t){if(!e||ya)return"";ya=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(p){var r=p}Reflect.construct(e,[],t)}else{try{t.call()}catch(p){r=p}e.call(t.prototype)}else{try{throw Error()}catch(p){r=p}e()}}catch(p){if(p&&r&&typeof p.stack=="string"){for(var l=p.stack.split(`
`),i=r.stack.split(`
`),a=l.length-1,c=i.length-1;1<=a&&0<=c&&l[a]!==i[c];)c--;for(;1<=a&&0<=c;a--,c--)if(l[a]!==i[c]){if(a!==1||c!==1)do if(a--,c--,0>c||l[a]!==i[c]){var d=`
`+l[a].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),d}while(1<=a&&0<=c);break}}}finally{ya=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?Fr(e):""}function fx(e){switch(e.tag){case 5:return Fr(e.type);case 16:return Fr("Lazy");case 13:return Fr("Suspense");case 19:return Fr("SuspenseList");case 0:case 2:case 15:return e=va(e.type,!1),e;case 11:return e=va(e.type.render,!1),e;case 1:return e=va(e.type,!0),e;default:return""}}function Va(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 Ys:return"Fragment";case Qs:return"Portal";case Xa:return"Profiler";case Jo:return"StrictMode";case qa:return"Suspense";case Ja:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case sp:return(e.displayName||"Context")+".Consumer";case np:return(e._context.displayName||"Context")+".Provider";case Vo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Zo:return t=e.displayName||null,t!==null?t:Va(e.type)||"Memo";case Cn:t=e._payload,e=e._init;try{return Va(e(t))}catch{}}return null}function hx(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Va(t);case 8:return t===Jo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Fn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function lp(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function gx(e){var t=lp(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var l=s.get,i=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ll(e){e._valueTracker||(e._valueTracker=gx(e))}function ip(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=lp(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function mi(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 Za(e,t){var s=t.checked;return Pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function mc(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=Fn(t.value!=null?t.value:s),e._wrapperState={initialChecked:r,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function ap(e,t){t=t.checked,t!=null&&qo(e,"checked",t,!1)}function eo(e,t){ap(e,t);var s=Fn(t.value),r=t.type;if(s!=null)r==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?to(e,t.type,s):t.hasOwnProperty("defaultValue")&&to(e,t.type,Fn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function yc(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function to(e,t,s){(t!=="number"||mi(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Mr=Array.isArray;function ir(e,t,s,r){if(e=e.options,t){t={};for(var l=0;l<s.length;l++)t["$"+s[l]]=!0;for(s=0;s<e.length;s++)l=t.hasOwnProperty("$"+e[s].value),e[s].selected!==l&&(e[s].selected=l),l&&r&&(e[s].defaultSelected=!0)}else{for(s=""+Fn(s),t=null,l=0;l<e.length;l++){if(e[l].value===s){e[l].selected=!0,r&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function no(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(U(91));return Pe({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function vc(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(U(92));if(Mr(s)){if(1<s.length)throw Error(U(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:Fn(s)}}function op(e,t){var s=Fn(t.value),r=Fn(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),r!=null&&(e.defaultValue=""+r)}function jc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function dp(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 so(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?dp(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ol,cp=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,s,r,l)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Ol=Ol||document.createElement("div"),Ol.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Ol.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function sl(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Qr={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},xx=["Webkit","ms","Moz","O"];Object.keys(Qr).forEach(function(e){xx.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Qr[t]=Qr[e]})});function up(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||Qr.hasOwnProperty(e)&&Qr[e]?(""+t).trim():t+"px"}function pp(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,l=up(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,l):e[s]=l}}var mx=Pe({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 ro(e,t){if(t){if(mx[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(U(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(U(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(U(61))}if(t.style!=null&&typeof t.style!="object")throw Error(U(62))}}function lo(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var io=null;function ed(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ao=null,ar=null,or=null;function bc(e){if(e=wl(e)){if(typeof ao!="function")throw Error(U(280));var t=e.stateNode;t&&(t=Yi(t),ao(e.stateNode,e.type,t))}}function fp(e){ar?or?or.push(e):or=[e]:ar=e}function hp(){if(ar){var e=ar,t=or;if(or=ar=null,bc(e),t)for(e=0;e<t.length;e++)bc(t[e])}}function gp(e,t){return e(t)}function xp(){}var ja=!1;function mp(e,t,s){if(ja)return e(t,s);ja=!0;try{return gp(e,t,s)}finally{ja=!1,(ar!==null||or!==null)&&(xp(),hp())}}function rl(e,t){var s=e.stateNode;if(s===null)return null;var r=Yi(s);if(r===null)return null;s=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(U(231,t,typeof s));return s}var oo=!1;if(mn)try{var Ir={};Object.defineProperty(Ir,"passive",{get:function(){oo=!0}}),window.addEventListener("test",Ir,Ir),window.removeEventListener("test",Ir,Ir)}catch{oo=!1}function yx(e,t,s,r,l,i,a,c,d){var p=Array.prototype.slice.call(arguments,3);try{t.apply(s,p)}catch(v){this.onError(v)}}var Yr=!1,yi=null,vi=!1,co=null,vx={onError:function(e){Yr=!0,yi=e}};function jx(e,t,s,r,l,i,a,c,d){Yr=!1,yi=null,yx.apply(vx,arguments)}function bx(e,t,s,r,l,i,a,c,d){if(jx.apply(this,arguments),Yr){if(Yr){var p=yi;Yr=!1,yi=null}else throw Error(U(198));vi||(vi=!0,co=p)}}function Ss(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function yp(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Sc(e){if(Ss(e)!==e)throw Error(U(188))}function Sx(e){var t=e.alternate;if(!t){if(t=Ss(e),t===null)throw Error(U(188));return t!==e?null:e}for(var s=e,r=t;;){var l=s.return;if(l===null)break;var i=l.alternate;if(i===null){if(r=l.return,r!==null){s=r;continue}break}if(l.child===i.child){for(i=l.child;i;){if(i===s)return Sc(l),e;if(i===r)return Sc(l),t;i=i.sibling}throw Error(U(188))}if(s.return!==r.return)s=l,r=i;else{for(var a=!1,c=l.child;c;){if(c===s){a=!0,s=l,r=i;break}if(c===r){a=!0,r=l,s=i;break}c=c.sibling}if(!a){for(c=i.child;c;){if(c===s){a=!0,s=i,r=l;break}if(c===r){a=!0,r=i,s=l;break}c=c.sibling}if(!a)throw Error(U(189))}}if(s.alternate!==r)throw Error(U(190))}if(s.tag!==3)throw Error(U(188));return s.stateNode.current===s?e:t}function vp(e){return e=Sx(e),e!==null?jp(e):null}function jp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=jp(e);if(t!==null)return t;e=e.sibling}return null}var bp=Ct.unstable_scheduleCallback,wc=Ct.unstable_cancelCallback,wx=Ct.unstable_shouldYield,kx=Ct.unstable_requestPaint,Be=Ct.unstable_now,_x=Ct.unstable_getCurrentPriorityLevel,td=Ct.unstable_ImmediatePriority,Sp=Ct.unstable_UserBlockingPriority,ji=Ct.unstable_NormalPriority,Cx=Ct.unstable_LowPriority,wp=Ct.unstable_IdlePriority,Hi=null,tn=null;function zx(e){if(tn&&typeof tn.onCommitFiberRoot=="function")try{tn.onCommitFiberRoot(Hi,e,void 0,(e.current.flags&128)===128)}catch{}}var Mt=Math.clz32?Math.clz32:Ex,Tx=Math.log,Ix=Math.LN2;function Ex(e){return e>>>=0,e===0?32:31-(Tx(e)/Ix|0)|0}var Dl=64,Nl=4194304;function Hr(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 bi(e,t){var s=e.pendingLanes;if(s===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,a=s&268435455;if(a!==0){var c=a&~l;c!==0?r=Hr(c):(i&=a,i!==0&&(r=Hr(i)))}else a=s&~l,a!==0?r=Hr(a):i!==0&&(r=Hr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)s=31-Mt(t),l=1<<s,r|=e[s],t&=~l;return r}function Px(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ax(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Mt(i),c=1<<a,d=l[a];d===-1?(!(c&s)||c&r)&&(l[a]=Px(c,t)):d<=t&&(e.expiredLanes|=c),i&=~c}}function uo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function kp(){var e=Dl;return Dl<<=1,!(Dl&4194240)&&(Dl=64),e}function ba(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function bl(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Mt(t),e[t]=s}function Rx(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<s;){var l=31-Mt(s),i=1<<l;t[l]=0,r[l]=-1,e[l]=-1,s&=~i}}function nd(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-Mt(s),l=1<<r;l&t|e[r]&t&&(e[r]|=t),s&=~l}}var ge=0;function _p(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Cp,sd,zp,Tp,Ip,po=!1,Wl=[],Ln=null,On=null,Dn=null,ll=new Map,il=new Map,Tn=[],Lx="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 kc(e,t){switch(e){case"focusin":case"focusout":Ln=null;break;case"dragenter":case"dragleave":On=null;break;case"mouseover":case"mouseout":Dn=null;break;case"pointerover":case"pointerout":ll.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":il.delete(t.pointerId)}}function Er(e,t,s,r,l,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:s,eventSystemFlags:r,nativeEvent:i,targetContainers:[l]},t!==null&&(t=wl(t),t!==null&&sd(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,l!==null&&t.indexOf(l)===-1&&t.push(l),e)}function Ox(e,t,s,r,l){switch(t){case"focusin":return Ln=Er(Ln,e,t,s,r,l),!0;case"dragenter":return On=Er(On,e,t,s,r,l),!0;case"mouseover":return Dn=Er(Dn,e,t,s,r,l),!0;case"pointerover":var i=l.pointerId;return ll.set(i,Er(ll.get(i)||null,e,t,s,r,l)),!0;case"gotpointercapture":return i=l.pointerId,il.set(i,Er(il.get(i)||null,e,t,s,r,l)),!0}return!1}function Ep(e){var t=cs(e.target);if(t!==null){var s=Ss(t);if(s!==null){if(t=s.tag,t===13){if(t=yp(s),t!==null){e.blockedOn=t,Ip(e.priority,function(){zp(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ii(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=fo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);io=r,s.target.dispatchEvent(r),io=null}else return t=wl(s),t!==null&&sd(t),e.blockedOn=s,!1;t.shift()}return!0}function _c(e,t,s){ii(e)&&s.delete(t)}function Dx(){po=!1,Ln!==null&&ii(Ln)&&(Ln=null),On!==null&&ii(On)&&(On=null),Dn!==null&&ii(Dn)&&(Dn=null),ll.forEach(_c),il.forEach(_c)}function Pr(e,t){e.blockedOn===t&&(e.blockedOn=null,po||(po=!0,Ct.unstable_scheduleCallback(Ct.unstable_NormalPriority,Dx)))}function al(e){function t(l){return Pr(l,e)}if(0<Wl.length){Pr(Wl[0],e);for(var s=1;s<Wl.length;s++){var r=Wl[s];r.blockedOn===e&&(r.blockedOn=null)}}for(Ln!==null&&Pr(Ln,e),On!==null&&Pr(On,e),Dn!==null&&Pr(Dn,e),ll.forEach(t),il.forEach(t),s=0;s<Tn.length;s++)r=Tn[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<Tn.length&&(s=Tn[0],s.blockedOn===null);)Ep(s),s.blockedOn===null&&Tn.shift()}var dr=bn.ReactCurrentBatchConfig,Si=!0;function Nx(e,t,s,r){var l=ge,i=dr.transition;dr.transition=null;try{ge=1,rd(e,t,s,r)}finally{ge=l,dr.transition=i}}function Wx(e,t,s,r){var l=ge,i=dr.transition;dr.transition=null;try{ge=4,rd(e,t,s,r)}finally{ge=l,dr.transition=i}}function rd(e,t,s,r){if(Si){var l=fo(e,t,s,r);if(l===null)Pa(e,t,r,wi,s),kc(e,r);else if(Ox(l,e,t,s,r))r.stopPropagation();else if(kc(e,r),t&4&&-1<Lx.indexOf(e)){for(;l!==null;){var i=wl(l);if(i!==null&&Cp(i),i=fo(e,t,s,r),i===null&&Pa(e,t,r,wi,s),i===l)break;l=i}l!==null&&r.stopPropagation()}else Pa(e,t,r,null,s)}}var wi=null;function fo(e,t,s,r){if(wi=null,e=ed(r),e=cs(e),e!==null)if(t=Ss(e),t===null)e=null;else if(s=t.tag,s===13){if(e=yp(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return wi=e,null}function Pp(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(_x()){case td:return 1;case Sp:return 4;case ji:case Cx:return 16;case wp:return 536870912;default:return 16}default:return 16}}var En=null,ld=null,ai=null;function Ap(){if(ai)return ai;var e,t=ld,s=t.length,r,l="value"in En?En.value:En.textContent,i=l.length;for(e=0;e<s&&t[e]===l[e];e++);var a=s-e;for(r=1;r<=a&&t[s-r]===l[i-r];r++);return ai=l.slice(e,1<r?1-r:void 0)}function oi(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Bl(){return!0}function Cc(){return!1}function Tt(e){function t(s,r,l,i,a){this._reactName=s,this._targetInst=l,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var c in e)e.hasOwnProperty(c)&&(s=e[c],this[c]=s?s(i):i[c]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Bl:Cc,this.isPropagationStopped=Cc,this}return Pe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Bl)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Bl)},persist:function(){},isPersistent:Bl}),t}var Sr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},id=Tt(Sr),Sl=Pe({},Sr,{view:0,detail:0}),Bx=Tt(Sl),Sa,wa,Ar,Gi=Pe({},Sl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ad,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!==Ar&&(Ar&&e.type==="mousemove"?(Sa=e.screenX-Ar.screenX,wa=e.screenY-Ar.screenY):wa=Sa=0,Ar=e),Sa)},movementY:function(e){return"movementY"in e?e.movementY:wa}}),zc=Tt(Gi),$x=Pe({},Gi,{dataTransfer:0}),Ux=Tt($x),Fx=Pe({},Sl,{relatedTarget:0}),ka=Tt(Fx),Mx=Pe({},Sr,{animationName:0,elapsedTime:0,pseudoElement:0}),Hx=Tt(Mx),Gx=Pe({},Sr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Kx=Tt(Gx),Qx=Pe({},Sr,{data:0}),Tc=Tt(Qx),Yx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xx={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"},qx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Jx(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=qx[e])?!!t[e]:!1}function ad(){return Jx}var Vx=Pe({},Sl,{key:function(e){if(e.key){var t=Yx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=oi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Xx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ad,charCode:function(e){return e.type==="keypress"?oi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?oi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Zx=Tt(Vx),em=Pe({},Gi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ic=Tt(em),tm=Pe({},Sl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ad}),nm=Tt(tm),sm=Pe({},Sr,{propertyName:0,elapsedTime:0,pseudoElement:0}),rm=Tt(sm),lm=Pe({},Gi,{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}),im=Tt(lm),am=[9,13,27,32],od=mn&&"CompositionEvent"in window,Xr=null;mn&&"documentMode"in document&&(Xr=document.documentMode);var om=mn&&"TextEvent"in window&&!Xr,Rp=mn&&(!od||Xr&&8<Xr&&11>=Xr),Ec=" ",Pc=!1;function Lp(e,t){switch(e){case"keyup":return am.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Op(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xs=!1;function dm(e,t){switch(e){case"compositionend":return Op(t);case"keypress":return t.which!==32?null:(Pc=!0,Ec);case"textInput":return e=t.data,e===Ec&&Pc?null:e;default:return null}}function cm(e,t){if(Xs)return e==="compositionend"||!od&&Lp(e,t)?(e=Ap(),ai=ld=En=null,Xs=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Rp&&t.locale!=="ko"?null:t.data;default:return null}}var um={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 t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!um[e.type]:t==="textarea"}function Dp(e,t,s,r){fp(r),t=ki(t,"onChange"),0<t.length&&(s=new id("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var qr=null,ol=null;function pm(e){Qp(e,0)}function Ki(e){var t=Vs(e);if(ip(t))return e}function fm(e,t){if(e==="change")return t}var Np=!1;if(mn){var _a;if(mn){var Ca="oninput"in document;if(!Ca){var Rc=document.createElement("div");Rc.setAttribute("oninput","return;"),Ca=typeof Rc.oninput=="function"}_a=Ca}else _a=!1;Np=_a&&(!document.documentMode||9<document.documentMode)}function Lc(){qr&&(qr.detachEvent("onpropertychange",Wp),ol=qr=null)}function Wp(e){if(e.propertyName==="value"&&Ki(ol)){var t=[];Dp(t,ol,e,ed(e)),mp(pm,t)}}function hm(e,t,s){e==="focusin"?(Lc(),qr=t,ol=s,qr.attachEvent("onpropertychange",Wp)):e==="focusout"&&Lc()}function gm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ki(ol)}function xm(e,t){if(e==="click")return Ki(t)}function mm(e,t){if(e==="input"||e==="change")return Ki(t)}function ym(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Gt=typeof Object.is=="function"?Object.is:ym;function dl(e,t){if(Gt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(r=0;r<s.length;r++){var l=s[r];if(!Ya.call(t,l)||!Gt(e[l],t[l]))return!1}return!0}function Oc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Dc(e,t){var s=Oc(e);e=0;for(var r;s;){if(s.nodeType===3){if(r=e+s.textContent.length,e<=t&&r>=t)return{node:s,offset:t-e};e=r}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Oc(s)}}function Bp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Bp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function $p(){for(var e=window,t=mi();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=mi(e.document)}return t}function dd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function vm(e){var t=$p(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Bp(s.ownerDocument.documentElement,s)){if(r!==null&&dd(s)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=s.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=Dc(s,i);var a=Dc(s,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var jm=mn&&"documentMode"in document&&11>=document.documentMode,qs=null,ho=null,Jr=null,go=!1;function Nc(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;go||qs==null||qs!==mi(r)||(r=qs,"selectionStart"in r&&dd(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Jr&&dl(Jr,r)||(Jr=r,r=ki(ho,"onSelect"),0<r.length&&(t=new id("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=qs)))}function $l(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Js={animationend:$l("Animation","AnimationEnd"),animationiteration:$l("Animation","AnimationIteration"),animationstart:$l("Animation","AnimationStart"),transitionend:$l("Transition","TransitionEnd")},za={},Up={};mn&&(Up=document.createElement("div").style,"AnimationEvent"in window||(delete Js.animationend.animation,delete Js.animationiteration.animation,delete Js.animationstart.animation),"TransitionEvent"in window||delete Js.transitionend.transition);function Qi(e){if(za[e])return za[e];if(!Js[e])return e;var t=Js[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Up)return za[e]=t[s];return e}var Fp=Qi("animationend"),Mp=Qi("animationiteration"),Hp=Qi("animationstart"),Gp=Qi("transitionend"),Kp=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 Gn(e,t){Kp.set(e,t),bs(t,[e])}for(var Ta=0;Ta<Wc.length;Ta++){var Ia=Wc[Ta],bm=Ia.toLowerCase(),Sm=Ia[0].toUpperCase()+Ia.slice(1);Gn(bm,"on"+Sm)}Gn(Fp,"onAnimationEnd");Gn(Mp,"onAnimationIteration");Gn(Hp,"onAnimationStart");Gn("dblclick","onDoubleClick");Gn("focusin","onFocus");Gn("focusout","onBlur");Gn(Gp,"onTransitionEnd");pr("onMouseEnter",["mouseout","mouseover"]);pr("onMouseLeave",["mouseout","mouseover"]);pr("onPointerEnter",["pointerout","pointerover"]);pr("onPointerLeave",["pointerout","pointerover"]);bs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));bs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));bs("onBeforeInput",["compositionend","keypress","textInput","paste"]);bs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));bs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));bs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gr="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(" "),wm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Gr));function Bc(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,bx(r,t,void 0,e),e.currentTarget=null}function Qp(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var r=e[s],l=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var c=r[a],d=c.instance,p=c.currentTarget;if(c=c.listener,d!==i&&l.isPropagationStopped())break e;Bc(l,c,p),i=d}else for(a=0;a<r.length;a++){if(c=r[a],d=c.instance,p=c.currentTarget,c=c.listener,d!==i&&l.isPropagationStopped())break e;Bc(l,c,p),i=d}}}if(vi)throw e=co,vi=!1,co=null,e}function be(e,t){var s=t[jo];s===void 0&&(s=t[jo]=new Set);var r=e+"__bubble";s.has(r)||(Yp(t,e,2,!1),s.add(r))}function Ea(e,t,s){var r=0;t&&(r|=4),Yp(s,e,r,t)}var Ul="_reactListening"+Math.random().toString(36).slice(2);function cl(e){if(!e[Ul]){e[Ul]=!0,tp.forEach(function(s){s!=="selectionchange"&&(wm.has(s)||Ea(s,!1,e),Ea(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ul]||(t[Ul]=!0,Ea("selectionchange",!1,t))}}function Yp(e,t,s,r){switch(Pp(t)){case 1:var l=Nx;break;case 4:l=Wx;break;default:l=rd}s=l.bind(null,t,s,e),l=void 0,!oo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(l=!0),r?l!==void 0?e.addEventListener(t,s,{capture:!0,passive:l}):e.addEventListener(t,s,!0):l!==void 0?e.addEventListener(t,s,{passive:l}):e.addEventListener(t,s,!1)}function Pa(e,t,s,r,l){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var c=r.stateNode.containerInfo;if(c===l||c.nodeType===8&&c.parentNode===l)break;if(a===4)for(a=r.return;a!==null;){var d=a.tag;if((d===3||d===4)&&(d=a.stateNode.containerInfo,d===l||d.nodeType===8&&d.parentNode===l))return;a=a.return}for(;c!==null;){if(a=cs(c),a===null)return;if(d=a.tag,d===5||d===6){r=i=a;continue e}c=c.parentNode}}r=r.return}mp(function(){var p=i,v=ed(s),f=[];e:{var u=Kp.get(e);if(u!==void 0){var m=id,j=e;switch(e){case"keypress":if(oi(s)===0)break e;case"keydown":case"keyup":m=Zx;break;case"focusin":j="focus",m=ka;break;case"focusout":j="blur",m=ka;break;case"beforeblur":case"afterblur":m=ka;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":m=zc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=Ux;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=nm;break;case Fp:case Mp:case Hp:m=Hx;break;case Gp:m=rm;break;case"scroll":m=Bx;break;case"wheel":m=im;break;case"copy":case"cut":case"paste":m=Kx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=Ic}var h=(t&4)!==0,S=!h&&e==="scroll",g=h?u!==null?u+"Capture":null:u;h=[];for(var x=p,o;x!==null;){o=x;var y=o.stateNode;if(o.tag===5&&y!==null&&(o=y,g!==null&&(y=rl(x,g),y!=null&&h.push(ul(x,y,o)))),S)break;x=x.return}0<h.length&&(u=new m(u,j,null,s,v),f.push({event:u,listeners:h}))}}if(!(t&7)){e:{if(u=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",u&&s!==io&&(j=s.relatedTarget||s.fromElement)&&(cs(j)||j[yn]))break e;if((m||u)&&(u=v.window===v?v:(u=v.ownerDocument)?u.defaultView||u.parentWindow:window,m?(j=s.relatedTarget||s.toElement,m=p,j=j?cs(j):null,j!==null&&(S=Ss(j),j!==S||j.tag!==5&&j.tag!==6)&&(j=null)):(m=null,j=p),m!==j)){if(h=zc,y="onMouseLeave",g="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(h=Ic,y="onPointerLeave",g="onPointerEnter",x="pointer"),S=m==null?u:Vs(m),o=j==null?u:Vs(j),u=new h(y,x+"leave",m,s,v),u.target=S,u.relatedTarget=o,y=null,cs(v)===p&&(h=new h(g,x+"enter",j,s,v),h.target=o,h.relatedTarget=S,y=h),S=y,m&&j)t:{for(h=m,g=j,x=0,o=h;o;o=Ns(o))x++;for(o=0,y=g;y;y=Ns(y))o++;for(;0<x-o;)h=Ns(h),x--;for(;0<o-x;)g=Ns(g),o--;for(;x--;){if(h===g||g!==null&&h===g.alternate)break t;h=Ns(h),g=Ns(g)}h=null}else h=null;m!==null&&$c(f,u,m,h,!1),j!==null&&S!==null&&$c(f,S,j,h,!0)}}e:{if(u=p?Vs(p):window,m=u.nodeName&&u.nodeName.toLowerCase(),m==="select"||m==="input"&&u.type==="file")var _=fm;else if(Ac(u))if(Np)_=mm;else{_=gm;var T=hm}else(m=u.nodeName)&&m.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(_=xm);if(_&&(_=_(e,p))){Dp(f,_,s,v);break e}T&&T(e,u,p),e==="focusout"&&(T=u._wrapperState)&&T.controlled&&u.type==="number"&&to(u,"number",u.value)}switch(T=p?Vs(p):window,e){case"focusin":(Ac(T)||T.contentEditable==="true")&&(qs=T,ho=p,Jr=null);break;case"focusout":Jr=ho=qs=null;break;case"mousedown":go=!0;break;case"contextmenu":case"mouseup":case"dragend":go=!1,Nc(f,s,v);break;case"selectionchange":if(jm)break;case"keydown":case"keyup":Nc(f,s,v)}var A;if(od)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Xs?Lp(e,s)&&(C="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(C="onCompositionStart");C&&(Rp&&s.locale!=="ko"&&(Xs||C!=="onCompositionStart"?C==="onCompositionEnd"&&Xs&&(A=Ap()):(En=v,ld="value"in En?En.value:En.textContent,Xs=!0)),T=ki(p,C),0<T.length&&(C=new Tc(C,e,null,s,v),f.push({event:C,listeners:T}),A?C.data=A:(A=Op(s),A!==null&&(C.data=A)))),(A=om?dm(e,s):cm(e,s))&&(p=ki(p,"onBeforeInput"),0<p.length&&(v=new Tc("onBeforeInput","beforeinput",null,s,v),f.push({event:v,listeners:p}),v.data=A))}Qp(f,t)})}function ul(e,t,s){return{instance:e,listener:t,currentTarget:s}}function ki(e,t){for(var s=t+"Capture",r=[];e!==null;){var l=e,i=l.stateNode;l.tag===5&&i!==null&&(l=i,i=rl(e,s),i!=null&&r.unshift(ul(e,i,l)),i=rl(e,t),i!=null&&r.push(ul(e,i,l))),e=e.return}return r}function Ns(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function $c(e,t,s,r,l){for(var i=t._reactName,a=[];s!==null&&s!==r;){var c=s,d=c.alternate,p=c.stateNode;if(d!==null&&d===r)break;c.tag===5&&p!==null&&(c=p,l?(d=rl(s,i),d!=null&&a.unshift(ul(s,d,c))):l||(d=rl(s,i),d!=null&&a.push(ul(s,d,c)))),s=s.return}a.length!==0&&e.push({event:t,listeners:a})}var km=/\r\n?/g,_m=/\u0000|\uFFFD/g;function Uc(e){return(typeof e=="string"?e:""+e).replace(km,`
`).replace(_m,"")}function Fl(e,t,s){if(t=Uc(t),Uc(e)!==t&&s)throw Error(U(425))}function _i(){}var xo=null,mo=null;function yo(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var vo=typeof setTimeout=="function"?setTimeout:void 0,Cm=typeof clearTimeout=="function"?clearTimeout:void 0,Fc=typeof Promise=="function"?Promise:void 0,zm=typeof queueMicrotask=="function"?queueMicrotask:typeof Fc<"u"?function(e){return Fc.resolve(null).then(e).catch(Tm)}:vo;function Tm(e){setTimeout(function(){throw e})}function Aa(e,t){var s=t,r=0;do{var l=s.nextSibling;if(e.removeChild(s),l&&l.nodeType===8)if(s=l.data,s==="/$"){if(r===0){e.removeChild(l),al(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=l}while(s);al(t)}function Nn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Mc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var wr=Math.random().toString(36).slice(2),en="__reactFiber$"+wr,pl="__reactProps$"+wr,yn="__reactContainer$"+wr,jo="__reactEvents$"+wr,Im="__reactListeners$"+wr,Em="__reactHandles$"+wr;function cs(e){var t=e[en];if(t)return t;for(var s=e.parentNode;s;){if(t=s[yn]||s[en]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=Mc(e);e!==null;){if(s=e[en])return s;e=Mc(e)}return t}e=s,s=e.parentNode}return null}function wl(e){return e=e[en]||e[yn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Vs(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(U(33))}function Yi(e){return e[pl]||null}var bo=[],Zs=-1;function Kn(e){return{current:e}}function Se(e){0>Zs||(e.current=bo[Zs],bo[Zs]=null,Zs--)}function ve(e,t){Zs++,bo[Zs]=e.current,e.current=t}var Mn={},ot=Kn(Mn),yt=Kn(!1),gs=Mn;function fr(e,t){var s=e.type.contextTypes;if(!s)return Mn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in s)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function vt(e){return e=e.childContextTypes,e!=null}function Ci(){Se(yt),Se(ot)}function Hc(e,t,s){if(ot.current!==Mn)throw Error(U(168));ve(ot,t),ve(yt,s)}function Xp(e,t,s){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return s;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(U(108,hx(e)||"Unknown",l));return Pe({},s,r)}function zi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Mn,gs=ot.current,ve(ot,e),ve(yt,yt.current),!0}function Gc(e,t,s){var r=e.stateNode;if(!r)throw Error(U(169));s?(e=Xp(e,t,gs),r.__reactInternalMemoizedMergedChildContext=e,Se(yt),Se(ot),ve(ot,e)):Se(yt),ve(yt,s)}var fn=null,Xi=!1,Ra=!1;function qp(e){fn===null?fn=[e]:fn.push(e)}function Pm(e){Xi=!0,qp(e)}function Qn(){if(!Ra&&fn!==null){Ra=!0;var e=0,t=ge;try{var s=fn;for(ge=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}fn=null,Xi=!1}catch(l){throw fn!==null&&(fn=fn.slice(e+1)),bp(td,Qn),l}finally{ge=t,Ra=!1}}return null}var er=[],tr=0,Ti=null,Ii=0,It=[],Et=0,xs=null,hn=1,gn="";function os(e,t){er[tr++]=Ii,er[tr++]=Ti,Ti=e,Ii=t}function Jp(e,t,s){It[Et++]=hn,It[Et++]=gn,It[Et++]=xs,xs=e;var r=hn;e=gn;var l=32-Mt(r)-1;r&=~(1<<l),s+=1;var i=32-Mt(t)+l;if(30<i){var a=l-l%5;i=(r&(1<<a)-1).toString(32),r>>=a,l-=a,hn=1<<32-Mt(t)+l|s<<l|r,gn=i+e}else hn=1<<i|s<<l|r,gn=e}function cd(e){e.return!==null&&(os(e,1),Jp(e,1,0))}function ud(e){for(;e===Ti;)Ti=er[--tr],er[tr]=null,Ii=er[--tr],er[tr]=null;for(;e===xs;)xs=It[--Et],It[Et]=null,gn=It[--Et],It[Et]=null,hn=It[--Et],It[Et]=null}var _t=null,kt=null,ze=!1,Ut=null;function Vp(e,t){var s=Pt(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function Kc(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,_t=e,kt=Nn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,_t=e,kt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=xs!==null?{id:hn,overflow:gn}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=Pt(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,_t=e,kt=null,!0):!1;default:return!1}}function So(e){return(e.mode&1)!==0&&(e.flags&128)===0}function wo(e){if(ze){var t=kt;if(t){var s=t;if(!Kc(e,t)){if(So(e))throw Error(U(418));t=Nn(s.nextSibling);var r=_t;t&&Kc(e,t)?Vp(r,s):(e.flags=e.flags&-4097|2,ze=!1,_t=e)}}else{if(So(e))throw Error(U(418));e.flags=e.flags&-4097|2,ze=!1,_t=e}}}function Qc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;_t=e}function Ml(e){if(e!==_t)return!1;if(!ze)return Qc(e),ze=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!yo(e.type,e.memoizedProps)),t&&(t=kt)){if(So(e))throw Zp(),Error(U(418));for(;t;)Vp(e,t),t=Nn(t.nextSibling)}if(Qc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(U(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){kt=Nn(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}kt=null}}else kt=_t?Nn(e.stateNode.nextSibling):null;return!0}function Zp(){for(var e=kt;e;)e=Nn(e.nextSibling)}function hr(){kt=_t=null,ze=!1}function pd(e){Ut===null?Ut=[e]:Ut.push(e)}var Am=bn.ReactCurrentBatchConfig;function Rr(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(U(309));var r=s.stateNode}if(!r)throw Error(U(147,e));var l=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var c=l.refs;a===null?delete c[i]:c[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(U(284));if(!s._owner)throw Error(U(290,e))}return e}function Hl(e,t){throw e=Object.prototype.toString.call(t),Error(U(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Yc(e){var t=e._init;return t(e._payload)}function ef(e){function t(g,x){if(e){var o=g.deletions;o===null?(g.deletions=[x],g.flags|=16):o.push(x)}}function s(g,x){if(!e)return null;for(;x!==null;)t(g,x),x=x.sibling;return null}function r(g,x){for(g=new Map;x!==null;)x.key!==null?g.set(x.key,x):g.set(x.index,x),x=x.sibling;return g}function l(g,x){return g=Un(g,x),g.index=0,g.sibling=null,g}function i(g,x,o){return g.index=o,e?(o=g.alternate,o!==null?(o=o.index,o<x?(g.flags|=2,x):o):(g.flags|=2,x)):(g.flags|=1048576,x)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function c(g,x,o,y){return x===null||x.tag!==6?(x=$a(o,g.mode,y),x.return=g,x):(x=l(x,o),x.return=g,x)}function d(g,x,o,y){var _=o.type;return _===Ys?v(g,x,o.props.children,y,o.key):x!==null&&(x.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Cn&&Yc(_)===x.type)?(y=l(x,o.props),y.ref=Rr(g,x,o),y.return=g,y):(y=gi(o.type,o.key,o.props,null,g.mode,y),y.ref=Rr(g,x,o),y.return=g,y)}function p(g,x,o,y){return x===null||x.tag!==4||x.stateNode.containerInfo!==o.containerInfo||x.stateNode.implementation!==o.implementation?(x=Ua(o,g.mode,y),x.return=g,x):(x=l(x,o.children||[]),x.return=g,x)}function v(g,x,o,y,_){return x===null||x.tag!==7?(x=hs(o,g.mode,y,_),x.return=g,x):(x=l(x,o),x.return=g,x)}function f(g,x,o){if(typeof x=="string"&&x!==""||typeof x=="number")return x=$a(""+x,g.mode,o),x.return=g,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Rl:return o=gi(x.type,x.key,x.props,null,g.mode,o),o.ref=Rr(g,null,x),o.return=g,o;case Qs:return x=Ua(x,g.mode,o),x.return=g,x;case Cn:var y=x._init;return f(g,y(x._payload),o)}if(Mr(x)||Tr(x))return x=hs(x,g.mode,o,null),x.return=g,x;Hl(g,x)}return null}function u(g,x,o,y){var _=x!==null?x.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return _!==null?null:c(g,x,""+o,y);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Rl:return o.key===_?d(g,x,o,y):null;case Qs:return o.key===_?p(g,x,o,y):null;case Cn:return _=o._init,u(g,x,_(o._payload),y)}if(Mr(o)||Tr(o))return _!==null?null:v(g,x,o,y,null);Hl(g,o)}return null}function m(g,x,o,y,_){if(typeof y=="string"&&y!==""||typeof y=="number")return g=g.get(o)||null,c(x,g,""+y,_);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Rl:return g=g.get(y.key===null?o:y.key)||null,d(x,g,y,_);case Qs:return g=g.get(y.key===null?o:y.key)||null,p(x,g,y,_);case Cn:var T=y._init;return m(g,x,o,T(y._payload),_)}if(Mr(y)||Tr(y))return g=g.get(o)||null,v(x,g,y,_,null);Hl(x,y)}return null}function j(g,x,o,y){for(var _=null,T=null,A=x,C=x=0,R=null;A!==null&&C<o.length;C++){A.index>C?(R=A,A=null):R=A.sibling;var $=u(g,A,o[C],y);if($===null){A===null&&(A=R);break}e&&A&&$.alternate===null&&t(g,A),x=i($,x,C),T===null?_=$:T.sibling=$,T=$,A=R}if(C===o.length)return s(g,A),ze&&os(g,C),_;if(A===null){for(;C<o.length;C++)A=f(g,o[C],y),A!==null&&(x=i(A,x,C),T===null?_=A:T.sibling=A,T=A);return ze&&os(g,C),_}for(A=r(g,A);C<o.length;C++)R=m(A,g,C,o[C],y),R!==null&&(e&&R.alternate!==null&&A.delete(R.key===null?C:R.key),x=i(R,x,C),T===null?_=R:T.sibling=R,T=R);return e&&A.forEach(function(J){return t(g,J)}),ze&&os(g,C),_}function h(g,x,o,y){var _=Tr(o);if(typeof _!="function")throw Error(U(150));if(o=_.call(o),o==null)throw Error(U(151));for(var T=_=null,A=x,C=x=0,R=null,$=o.next();A!==null&&!$.done;C++,$=o.next()){A.index>C?(R=A,A=null):R=A.sibling;var J=u(g,A,$.value,y);if(J===null){A===null&&(A=R);break}e&&A&&J.alternate===null&&t(g,A),x=i(J,x,C),T===null?_=J:T.sibling=J,T=J,A=R}if($.done)return s(g,A),ze&&os(g,C),_;if(A===null){for(;!$.done;C++,$=o.next())$=f(g,$.value,y),$!==null&&(x=i($,x,C),T===null?_=$:T.sibling=$,T=$);return ze&&os(g,C),_}for(A=r(g,A);!$.done;C++,$=o.next())$=m(A,g,C,$.value,y),$!==null&&(e&&$.alternate!==null&&A.delete($.key===null?C:$.key),x=i($,x,C),T===null?_=$:T.sibling=$,T=$);return e&&A.forEach(function(ae){return t(g,ae)}),ze&&os(g,C),_}function S(g,x,o,y){if(typeof o=="object"&&o!==null&&o.type===Ys&&o.key===null&&(o=o.props.children),typeof o=="object"&&o!==null){switch(o.$$typeof){case Rl:e:{for(var _=o.key,T=x;T!==null;){if(T.key===_){if(_=o.type,_===Ys){if(T.tag===7){s(g,T.sibling),x=l(T,o.props.children),x.return=g,g=x;break e}}else if(T.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Cn&&Yc(_)===T.type){s(g,T.sibling),x=l(T,o.props),x.ref=Rr(g,T,o),x.return=g,g=x;break e}s(g,T);break}else t(g,T);T=T.sibling}o.type===Ys?(x=hs(o.props.children,g.mode,y,o.key),x.return=g,g=x):(y=gi(o.type,o.key,o.props,null,g.mode,y),y.ref=Rr(g,x,o),y.return=g,g=y)}return a(g);case Qs:e:{for(T=o.key;x!==null;){if(x.key===T)if(x.tag===4&&x.stateNode.containerInfo===o.containerInfo&&x.stateNode.implementation===o.implementation){s(g,x.sibling),x=l(x,o.children||[]),x.return=g,g=x;break e}else{s(g,x);break}else t(g,x);x=x.sibling}x=Ua(o,g.mode,y),x.return=g,g=x}return a(g);case Cn:return T=o._init,S(g,x,T(o._payload),y)}if(Mr(o))return j(g,x,o,y);if(Tr(o))return h(g,x,o,y);Hl(g,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,x!==null&&x.tag===6?(s(g,x.sibling),x=l(x,o),x.return=g,g=x):(s(g,x),x=$a(o,g.mode,y),x.return=g,g=x),a(g)):s(g,x)}return S}var gr=ef(!0),tf=ef(!1),Ei=Kn(null),Pi=null,nr=null,fd=null;function hd(){fd=nr=Pi=null}function gd(e){var t=Ei.current;Se(Ei),e._currentValue=t}function ko(e,t,s){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===s)break;e=e.return}}function cr(e,t){Pi=e,fd=nr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(mt=!0),e.firstContext=null)}function Rt(e){var t=e._currentValue;if(fd!==e)if(e={context:e,memoizedValue:t,next:null},nr===null){if(Pi===null)throw Error(U(308));nr=e,Pi.dependencies={lanes:0,firstContext:e}}else nr=nr.next=e;return t}var us=null;function xd(e){us===null?us=[e]:us.push(e)}function nf(e,t,s,r){var l=t.interleaved;return l===null?(s.next=s,xd(t)):(s.next=l.next,l.next=s),t.interleaved=s,vn(e,r)}function vn(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var zn=!1;function md(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sf(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function xn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Wn(e,t,s){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ue&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,vn(e,s)}return l=r.interleaved,l===null?(t.next=t,xd(r)):(t.next=l.next,l.next=t),r.interleaved=t,vn(e,s)}function di(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,nd(e,s)}}function Xc(e,t){var s=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,s===r)){var l=null,i=null;if(s=s.firstBaseUpdate,s!==null){do{var a={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};i===null?l=i=a:i=i.next=a,s=s.next}while(s!==null);i===null?l=i=t:i=i.next=t}else l=i=t;s={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function Ai(e,t,s,r){var l=e.updateQueue;zn=!1;var i=l.firstBaseUpdate,a=l.lastBaseUpdate,c=l.shared.pending;if(c!==null){l.shared.pending=null;var d=c,p=d.next;d.next=null,a===null?i=p:a.next=p,a=d;var v=e.alternate;v!==null&&(v=v.updateQueue,c=v.lastBaseUpdate,c!==a&&(c===null?v.firstBaseUpdate=p:c.next=p,v.lastBaseUpdate=d))}if(i!==null){var f=l.baseState;a=0,v=p=d=null,c=i;do{var u=c.lane,m=c.eventTime;if((r&u)===u){v!==null&&(v=v.next={eventTime:m,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var j=e,h=c;switch(u=t,m=s,h.tag){case 1:if(j=h.payload,typeof j=="function"){f=j.call(m,f,u);break e}f=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=h.payload,u=typeof j=="function"?j.call(m,f,u):j,u==null)break e;f=Pe({},f,u);break e;case 2:zn=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,u=l.effects,u===null?l.effects=[c]:u.push(c))}else m={eventTime:m,lane:u,tag:c.tag,payload:c.payload,callback:c.callback,next:null},v===null?(p=v=m,d=f):v=v.next=m,a|=u;if(c=c.next,c===null){if(c=l.shared.pending,c===null)break;u=c,c=u.next,u.next=null,l.lastBaseUpdate=u,l.shared.pending=null}}while(!0);if(v===null&&(d=f),l.baseState=d,l.firstBaseUpdate=p,l.lastBaseUpdate=v,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);ys|=a,e.lanes=a,e.memoizedState=f}}function qc(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],l=r.callback;if(l!==null){if(r.callback=null,r=s,typeof l!="function")throw Error(U(191,l));l.call(r)}}}var kl={},nn=Kn(kl),fl=Kn(kl),hl=Kn(kl);function ps(e){if(e===kl)throw Error(U(174));return e}function yd(e,t){switch(ve(hl,t),ve(fl,e),ve(nn,kl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:so(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=so(t,e)}Se(nn),ve(nn,t)}function xr(){Se(nn),Se(fl),Se(hl)}function rf(e){ps(hl.current);var t=ps(nn.current),s=so(t,e.type);t!==s&&(ve(fl,e),ve(nn,s))}function vd(e){fl.current===e&&(Se(nn),Se(fl))}var Ie=Kn(0);function Ri(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var La=[];function jd(){for(var e=0;e<La.length;e++)La[e]._workInProgressVersionPrimary=null;La.length=0}var ci=bn.ReactCurrentDispatcher,Oa=bn.ReactCurrentBatchConfig,ms=0,Ee=null,Ye=null,Ve=null,Li=!1,Vr=!1,gl=0,Rm=0;function lt(){throw Error(U(321))}function bd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Gt(e[s],t[s]))return!1;return!0}function Sd(e,t,s,r,l,i){if(ms=i,Ee=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ci.current=e===null||e.memoizedState===null?Nm:Wm,e=s(r,l),Vr){i=0;do{if(Vr=!1,gl=0,25<=i)throw Error(U(301));i+=1,Ve=Ye=null,t.updateQueue=null,ci.current=Bm,e=s(r,l)}while(Vr)}if(ci.current=Oi,t=Ye!==null&&Ye.next!==null,ms=0,Ve=Ye=Ee=null,Li=!1,t)throw Error(U(300));return e}function wd(){var e=gl!==0;return gl=0,e}function Zt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ve===null?Ee.memoizedState=Ve=e:Ve=Ve.next=e,Ve}function Lt(){if(Ye===null){var e=Ee.alternate;e=e!==null?e.memoizedState:null}else e=Ye.next;var t=Ve===null?Ee.memoizedState:Ve.next;if(t!==null)Ve=t,Ye=e;else{if(e===null)throw Error(U(310));Ye=e,e={memoizedState:Ye.memoizedState,baseState:Ye.baseState,baseQueue:Ye.baseQueue,queue:Ye.queue,next:null},Ve===null?Ee.memoizedState=Ve=e:Ve=Ve.next=e}return Ve}function xl(e,t){return typeof t=="function"?t(e):t}function Da(e){var t=Lt(),s=t.queue;if(s===null)throw Error(U(311));s.lastRenderedReducer=e;var r=Ye,l=r.baseQueue,i=s.pending;if(i!==null){if(l!==null){var a=l.next;l.next=i.next,i.next=a}r.baseQueue=l=i,s.pending=null}if(l!==null){i=l.next,r=r.baseState;var c=a=null,d=null,p=i;do{var v=p.lane;if((ms&v)===v)d!==null&&(d=d.next={lane:0,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null}),r=p.hasEagerState?p.eagerState:e(r,p.action);else{var f={lane:v,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null};d===null?(c=d=f,a=r):d=d.next=f,Ee.lanes|=v,ys|=v}p=p.next}while(p!==null&&p!==i);d===null?a=r:d.next=c,Gt(r,t.memoizedState)||(mt=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=d,s.lastRenderedState=r}if(e=s.interleaved,e!==null){l=e;do i=l.lane,Ee.lanes|=i,ys|=i,l=l.next;while(l!==e)}else l===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function Na(e){var t=Lt(),s=t.queue;if(s===null)throw Error(U(311));s.lastRenderedReducer=e;var r=s.dispatch,l=s.pending,i=t.memoizedState;if(l!==null){s.pending=null;var a=l=l.next;do i=e(i,a.action),a=a.next;while(a!==l);Gt(i,t.memoizedState)||(mt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),s.lastRenderedState=i}return[i,r]}function lf(){}function af(e,t){var s=Ee,r=Lt(),l=t(),i=!Gt(r.memoizedState,l);if(i&&(r.memoizedState=l,mt=!0),r=r.queue,kd(cf.bind(null,s,r,e),[e]),r.getSnapshot!==t||i||Ve!==null&&Ve.memoizedState.tag&1){if(s.flags|=2048,ml(9,df.bind(null,s,r,l,t),void 0,null),Ze===null)throw Error(U(349));ms&30||of(s,t,l)}return l}function of(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=Ee.updateQueue,t===null?(t={lastEffect:null,stores:null},Ee.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function df(e,t,s,r){t.value=s,t.getSnapshot=r,uf(t)&&pf(e)}function cf(e,t,s){return s(function(){uf(t)&&pf(e)})}function uf(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Gt(e,s)}catch{return!0}}function pf(e){var t=vn(e,1);t!==null&&Ht(t,e,1,-1)}function Jc(e){var t=Zt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:xl,lastRenderedState:e},t.queue=e,e=e.dispatch=Dm.bind(null,Ee,e),[t.memoizedState,e]}function ml(e,t,s,r){return e={tag:e,create:t,destroy:s,deps:r,next:null},t=Ee.updateQueue,t===null?(t={lastEffect:null,stores:null},Ee.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(r=s.next,s.next=e,e.next=r,t.lastEffect=e)),e}function ff(){return Lt().memoizedState}function ui(e,t,s,r){var l=Zt();Ee.flags|=e,l.memoizedState=ml(1|t,s,void 0,r===void 0?null:r)}function qi(e,t,s,r){var l=Lt();r=r===void 0?null:r;var i=void 0;if(Ye!==null){var a=Ye.memoizedState;if(i=a.destroy,r!==null&&bd(r,a.deps)){l.memoizedState=ml(t,s,i,r);return}}Ee.flags|=e,l.memoizedState=ml(1|t,s,i,r)}function Vc(e,t){return ui(8390656,8,e,t)}function kd(e,t){return qi(2048,8,e,t)}function hf(e,t){return qi(4,2,e,t)}function gf(e,t){return qi(4,4,e,t)}function xf(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function mf(e,t,s){return s=s!=null?s.concat([e]):null,qi(4,4,xf.bind(null,t,e),s)}function _d(){}function yf(e,t){var s=Lt();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&bd(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function vf(e,t){var s=Lt();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&bd(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function jf(e,t,s){return ms&21?(Gt(s,t)||(s=kp(),Ee.lanes|=s,ys|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,mt=!0),e.memoizedState=s)}function Lm(e,t){var s=ge;ge=s!==0&&4>s?s:4,e(!0);var r=Oa.transition;Oa.transition={};try{e(!1),t()}finally{ge=s,Oa.transition=r}}function bf(){return Lt().memoizedState}function Om(e,t,s){var r=$n(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},Sf(e))wf(t,s);else if(s=nf(e,t,s,r),s!==null){var l=ft();Ht(s,e,r,l),kf(s,t,r)}}function Dm(e,t,s){var r=$n(e),l={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(Sf(e))wf(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,c=i(a,s);if(l.hasEagerState=!0,l.eagerState=c,Gt(c,a)){var d=t.interleaved;d===null?(l.next=l,xd(t)):(l.next=d.next,d.next=l),t.interleaved=l;return}}catch{}finally{}s=nf(e,t,l,r),s!==null&&(l=ft(),Ht(s,e,r,l),kf(s,t,r))}}function Sf(e){var t=e.alternate;return e===Ee||t!==null&&t===Ee}function wf(e,t){Vr=Li=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function kf(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,nd(e,s)}}var Oi={readContext:Rt,useCallback:lt,useContext:lt,useEffect:lt,useImperativeHandle:lt,useInsertionEffect:lt,useLayoutEffect:lt,useMemo:lt,useReducer:lt,useRef:lt,useState:lt,useDebugValue:lt,useDeferredValue:lt,useTransition:lt,useMutableSource:lt,useSyncExternalStore:lt,useId:lt,unstable_isNewReconciler:!1},Nm={readContext:Rt,useCallback:function(e,t){return Zt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:Vc,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,ui(4194308,4,xf.bind(null,t,e),s)},useLayoutEffect:function(e,t){return ui(4194308,4,e,t)},useInsertionEffect:function(e,t){return ui(4,2,e,t)},useMemo:function(e,t){var s=Zt();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=Zt();return t=s!==void 0?s(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Om.bind(null,Ee,e),[r.memoizedState,e]},useRef:function(e){var t=Zt();return e={current:e},t.memoizedState=e},useState:Jc,useDebugValue:_d,useDeferredValue:function(e){return Zt().memoizedState=e},useTransition:function(){var e=Jc(!1),t=e[0];return e=Lm.bind(null,e[1]),Zt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=Ee,l=Zt();if(ze){if(s===void 0)throw Error(U(407));s=s()}else{if(s=t(),Ze===null)throw Error(U(349));ms&30||of(r,t,s)}l.memoizedState=s;var i={value:s,getSnapshot:t};return l.queue=i,Vc(cf.bind(null,r,i,e),[e]),r.flags|=2048,ml(9,df.bind(null,r,i,s,t),void 0,null),s},useId:function(){var e=Zt(),t=Ze.identifierPrefix;if(ze){var s=gn,r=hn;s=(r&~(1<<32-Mt(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=gl++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=Rm++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Wm={readContext:Rt,useCallback:yf,useContext:Rt,useEffect:kd,useImperativeHandle:mf,useInsertionEffect:hf,useLayoutEffect:gf,useMemo:vf,useReducer:Da,useRef:ff,useState:function(){return Da(xl)},useDebugValue:_d,useDeferredValue:function(e){var t=Lt();return jf(t,Ye.memoizedState,e)},useTransition:function(){var e=Da(xl)[0],t=Lt().memoizedState;return[e,t]},useMutableSource:lf,useSyncExternalStore:af,useId:bf,unstable_isNewReconciler:!1},Bm={readContext:Rt,useCallback:yf,useContext:Rt,useEffect:kd,useImperativeHandle:mf,useInsertionEffect:hf,useLayoutEffect:gf,useMemo:vf,useReducer:Na,useRef:ff,useState:function(){return Na(xl)},useDebugValue:_d,useDeferredValue:function(e){var t=Lt();return Ye===null?t.memoizedState=e:jf(t,Ye.memoizedState,e)},useTransition:function(){var e=Na(xl)[0],t=Lt().memoizedState;return[e,t]},useMutableSource:lf,useSyncExternalStore:af,useId:bf,unstable_isNewReconciler:!1};function Bt(e,t){if(e&&e.defaultProps){t=Pe({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function _o(e,t,s,r){t=e.memoizedState,s=s(r,t),s=s==null?t:Pe({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Ji={isMounted:function(e){return(e=e._reactInternals)?Ss(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=ft(),l=$n(e),i=xn(r,l);i.payload=t,s!=null&&(i.callback=s),t=Wn(e,i,l),t!==null&&(Ht(t,e,l,r),di(t,e,l))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=ft(),l=$n(e),i=xn(r,l);i.tag=1,i.payload=t,s!=null&&(i.callback=s),t=Wn(e,i,l),t!==null&&(Ht(t,e,l,r),di(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=ft(),r=$n(e),l=xn(s,r);l.tag=2,t!=null&&(l.callback=t),t=Wn(e,l,r),t!==null&&(Ht(t,e,r,s),di(t,e,r))}};function Zc(e,t,s,r,l,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!dl(s,r)||!dl(l,i):!0}function _f(e,t,s){var r=!1,l=Mn,i=t.contextType;return typeof i=="object"&&i!==null?i=Rt(i):(l=vt(t)?gs:ot.current,r=t.contextTypes,i=(r=r!=null)?fr(e,l):Mn),t=new t(s,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ji,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function eu(e,t,s,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,r),t.state!==e&&Ji.enqueueReplaceState(t,t.state,null)}function Co(e,t,s,r){var l=e.stateNode;l.props=s,l.state=e.memoizedState,l.refs={},md(e);var i=t.contextType;typeof i=="object"&&i!==null?l.context=Rt(i):(i=vt(t)?gs:ot.current,l.context=fr(e,i)),l.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(_o(e,t,i,s),l.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof l.getSnapshotBeforeUpdate=="function"||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(t=l.state,typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount(),t!==l.state&&Ji.enqueueReplaceState(l,l.state,null),Ai(e,s,l,r),l.state=e.memoizedState),typeof l.componentDidMount=="function"&&(e.flags|=4194308)}function mr(e,t){try{var s="",r=t;do s+=fx(r),r=r.return;while(r);var l=s}catch(i){l=`
Error generating stack: `+i.message+`
`+i.stack}return{value:e,source:t,stack:l,digest:null}}function Wa(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function zo(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var $m=typeof WeakMap=="function"?WeakMap:Map;function Cf(e,t,s){s=xn(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){Ni||(Ni=!0,No=r),zo(e,t)},s}function zf(e,t,s){s=xn(-1,s),s.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;s.payload=function(){return r(l)},s.callback=function(){zo(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(s.callback=function(){zo(e,t),typeof r!="function"&&(Bn===null?Bn=new Set([this]):Bn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),s}function tu(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new $m;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(s)||(l.add(s),e=ey.bind(null,e,t,s),t.then(e,e))}function nu(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function su(e,t,s,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=xn(-1,1),t.tag=2,Wn(s,t,1))),s.lanes|=1),e)}var Um=bn.ReactCurrentOwner,mt=!1;function pt(e,t,s,r){t.child=e===null?tf(t,null,s,r):gr(t,e.child,s,r)}function ru(e,t,s,r,l){s=s.render;var i=t.ref;return cr(t,l),r=Sd(e,t,s,r,i,l),s=wd(),e!==null&&!mt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,jn(e,t,l)):(ze&&s&&cd(t),t.flags|=1,pt(e,t,r,l),t.child)}function lu(e,t,s,r,l){if(e===null){var i=s.type;return typeof i=="function"&&!Rd(i)&&i.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=i,Tf(e,t,i,r,l)):(e=gi(s.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&l)){var a=i.memoizedProps;if(s=s.compare,s=s!==null?s:dl,s(a,r)&&e.ref===t.ref)return jn(e,t,l)}return t.flags|=1,e=Un(i,r),e.ref=t.ref,e.return=t,t.child=e}function Tf(e,t,s,r,l){if(e!==null){var i=e.memoizedProps;if(dl(i,r)&&e.ref===t.ref)if(mt=!1,t.pendingProps=r=i,(e.lanes&l)!==0)e.flags&131072&&(mt=!0);else return t.lanes=e.lanes,jn(e,t,l)}return To(e,t,s,r,l)}function If(e,t,s){var r=t.pendingProps,l=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ve(rr,wt),wt|=s;else{if(!(s&1073741824))return e=i!==null?i.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ve(rr,wt),wt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:s,ve(rr,wt),wt|=r}else i!==null?(r=i.baseLanes|s,t.memoizedState=null):r=s,ve(rr,wt),wt|=r;return pt(e,t,l,s),t.child}function Ef(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function To(e,t,s,r,l){var i=vt(s)?gs:ot.current;return i=fr(t,i),cr(t,l),s=Sd(e,t,s,r,i,l),r=wd(),e!==null&&!mt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,jn(e,t,l)):(ze&&r&&cd(t),t.flags|=1,pt(e,t,s,l),t.child)}function iu(e,t,s,r,l){if(vt(s)){var i=!0;zi(t)}else i=!1;if(cr(t,l),t.stateNode===null)pi(e,t),_f(t,s,r),Co(t,s,r,l),r=!0;else if(e===null){var a=t.stateNode,c=t.memoizedProps;a.props=c;var d=a.context,p=s.contextType;typeof p=="object"&&p!==null?p=Rt(p):(p=vt(s)?gs:ot.current,p=fr(t,p));var v=s.getDerivedStateFromProps,f=typeof v=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(c!==r||d!==p)&&eu(t,a,r,p),zn=!1;var u=t.memoizedState;a.state=u,Ai(t,r,a,l),d=t.memoizedState,c!==r||u!==d||yt.current||zn?(typeof v=="function"&&(_o(t,s,v,r),d=t.memoizedState),(c=zn||Zc(t,s,c,r,u,d,p))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=d),a.props=r,a.state=d,a.context=p,r=c):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,sf(e,t),c=t.memoizedProps,p=t.type===t.elementType?c:Bt(t.type,c),a.props=p,f=t.pendingProps,u=a.context,d=s.contextType,typeof d=="object"&&d!==null?d=Rt(d):(d=vt(s)?gs:ot.current,d=fr(t,d));var m=s.getDerivedStateFromProps;(v=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(c!==f||u!==d)&&eu(t,a,r,d),zn=!1,u=t.memoizedState,a.state=u,Ai(t,r,a,l);var j=t.memoizedState;c!==f||u!==j||yt.current||zn?(typeof m=="function"&&(_o(t,s,m,r),j=t.memoizedState),(p=zn||Zc(t,s,p,r,u,j,d)||!1)?(v||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,j,d),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,j,d)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),a.props=r,a.state=j,a.context=d,r=p):(typeof a.componentDidUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),r=!1)}return Io(e,t,s,r,i,l)}function Io(e,t,s,r,l,i){Ef(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return l&&Gc(t,s,!1),jn(e,t,i);r=t.stateNode,Um.current=t;var c=a&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=gr(t,e.child,null,i),t.child=gr(t,null,c,i)):pt(e,t,c,i),t.memoizedState=r.state,l&&Gc(t,s,!0),t.child}function Pf(e){var t=e.stateNode;t.pendingContext?Hc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Hc(e,t.context,!1),yd(e,t.containerInfo)}function au(e,t,s,r,l){return hr(),pd(l),t.flags|=256,pt(e,t,s,r),t.child}var Eo={dehydrated:null,treeContext:null,retryLane:0};function Po(e){return{baseLanes:e,cachePool:null,transitions:null}}function Af(e,t,s){var r=t.pendingProps,l=Ie.current,i=!1,a=(t.flags&128)!==0,c;if((c=a)||(c=e!==null&&e.memoizedState===null?!1:(l&2)!==0),c?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),ve(Ie,l&1),e===null)return wo(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=ea(a,r,0,null),e=hs(e,r,s,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Po(s),t.memoizedState=Eo,e):Cd(t,a));if(l=e.memoizedState,l!==null&&(c=l.dehydrated,c!==null))return Fm(e,t,a,r,c,l,s);if(i){i=r.fallback,a=t.mode,l=e.child,c=l.sibling;var d={mode:"hidden",children:r.children};return!(a&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=d,t.deletions=null):(r=Un(l,d),r.subtreeFlags=l.subtreeFlags&14680064),c!==null?i=Un(c,i):(i=hs(i,a,s,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?Po(s):{baseLanes:a.baseLanes|s,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~s,t.memoizedState=Eo,r}return i=e.child,e=i.sibling,r=Un(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=s),r.return=t,r.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=r,t.memoizedState=null,r}function Cd(e,t){return t=ea({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Gl(e,t,s,r){return r!==null&&pd(r),gr(t,e.child,null,s),e=Cd(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Fm(e,t,s,r,l,i,a){if(s)return t.flags&256?(t.flags&=-257,r=Wa(Error(U(422))),Gl(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,l=t.mode,r=ea({mode:"visible",children:r.children},l,0,null),i=hs(i,l,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&gr(t,e.child,null,a),t.child.memoizedState=Po(a),t.memoizedState=Eo,i);if(!(t.mode&1))return Gl(e,t,a,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var c=r.dgst;return r=c,i=Error(U(419)),r=Wa(i,r,void 0),Gl(e,t,a,r)}if(c=(a&e.childLanes)!==0,mt||c){if(r=Ze,r!==null){switch(a&-a){case 4:l=2;break;case 16:l=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|a)?0:l,l!==0&&l!==i.retryLane&&(i.retryLane=l,vn(e,l),Ht(r,e,l,-1))}return Ad(),r=Wa(Error(U(421))),Gl(e,t,a,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=ty.bind(null,e),l._reactRetry=t,null):(e=i.treeContext,kt=Nn(l.nextSibling),_t=t,ze=!0,Ut=null,e!==null&&(It[Et++]=hn,It[Et++]=gn,It[Et++]=xs,hn=e.id,gn=e.overflow,xs=t),t=Cd(t,r.children),t.flags|=4096,t)}function ou(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ko(e.return,t,s)}function Ba(e,t,s,r,l){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:s,tailMode:l}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=s,i.tailMode=l)}function Rf(e,t,s){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(pt(e,t,r.children,s),r=Ie.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ou(e,s,t);else if(e.tag===19)ou(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ve(Ie,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(s=t.child,l=null;s!==null;)e=s.alternate,e!==null&&Ri(e)===null&&(l=s),s=s.sibling;s=l,s===null?(l=t.child,t.child=null):(l=s.sibling,s.sibling=null),Ba(t,!1,l,s,i);break;case"backwards":for(s=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&Ri(e)===null){t.child=l;break}e=l.sibling,l.sibling=s,s=l,l=e}Ba(t,!0,s,null,i);break;case"together":Ba(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function pi(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function jn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),ys|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(U(153));if(t.child!==null){for(e=t.child,s=Un(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Un(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Mm(e,t,s){switch(t.tag){case 3:Pf(t),hr();break;case 5:rf(t);break;case 1:vt(t.type)&&zi(t);break;case 4:yd(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;ve(Ei,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ve(Ie,Ie.current&1),t.flags|=128,null):s&t.child.childLanes?Af(e,t,s):(ve(Ie,Ie.current&1),e=jn(e,t,s),e!==null?e.sibling:null);ve(Ie,Ie.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return Rf(e,t,s);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),ve(Ie,Ie.current),r)break;return null;case 22:case 23:return t.lanes=0,If(e,t,s)}return jn(e,t,s)}var Lf,Ao,Of,Df;Lf=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};Ao=function(){};Of=function(e,t,s,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,ps(nn.current);var i=null;switch(s){case"input":l=Za(e,l),r=Za(e,r),i=[];break;case"select":l=Pe({},l,{value:void 0}),r=Pe({},r,{value:void 0}),i=[];break;case"textarea":l=no(e,l),r=no(e,r),i=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=_i)}ro(s,r);var a;s=null;for(p in l)if(!r.hasOwnProperty(p)&&l.hasOwnProperty(p)&&l[p]!=null)if(p==="style"){var c=l[p];for(a in c)c.hasOwnProperty(a)&&(s||(s={}),s[a]="")}else p!=="dangerouslySetInnerHTML"&&p!=="children"&&p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(nl.hasOwnProperty(p)?i||(i=[]):(i=i||[]).push(p,null));for(p in r){var d=r[p];if(c=l!=null?l[p]:void 0,r.hasOwnProperty(p)&&d!==c&&(d!=null||c!=null))if(p==="style")if(c){for(a in c)!c.hasOwnProperty(a)||d&&d.hasOwnProperty(a)||(s||(s={}),s[a]="");for(a in d)d.hasOwnProperty(a)&&c[a]!==d[a]&&(s||(s={}),s[a]=d[a])}else s||(i||(i=[]),i.push(p,s)),s=d;else p==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,c=c?c.__html:void 0,d!=null&&c!==d&&(i=i||[]).push(p,d)):p==="children"?typeof d!="string"&&typeof d!="number"||(i=i||[]).push(p,""+d):p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&(nl.hasOwnProperty(p)?(d!=null&&p==="onScroll"&&be("scroll",e),i||c===d||(i=[])):(i=i||[]).push(p,d))}s&&(i=i||[]).push("style",s);var p=i;(t.updateQueue=p)&&(t.flags|=4)}};Df=function(e,t,s,r){s!==r&&(t.flags|=4)};function Lr(e,t){if(!ze)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function it(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,r=0;if(t)for(var l=e.child;l!==null;)s|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)s|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=s,t}function Hm(e,t,s){var r=t.pendingProps;switch(ud(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return it(t),null;case 1:return vt(t.type)&&Ci(),it(t),null;case 3:return r=t.stateNode,xr(),Se(yt),Se(ot),jd(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ml(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ut!==null&&($o(Ut),Ut=null))),Ao(e,t),it(t),null;case 5:vd(t);var l=ps(hl.current);if(s=t.type,e!==null&&t.stateNode!=null)Of(e,t,s,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(U(166));return it(t),null}if(e=ps(nn.current),Ml(t)){r=t.stateNode,s=t.type;var i=t.memoizedProps;switch(r[en]=t,r[pl]=i,e=(t.mode&1)!==0,s){case"dialog":be("cancel",r),be("close",r);break;case"iframe":case"object":case"embed":be("load",r);break;case"video":case"audio":for(l=0;l<Gr.length;l++)be(Gr[l],r);break;case"source":be("error",r);break;case"img":case"image":case"link":be("error",r),be("load",r);break;case"details":be("toggle",r);break;case"input":mc(r,i),be("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},be("invalid",r);break;case"textarea":vc(r,i),be("invalid",r)}ro(s,i),l=null;for(var a in i)if(i.hasOwnProperty(a)){var c=i[a];a==="children"?typeof c=="string"?r.textContent!==c&&(i.suppressHydrationWarning!==!0&&Fl(r.textContent,c,e),l=["children",c]):typeof c=="number"&&r.textContent!==""+c&&(i.suppressHydrationWarning!==!0&&Fl(r.textContent,c,e),l=["children",""+c]):nl.hasOwnProperty(a)&&c!=null&&a==="onScroll"&&be("scroll",r)}switch(s){case"input":Ll(r),yc(r,i,!0);break;case"textarea":Ll(r),jc(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=_i)}r=l,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=l.nodeType===9?l:l.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=dp(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(s,{is:r.is}):(e=a.createElement(s),s==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,s),e[en]=t,e[pl]=r,Lf(e,t,!1,!1),t.stateNode=e;e:{switch(a=lo(s,r),s){case"dialog":be("cancel",e),be("close",e),l=r;break;case"iframe":case"object":case"embed":be("load",e),l=r;break;case"video":case"audio":for(l=0;l<Gr.length;l++)be(Gr[l],e);l=r;break;case"source":be("error",e),l=r;break;case"img":case"image":case"link":be("error",e),be("load",e),l=r;break;case"details":be("toggle",e),l=r;break;case"input":mc(e,r),l=Za(e,r),be("invalid",e);break;case"option":l=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},l=Pe({},r,{value:void 0}),be("invalid",e);break;case"textarea":vc(e,r),l=no(e,r),be("invalid",e);break;default:l=r}ro(s,l),c=l;for(i in c)if(c.hasOwnProperty(i)){var d=c[i];i==="style"?pp(e,d):i==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,d!=null&&cp(e,d)):i==="children"?typeof d=="string"?(s!=="textarea"||d!=="")&&sl(e,d):typeof d=="number"&&sl(e,""+d):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(nl.hasOwnProperty(i)?d!=null&&i==="onScroll"&&be("scroll",e):d!=null&&qo(e,i,d,a))}switch(s){case"input":Ll(e),yc(e,r,!1);break;case"textarea":Ll(e),jc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Fn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?ir(e,!!r.multiple,i,!1):r.defaultValue!=null&&ir(e,!!r.multiple,r.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=_i)}switch(s){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return it(t),null;case 6:if(e&&t.stateNode!=null)Df(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(U(166));if(s=ps(hl.current),ps(nn.current),Ml(t)){if(r=t.stateNode,s=t.memoizedProps,r[en]=t,(i=r.nodeValue!==s)&&(e=_t,e!==null))switch(e.tag){case 3:Fl(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Fl(r.nodeValue,s,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[en]=t,t.stateNode=r}return it(t),null;case 13:if(Se(Ie),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ze&&kt!==null&&t.mode&1&&!(t.flags&128))Zp(),hr(),t.flags|=98560,i=!1;else if(i=Ml(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(U(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(U(317));i[en]=t}else hr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;it(t),i=!1}else Ut!==null&&($o(Ut),Ut=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ie.current&1?Xe===0&&(Xe=3):Ad())),t.updateQueue!==null&&(t.flags|=4),it(t),null);case 4:return xr(),Ao(e,t),e===null&&cl(t.stateNode.containerInfo),it(t),null;case 10:return gd(t.type._context),it(t),null;case 17:return vt(t.type)&&Ci(),it(t),null;case 19:if(Se(Ie),i=t.memoizedState,i===null)return it(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Lr(i,!1);else{if(Xe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Ri(e),a!==null){for(t.flags|=128,Lr(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=s,s=t.child;s!==null;)i=s,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return ve(Ie,Ie.current&1|2),t.child}e=e.sibling}i.tail!==null&&Be()>yr&&(t.flags|=128,r=!0,Lr(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ri(a),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),Lr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ze)return it(t),null}else 2*Be()-i.renderingStartTime>yr&&s!==1073741824&&(t.flags|=128,r=!0,Lr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(s=i.last,s!==null?s.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Be(),t.sibling=null,s=Ie.current,ve(Ie,r?s&1|2:s&1),t):(it(t),null);case 22:case 23:return Pd(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?wt&1073741824&&(it(t),t.subtreeFlags&6&&(t.flags|=8192)):it(t),null;case 24:return null;case 25:return null}throw Error(U(156,t.tag))}function Gm(e,t){switch(ud(t),t.tag){case 1:return vt(t.type)&&Ci(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xr(),Se(yt),Se(ot),jd(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vd(t),null;case 13:if(Se(Ie),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(U(340));hr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Ie),null;case 4:return xr(),null;case 10:return gd(t.type._context),null;case 22:case 23:return Pd(),null;case 24:return null;default:return null}}var Kl=!1,at=!1,Km=typeof WeakSet=="function"?WeakSet:Set,X=null;function sr(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(r){Oe(e,t,r)}else s.current=null}function Ro(e,t,s){try{s()}catch(r){Oe(e,t,r)}}var du=!1;function Qm(e,t){if(xo=Si,e=$p(),dd(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var r=s.getSelection&&s.getSelection();if(r&&r.rangeCount!==0){s=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{s.nodeType,i.nodeType}catch{s=null;break e}var a=0,c=-1,d=-1,p=0,v=0,f=e,u=null;t:for(;;){for(var m;f!==s||l!==0&&f.nodeType!==3||(c=a+l),f!==i||r!==0&&f.nodeType!==3||(d=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(m=f.firstChild)!==null;)u=f,f=m;for(;;){if(f===e)break t;if(u===s&&++p===l&&(c=a),u===i&&++v===r&&(d=a),(m=f.nextSibling)!==null)break;f=u,u=f.parentNode}f=m}s=c===-1||d===-1?null:{start:c,end:d}}else s=null}s=s||{start:0,end:0}}else s=null;for(mo={focusedElem:e,selectionRange:s},Si=!1,X=t;X!==null;)if(t=X,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,X=e;else for(;X!==null;){t=X;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var h=j.memoizedProps,S=j.memoizedState,g=t.stateNode,x=g.getSnapshotBeforeUpdate(t.elementType===t.type?h:Bt(t.type,h),S);g.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var o=t.stateNode.containerInfo;o.nodeType===1?o.textContent="":o.nodeType===9&&o.documentElement&&o.removeChild(o.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(U(163))}}catch(y){Oe(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,X=e;break}X=t.return}return j=du,du=!1,j}function Zr(e,t,s){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Ro(t,s,i)}l=l.next}while(l!==r)}}function Vi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var r=s.create;s.destroy=r()}s=s.next}while(s!==t)}}function Lo(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function Nf(e){var t=e.alternate;t!==null&&(e.alternate=null,Nf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[en],delete t[pl],delete t[jo],delete t[Im],delete t[Em])),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 Wf(e){return e.tag===5||e.tag===3||e.tag===4}function cu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Wf(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 Oo(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=_i));else if(r!==4&&(e=e.child,e!==null))for(Oo(e,t,s),e=e.sibling;e!==null;)Oo(e,t,s),e=e.sibling}function Do(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Do(e,t,s),e=e.sibling;e!==null;)Do(e,t,s),e=e.sibling}var et=null,$t=!1;function kn(e,t,s){for(s=s.child;s!==null;)Bf(e,t,s),s=s.sibling}function Bf(e,t,s){if(tn&&typeof tn.onCommitFiberUnmount=="function")try{tn.onCommitFiberUnmount(Hi,s)}catch{}switch(s.tag){case 5:at||sr(s,t);case 6:var r=et,l=$t;et=null,kn(e,t,s),et=r,$t=l,et!==null&&($t?(e=et,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):et.removeChild(s.stateNode));break;case 18:et!==null&&($t?(e=et,s=s.stateNode,e.nodeType===8?Aa(e.parentNode,s):e.nodeType===1&&Aa(e,s),al(e)):Aa(et,s.stateNode));break;case 4:r=et,l=$t,et=s.stateNode.containerInfo,$t=!0,kn(e,t,s),et=r,$t=l;break;case 0:case 11:case 14:case 15:if(!at&&(r=s.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&Ro(s,t,a),l=l.next}while(l!==r)}kn(e,t,s);break;case 1:if(!at&&(sr(s,t),r=s.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=s.memoizedProps,r.state=s.memoizedState,r.componentWillUnmount()}catch(c){Oe(s,t,c)}kn(e,t,s);break;case 21:kn(e,t,s);break;case 22:s.mode&1?(at=(r=at)||s.memoizedState!==null,kn(e,t,s),at=r):kn(e,t,s);break;default:kn(e,t,s)}}function uu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new Km),t.forEach(function(r){var l=ny.bind(null,e,r);s.has(r)||(s.add(r),r.then(l,l))})}}function Wt(e,t){var s=t.deletions;if(s!==null)for(var r=0;r<s.length;r++){var l=s[r];try{var i=e,a=t,c=a;e:for(;c!==null;){switch(c.tag){case 5:et=c.stateNode,$t=!1;break e;case 3:et=c.stateNode.containerInfo,$t=!0;break e;case 4:et=c.stateNode.containerInfo,$t=!0;break e}c=c.return}if(et===null)throw Error(U(160));Bf(i,a,l),et=null,$t=!1;var d=l.alternate;d!==null&&(d.return=null),l.return=null}catch(p){Oe(l,t,p)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)$f(t,e),t=t.sibling}function $f(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Wt(t,e),qt(e),r&4){try{Zr(3,e,e.return),Vi(3,e)}catch(h){Oe(e,e.return,h)}try{Zr(5,e,e.return)}catch(h){Oe(e,e.return,h)}}break;case 1:Wt(t,e),qt(e),r&512&&s!==null&&sr(s,s.return);break;case 5:if(Wt(t,e),qt(e),r&512&&s!==null&&sr(s,s.return),e.flags&32){var l=e.stateNode;try{sl(l,"")}catch(h){Oe(e,e.return,h)}}if(r&4&&(l=e.stateNode,l!=null)){var i=e.memoizedProps,a=s!==null?s.memoizedProps:i,c=e.type,d=e.updateQueue;if(e.updateQueue=null,d!==null)try{c==="input"&&i.type==="radio"&&i.name!=null&&ap(l,i),lo(c,a);var p=lo(c,i);for(a=0;a<d.length;a+=2){var v=d[a],f=d[a+1];v==="style"?pp(l,f):v==="dangerouslySetInnerHTML"?cp(l,f):v==="children"?sl(l,f):qo(l,v,f,p)}switch(c){case"input":eo(l,i);break;case"textarea":op(l,i);break;case"select":var u=l._wrapperState.wasMultiple;l._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?ir(l,!!i.multiple,m,!1):u!==!!i.multiple&&(i.defaultValue!=null?ir(l,!!i.multiple,i.defaultValue,!0):ir(l,!!i.multiple,i.multiple?[]:"",!1))}l[pl]=i}catch(h){Oe(e,e.return,h)}}break;case 6:if(Wt(t,e),qt(e),r&4){if(e.stateNode===null)throw Error(U(162));l=e.stateNode,i=e.memoizedProps;try{l.nodeValue=i}catch(h){Oe(e,e.return,h)}}break;case 3:if(Wt(t,e),qt(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{al(t.containerInfo)}catch(h){Oe(e,e.return,h)}break;case 4:Wt(t,e),qt(e);break;case 13:Wt(t,e),qt(e),l=e.child,l.flags&8192&&(i=l.memoizedState!==null,l.stateNode.isHidden=i,!i||l.alternate!==null&&l.alternate.memoizedState!==null||(Id=Be())),r&4&&uu(e);break;case 22:if(v=s!==null&&s.memoizedState!==null,e.mode&1?(at=(p=at)||v,Wt(t,e),at=p):Wt(t,e),qt(e),r&8192){if(p=e.memoizedState!==null,(e.stateNode.isHidden=p)&&!v&&e.mode&1)for(X=e,v=e.child;v!==null;){for(f=X=v;X!==null;){switch(u=X,m=u.child,u.tag){case 0:case 11:case 14:case 15:Zr(4,u,u.return);break;case 1:sr(u,u.return);var j=u.stateNode;if(typeof j.componentWillUnmount=="function"){r=u,s=u.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(h){Oe(r,s,h)}}break;case 5:sr(u,u.return);break;case 22:if(u.memoizedState!==null){fu(f);continue}}m!==null?(m.return=u,X=m):fu(f)}v=v.sibling}e:for(v=null,f=e;;){if(f.tag===5){if(v===null){v=f;try{l=f.stateNode,p?(i=l.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(c=f.stateNode,d=f.memoizedProps.style,a=d!=null&&d.hasOwnProperty("display")?d.display:null,c.style.display=up("display",a))}catch(h){Oe(e,e.return,h)}}}else if(f.tag===6){if(v===null)try{f.stateNode.nodeValue=p?"":f.memoizedProps}catch(h){Oe(e,e.return,h)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;v===f&&(v=null),f=f.return}v===f&&(v=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Wt(t,e),qt(e),r&4&&uu(e);break;case 21:break;default:Wt(t,e),qt(e)}}function qt(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(Wf(s)){var r=s;break e}s=s.return}throw Error(U(160))}switch(r.tag){case 5:var l=r.stateNode;r.flags&32&&(sl(l,""),r.flags&=-33);var i=cu(e);Do(e,i,l);break;case 3:case 4:var a=r.stateNode.containerInfo,c=cu(e);Oo(e,c,a);break;default:throw Error(U(161))}}catch(d){Oe(e,e.return,d)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ym(e,t,s){X=e,Uf(e)}function Uf(e,t,s){for(var r=(e.mode&1)!==0;X!==null;){var l=X,i=l.child;if(l.tag===22&&r){var a=l.memoizedState!==null||Kl;if(!a){var c=l.alternate,d=c!==null&&c.memoizedState!==null||at;c=Kl;var p=at;if(Kl=a,(at=d)&&!p)for(X=l;X!==null;)a=X,d=a.child,a.tag===22&&a.memoizedState!==null?hu(l):d!==null?(d.return=a,X=d):hu(l);for(;i!==null;)X=i,Uf(i),i=i.sibling;X=l,Kl=c,at=p}pu(e)}else l.subtreeFlags&8772&&i!==null?(i.return=l,X=i):pu(e)}}function pu(e){for(;X!==null;){var t=X;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:at||Vi(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!at)if(s===null)r.componentDidMount();else{var l=t.elementType===t.type?s.memoizedProps:Bt(t.type,s.memoizedProps);r.componentDidUpdate(l,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&qc(t,i,r);break;case 3:var a=t.updateQueue;if(a!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}qc(t,a,s)}break;case 5:var c=t.stateNode;if(s===null&&t.flags&4){s=c;var d=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":d.autoFocus&&s.focus();break;case"img":d.src&&(s.src=d.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var p=t.alternate;if(p!==null){var v=p.memoizedState;if(v!==null){var f=v.dehydrated;f!==null&&al(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(U(163))}at||t.flags&512&&Lo(t)}catch(u){Oe(t,t.return,u)}}if(t===e){X=null;break}if(s=t.sibling,s!==null){s.return=t.return,X=s;break}X=t.return}}function fu(e){for(;X!==null;){var t=X;if(t===e){X=null;break}var s=t.sibling;if(s!==null){s.return=t.return,X=s;break}X=t.return}}function hu(e){for(;X!==null;){var t=X;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Vi(4,t)}catch(d){Oe(t,s,d)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var l=t.return;try{r.componentDidMount()}catch(d){Oe(t,l,d)}}var i=t.return;try{Lo(t)}catch(d){Oe(t,i,d)}break;case 5:var a=t.return;try{Lo(t)}catch(d){Oe(t,a,d)}}}catch(d){Oe(t,t.return,d)}if(t===e){X=null;break}var c=t.sibling;if(c!==null){c.return=t.return,X=c;break}X=t.return}}var Xm=Math.ceil,Di=bn.ReactCurrentDispatcher,zd=bn.ReactCurrentOwner,At=bn.ReactCurrentBatchConfig,ue=0,Ze=null,Me=null,tt=0,wt=0,rr=Kn(0),Xe=0,yl=null,ys=0,Zi=0,Td=0,el=null,xt=null,Id=0,yr=1/0,pn=null,Ni=!1,No=null,Bn=null,Ql=!1,Pn=null,Wi=0,tl=0,Wo=null,fi=-1,hi=0;function ft(){return ue&6?Be():fi!==-1?fi:fi=Be()}function $n(e){return e.mode&1?ue&2&&tt!==0?tt&-tt:Am.transition!==null?(hi===0&&(hi=kp()),hi):(e=ge,e!==0||(e=window.event,e=e===void 0?16:Pp(e.type)),e):1}function Ht(e,t,s,r){if(50<tl)throw tl=0,Wo=null,Error(U(185));bl(e,s,r),(!(ue&2)||e!==Ze)&&(e===Ze&&(!(ue&2)&&(Zi|=s),Xe===4&&In(e,tt)),jt(e,r),s===1&&ue===0&&!(t.mode&1)&&(yr=Be()+500,Xi&&Qn()))}function jt(e,t){var s=e.callbackNode;Ax(e,t);var r=bi(e,e===Ze?tt:0);if(r===0)s!==null&&wc(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&wc(s),t===1)e.tag===0?Pm(gu.bind(null,e)):qp(gu.bind(null,e)),zm(function(){!(ue&6)&&Qn()}),s=null;else{switch(_p(r)){case 1:s=td;break;case 4:s=Sp;break;case 16:s=ji;break;case 536870912:s=wp;break;default:s=ji}s=Xf(s,Ff.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function Ff(e,t){if(fi=-1,hi=0,ue&6)throw Error(U(327));var s=e.callbackNode;if(ur()&&e.callbackNode!==s)return null;var r=bi(e,e===Ze?tt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Bi(e,r);else{t=r;var l=ue;ue|=2;var i=Hf();(Ze!==e||tt!==t)&&(pn=null,yr=Be()+500,fs(e,t));do try{Vm();break}catch(c){Mf(e,c)}while(!0);hd(),Di.current=i,ue=l,Me!==null?t=0:(Ze=null,tt=0,t=Xe)}if(t!==0){if(t===2&&(l=uo(e),l!==0&&(r=l,t=Bo(e,l))),t===1)throw s=yl,fs(e,0),In(e,r),jt(e,Be()),s;if(t===6)In(e,r);else{if(l=e.current.alternate,!(r&30)&&!qm(l)&&(t=Bi(e,r),t===2&&(i=uo(e),i!==0&&(r=i,t=Bo(e,i))),t===1))throw s=yl,fs(e,0),In(e,r),jt(e,Be()),s;switch(e.finishedWork=l,e.finishedLanes=r,t){case 0:case 1:throw Error(U(345));case 2:ds(e,xt,pn);break;case 3:if(In(e,r),(r&130023424)===r&&(t=Id+500-Be(),10<t)){if(bi(e,0)!==0)break;if(l=e.suspendedLanes,(l&r)!==r){ft(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=vo(ds.bind(null,e,xt,pn),t);break}ds(e,xt,pn);break;case 4:if(In(e,r),(r&4194240)===r)break;for(t=e.eventTimes,l=-1;0<r;){var a=31-Mt(r);i=1<<a,a=t[a],a>l&&(l=a),r&=~i}if(r=l,r=Be()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Xm(r/1960))-r,10<r){e.timeoutHandle=vo(ds.bind(null,e,xt,pn),r);break}ds(e,xt,pn);break;case 5:ds(e,xt,pn);break;default:throw Error(U(329))}}}return jt(e,Be()),e.callbackNode===s?Ff.bind(null,e):null}function Bo(e,t){var s=el;return e.current.memoizedState.isDehydrated&&(fs(e,t).flags|=256),e=Bi(e,t),e!==2&&(t=xt,xt=s,t!==null&&$o(t)),e}function $o(e){xt===null?xt=e:xt.push.apply(xt,e)}function qm(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var r=0;r<s.length;r++){var l=s[r],i=l.getSnapshot;l=l.value;try{if(!Gt(i(),l))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function In(e,t){for(t&=~Td,t&=~Zi,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-Mt(t),r=1<<s;e[s]=-1,t&=~r}}function gu(e){if(ue&6)throw Error(U(327));ur();var t=bi(e,0);if(!(t&1))return jt(e,Be()),null;var s=Bi(e,t);if(e.tag!==0&&s===2){var r=uo(e);r!==0&&(t=r,s=Bo(e,r))}if(s===1)throw s=yl,fs(e,0),In(e,t),jt(e,Be()),s;if(s===6)throw Error(U(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ds(e,xt,pn),jt(e,Be()),null}function Ed(e,t){var s=ue;ue|=1;try{return e(t)}finally{ue=s,ue===0&&(yr=Be()+500,Xi&&Qn())}}function vs(e){Pn!==null&&Pn.tag===0&&!(ue&6)&&ur();var t=ue;ue|=1;var s=At.transition,r=ge;try{if(At.transition=null,ge=1,e)return e()}finally{ge=r,At.transition=s,ue=t,!(ue&6)&&Qn()}}function Pd(){wt=rr.current,Se(rr)}function fs(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,Cm(s)),Me!==null)for(s=Me.return;s!==null;){var r=s;switch(ud(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ci();break;case 3:xr(),Se(yt),Se(ot),jd();break;case 5:vd(r);break;case 4:xr();break;case 13:Se(Ie);break;case 19:Se(Ie);break;case 10:gd(r.type._context);break;case 22:case 23:Pd()}s=s.return}if(Ze=e,Me=e=Un(e.current,null),tt=wt=t,Xe=0,yl=null,Td=Zi=ys=0,xt=el=null,us!==null){for(t=0;t<us.length;t++)if(s=us[t],r=s.interleaved,r!==null){s.interleaved=null;var l=r.next,i=s.pending;if(i!==null){var a=i.next;i.next=l,r.next=a}s.pending=r}us=null}return e}function Mf(e,t){do{var s=Me;try{if(hd(),ci.current=Oi,Li){for(var r=Ee.memoizedState;r!==null;){var l=r.queue;l!==null&&(l.pending=null),r=r.next}Li=!1}if(ms=0,Ve=Ye=Ee=null,Vr=!1,gl=0,zd.current=null,s===null||s.return===null){Xe=1,yl=t,Me=null;break}e:{var i=e,a=s.return,c=s,d=t;if(t=tt,c.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){var p=d,v=c,f=v.tag;if(!(v.mode&1)&&(f===0||f===11||f===15)){var u=v.alternate;u?(v.updateQueue=u.updateQueue,v.memoizedState=u.memoizedState,v.lanes=u.lanes):(v.updateQueue=null,v.memoizedState=null)}var m=nu(a);if(m!==null){m.flags&=-257,su(m,a,c,i,t),m.mode&1&&tu(i,p,t),t=m,d=p;var j=t.updateQueue;if(j===null){var h=new Set;h.add(d),t.updateQueue=h}else j.add(d);break e}else{if(!(t&1)){tu(i,p,t),Ad();break e}d=Error(U(426))}}else if(ze&&c.mode&1){var S=nu(a);if(S!==null){!(S.flags&65536)&&(S.flags|=256),su(S,a,c,i,t),pd(mr(d,c));break e}}i=d=mr(d,c),Xe!==4&&(Xe=2),el===null?el=[i]:el.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=Cf(i,d,t);Xc(i,g);break e;case 1:c=d;var x=i.type,o=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Bn===null||!Bn.has(o)))){i.flags|=65536,t&=-t,i.lanes|=t;var y=zf(i,c,t);Xc(i,y);break e}}i=i.return}while(i!==null)}Kf(s)}catch(_){t=_,Me===s&&s!==null&&(Me=s=s.return);continue}break}while(!0)}function Hf(){var e=Di.current;return Di.current=Oi,e===null?Oi:e}function Ad(){(Xe===0||Xe===3||Xe===2)&&(Xe=4),Ze===null||!(ys&268435455)&&!(Zi&268435455)||In(Ze,tt)}function Bi(e,t){var s=ue;ue|=2;var r=Hf();(Ze!==e||tt!==t)&&(pn=null,fs(e,t));do try{Jm();break}catch(l){Mf(e,l)}while(!0);if(hd(),ue=s,Di.current=r,Me!==null)throw Error(U(261));return Ze=null,tt=0,Xe}function Jm(){for(;Me!==null;)Gf(Me)}function Vm(){for(;Me!==null&&!wx();)Gf(Me)}function Gf(e){var t=Yf(e.alternate,e,wt);e.memoizedProps=e.pendingProps,t===null?Kf(e):Me=t,zd.current=null}function Kf(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=Gm(s,t),s!==null){s.flags&=32767,Me=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Xe=6,Me=null;return}}else if(s=Hm(s,t,wt),s!==null){Me=s;return}if(t=t.sibling,t!==null){Me=t;return}Me=t=e}while(t!==null);Xe===0&&(Xe=5)}function ds(e,t,s){var r=ge,l=At.transition;try{At.transition=null,ge=1,Zm(e,t,s,r)}finally{At.transition=l,ge=r}return null}function Zm(e,t,s,r){do ur();while(Pn!==null);if(ue&6)throw Error(U(327));s=e.finishedWork;var l=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(U(177));e.callbackNode=null,e.callbackPriority=0;var i=s.lanes|s.childLanes;if(Rx(e,i),e===Ze&&(Me=Ze=null,tt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||Ql||(Ql=!0,Xf(ji,function(){return ur(),null})),i=(s.flags&15990)!==0,s.subtreeFlags&15990||i){i=At.transition,At.transition=null;var a=ge;ge=1;var c=ue;ue|=4,zd.current=null,Qm(e,s),$f(s,e),vm(mo),Si=!!xo,mo=xo=null,e.current=s,Ym(s),kx(),ue=c,ge=a,At.transition=i}else e.current=s;if(Ql&&(Ql=!1,Pn=e,Wi=l),i=e.pendingLanes,i===0&&(Bn=null),zx(s.stateNode),jt(e,Be()),t!==null)for(r=e.onRecoverableError,s=0;s<t.length;s++)l=t[s],r(l.value,{componentStack:l.stack,digest:l.digest});if(Ni)throw Ni=!1,e=No,No=null,e;return Wi&1&&e.tag!==0&&ur(),i=e.pendingLanes,i&1?e===Wo?tl++:(tl=0,Wo=e):tl=0,Qn(),null}function ur(){if(Pn!==null){var e=_p(Wi),t=At.transition,s=ge;try{if(At.transition=null,ge=16>e?16:e,Pn===null)var r=!1;else{if(e=Pn,Pn=null,Wi=0,ue&6)throw Error(U(331));var l=ue;for(ue|=4,X=e.current;X!==null;){var i=X,a=i.child;if(X.flags&16){var c=i.deletions;if(c!==null){for(var d=0;d<c.length;d++){var p=c[d];for(X=p;X!==null;){var v=X;switch(v.tag){case 0:case 11:case 15:Zr(8,v,i)}var f=v.child;if(f!==null)f.return=v,X=f;else for(;X!==null;){v=X;var u=v.sibling,m=v.return;if(Nf(v),v===p){X=null;break}if(u!==null){u.return=m,X=u;break}X=m}}}var j=i.alternate;if(j!==null){var h=j.child;if(h!==null){j.child=null;do{var S=h.sibling;h.sibling=null,h=S}while(h!==null)}}X=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,X=a;else e:for(;X!==null;){if(i=X,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Zr(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,X=g;break e}X=i.return}}var x=e.current;for(X=x;X!==null;){a=X;var o=a.child;if(a.subtreeFlags&2064&&o!==null)o.return=a,X=o;else e:for(a=x;X!==null;){if(c=X,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Vi(9,c)}}catch(_){Oe(c,c.return,_)}if(c===a){X=null;break e}var y=c.sibling;if(y!==null){y.return=c.return,X=y;break e}X=c.return}}if(ue=l,Qn(),tn&&typeof tn.onPostCommitFiberRoot=="function")try{tn.onPostCommitFiberRoot(Hi,e)}catch{}r=!0}return r}finally{ge=s,At.transition=t}}return!1}function xu(e,t,s){t=mr(s,t),t=Cf(e,t,1),e=Wn(e,t,1),t=ft(),e!==null&&(bl(e,1,t),jt(e,t))}function Oe(e,t,s){if(e.tag===3)xu(e,e,s);else for(;t!==null;){if(t.tag===3){xu(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Bn===null||!Bn.has(r))){e=mr(s,e),e=zf(t,e,1),t=Wn(t,e,1),e=ft(),t!==null&&(bl(t,1,e),jt(t,e));break}}t=t.return}}function ey(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=ft(),e.pingedLanes|=e.suspendedLanes&s,Ze===e&&(tt&s)===s&&(Xe===4||Xe===3&&(tt&130023424)===tt&&500>Be()-Id?fs(e,0):Td|=s),jt(e,t)}function Qf(e,t){t===0&&(e.mode&1?(t=Nl,Nl<<=1,!(Nl&130023424)&&(Nl=4194304)):t=1);var s=ft();e=vn(e,t),e!==null&&(bl(e,t,s),jt(e,s))}function ty(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Qf(e,s)}function ny(e,t){var s=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(s=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(U(314))}r!==null&&r.delete(t),Qf(e,s)}var Yf;Yf=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||yt.current)mt=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return mt=!1,Mm(e,t,s);mt=!!(e.flags&131072)}else mt=!1,ze&&t.flags&1048576&&Jp(t,Ii,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;pi(e,t),e=t.pendingProps;var l=fr(t,ot.current);cr(t,s),l=Sd(null,t,r,e,l,s);var i=wd();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,vt(r)?(i=!0,zi(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,md(t),l.updater=Ji,t.stateNode=l,l._reactInternals=t,Co(t,r,e,s),t=Io(null,t,r,!0,i,s)):(t.tag=0,ze&&i&&cd(t),pt(null,t,l,s),t=t.child),t;case 16:r=t.elementType;e:{switch(pi(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=ry(r),e=Bt(r,e),l){case 0:t=To(null,t,r,e,s);break e;case 1:t=iu(null,t,r,e,s);break e;case 11:t=ru(null,t,r,e,s);break e;case 14:t=lu(null,t,r,Bt(r.type,e),s);break e}throw Error(U(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Bt(r,l),To(e,t,r,l,s);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Bt(r,l),iu(e,t,r,l,s);case 3:e:{if(Pf(t),e===null)throw Error(U(387));r=t.pendingProps,i=t.memoizedState,l=i.element,sf(e,t),Ai(t,r,null,s);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=mr(Error(U(423)),t),t=au(e,t,r,s,l);break e}else if(r!==l){l=mr(Error(U(424)),t),t=au(e,t,r,s,l);break e}else for(kt=Nn(t.stateNode.containerInfo.firstChild),_t=t,ze=!0,Ut=null,s=tf(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(hr(),r===l){t=jn(e,t,s);break e}pt(e,t,r,s)}t=t.child}return t;case 5:return rf(t),e===null&&wo(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,a=l.children,yo(r,l)?a=null:i!==null&&yo(r,i)&&(t.flags|=32),Ef(e,t),pt(e,t,a,s),t.child;case 6:return e===null&&wo(t),null;case 13:return Af(e,t,s);case 4:return yd(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=gr(t,null,r,s):pt(e,t,r,s),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Bt(r,l),ru(e,t,r,l,s);case 7:return pt(e,t,t.pendingProps,s),t.child;case 8:return pt(e,t,t.pendingProps.children,s),t.child;case 12:return pt(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,a=l.value,ve(Ei,r._currentValue),r._currentValue=a,i!==null)if(Gt(i.value,a)){if(i.children===l.children&&!yt.current){t=jn(e,t,s);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var c=i.dependencies;if(c!==null){a=i.child;for(var d=c.firstContext;d!==null;){if(d.context===r){if(i.tag===1){d=xn(-1,s&-s),d.tag=2;var p=i.updateQueue;if(p!==null){p=p.shared;var v=p.pending;v===null?d.next=d:(d.next=v.next,v.next=d),p.pending=d}}i.lanes|=s,d=i.alternate,d!==null&&(d.lanes|=s),ko(i.return,s,t),c.lanes|=s;break}d=d.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(U(341));a.lanes|=s,c=a.alternate,c!==null&&(c.lanes|=s),ko(a,s,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}pt(e,t,l.children,s),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,cr(t,s),l=Rt(l),r=r(l),t.flags|=1,pt(e,t,r,s),t.child;case 14:return r=t.type,l=Bt(r,t.pendingProps),l=Bt(r.type,l),lu(e,t,r,l,s);case 15:return Tf(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Bt(r,l),pi(e,t),t.tag=1,vt(r)?(e=!0,zi(t)):e=!1,cr(t,s),_f(t,r,l),Co(t,r,l,s),Io(null,t,r,!0,e,s);case 19:return Rf(e,t,s);case 22:return If(e,t,s)}throw Error(U(156,t.tag))};function Xf(e,t){return bp(e,t)}function sy(e,t,s,r){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pt(e,t,s,r){return new sy(e,t,s,r)}function Rd(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ry(e){if(typeof e=="function")return Rd(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Vo)return 11;if(e===Zo)return 14}return 2}function Un(e,t){var s=e.alternate;return s===null?(s=Pt(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function gi(e,t,s,r,l,i){var a=2;if(r=e,typeof e=="function")Rd(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Ys:return hs(s.children,l,i,t);case Jo:a=8,l|=8;break;case Xa:return e=Pt(12,s,t,l|2),e.elementType=Xa,e.lanes=i,e;case qa:return e=Pt(13,s,t,l),e.elementType=qa,e.lanes=i,e;case Ja:return e=Pt(19,s,t,l),e.elementType=Ja,e.lanes=i,e;case rp:return ea(s,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case np:a=10;break e;case sp:a=9;break e;case Vo:a=11;break e;case Zo:a=14;break e;case Cn:a=16,r=null;break e}throw Error(U(130,e==null?e:typeof e,""))}return t=Pt(a,s,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function hs(e,t,s,r){return e=Pt(7,e,r,t),e.lanes=s,e}function ea(e,t,s,r){return e=Pt(22,e,r,t),e.elementType=rp,e.lanes=s,e.stateNode={isHidden:!1},e}function $a(e,t,s){return e=Pt(6,e,null,t),e.lanes=s,e}function Ua(e,t,s){return t=Pt(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ly(e,t,s,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ba(0),this.expirationTimes=ba(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ba(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Ld(e,t,s,r,l,i,a,c,d){return e=new ly(e,t,s,c,d),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Pt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},md(i),e}function iy(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Qs,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function qf(e){if(!e)return Mn;e=e._reactInternals;e:{if(Ss(e)!==e||e.tag!==1)throw Error(U(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(vt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(U(171))}if(e.tag===1){var s=e.type;if(vt(s))return Xp(e,s,t)}return t}function Jf(e,t,s,r,l,i,a,c,d){return e=Ld(s,r,!0,e,l,i,a,c,d),e.context=qf(null),s=e.current,r=ft(),l=$n(s),i=xn(r,l),i.callback=t??null,Wn(s,i,l),e.current.lanes=l,bl(e,l,r),jt(e,r),e}function ta(e,t,s,r){var l=t.current,i=ft(),a=$n(l);return s=qf(s),t.context===null?t.context=s:t.pendingContext=s,t=xn(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Wn(l,t,a),e!==null&&(Ht(e,l,a,i),di(e,l,a)),a}function $i(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 mu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Od(e,t){mu(e,t),(e=e.alternate)&&mu(e,t)}function ay(){return null}var Vf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Dd(e){this._internalRoot=e}na.prototype.render=Dd.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(U(409));ta(e,t,null,null)};na.prototype.unmount=Dd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;vs(function(){ta(null,e,null,null)}),t[yn]=null}};function na(e){this._internalRoot=e}na.prototype.unstable_scheduleHydration=function(e){if(e){var t=Tp();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Tn.length&&t!==0&&t<Tn[s].priority;s++);Tn.splice(s,0,e),s===0&&Ep(e)}};function Nd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function sa(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function yu(){}function oy(e,t,s,r,l){if(l){if(typeof r=="function"){var i=r;r=function(){var p=$i(a);i.call(p)}}var a=Jf(t,r,e,0,null,!1,!1,"",yu);return e._reactRootContainer=a,e[yn]=a.current,cl(e.nodeType===8?e.parentNode:e),vs(),a}for(;l=e.lastChild;)e.removeChild(l);if(typeof r=="function"){var c=r;r=function(){var p=$i(d);c.call(p)}}var d=Ld(e,0,!1,null,null,!1,!1,"",yu);return e._reactRootContainer=d,e[yn]=d.current,cl(e.nodeType===8?e.parentNode:e),vs(function(){ta(t,d,s,r)}),d}function ra(e,t,s,r,l){var i=s._reactRootContainer;if(i){var a=i;if(typeof l=="function"){var c=l;l=function(){var d=$i(a);c.call(d)}}ta(t,a,e,l)}else a=oy(s,t,e,l,r);return $i(a)}Cp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=Hr(t.pendingLanes);s!==0&&(nd(t,s|1),jt(t,Be()),!(ue&6)&&(yr=Be()+500,Qn()))}break;case 13:vs(function(){var r=vn(e,1);if(r!==null){var l=ft();Ht(r,e,1,l)}}),Od(e,1)}};sd=function(e){if(e.tag===13){var t=vn(e,134217728);if(t!==null){var s=ft();Ht(t,e,134217728,s)}Od(e,134217728)}};zp=function(e){if(e.tag===13){var t=$n(e),s=vn(e,t);if(s!==null){var r=ft();Ht(s,e,t,r)}Od(e,t)}};Tp=function(){return ge};Ip=function(e,t){var s=ge;try{return ge=e,t()}finally{ge=s}};ao=function(e,t,s){switch(t){case"input":if(eo(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var r=s[t];if(r!==e&&r.form===e.form){var l=Yi(r);if(!l)throw Error(U(90));ip(r),eo(r,l)}}}break;case"textarea":op(e,s);break;case"select":t=s.value,t!=null&&ir(e,!!s.multiple,t,!1)}};gp=Ed;xp=vs;var dy={usingClientEntryPoint:!1,Events:[wl,Vs,Yi,fp,hp,Ed]},Or={findFiberByHostInstance:cs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},cy={bundleType:Or.bundleType,version:Or.version,rendererPackageName:Or.rendererPackageName,rendererConfig:Or.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:bn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=vp(e),e===null?null:e.stateNode},findFiberByHostInstance:Or.findFiberByHostInstance||ay,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 Yl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yl.isDisabled&&Yl.supportsFiber)try{Hi=Yl.inject(cy),tn=Yl}catch{}}zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dy;zt.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Nd(t))throw Error(U(200));return iy(e,t,null,s)};zt.createRoot=function(e,t){if(!Nd(e))throw Error(U(299));var s=!1,r="",l=Vf;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(l=t.onRecoverableError)),t=Ld(e,1,!1,null,null,s,!1,r,l),e[yn]=t.current,cl(e.nodeType===8?e.parentNode:e),new Dd(t)};zt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(U(188)):(e=Object.keys(e).join(","),Error(U(268,e)));return e=vp(t),e=e===null?null:e.stateNode,e};zt.flushSync=function(e){return vs(e)};zt.hydrate=function(e,t,s){if(!sa(t))throw Error(U(200));return ra(null,e,t,!0,s)};zt.hydrateRoot=function(e,t,s){if(!Nd(e))throw Error(U(405));var r=s!=null&&s.hydratedSources||null,l=!1,i="",a=Vf;if(s!=null&&(s.unstable_strictMode===!0&&(l=!0),s.identifierPrefix!==void 0&&(i=s.identifierPrefix),s.onRecoverableError!==void 0&&(a=s.onRecoverableError)),t=Jf(t,null,e,1,s??null,l,!1,i,a),e[yn]=t.current,cl(e),r)for(e=0;e<r.length;e++)s=r[e],l=s._getVersion,l=l(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,l]:t.mutableSourceEagerHydrationData.push(s,l);return new na(t)};zt.render=function(e,t,s){if(!sa(t))throw Error(U(200));return ra(null,e,t,!1,s)};zt.unmountComponentAtNode=function(e){if(!sa(e))throw Error(U(40));return e._reactRootContainer?(vs(function(){ra(null,null,e,!1,function(){e._reactRootContainer=null,e[yn]=null})}),!0):!1};zt.unstable_batchedUpdates=Ed;zt.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!sa(s))throw Error(U(200));if(e==null||e._reactInternals===void 0)throw Error(U(38));return ra(e,t,s,!1,r)};zt.version="18.3.1-next-f1338f8080-20240426";function Zf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Zf)}catch(e){console.error(e)}}Zf(),Vu.exports=zt;var uy=Vu.exports,eh,vu=uy;eh=vu.createRoot,vu.hydrateRoot;const oe="",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"},N={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},py=[{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"}],th=[{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"}],fy=new Set(["users","group-companies"]);function hy(e){return e!=="Admin"&&e!=="Auditor"?[]:th.filter(({id:t})=>e==="Admin"||!fy.has(t))}const _n=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],gy={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:_n(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:_n(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:_n(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:_n(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:_n([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:_n([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:_n([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:_n([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},users:{label:"Users",orgField:"custom_organization",columns:[{key:"full_name",label:"Full Name"},{key:"email",label:"Email"},{key:"username",label:"Username"},{key:"mobile_no",label:"Phone"},{key:"custom_category",label:"Category"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_department",label:"Department"},{key:"custom_branch",label:"Branch"},{key:"custom_number",label:"User ID No"},{key:"enabled",label:"Active"},{key:"creation",label:"Created On"}],defaultColumns:["full_name","email","custom_category","custom_organization","enabled"]},delegations:{label:"Delegations",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"auditor",label:"Auditor"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"create_processes",label:"Create Processes"},{key:"update_process_status",label:"Update Process Status"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","status","requested_on"]}},xy=()=>n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),my=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),yy=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]});function qe({onView:e,onEdit:t,onDelete:s}){const r=(l,i,a,c,d,p)=>c?n.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),c()},title:p,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid transparent",cursor:"pointer",background:l,color:a,flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:v=>{v.currentTarget.style.background=i,v.currentTarget.style.transform="scale(1.08)"},onMouseLeave:v=>{v.currentTarget.style.background=l,v.currentTarget.style.transform="scale(1)"},children:d},p):null;return n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r("#f0f9ff","#e0f2fe","#0284c7",e,n.jsx(xy,{}),"View"),r("#f0fdf4","#dcfce7","#16a34a",t,n.jsx(my,{}),"Edit"),s&&r("#fff1f2","#fee2e2","#e11d48",s,n.jsx(yy,{}),"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"},z={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function vy(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 fe(e,t){return e.filter(s=>vy(s)||s.name===t)}const jy={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function An(e,t){return!!t&&jy[e].includes(t)}function vr(e,t,s,r){return e.filter(l=>{const i=t[l.name]||[];return!(i.includes("SB Admin")||i.includes("System Manager")||!i.includes(s)||r&&l.custom_organization&&l.custom_organization!==r)})}const jr={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function xi(e){const t=(e||"").trim().toLowerCase();return t==="new"||t==="initial evaluation"||t==="draft"?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:t.includes("progress")||t.includes("review")||t.includes("proposal")||t.includes("resolution")?{bg:"#fefce8",color:"#a16207",border:"#fef08a"}:t.includes("executed")||t.includes("approved")||t.includes("active")||t.includes("closed")||t.includes("completed")?{bg:"#f0fdf4",color:"#15803d",border:"#bbf7d0"}:t.includes("rejected")||t.includes("overdue")||t.includes("fail")||t.includes("inactive")?{bg:"#fef2f2",color:"#b91c1c",border:"#fecaca"}:t.includes("deleted")?{bg:"#fff1f2",color:"#e11d48",border:"#fecdd3"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}function by(e){const t=(e||"").trim().toLowerCase();return t.includes("incident")?{bg:"#f1f5f9",color:"#334155",border:"#cbd5e1"}:t.includes("complaint")?{bg:"#fff7ed",color:"#c2410c",border:"#fed7aa"}:t.includes("violation")?{bg:"#faf5ff",color:"#7e22ce",border:"#e9d5ff"}:t.includes("process")?{bg:"#f0fdfa",color:"#0f766e",border:"#99f6e4"}:t.includes("asset")?{bg:"#ecfeff",color:"#0e7490",border:"#a5f3fc"}:t.includes("human")?{bg:"#f5f3ff",color:"#6d28d9",border:"#ddd6fe"}:t.includes("idea")?{bg:"#ecfdf5",color:"#047857",border:"#a7f3d0"}:t.includes("study")?{bg:"#eff6ff",color:"#1d4ed8",border:"#bfdbfe"}:{bg:"#f8fafc",color:"#475569",border:"#e2e8f0"}}const vl=(e,t)=>{let s;return typeof t=="object"&&t!==null?s=t:typeof t=="string"&&t.startsWith("#")?s=xi(e):typeof t=="string"?s=xi(t):s=xi(e),n.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})},Hn=e=>vl(e,xi(e)),Wd=e=>vl(e,by(e));function _l({deletedBy:e,deletedOn:t,reason:s,onRestore:r,isRestoring:l}){return n.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,padding:"12px 16px",marginBottom:16,display:"flex",alignItems:"center",justifyContent:"space-between",color:"#991b1b",fontSize:13},children:[n.jsxs("div",{children:[n.jsxs("div",{style:{fontWeight:700,fontSize:14,display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[n.jsx("span",{children:"⚠️"}),n.jsx("span",{children:"DELETED RECORD / سجل محذوف"})]}),n.jsxs("div",{style:{fontSize:12,color:"#7f1d1d"},children:[e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Deleted By:"})," ",e," "]}),t&&n.jsxs("span",{children:["| ",n.jsx("strong",{children:"Deleted On:"})," ",t," "]}),s&&n.jsxs("div",{children:[n.jsx("strong",{children:"Reason:"})," ",s]})]})]}),r&&n.jsxs("button",{onClick:r,disabled:l,style:{background:"#dc2626",color:"white",border:"none",borderRadius:6,padding:"8px 16px",fontSize:12,fontWeight:700,cursor:l?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{children:"↺"}),n.jsx("span",{children:l?"Restoring...":"Restore Record / استعادة"})]})]})}function la({onDelete:e,disabled:t,title:s="Delete Request",btnText:r="Delete"}){return n.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #fee2e2",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:s}),n.jsxs("button",{type:"button",onClick:e,disabled:t,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:"#dc2626",color:"#ffffff",fontWeight:700,fontSize:12,cursor:t?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,boxShadow:"0 1px 3px rgba(220, 38, 38, 0.25)",transition:"all 0.15s ease"},onMouseEnter:l=>{t||(l.currentTarget.style.background="#b91c1c")},onMouseLeave:l=>{t||(l.currentTarget.style.background="#dc2626")},children:[n.jsx("span",{children:"🗑️"}),n.jsx("span",{children:r})]})]})}const Sy="modulepreload",wy=function(e){return"/"+e},ju={},ky=function(t,s,r){let l=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));l=Promise.allSettled(s.map(d=>{if(d=wy(d),d in ju)return;ju[d]=!0;const p=d.endsWith(".css"),v=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${v}`))return;const f=document.createElement("link");if(f.rel=p?"stylesheet":Sy,p||(f.as="script"),f.crossOrigin="",f.href=d,c&&f.setAttribute("nonce",c),document.head.appendChild(f),p)return new Promise((u,m)=>{f.addEventListener("load",u),f.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return l.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};function nh(e,t){const s=e[t.key];return s==null||s===""?"":typeof s=="object"?JSON.stringify(s):String(s)}function _y(e,t){const s=URL.createObjectURL(e),r=document.createElement("a");r.href=s,r.download=t,r.click(),URL.revokeObjectURL(s)}function Cy(e,t,s){const r=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),l=t.map(a=>e.map(c=>`"${nh(a,c).replace(/"/g,'""')}"`).join(",")).join(`
`),i=new Blob([r+`
`+l],{type:"text/csv;charset=utf-8;"});_y(i,`${s}.csv`)}async function zy(e,t,s){const r=await ky(()=>import("./xlsx-D_0l8YDs.js"),[]),l=t.map(c=>{const d={};for(const p of e)d[p.label]=nh(c,p);return d}),i=r.utils.json_to_sheet(l,{header:e.map(c=>c.label)}),a=r.utils.book_new();r.utils.book_append_sheet(a,i,"Export"),r.writeFile(a,`${s}.xlsx`)}const Xl="#16a34a";function Ty({title:e,rows:t,columns:s,defaultColumnKeys:r,orgField:l,organizations:i,filenameBase:a,onClose:c}){const[d,p]=w.useState(""),[v,f]=w.useState("csv"),[u,m]=w.useState(new Set(r)),j=d?t.filter(y=>y[l||"organization"]===d):t,h=s.filter(y=>u.has(y.key)),S=y=>{m(_=>{const T=new Set(_);return T.has(y)?T.delete(y):T.add(y),T})},g=async()=>{h.length===0||j.length===0||(v==="csv"?Cy(h,j,a):await zy(h,j,a),c())},x={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},o={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick:c,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:n.jsxs("div",{onClick:y=>y.stopPropagation(),style:{width:560,maxWidth:"92vw",maxHeight:"86vh",background:"white",borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.3)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[n.jsxs("div",{style:{background:Xl,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[n.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e]}),n.jsx("button",{onClick:c,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"white",width:28,height:28,borderRadius:8,cursor:"pointer",fontSize:15,lineHeight:1},children:"✕"})]}),n.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1},children:[l&&i&&i.length>0&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"Filter by Organization"}),n.jsxs("select",{value:d,onChange:y=>p(y.target.value),style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",boxSizing:"border-box"},children:[n.jsxs("option",{value:"",children:["All Organizations (",t.length," total)"]}),i.map(y=>n.jsx("option",{value:y.name,children:y.organization_name||y.name},y.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"File Format"}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Comma-separated values"},{id:"xlsx",label:"Excel",desc:"XLSX spreadsheet"}].map(y=>n.jsxs("div",{onClick:()=>f(y.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${v===y.id?Xl:"#e5e7eb"}`,background:v===y.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:y.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:y.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:y.desc})]})]},y.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...x,marginBottom:0},children:"Columns to Export"}),n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[n.jsx("button",{onClick:()=>m(new Set(s.map(y=>y.key))),style:o,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>m(new Set(r)),style:o,children:"Reset to Default"})]})]}),n.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"10px 12px"},children:s.map(y=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:u.has(y.key),onChange:()=>S(y.key),style:{accentColor:Xl,cursor:"pointer"}}),y.label]},y.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[u.size," column",u.size!==1?"s":""," selected"]})]})]}),n.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("span",{style:{fontSize:12,color:"#888"},children:d?`Exporting ${j.length} filtered row${j.length!==1?"s":""}`:`Exporting all ${j.length} row${j.length!==1?"s":""}`}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:c,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),n.jsx("button",{onClick:g,disabled:h.length===0||j.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Xl,color:"white",fontWeight:700,fontSize:13,cursor:h.length===0||j.length===0?"not-allowed":"pointer",opacity:h.length===0||j.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}const sh="sidrah_rtl",Uo="sidrah-lang-change";function lr(){try{return localStorage.getItem(sh)==="1"}catch{return!1}}function rh(){const e=!lr();try{localStorage.setItem(sh,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(Uo))}function ne(){const[e,t]=w.useState(lr);return w.useEffect(()=>{const s=()=>t(lr());return window.addEventListener(Uo,s),document.documentElement.setAttribute("dir",lr()?"rtl":"ltr"),document.documentElement.setAttribute("lang",lr()?"ar":"en-GB"),()=>window.removeEventListener(Uo,s)},[]),e?Ey:Iy}const Iy={rtl:!1,nav:{dashboard:"Dashboard",inbox:"Inbox",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",reports:"Reports",users:"Users",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",settings:"Settings"},pages:{dashboard:"Dashboard",inbox:"Inbox",reports:"Reports",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",users:"Users"},new:"+ New",save:"Save",cancel:"Cancel",edit:"Edit",delete:"Delete",deletedBadge:"DELETED",restore:"Restore",restoring:"Restoring...",restoredOk:"Record restored successfully!",deletedBanner:"⚠️ This record has been deleted",deletedBy:"Deleted by",deletedOn:"Deleted on",deletedReason:"Reason",deleteModal:{title:"Confirm Deletion",subtitle:"Are you sure you want to delete this record?",softDeleteTitle:"Delete",softDeleteDesc:"Moves the record to deleted state. It can be restored later by an Administrator.",permanentDeleteTitle:"Permanent Delete",permanentDeleteDesc:"Permanently removes this record from the database. This action cannot be undone.",reasonLabel:"Reason for deletion (optional):",reasonPlaceholder:"Enter deletion reason…",softDeleteBtn:"Delete",permanentDeleteBtn:"Permanent Delete",cancelBtn:"Cancel",deleting:"Deleting…"},view:"View",back:"← Back",clear:"Clear",search:"Search",loading:"Loading...",saving:"Saving...",savedOk:"Saved successfully!",home:"Home",noRecords:"No records found",login:{subtitle:"Sign in to continue",username:"USERNAME",password:"PASSWORD",usernamePlaceholder:"Enter username",passwordPlaceholder:"Enter password",signIn:"Sign In",signingIn:"Signing in...",invalidCreds:"Invalid username or password",emptyFields:"Please enter username and password",connError:"Connection error: "},myProfile:"My Profile",signOut:"Sign Out",switchLang:"العربية (RTL)",filter:{numberTitle:"Number / Title",searchPlaceholder:"Search...",organization:"Organization",department:"Department",branch:"Branch",status:"Status",allOrgs:"All Organizations",allDepts:"All Departments",allBranches:"All Branches",allStatuses:"All Statuses",allTypes:"All Types"},col:{number:"Number",title:"Title",organization:"Organization",type:"Type",status:"Status",actions:"Actions",name:"Name",department:"Department",branch:"Branch",city:"City",email:"Email",management:"Management",organization_type:"Type",frequency:"Frequency",period:"Period",startDate:"Start Date",endDate:"End Date",auditor:"Auditor",manager:"Manager",functions:"Functions",requestedOn:"Requested On"},field:{number:"Number",title:"Title",organization:"Organization",management:"Management",department:"Department",section:"Section",branch:"Branch",type:"Type",date:"Date",time:"Time",status:"Status",description:"Description",assignedTo:"Assigned To",hsesField:"HSES Field",priority:"Priority",economyClass:"Economy Class",entityScope:"Entity Scope",productRelation:"Product Relation",repeatedEvent:"Repeated Event",solution:"Solution / Action Plan",actualCost:"Actual Cost",summary:"Resolution Summary",auditorComment:"Auditor Comment",incidentClass:"Incident Class",incidentField:"Incident Field",currentCondition:"Current Condition",proposedCondition:"Proposed Condition",ideaClass:"Idea Class",startingDate:"Starting Date",endingDate:"Ending Date",budget:"Budget",currency:"Currency",notes:"Notes",cycle:"Cycle",stage:"Stage",completionPct:"Completion %",actor:"Actor",escalationLevel:"Escalation Level",dateStart:"Start Date",dateEnd:"End Date",cycleType:"Cycle Type",progressIndicators:"Progress Indicators",impactLevel:"Impact Level",kpiName:"KPI Name",kpiType:"KPI Type",kpiMeasure:"KPI Measure",costPerCycle:"Cost per Cycle",chainLocation:"Chain Location",notifyManager:"Notify Manager",creationDate:"Creation Date",statusActive:"Active",statusInactive:"Inactive",name1:"Name",fullName:"Full Name",username:"Username",emailAddress:"Email Address",phoneNumber:"Phone Number",category:"Category",since:"Since",active:"Active",inactive:"Inactive",enabled:"Enabled",selectMgr:"-- Select manager --",select:"-- Select --",selectType:"-- Select type --",selectClass:"-- Select class --",selectField:"-- Select field --",selectStatus:"-- Select status --",solutionPlaceholder:"Describe the solution or action taken…",commentPlaceholder:"Optional comment…",high:"High",normal:"Normal",expenses:"Expenses",capital:"Capital",earn:"Earn",payLoss:"Pay/Loss",upstream:"Upstream",onstream:"On-stream",downstream:"Downstream",government:"Government",private:"Private",linkedOrder:"Linked Order",linkedIdea:"Linked Idea",convertedToOrder:"Converted to Order",originatingIdea:"Originating Idea",viewOrder:"View Order",viewIdea:"View Idea",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",cycleActive:"Active",cycleCompleted:"Completed",cyclePaused:"Paused",updateWindowDays:"Update Window (days)",incidentTriageWindowDays:"Triage Window (days)",incidentResolutionWindowDays:"Resolution Window (days)",orgAcronym:"Acronym",contactEmail:"Contact Email",orgCity:"City",orgName:"Organization Name",organizationType:"Organization Type",revenue_growth:"Revenue Growth (%)",net_profit:"Net Profit",cash_flow:"Cash Flow",strategic_goal_pct:"Strategic Goal (%)",customer_satisfaction:"Customer Satisfaction",employee_turnover_pct:"Employee Turnover (%)",open_safety_incidents:"Open Safety Incidents",compliance_score:"Compliance Score"},wf:{workflow:"Workflow",noActions:"No actions available for your role in this state.",applying:"Applying…",submit:"Submit",assignToManager:"Assign to Manager",reject:"Reject",submitSolution:"Submit Solution",resolutionComplete:"Resolution complete",moveToOutsourcing:"Move to Outsourcing",closeIdea:"Close Idea"},steps:{auditorTriage:"Auditor Triage (Step 2)",managerSolution:"Manager Solution (Step 3)",ownerComment:"Owner / Auditor Comment (Step 4)",auditorEval:"Auditor Evaluation (Step 2)",managerReview:"Manager Review (Step 3)"},formTitle:{newIncident:"New Incident",editIncident:"Edit Incident",viewIncident:"Incident: ",newIdea:"New Idea",editIdea:"Edit Idea",viewIdea:"Idea: ",newOrder:"New Order",editOrder:"Edit Order",viewOrder:"Order: ",newProcess:"New Process",editProcess:"Edit Process",viewProcess:"Process: ",newOrg:"New Organization",editOrg:"Edit Organization",newMgmt:"New Management",editMgmt:"Edit Management",newDept:"New Department",editDept:"Edit Department",newBranch:"New Branch",editBranch:"Edit Branch",newUser:"New User",editUser:"Edit User",viewUser:"User Profile",newCycle:"New Cycle",editCycle:"Edit Cycle",newKpi:"New KPI Input",editKpi:"Edit KPI Input",newDelegation:"New Delegation",viewDelegation:"Delegation: "},saveIncident:"Save Incident",saveIdea:"Save Idea",saveOrder:"Save Order",saveProcess:"Save Process",saveOrg:"Save Organization",saveMgmt:"Save Management",saveDept:"Save Department",saveBranch:"Save Branch",saveUser:"Save User",saveCycle:"Save Cycle",saveKpi:"Save KPI Input",saveDelegation:"Send Delegation",saveName:"Save",dash:{allOrgs:"All organizations",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",level2:"Level 2 — Critical Escalation",level1:"Level 1 — Auditor Review Needed",overduePrefix:"Overdue for Triage — ",overdueSuffix:" incident(s) past 3-day window",untriaged:"Untriaged Incidents",recentKpi:"Recent KPI Inputs",manageKpi:"Manage KPI Inputs",escalatedProcesses:"Escalated Processes",escalatedOrders:"Escalated Orders",level:"Level",revenueGrowth:"Revenue Growth",netProfit:"Net Profit",strategicGoal:"Strategic Goal",customerSat:"Customer Sat.",compliance:"Compliance",safetyInc:"Safety Incidents",total:"Total"},noIncidents:"No incidents found",noIdeas:"No ideas found",noOrders:"No orders found",noProcesses:"No processes found",noUsers:"No users found",noData:"No data found",users:{category:"Category",number:"Number",fullName:"Full Name",username:"Username",email:"Email Address",phone:"Phone Number",organization:"Organization",management:"Management",department:"Department",branch:"Branch",since:"Since",status:"Status",tools:"Tools",active:"Active",inactive:"Inactive",setPassword:"Set Password",newPassword:"New password",passwordUpdated:"Password updated!",passwordFailed:"Failed. Please try again.",disableConfirm:"Delete user? They will no longer appear in the list.",password:"Password"},inbox:{title:"Inbox",noMessages:"No messages"},reports:{title:"Reports",selectOrg:"Select Organization",generate:"Generate Report"},comments:{title:"Comments",placeholder:"Write a comment…",post:"Post",noComments:"No comments yet."},activity:{title:"Activity Log",created:"Created",by:"by"}},Ey={rtl:!0,nav:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",reports:"التقارير",users:"المستخدمون",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",settings:"الإعدادات"},pages:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",reports:"التقارير",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",users:"المستخدمون"},new:"+ جديد",save:"حفظ",cancel:"إلغاء",edit:"تعديل",delete:"حذف",deletedBadge:"محذوف",restore:"استعادة",restoring:"جارٍ الاستعادة...",restoredOk:"تمت استعادة السجل بنجاح!",deletedBanner:"⚠️ هذا السجل محذوف",deletedBy:"تم الحذف بواسطة",deletedOn:"تاريخ الحذف",deletedReason:"السبب",deleteModal:{title:"تأكيد الحذف",subtitle:"هل أنت متأكد من رغبتك في حذف هذا السجل؟",softDeleteTitle:"حذف",softDeleteDesc:"يتم نقل السجل إلى سلة المحذوفات. يمكن للمسؤول استعادته لاحقاً.",permanentDeleteTitle:"حذف نهائي",permanentDeleteDesc:"حذف السجل نهائياً من قاعدة البيانات. لا يمكن التراجع عن هذا الإجراء.",reasonLabel:"سبب الحذف (اختياري):",reasonPlaceholder:"أدخل سبب الحذف…",softDeleteBtn:"حذف",permanentDeleteBtn:"حذف نهائي",cancelBtn:"إلغاء",deleting:"جارٍ الحذف…"},view:"عرض",back:"رجوع →",clear:"مسح",search:"بحث",loading:"جارٍ التحميل...",saving:"جارٍ الحفظ...",savedOk:"تم الحفظ بنجاح!",home:"الرئيسية",noRecords:"لا توجد سجلات",login:{subtitle:"تسجيل الدخول للمتابعة",username:"اسم المستخدم",password:"كلمة المرور",usernamePlaceholder:"أدخل اسم المستخدم",passwordPlaceholder:"أدخل كلمة المرور",signIn:"تسجيل الدخول",signingIn:"جارٍ تسجيل الدخول...",invalidCreds:"اسم المستخدم أو كلمة المرور غير صحيحة",emptyFields:"الرجاء إدخال اسم المستخدم وكلمة المرور",connError:"خطأ في الاتصال: "},myProfile:"ملفي الشخصي",signOut:"تسجيل الخروج",switchLang:"English (LTR)",filter:{numberTitle:"الرقم / العنوان",searchPlaceholder:"بحث...",organization:"المؤسسة",department:"القسم",branch:"الفرع",status:"الحالة",allOrgs:"جميع المؤسسات",allDepts:"جميع الأقسام",allBranches:"جميع الفروع",allStatuses:"جميع الحالات",allTypes:"جميع الأنواع"},col:{number:"الرقم",title:"العنوان",organization:"المؤسسة",type:"النوع",status:"الحالة",actions:"الإجراءات",name:"الاسم",department:"القسم",branch:"الفرع",city:"المدينة",email:"البريد الإلكتروني",management:"الإدارة",organization_type:"النوع",frequency:"التكرار",period:"الفترة",startDate:"تاريخ البدء",endDate:"تاريخ الانتهاء",auditor:"المدقق",manager:"المدير",functions:"الوظائف",requestedOn:"تاريخ الطلب"},field:{number:"الرقم",title:"العنوان",organization:"المؤسسة",management:"الإدارة",department:"القسم",section:"القطاع",branch:"الفرع",type:"النوع",date:"التاريخ",time:"الوقت",status:"الحالة",description:"الوصف",assignedTo:"مُسند إلى",hsesField:"مجال السلامة والصحة",priority:"الأولوية",economyClass:"التصنيف الاقتصادي",entityScope:"نطاق الكيان",productRelation:"علاقة المنتج",repeatedEvent:"حدث متكرر",solution:"الحل / خطة العمل",actualCost:"التكلفة الفعلية",summary:"ملخص الحل",auditorComment:"تعليق المدقق",incidentClass:"تصنيف الحادث",incidentField:"مجال الحادث",currentCondition:"الوضع الراهن",proposedCondition:"الوضع المقترح",ideaClass:"تصنيف الفكرة",startingDate:"تاريخ البدء",endingDate:"تاريخ الانتهاء",budget:"الميزانية",currency:"العملة",notes:"الملاحظات",cycle:"الدورة",stage:"المرحلة",completionPct:"نسبة الاكتمال",actor:"المنفذ",escalationLevel:"مستوى التصعيد",dateStart:"تاريخ البدء",dateEnd:"تاريخ الانتهاء",cycleType:"نوع الدورة",progressIndicators:"مؤشرات التقدم",impactLevel:"مستوى التأثير",kpiName:"اسم المؤشر",kpiType:"نوع المؤشر",kpiMeasure:"قياس المؤشر",costPerCycle:"التكلفة لكل دورة",chainLocation:"موقع السلسلة",notifyManager:"إشعار المدير",creationDate:"تاريخ الإنشاء",statusActive:"نشط",statusInactive:"غير نشط",name1:"الاسم",fullName:"الاسم الكامل",username:"اسم المستخدم",emailAddress:"البريد الإلكتروني",phoneNumber:"رقم الهاتف",category:"الفئة",since:"منذ",active:"نشط",inactive:"غير نشط",enabled:"مفعّل",selectMgr:"-- اختر المدير --",select:"-- اختر --",selectType:"-- اختر النوع --",selectClass:"-- اختر التصنيف --",selectField:"-- اختر المجال --",selectStatus:"-- اختر الحالة --",solutionPlaceholder:"صف الحل أو الإجراء المتخذ…",commentPlaceholder:"تعليق اختياري…",high:"عالي",normal:"عادي",expenses:"مصروفات",capital:"رأس مال",earn:"إيرادات",payLoss:"دفع/خسارة",upstream:"مرحلة المنبع",onstream:"على الخط",downstream:"مرحلة المصب",government:"حكومي",private:"خاص",linkedOrder:"الأمر المرتبط",linkedIdea:"الفكرة المرتبطة",convertedToOrder:"تم التحويل إلى أمر",originatingIdea:"الفكرة الأصلية",viewOrder:"عرض الأمر",viewIdea:"عرض الفكرة",monthly:"شهري",quarterly:"ربع سنوي",yearly:"سنوي",cycleActive:"نشط",cycleCompleted:"مكتمل",cyclePaused:"موقوف",updateWindowDays:"نافذة التحديث (أيام)",incidentTriageWindowDays:"نافذة الفرز (أيام)",incidentResolutionWindowDays:"نافذة الحل (أيام)",orgAcronym:"الاختصار",contactEmail:"البريد الإلكتروني للتواصل",orgCity:"المدينة",orgName:"اسم المؤسسة",organizationType:"نوع المؤسسة",revenue_growth:"نمو الإيرادات (%)",net_profit:"صافي الربح",cash_flow:"التدفق النقدي",strategic_goal_pct:"الهدف الاستراتيجي (%)",customer_satisfaction:"رضا العملاء",employee_turnover_pct:"معدل دوران الموظفين (%)",open_safety_incidents:"حوادث السلامة المفتوحة",compliance_score:"درجة الامتثال"},wf:{workflow:"سير العمل",noActions:"لا توجد إجراءات متاحة لدورك في هذه الحالة.",applying:"جارٍ التطبيق...",submit:"إرسال",assignToManager:"تعيين للمدير",reject:"رفض",submitSolution:"إرسال الحل",resolutionComplete:"اكتمال الحل",moveToOutsourcing:"نقل للاستعانة بمصادر خارجية",closeIdea:"إغلاق الفكرة"},steps:{auditorTriage:"فرز المدقق (الخطوة 2)",managerSolution:"حل المدير (الخطوة 3)",ownerComment:"تعليق المالك / المدقق (الخطوة 4)",auditorEval:"تقييم المدقق (الخطوة 2)",managerReview:"مراجعة المدير (الخطوة 3)"},formTitle:{newIncident:"حادث جديد",editIncident:"تعديل الحادث",viewIncident:"الحادث: ",newIdea:"فكرة جديدة",editIdea:"تعديل الفكرة",viewIdea:"الفكرة: ",newOrder:"طلب جديد",editOrder:"تعديل الطلب",viewOrder:"الطلب: ",newProcess:"عملية جديدة",editProcess:"تعديل العملية",viewProcess:"العملية: ",newOrg:"مؤسسة جديدة",editOrg:"تعديل المؤسسة",newMgmt:"إدارة جديدة",editMgmt:"تعديل الإدارة",newDept:"قسم جديد",editDept:"تعديل القسم",newBranch:"فرع جديد",editBranch:"تعديل الفرع",newUser:"مستخدم جديد",editUser:"تعديل المستخدم",viewUser:"ملف المستخدم",newCycle:"دورة جديدة",editCycle:"تعديل الدورة",newKpi:"مؤشر أداء جديد",editKpi:"تعديل مؤشر الأداء",newDelegation:"تفويض جديد",viewDelegation:"التفويض: "},saveIncident:"حفظ الحادث",saveIdea:"حفظ الفكرة",saveOrder:"حفظ الطلب",saveProcess:"حفظ العملية",saveOrg:"حفظ المؤسسة",saveMgmt:"حفظ الإدارة",saveDept:"حفظ القسم",saveBranch:"حفظ الفرع",saveUser:"حفظ المستخدم",saveCycle:"حفظ الدورة",saveKpi:"حفظ مؤشر الأداء",saveDelegation:"إرسال التفويض",saveName:"حفظ",dash:{allOrgs:"جميع المؤسسات",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",level2:"المستوى 2 — تصعيد حرج",level1:"المستوى 1 — مراجعة المدقق مطلوبة",overduePrefix:"متأخر للفرز — ",overdueSuffix:" حادث(ة) تجاوز نافذة 3 أيام",untriaged:"حوادث غير مفرزة",recentKpi:"مؤشرات الأداء الأخيرة",manageKpi:"إدارة مؤشرات الأداء",escalatedProcesses:"عمليات متصاعدة",escalatedOrders:"طلبات متصاعدة",level:"المستوى",revenueGrowth:"نمو الإيرادات",netProfit:"صافي الربح",strategicGoal:"الهدف الاستراتيجي",customerSat:"رضا العملاء",compliance:"الامتثال",safetyInc:"حوادث السلامة",total:"الإجمالي"},noIncidents:"لا توجد حوادث",noIdeas:"لا توجد أفكار",noOrders:"لا توجد طلبات",noProcesses:"لا توجد عمليات",noUsers:"لا يوجد مستخدمون",noData:"لا توجد بيانات",users:{category:"الفئة",number:"الرقم",fullName:"الاسم الكامل",username:"اسم المستخدم",email:"البريد الإلكتروني",phone:"رقم الهاتف",organization:"المؤسسة",management:"الإدارة",department:"القسم",branch:"الفرع",since:"منذ",status:"الحالة",tools:"الأدوات",active:"نشط",inactive:"غير نشط",setPassword:"تعيين كلمة المرور",newPassword:"كلمة مرور جديدة",passwordUpdated:"تم تحديث كلمة المرور!",passwordFailed:"فشل. الرجاء المحاولة مرة أخرى.",disableConfirm:"حذف المستخدم؟ لن يظهر في القائمة بعد الآن.",password:"كلمة المرور"},inbox:{title:"البريد الوارد",noMessages:"لا توجد رسائل"},reports:{title:"التقارير",selectOrg:"اختر المؤسسة",generate:"إنشاء التقرير"},comments:{title:"التعليقات",placeholder:"اكتب تعليقاً…",post:"نشر",noComments:"لا توجد تعليقات بعد."},activity:{title:"سجل النشاط",created:"أُنشئ",by:"بواسطة"}};function Py({isOpen:e,doctype:t,docname:s,docTitle:r,isAdmin:l,isDeleting:i,onClose:a,onConfirmSoftDelete:c,onConfirmPermanentDelete:d}){const p=ne(),[v,f]=w.useState("");if(w.useEffect(()=>{e&&f("")},[e]),w.useEffect(()=>{const m=j=>{j.key==="Escape"&&e&&!i&&a()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[e,i,a]),!e)return null;const u=t.replace(/^SB\s+/,"");return n.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:m=>{m.target===m.currentTarget&&!i&&a()},children:n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[n.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"#fee2e2",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#ef4444"},children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"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"}),n.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),n.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("h3",{style:{margin:0,fontSize:14,fontWeight:700,color:"#1e293b"},children:p.deleteModal.title}),n.jsx("p",{style:{margin:"2px 0 0",fontSize:11,color:"#64748b",lineHeight:1.3},children:p.deleteModal.subtitle})]}),n.jsx("button",{type:"button",onClick:a,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:"✕"})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"6px 10px",marginBottom:12,display:"flex",alignItems:"center",gap:6},children:[n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.4px",flexShrink:0},children:[u,":"]}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1e293b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r?`${r} (${s})`:s})]}),n.jsxs("div",{style:{marginBottom:14},children:[n.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#475569",marginBottom:4},children:p.deleteModal.reasonLabel}),n.jsx("input",{type:"text",value:v,onChange:m=>f(m.target.value),placeholder:p.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:m=>{m.target.style.borderColor="#6366f1",m.target.style.boxShadow="0 0 0 2px rgba(99, 102, 241, 0.15)"},onBlur:m=>{m.target.style.borderColor="#cbd5e1",m.target.style.boxShadow="none"}})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:8,flexWrap:"wrap"},children:[n.jsx("button",{type:"button",onClick:a,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:p.deleteModal.cancelBtn}),n.jsxs("button",{type:"button",onClick:()=>c(v),disabled:i,title:p.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:m=>{i||(m.currentTarget.style.background="#fee2e2")},onMouseLeave:m=>{i||(m.currentTarget.style.background="#fff1f2")},children:[n.jsx("span",{children:"🗑️"}),i?p.deleteModal.deleting:p.deleteModal.softDeleteBtn]}),l&&n.jsxs("button",{type:"button",onClick:()=>d(v),disabled:i,title:p.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:m=>{i||(m.currentTarget.style.background="#dc2626")},onMouseLeave:m=>{i||(m.currentTarget.style.background="#ef4444")},children:[n.jsx("span",{children:"💥"}),i?p.deleteModal.deleting:p.deleteModal.permanentDeleteBtn]})]})]})})}const lh="/assets/logo-BlYgMyx5.png";function ih({collapsed:e,onToggleCollapsed:t,activePage:s,onNavigate:r,hasDashboard:l,hasReports:i,hasDelegations:a,role:c,hideSettings:d,rtl:p,navLabels:v,settingsLabel:f}){const u=d?[]:hy(c);return n.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:[n.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:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[n.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:n.jsx("img",{src:lh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:m=>{m.currentTarget.style.display="none"}})}),!e&&n.jsx("div",{style:{display:"flex",flexDirection:"column"},children:n.jsx("span",{style:{fontSize:14,fontWeight:800,whiteSpace:"nowrap",color:"#ffffff",letterSpacing:"-0.2px"},children:p?"صدرة للأعمال":"SEERA-ASM"})})]}),n.jsx("button",{type:"button",onClick:t,title:e?p?"توسيع":"Expand":p?"طي":"Collapse",style:{background:"rgba(255, 255, 255, 0.06)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:6,color:"rgba(255, 255, 255, 0.75)",cursor:"pointer",fontSize:11,padding:"4px 7px",flexShrink:0,lineHeight:1,transition:"all 0.15s ease"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(255, 255, 255, 0.15)",m.currentTarget.style.color="#ffffff"},onMouseLeave:m=>{m.currentTarget.style.background="rgba(255, 255, 255, 0.06)",m.currentTarget.style.color="rgba(255, 255, 255, 0.75)"},children:e?"▶":"✕"})]}),n.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[py.filter(({id:m})=>(m!=="dashboard"||l)&&(m!=="reports"||i)&&(m!=="delegations"||a)).map(({id:m,icon:j})=>{const h=v[m]||m,S=m===s;return n.jsxs("div",{onClick:()=>r(m),title:e?h: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:S?"rgba(99, 102, 241, 0.28)":"transparent",border:S?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:S?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:S?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2,position:"relative"},onMouseEnter:g=>{S||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{S||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[n.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:j}),!e&&n.jsx("span",{children:h})]},m)}),u.length>0&&n.jsxs(n.Fragment,{children:[!e&&n.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:f}),e&&n.jsx("div",{style:{margin:"10px auto",width:26,borderTop:"1px solid rgba(255, 255, 255, 0.12)"}}),u.map(({id:m,icon:j})=>{const h=v[m]||m,S=m===s;return n.jsxs("div",{onClick:()=>r(m),title:e?h: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:S?"rgba(99, 102, 241, 0.28)":"transparent",border:S?"1px solid rgba(129, 140, 248, 0.35)":"1px solid transparent",borderRadius:8,fontSize:e?15:13,color:S?"#ffffff":"rgba(255, 255, 255, 0.78)",fontWeight:S?600:400,transition:"all 0.15s ease",whiteSpace:"nowrap",marginBottom:2},onMouseEnter:g=>{S||(g.currentTarget.style.background="rgba(255, 255, 255, 0.08)",g.currentTarget.style.color="#ffffff")},onMouseLeave:g=>{S||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="rgba(255, 255, 255, 0.78)")},children:[n.jsx("span",{style:{flexShrink:0,fontSize:e?15:13},children:j}),!e&&n.jsx("span",{children:h})]},m)})]})]})]})}const kr=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 js="";async function Bd(){try{const e=await fetch(`${oe}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const s=(await e.json()).message||"";if(s)return js=s,s}}catch(e){console.error("CSRF fetch error:",e)}return js}async function Kt(){return js||await Bd(),js}function Ui(e,t){try{if(e!=null&&e._server_messages){const s=JSON.parse(e._server_messages);if(s.length){const r=JSON.parse(s[0]);if(r!=null&&r.message)return r.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function St(e,t,s=[]){if(kr.has(e)){const a=`${oe}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,c=await fetch(a,{credentials:"include",headers:{Accept:"application/json"}});if(!c.ok)throw new Error(`API Error: ${c.status}`);return(await c.json()).message}const r=s.length?`?fields=${encodeURIComponent(JSON.stringify(s))}`:"",l=await fetch(`${oe}/api/v1/resource/${e}/${encodeURIComponent(t)}${r}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!l.ok)throw new Error(`API Error: ${l.status}`);return(await l.json()).data}async function Fo(e,t,s="",r=!1){const l=await Kt();if(kr.has(e)){const c=new URLSearchParams({doctype:e,name:t});s&&c.append("reason",s),r&&c.append("permanent","1");const d=await fetch(`${oe}/api/method/sidrah_business.api.delete_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:c.toString()});if(!d.ok){const p=await d.json().catch(()=>({}));throw new Error(Ui(p,`Error deleting ${t}`))}return}const i=new URLSearchParams({doctype:e,name:t});s&&i.append("reason",s),r&&i.append("permanent","1");const a=await fetch(`${oe}/api/method/sidrah_business.soft_delete.soft_delete`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:i.toString()});if(!a.ok){const c=await a.json().catch(()=>({}));throw new Error(Ui(c,`Error deleting ${t}`))}return await a.json()}async function Ay(e,t){const s=await Kt();if(kr.has(e)){const i=new URLSearchParams({doctype:e,name:t}),a=await fetch(`${oe}/api/method/sidrah_business.api.restore_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:i.toString()});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(Ui(d,`Error restoring ${t}`))}return(await a.json()).message||{success:!0}}const r=new URLSearchParams({doctype:e,name:t}),l=await fetch(`${oe}/api/method/sidrah_business.soft_delete.restore_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!l.ok){const i=await l.json().catch(()=>({}));throw new Error(Ui(i,`Error restoring ${t}`))}return await l.json()}async function Ce(e){if(kr.has(e))try{const r=`${oe}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,l=await fetch(r,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}const t=encodeURIComponent('["*"]'),s=`${oe}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;try{const r=await fetch(s,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return r.status===401||r.status===403?[]:r.ok?(await r.json()).data||[]:[]}catch(r){return console.error("Get error:",r),[]}}async function Fa(e,t){const s=await Kt();if(kr.has(e)){const l=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${oe}/api/method/sidrah_business.api.create_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:l.toString()});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.message||c.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const r=`${oe}/api/v1/resource/${e}`;try{const l=await fetch(r,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(t)});if(l.status===401||l.status===403)throw new Error("Permission denied - login required");if(!l.ok){const i=await l.json();throw new Error(i.message||i.exc||`API Error: ${l.status}`)}return await l.json()}catch(l){throw console.error("Post error:",l),l}}async function Fi(e,t,s){const r=await Kt();if(kr.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(s)}),a=await fetch(`${oe}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:i.toString()});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error updating ${e}`)}return{data:(await a.json()).message}}const l=`${oe}/api/v1/resource/${e}/${encodeURIComponent(t)}`;try{const i=await fetch(l,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":r},body:JSON.stringify(s)});if(i.status===401||i.status===403)throw new Error("Permission denied - login required");if(!i.ok){const a=await i.json();throw new Error(a.message||"Update Error")}return await i.json()}catch(i){throw console.error("Update error:",i),i}}async function Ry(){const e=`${oe}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.status===401||t.status===403?[]:t.ok?(await t.json()).data||[]:[]}catch(t){return console.error("Get users error:",t),[]}}async function Ly(e,t){const s=new FormData;s.append("usr",e),s.append("pwd",t);const l=await(await fetch(`${oe}/api/method/login`,{method:"POST",credentials:"include",body:s})).json();return l.csrf_token?js=l.csrf_token:await Bd(),l}async function Oy(){const e=await Kt();try{await fetch(`${oe}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}js=""}function Dy(){return js}async function ah(){try{const e=await fetch(`${oe}/api/method/frappe.auth.get_logged_user`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return e.ok&&(await e.json()).message||""}catch{return""}}async function Ny(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${oe}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).data||[]:[]}catch{return[]}}async function Wy(){const e=`${oe}/api/method/sidrah_business.api.get_user_role_map`;try{const t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function oh(e,t){await Fi("User",e,{new_password:t})}async function By(e=20){try{const t=`${oe}/api/method/sidrah_business.api.get_notifications?limit=${e}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function $y(){const e=await Kt();try{await fetch(`${oe}/api/method/sidrah_business.api.mark_notifications_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":e}})}catch{}}async function Uy(e){const t=await Kt();try{await fetch(`${oe}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:new URLSearchParams({name:e}).toString()})}catch{}}async function Fy(e){const t=await Kt(),s=new URLSearchParams({name:e});await fetch(`${oe}/api/method/sidrah_business.api.disable_user`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:s.toString()})}async function My(e,t){try{const s=`${oe}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,r=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function Hy(e,t,s){const r=await Kt(),l=new URLSearchParams({doctype:e,docname:t,content:s}),i=await fetch(`${oe}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:l.toString()});if(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function Gy(e,t){try{const s=`${oe}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,r=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function dh(e){try{const t=`${oe}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,s=await fetch(t,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Ky(){try{const e=`${oe}/api/method/sidrah_business.api.get_my_organization`,t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.ok&&(await t.json()).message||""}catch{return""}}async function ws(e,t={}){const s=await Kt(),r=new URLSearchParams(t),l=await fetch(`${oe}/api/method/sidrah_business.api.${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!l.ok){const a=await l.json().catch(()=>({}));throw new Error(a.message||a.exc||`Error calling ${e}`)}return(await l.json()).message}async function Qy(e,t,s="",r,l,i){const a={name:e,action:t,comment:s};return r!==void 0&&(a.stage=r),i!==void 0&&(a.cycle_status=i),ws("apply_order_workflow",a)}async function Yy(e,t,s=""){return ws("apply_incident_workflow",{name:e,action:t,fields_json:s})}async function Xy(e,t,s=""){return ws("apply_idea_workflow",{name:e,action:t,fields_json:s})}async function qy(e=""){const t=`${oe}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function Jy(e,t={}){return ws("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function Vy(){try{const e=`${oe}/api/method/sidrah_business.api.get_inbox_items`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Zy(e,t,s="",r=""){return ws("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:s,remarks:r})}async function e0(e,t,s=""){return ws("respond_to_delegation",{name:e,response:t,remarks:s})}async function t0(e,t=""){return ws("revoke_delegation",{name:e,remarks:t})}async function n0(){try{const e=`${oe}/api/method/sidrah_business.api.get_delegations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function s0(e){const t=`${oe}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,s=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error("Failed to load delegation");return(await s.json()).message}async function r0(){try{const e=`${oe}/api/method/sidrah_business.api.get_my_delegated_functions`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function l0(){try{const e=`${oe}/api/method/sidrah_business.api.get_my_delegated_organizations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function i0(){try{const e=await Kt(),t=await fetch(`${oe}/api/method/sidrah_business.api.get_group_companies`,{method:"GET",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":e}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function a0(){const e=Dy();return e||Bd()}async function Kr(e){const t=await fetch(`${oe}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r.message||`Failed to load process (${t.status})`)}const s=await t.json();return s.message||s.data}async function o0(e,t,s={}){const r=await a0(),l=new URLSearchParams({name:e,action:t});s.actor_status&&l.set("actor_status",String(s.actor_status)),s.actor_comment&&l.set("actor_comment",String(s.actor_comment)),s.progress_indicators&&l.set("progress_indicators",JSON.stringify(s.progress_indicators));const i=await fetch(`${oe}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:l.toString()});if(!i.ok){const c=await i.json().catch(()=>({})),d=c.message||(c.exception?String(c.exception).split(`
`).pop():"")||c.exc_type||`Workflow action "${t}" failed (${i.status})`;throw new Error(d)}const a=await i.json();return a.message||a.data}const d0=["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"],bu=new Set(d0),c0={"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 Su(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return bu.has(e)?e:null;const t=window.location.pathname.split("/").filter(Boolean).pop()||"";return bu.has(t)?t:null}function u0(e){return e?c0[e]??e:null}function p0(e){return`#/${e}`}function f0({onLogin:e}){const t=ne(),[s,r]=w.useState(""),[l,i]=w.useState(""),[a,c]=w.useState(""),[d,p]=w.useState(!1),[v,f]=w.useState(!1),[u,m]=w.useState(!1),j=async()=>{if(!s||!l){c(t.login.emptyFields);return}p(!0),c("");try{const S=await Ly(s,l);if(S.message==="Logged In"){const x=await ah()||s,o=await dh(x),y=o.some(_=>["SB Admin","System Manager"].includes(_))?"Admin":o.includes("SB Auditor")?"Auditor":o.includes("SB Owner")?"Owner":o.includes("SB X-Auditor")?"XAuditor":o.includes("SB Manager")?"Manager":"Employee";e({name:x,full_name:S.full_name||s,role:y})}else c(t.login.invalidCreds)}catch(S){c(t.login.connError+(S instanceof Error?S.message:"Unknown"))}p(!1)},h=S=>({width:"100%",padding:"11px 16px",border:`1.5px solid ${S?"#6366f1":"#e2e8f0"}`,borderRadius:8,fontSize:14,background:S?"#f8faff":"#ffffff",color:"#1e293b",outline:"none",transition:"all 0.18s ease",boxSizing:"border-box",boxShadow:S?"0 0 0 3px rgba(99, 102, 241, 0.15)":"none"});return n.jsx("div",{style:{minHeight:"100vh",background:"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif",padding:"20px"},children:n.jsxs("div",{style:{width:380,maxWidth:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:[n.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:n.jsx("img",{src:lh,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"contain"},onError:S=>{S.currentTarget.style.display="none"}})}),n.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[n.jsx("h1",{style:{fontSize:22,fontWeight:800,color:"#0f172a",letterSpacing:"-0.3px",margin:0},children:t.rtl?"صدرة للأعمال":"SEERA-ASM"}),n.jsx("div",{style:{fontSize:13,color:"#6366f1",fontWeight:600,marginTop:4},children:t.rtl?"نظام إدارة العمليات والأعمال":"Asset Management System"}),n.jsx("div",{style:{fontSize:12,color:"#94a3b8",marginTop:6},children:t.login.subtitle})]}),n.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:12},children:[n.jsx("div",{children:n.jsx("input",{value:s,onChange:S=>r(S.target.value),onKeyDown:S=>S.key==="Enter"&&j(),onFocus:()=>f(!0),onBlur:()=>f(!1),style:h(v),placeholder:t.login.usernamePlaceholder,autoComplete:"username"})}),n.jsx("div",{children:n.jsx("input",{type:"password",value:l,onChange:S=>i(S.target.value),onKeyDown:S=>S.key==="Enter"&&j(),onFocus:()=>m(!0),onBlur:()=>m(!1),style:h(u),placeholder:t.login.passwordPlaceholder,autoComplete:"current-password"})}),a&&n.jsx("div",{style:{padding:"9px 12px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:12,textAlign:"center"},children:a}),n.jsx("button",{type:"button",onClick:j,disabled:d,style:{background:d?"#818cf8":"#4f46e5",color:"white",border:"none",padding:"12px",borderRadius:8,fontSize:14,cursor:d?"not-allowed":"pointer",fontWeight:600,marginTop:4,boxShadow:"0 2px 8px rgba(79, 70, 229, 0.3)",transition:"all 0.18s ease"},onMouseEnter:S=>{d||(S.currentTarget.style.background="#4338ca")},onMouseLeave:S=>{d||(S.currentTarget.style.background="#4f46e5")},children:d?t.login.signingIn:t.login.signIn}),n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("span",{style:{fontSize:12,color:"#6366f1",cursor:"pointer",fontWeight:500},onMouseEnter:S=>S.currentTarget.style.textDecoration="underline",onMouseLeave:S=>S.currentTarget.style.textDecoration="none",children:t.rtl?"نسيت كلمة المرور؟":"Forgot password?"})}),n.jsx("div",{style:{textAlign:"center",marginTop:8},children:n.jsx("button",{type:"button",onClick:rh,style:{fontSize:12,color:"#94a3b8",background:"none",border:"none",cursor:"pointer"},onMouseEnter:S=>S.currentTarget.style.color="#475569",onMouseLeave:S=>S.currentTarget.style.color="#94a3b8",children:t.switchLang})})]})]})})}function h0(e,t){const s=parseInt(e.replace("#",""),16),r=s>>16&255,l=s>>8&255,i=s&255,a=c=>Math.round(c+(255-c)*t);return`rgb(${a(r)}, ${a(l)}, ${a(i)})`}function Dr(e,t){const s=parseInt(e.replace("#",""),16),r=s>>16&255,l=s>>8&255,i=s&255;return`rgba(${r}, ${l}, ${i}, ${t})`}function ql({title:e,data:t,color:s,onSelect:r}){const[,l]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((d,p)=>h0(s,Math.min(p*.16,.7))),c=i.map(([d,p,v],f)=>[d,p,v,a[f]]).filter(([,d])=>d>0);return n.jsxs("div",{className:"status-card",style:{borderRadius:18,padding:"16px 18px 18px",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0,position:"relative",overflow:"hidden"},children:[n.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${Dr(s,.09)} 0%, transparent 55%)`}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, ${Dr(s,.35)})`}}),n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[n.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),n.jsx("span",{style:{fontSize:14,fontWeight:800,color:"white",background:s,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${Dr(s,.35)}`},children:l})]}),l>0&&n.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:Dr(s,.1),marginBottom:13},children:c.map(([d,p,v,f],u)=>n.jsx("div",{title:`${d}: ${p}`,onClick:m=>{m.stopPropagation(),r==null||r(v)},style:{flex:`${p} 0 0`,background:f,borderRight:u<c.length-1?"2px solid white":"none",cursor:r?"pointer":"default"}},d))}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:i.map(([d,p,v],f)=>n.jsxs("div",{className:"status-card-row",onClick:p>0?u=>{u.stopPropagation(),r==null||r(v)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:p>0&&r?"pointer":"default",transition:"background 0.12s"},children:[n.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:a[f],flexShrink:0,boxShadow:`0 0 0 3px ${Dr(a[f],.18)}`}}),n.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),n.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:p})]},d))})]})}function Ot({value:e,onChange:t,organizations:s,placeholder:r="-- Choose organization --",disabled:l=!1,small:i=!1}){var f;const[a,c]=w.useState(!1),d=w.useRef(null);w.useEffect(()=>{const u=m=>{d.current&&!d.current.contains(m.target)&&c(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const p=e?((f=s.find(u=>u.organization_name===e||u.name===e))==null?void 0:f.organization_name)??e:r,v=s.filter(u=>!!u.is_active||u.organization_name===e||u.name===e);return n.jsxs("div",{ref:d,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!l&&c(u=>!u),style:{width:"100%",padding:i?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:i?11:12,cursor:l?"default":"pointer",height:i?28:34,background:l?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",borderColor:a?"#3498db":"#ddd",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:l?.75:1},children:[n.jsx("span",{children:p}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:a?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),a&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx(wu,{label:r,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{t(""),c(!1)}}),v.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),v.map(u=>n.jsx(wu,{label:u.organization_name,selected:e===u.organization_name||e===u.name,active:!!u.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(u.organization_name),c(!1)}},u.name))]})})]})}function wu({label:e,selected:t,active:s,isPlaceholder:r,small:l,onClick:i}){const[a,c]=w.useState(!1),d=t?"#2563eb":a?"#f0f4ff":"transparent",p=t?"white":r?"#aaa":s?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:i,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{padding:l?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:d,color:p,transition:"background 0.1s"},children:e})}function Rn({items:e,type:t,onNavigate:s}){const r=ne();if(!e.length)return null;const l=t==="process"?"processes-form":"orders-form",i=t==="process"?r.dash.escalatedProcesses:r.dash.escalatedOrders;return n.jsxs("div",{children:[n.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[i," (",e.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(a=>n.jsxs("div",{onClick:()=>s(l,a.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:700,fontSize:12},children:a.number||a.name}),n.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:a.title})]}),n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[r.dash.level," ",a.escalation_level]})]},a.name))})]})}function g0({kpi:e}){const t=ne();return n.jsxs("div",{className:"dashboard-kpi-card",style:{borderRadius:12,padding:14,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[n.jsx("div",{style:{fontWeight:700,fontSize:13,color:"#1e293b"},children:e.organization}),n.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#6366f1",background:"#eff6ff",border:"1px solid #bfdbfe",padding:"1px 7px",borderRadius:12},children:e.period})]}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[{label:t.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—"},{label:t.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—"},{label:t.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—"},{label:t.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—"},{label:t.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—"},{label:t.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—"}].map(({label:s,val:r})=>n.jsxs("div",{style:{background:"#f8fafc",padding:"6px 8px",borderRadius:6,border:"1px solid #f1f5f9"},children:[n.jsx("div",{style:{fontSize:10,color:"#64748b",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.2px"},children:s}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginTop:1},children:r})]},s))})]})}function x0({data:e}){if(!e.length)return n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const t=Math.max(...e.map(s=>s.pass+s.fail+s.unknown),1);return n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",gap:10,alignItems:"flex-end",overflowX:"auto",paddingBottom:4},children:e.map(s=>{const r=s.pass+s.fail+s.unknown||1,l=80;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,minWidth:48},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:1,height:l,width:32},children:[n.jsx("div",{title:`Pass: ${s.pass}`,style:{height:Math.round(s.pass/t*l),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:s.pass?2:0}}),n.jsx("div",{title:`Fail: ${s.fail}`,style:{height:Math.round(s.fail/t*l),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:s.fail?2:0}}),n.jsx("div",{title:`Unknown: ${s.unknown}`,style:{height:Math.round(s.unknown/t*l),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:s.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:s.month.replace(/^(\d{4})-(\d{2})$/,(i,a,c)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+c-1]}
${a}`)}),n.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:r>1?Math.round(s.pass/r*100)+"%":"—"})]},s.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([s,r])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:s,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:r})]},r))})]})}function Ft({label:e,icon:t,onClick:s}){return n.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:7,padding:"7px 12px",background:"white",border:"1px solid #e8e8e8",borderRadius:8,cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 0.15s"},onMouseEnter:r=>r.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:r=>r.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[n.jsx("span",{style:{fontSize:15},children:t}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function m0({dashData:e,fi:t,fid:s,fo:r,fp:l,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,onNavigate:p,onNavigateStatus:v}){const f=ne(),u=(e==null?void 0:e.escalated_processes)||[],m=(e==null?void 0:e.escalated_orders)||[],j=(e==null?void 0:e.attention_processes)||[],h=(e==null?void 0:e.attention_orders)||[],S=(e==null?void 0:e.untriaged_incidents)||[],g=(e==null?void 0:e.overdue_triage)||[],x=u.length>0||m.length>0,o=j.length>0||h.length>0,y=[["Total",t.length,""],...i.map(C=>[C.name1||C.name,t.filter(R=>R.status===C.name).length,C.name])],_=[["Total",s.length,""],...a.map(C=>[C.name1||C.name,s.filter(R=>R.status===C.name).length,C.name])],T=[["Total",r.length,""],...c.map(C=>[C.name1||C.name,r.filter(R=>R.status===C.name).length,C.name])],A=[["Total",l.length,""],...d.map(C=>[C.name1||C.name,l.filter(R=>R.status===C.name).length,C.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(Ft,{label:"Incidents",icon:"⚠️",onClick:()=>p("incidents")}),n.jsx(Ft,{label:"Ideas",icon:"💡",onClick:()=>p("ideas")}),n.jsx(Ft,{label:"Orders",icon:"📦",onClick:()=>p("orders")}),n.jsx(Ft,{label:"Processes",icon:"⚙️",onClick:()=>p("processes")}),n.jsx(Ft,{label:"Inbox",icon:"📥",onClick:()=>p("inbox")}),n.jsx(Ft,{label:"Reports",icon:"📊",onClick:()=>p("reports")})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[n.jsx("div",{onClick:()=>p("incidents"),style:{cursor:"pointer"},children:n.jsx(ql,{title:f.dash.incidents,color:N.orange,data:y,onSelect:C=>v("incidents",C)})}),n.jsx("div",{onClick:()=>p("ideas"),style:{cursor:"pointer"},children:n.jsx(ql,{title:f.dash.ideas,color:N.blue,data:_,onSelect:C=>v("ideas",C)})}),n.jsx("div",{onClick:()=>p("orders"),style:{cursor:"pointer"},children:n.jsx(ql,{title:f.dash.orders,color:N.purple,data:T,onSelect:C=>v("orders",C)})}),n.jsx("div",{onClick:()=>p("processes"),style:{cursor:"pointer"},children:n.jsx(ql,{title:f.dash.processes,color:N.red,data:A,onSelect:C=>v("processes",C)})})]}),x&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:f.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Rn,{items:u,type:"process",onNavigate:p}),n.jsx(Rn,{items:m,type:"order",onNavigate:p})]})]}),o&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:f.dash.level1}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Rn,{items:j,type:"process",onNavigate:p}),n.jsx(Rn,{items:h,type:"order",onNavigate:p})]})]}),g.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:8},children:[f.dash.overduePrefix,g.length,f.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:g.map(C=>n.jsxs("div",{onClick:()=>p("incidents-form",C.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:C.number||C.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:C.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:C.date})]},C.name))})]}),S.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:N.orange,marginBottom:8},children:[f.dash.untriaged," (",S.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(C=>n.jsxs("div",{onClick:()=>p("incidents-form",C.name),style:{padding:"8px 12px",background:"#fffbeb",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:C.number||C.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:C.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:C.date})]},C.name))})]})]})}function y0({dashData:e,selectedOrg:t,onNavigate:s}){const r=ne(),[l,i]=w.useState([]),[a,c]=w.useState([]),[d,p]=w.useState(!1),v=(e==null?void 0:e.escalated_processes)||[],f=(e==null?void 0:e.escalated_orders)||[],u=(e==null?void 0:e.attention_processes)||[],m=(e==null?void 0:e.attention_orders)||[],j=(e==null?void 0:e.kpi_inputs)||[];w.useEffect(()=>{p(!0);const g=new URLSearchParams({months:"6"});t&&g.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${g}`,{credentials:"include",headers:{Accept:"application/json"}}).then(x=>x.json()).then(x=>{const o=x.message||[],y={};for(const _ of o)y[_.month]||(y[_.month]={pass:0,fail:0,unknown:0}),_.status==="Pass"?y[_.month].pass=_.count:_.status==="Fail"?y[_.month].fail=_.count:_.status==="Unknown"&&(y[_.month].unknown=_.count);i(Object.entries(y).map(([_,T])=>({month:_,...T})))}).catch(()=>{}).finally(()=>p(!1))},[t]),w.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(g=>g.json()).then(g=>{var x;c((((x=g.message)==null?void 0:x.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const h=v.length>0||f.length>0,S=u.length>0||m.length>0;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[n.jsx(Ft,{label:"Manage Users & Roles",icon:"👥",onClick:()=>s("users")}),n.jsx(Ft,{label:"Change Active Cycle",icon:"🔄",onClick:()=>s("cycles")}),n.jsx(Ft,{label:"KPI Inputs",icon:"📈",onClick:()=>s("kpi-input")}),n.jsx(Ft,{label:"Reports",icon:"📊",onClick:()=>s("reports")}),n.jsx(Ft,{label:"Organizations",icon:"🏢",onClick:()=>s("organizations")})]}),j.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:r.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:j.map(g=>n.jsx(g0,{kpi:g},g.name))}),n.jsx("button",{onClick:()=>s("kpi-input"),style:{marginTop:10,padding:"6px 14px",borderRadius:7,border:"1px solid #2980b9",background:"white",color:"#2980b9",fontWeight:600,fontSize:12,cursor:"pointer"},children:r.dash.manageKpi})]}),h&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",v.length+f.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Rn,{items:v,type:"process",onNavigate:s}),n.jsx(Rn,{items:f,type:"order",onNavigate:s})]})]}),S&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",u.length+m.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(Rn,{items:u,type:"process",onNavigate:s}),n.jsx(Rn,{items:m,type:"order",onNavigate:s})]})]}),n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:4},children:"Process Trend — Last 6 Months"}),n.jsx("p",{style:{fontSize:11,color:"#888",marginBottom:10},children:"Pass/Fail/Unknown ratio per month across all processes. Pass % shown at bottom of each bar."}),d?n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):n.jsx(x0,{data:l})]}),a.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:"Log Book — Recent Activity"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(g=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:g},g))})}),n.jsx("tbody",{children:a.map((g,x)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:g.timestamp?String(g.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:g.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:g.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:g.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.changes||"—"})]},x))})]})}),n.jsx("button",{onClick:()=>s("reports"),style:{marginTop:12,padding:"7px 16px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log (Reports →)"})]})]})}function v0({incidents:e,ideas:t,orders:s,processes:r,organizations:l,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,selectedOrg:p,onOrgChange:v,onNavigate:f,onNavigateStatus:u,userRole:m}){const[j,h]=w.useState(null);w.useEffect(()=>{qy(p).then(h)},[p]);const S=p?e.filter(R=>R.organization===p):e,g=p?t.filter(R=>R.organization===p):t,x=p?s.filter(R=>R.organization===p):s,o=p?r.filter(R=>R.organization===p):r,y=m==="Admin",_=m==="Owner",[T,A]=w.useState("level1"),C=_||y&&T==="level2";return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"8px 14px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#4f46e5",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e1b4b",whiteSpace:"nowrap"},children:"Filter"})]}),n.jsx("div",{style:{flex:1,minWidth:160,maxWidth:260},children:n.jsx(Ot,{value:p,onChange:v,organizations:l,placeholder:"All Organizations",small:!0})}),y&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(R=>n.jsx("button",{onClick:()=>A(R),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:T===R?R==="level2"?N.purple:N.blue:"transparent",color:T===R?"white":"#6b7280",transition:"all 0.15s"},children:R==="level1"?"Level 1":"Level 2"},R))}),!y&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:C?N.purple:N.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:C?"Level 2 — Owner":"Level 1 — Operational"})]}),C?n.jsx(y0,{dashData:j,selectedOrg:p,onNavigate:f}):n.jsx(m0,{dashData:j,fi:S,fid:g,fo:x,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,onNavigate:f,onNavigateStatus:u})]})}const He={fontSize:10,color:"#6b7280",fontWeight:600,marginBottom:3,display:"block",textTransform:"uppercase",letterSpacing:.4},Ge={width:"100%",padding:"4px 8px",border:"1px solid #d1d5db",borderRadius:6,fontSize:11,background:"white",color:"#374151",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:28};function ia({children:e}){const[t,s]=w.useState(!1);return n.jsxs("div",{style:{borderRadius:8,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",flexShrink:0},children:[n.jsxs("div",{onClick:()=>s(r=>!r),style:{background:"#4f46e5",color:"white",padding:"9px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none"},children:[n.jsx("span",{style:{fontSize:13,opacity:.9},children:t?"▲":"▼"}),n.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Filters"})]}),t&&n.jsx("div",{style:{background:"white",padding:"12px 16px",borderTop:"1px solid #e5e7eb"},children:e})]})}const le=20,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 $e({page:e,pageSize:t=le,total:s,onPageChange:r}){if(s===0)return null;const l=Math.max(1,Math.ceil(s/t)),i=(e-1)*t+1,a=Math.min(e*t,s);return n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[n.jsxs("span",{children:["Showing ",i," to ",a," of ",s," results"]}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{disabled:e<=1,onClick:()=>r(e-1),style:ku(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=l,onClick:()=>r(e+1),style:ku(e>=l),children:"Next"})]})]})}function j0({incidents:e,organizations:t,departments:s,branches:r,incidentStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=ne(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*le,h*le);return n.jsxs(n.Fragment,{children:[n.jsx(ia,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.numberTitle}),n.jsx("input",{style:Ge,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.organization}),n.jsxs("select",{style:Ge,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.department}),n.jsxs("select",{style:Ge,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.branch}),n.jsxs("select",{style:Ge,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.status}),n.jsxs("select",{style:Ge,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:f.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.type}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:f.noIncidents})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:o.title||"—"}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.type?Wd(o.type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Hn(f.deletedBadge):o.status?Hn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(qe,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!An("incident",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx($e,{page:h,total:g.length,onPageChange:S})]})}function b0(e){if(!e)return"";const[t,s,r]=e.split("-");return!t||!s||!r?"":`${r}/${s}/${t}`}function me({value:e,onChange:t,disabled:s,style:r,min:l,max:i}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:b0(e),placeholder:"DD/MM/YYYY",style:{...r,pointerEvents:"none",paddingRight:30}}),n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:s?"#bbb":"#666",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),n.jsx("input",{type:"date",value:e||"",disabled:s,min:l,max:i,onChange:a=>t(a.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:s?"default":"pointer",border:"none",padding:0,margin:0}})]})}function S0({title:e,children:t}){return n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"18px 20px",marginBottom:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&n.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16,color:"#1e1b4b"},children:e}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:13},children:t})]})}const _u={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function w0(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function ch({notifCount:e,darkMode:t,onCountChange:s,onToggleDark:r,onViewProfile:l,onLogout:i,onNavigate:a,userName:c,userRole:d}){const[p,v]=w.useState(!1),[f,u]=w.useState([]),[m,j]=w.useState(!1),h=w.useRef(null);w.useEffect(()=>{const $=J=>{h.current&&!h.current.contains(J.target)&&v(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const S=async()=>{j(!0);const $=await By(30);u($),j(!1)},g=()=>{const $=!p;v($),$&&S()},x=async()=>{await $y(),u($=>$.map(J=>({...J,read:1}))),s(0)},o=$=>{$.read||(Uy($.name),u(ae=>ae.map(O=>O.name===$.name?{...O,read:1}:O)),s(Math.max(0,e-1)));const J=$.document_type?_u[$.document_type]:void 0;J&&a&&(a(J,$.document_type==="SB Delegation"?void 0:$.document_name),v(!1))},y=f.filter($=>!$.read).length,_=$=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:t?"#2d3748":"#f3f4f6",color:t?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...$}),T=t,A=T?"#1a202c":"white",C=T?"#2d3748":"#e5e7eb",R=T?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[c&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginRight:4,lineHeight:1.25},children:[n.jsx("span",{style:{fontSize:13,fontWeight:600,color:T?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:c}),d&&n.jsx("span",{style:{fontSize:11,color:T?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:d})]}),n.jsx("button",{style:_({background:"#4f46e5",color:"white"}),onClick:l,title:"My Profile",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),n.jsxs("div",{ref:h,style:{position:"relative"},children:[n.jsxs("button",{style:_(),onClick:g,title:"Notifications",children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&n.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),p&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:A,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${C}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${C}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:A},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:R},children:["Notifications",y>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[y," new"]})]}),y>0&&n.jsx("button",{onClick:x,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),n.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[m&&n.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!m&&f.length===0&&n.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[n.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),n.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!m&&f.map($=>{const J=!!($.document_type&&_u[$.document_type]&&a);return n.jsxs("div",{onClick:()=>o($),style:{padding:"11px 16px",borderBottom:`1px solid ${T?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:$.read?A:T?"#1e3a5f":"#eff6ff",cursor:J?"pointer":"default",transition:"background 0.12s"},onMouseEnter:ae=>{J&&(ae.currentTarget.style.background=T?"#243244":"#e0ecfd")},onMouseLeave:ae=>{ae.currentTarget.style.background=$.read?A:T?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:$.read?400:600,color:R,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$.subject||`${$.document_type}: ${$.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:$.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:T?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[$.document_type.replace("SB ",""),$.document_name?` · ${$.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:w0($.creation)})]}),!$.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},$.name)})]})]})]}),n.jsx("button",{style:_(),onClick:rh,title:lr()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:_(),onClick:r,title:t?"Light mode":"Dark mode",children:t?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),n.jsx("button",{style:_({background:T?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:i,title:"Logout",children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16,17 21,12 16,7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Ue({title:e,activePage:t,user:s,formStatus:r,buttonText:l,buttonColor:i,viewMode:a,onEdit:c,hideSettings:d,rightPanel:p,darkMode:v,notifCount:f,onToggleDark:u,onCountChange:m,onViewProfile:j,onSubmit:h,onBack:S,onNavigate:g,onLogout:x,children:o}){const y=ne(),_=y.nav[t]||t,T=s.role,A=T==="Admin"||T==="Owner"||T==="Auditor"||T==="Manager",C=T==="Admin"||T==="Owner"||T==="Auditor"||T==="Manager",R=T==="Admin"||T==="Auditor"||T==="Manager",$=A?"dashboard":"inbox",[J,ae]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),O=()=>ae(I=>{const E=!I;return localStorage.setItem("sb_sidebar",E?"1":"0"),E});return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:N.bg},children:[n.jsx(ih,{collapsed:J,onToggleCollapsed:O,activePage:t,onNavigate:g,hasDashboard:A,hasReports:C,hasDelegations:R,role:T,hideSettings:d,rtl:y.rtl,navLabels:y.nav,settingsLabel:y.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"10px 20px",borderBottom:"1px solid #e9eaf0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("button",{onClick:S,title:y.back,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"1.5px solid #e5e7eb",background:"white",cursor:"pointer",color:"#4f46e5",flexShrink:0},children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1e1b4b"},children:e}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:1},children:[n.jsx("span",{onClick:()=>g($),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:I=>I.currentTarget.style.textDecoration="underline",onMouseLeave:I=>I.currentTarget.style.textDecoration="none",children:y.home}),!d&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:S,style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:I=>I.currentTarget.style.textDecoration="underline",onMouseLeave:I=>I.currentTarget.style.textDecoration="none",children:_})]})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[a&&c&&n.jsxs("button",{onClick:c,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:7,border:"none",background:"#4f46e5",color:"white",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI"},children:[n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),y.edit]}),n.jsx(ch,{notifCount:f,darkMode:v,onCountChange:m,onToggleDark:u,onNavigate:g,onViewProfile:j,onLogout:x,userName:s.full_name||s.name,userRole:s.role})]})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px",display:"grid",gridTemplateColumns:p?"1fr auto":"1fr",gap:14,alignItems:"start"},children:[n.jsx("div",{style:{minWidth:0},children:n.jsxs(S0,{children:[o,!a&&n.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[n.jsx("button",{onClick:S,style:{padding:"9px 22px",borderRadius:8,border:"1.5px solid #e5e7eb",cursor:"pointer",fontSize:13,fontWeight:600,background:"white",color:"#374151",fontFamily:"Segoe UI"},children:y.cancel}),n.jsx("button",{onClick:h,disabled:r==="loading",style:{padding:"9px 22px",borderRadius:8,background:i,color:"white",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,opacity:r==="loading"?.7:1,boxShadow:"0 2px 10px rgba(79,70,229,0.18)",fontFamily:"Segoe UI"},children:r==="loading"?y.saving:l})]}),r==="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:10},children:y.savedOk}),r!=="idle"&&r!=="loading"&&r!=="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:10},children:r})]})}),p&&n.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start"},children:p})]})]})]})}function pe({value:e,onChange:t,items:s,placeholder:r="-- Select --",disabled:l=!1}){var f;const[i,a]=w.useState(!1),[c,d]=w.useState(""),p=w.useRef(null);w.useEffect(()=>{const u=m=>{p.current&&!p.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const v=e?((f=s.find(u=>u.name===e))==null?void 0:f.label)??e:r;return n.jsxs("div",{ref:p,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!l&&a(u=>!u),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:i?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:l?"default":"pointer",background:l?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:l?.75:1},children:[n.jsx("span",{children:v}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:i?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),i&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx("div",{onClick:()=>{t(""),a(!1)},onMouseEnter:()=>d("__placeholder"),onMouseLeave:()=>d(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:c==="__placeholder"?"#f5f5f5":"transparent"},children:r}),s.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),s.map(u=>n.jsx("div",{onClick:()=>{t(u.name),a(!1)},onMouseEnter:()=>d(u.name),onMouseLeave:()=>d(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===u.name?"#2563eb":c===u.name?"#f0f4ff":"transparent",color:e===u.name?"white":"#1a2332",transition:"background 0.1s"},children:u.label},u.name))]})})]})}function k0(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function _0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function aa({doctype:e,docname:t,currentUserName:s}){const r=ne(),[l,i]=w.useState([]),[a,c]=w.useState(!1),[d,p]=w.useState(""),[v,f]=w.useState(!1),[u,m]=w.useState(!1),[j,h]=w.useState(!1),[S,g]=w.useState(""),x=5,o=w.useCallback(async()=>{c(!0);const C=await My(e,t);i(C),c(!1)},[e,t]);w.useEffect(()=>{o()},[o]);const y=async()=>{const C=d.trim();if(!(!C||v)){f(!0),g("");try{await Hy(e,t,C),p(""),await o()}catch{g("Failed to post comment. Please try again.")}f(!1)}},_=async C=>{if(window.confirm("Delete this comment?"))try{await Fo("Comment",C),i(R=>R.filter($=>$.name!==C))}catch{alert("Failed to delete comment.")}},T=j?l:l.slice(-x),A=Math.max(0,l.length-x);return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>m(C=>!C),style:{padding:"12px 20px",borderBottom:u?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",r.comments.title,l.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:l.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{onClick:C=>{C.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:u?"▼":"▲"})]})]}),!u&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!j&&A>0&&n.jsxs("button",{onClick:()=>h(!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 ",A," older comment",A!==1?"s":""]}),a&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!a&&l.length===0&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:r.comments.noComments}),!a&&T.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:T.map(C=>{const R=C.comment_by||C.comment_email||C.owner||"Unknown",$=C.owner===s||C.comment_by===s;return n.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[n.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,flexShrink:0},children:_0(R)}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:R}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:k0(C.creation)})]}),$&&n.jsx("button",{onClick:()=>_(C.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),n.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:C.content||""}})]})]},C.name)})}),n.jsxs("div",{style:{borderTop:l.length>0?"1px solid #f0f0f0":"none",paddingTop:l.length>0?14:0},children:[n.jsx("textarea",{value:d,onChange:C=>p(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&y()},placeholder:r.comments.placeholder,rows:3,style:{width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:8,fontSize:13,fontFamily:"Segoe UI",resize:"vertical",boxSizing:"border-box",outline:"none",color:"#1a2332"}}),S&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:S}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:y,disabled:!d.trim()||v,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!d.trim()||v?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!d.trim()||v?.6:1},children:v?r.saving:r.comments.post})})]})]})]})}function Cu(e){if(!e)return"";const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function C0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function zu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function Mo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Tu(e){return Mo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function z0(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const s=(t.changed||[]).map(r=>({field:r[0]||"",oldVal:zu(r[1]),newVal:zu(r[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:s,added:(t.added||[]).length,removed:(t.removed||[]).length,rowChanged:(t.row_changed||[]).length}}function oa({doctype:e,docname:t,docCreation:s,docOwner:r}){const l=ne(),[i,a]=w.useState([]),[c,d]=w.useState(!1),[p,v]=w.useState(!0),[f,u]=w.useState(!1),m=5,j=w.useCallback(async()=>{d(!0);const x=await Gy(e,t);a(x.map(z0)),d(!1)},[e,t]);w.useEffect(()=>{p||j()},[p,j]);const h=f?i:i.slice(0,m),S=i.length-m,g=(x,o=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:x,border:"2px solid white",boxShadow:o?`0 0 0 2px ${x}44`:"none"});return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>v(x=>!x),style:{padding:"12px 20px",borderBottom:p?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",l.activity.title,!p&&i.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:i.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!p&&n.jsx("button",{onClick:x=>{x.stopPropagation(),j()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:p?"▼":"▲"})]})]}),!p&&n.jsxs("div",{style:{padding:"16px 20px"},children:[c&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:l.loading}),!c&&n.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[n.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[h.map((x,o)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g(o===0?"#3498db":"#d1d5db",o===0)}),n.jsxs("div",{style:{background:o===0?"#eff6ff":"#f9fafb",border:`1px solid ${o===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Tu(x.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Mo(x.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Cu(x.creation)})]}),x.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:x.changes.map((y,_)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:C0(y.field)}),n.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),n.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:y.oldVal}),n.jsx("span",{style:{color:"#6b7280"},children:" → "}),n.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:y.newVal})]},_))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",x.added>0&&n.jsxs("span",{children:[" · +",x.added," row(s)"]}),x.removed>0&&n.jsxs("span",{children:[" · -",x.removed," row(s)"]}),x.rowChanged>0&&n.jsxs("span",{children:[" · ~",x.rowChanged," row(s) modified"]})]})]})]},x.name)),s&&r&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g("#22c55e")}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#22c55e",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Tu(r)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:Mo(r)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Cu(s)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",l.activity.created]})]})]}),i.length===0&&!s&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!c&&S>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>u(x=>!x),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:f?"▲ Show less":`▼ Show all (${i.length})`})})]})]})}const Ma={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Nr={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},T0={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 I0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...T0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function E0({incForm:e,setIncForm:t,organizations:s,managements:r,departments:l,branches:i,incidentTypes:a,incidentClasses:c,incidentFields:d,incidentStatuses:p,users:v,userRoleMap:f={},formStatus:u,viewMode:m,canModify:j,onEdit:h,onDelete:S,onRestore:g,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:T,userRole:A,onSubmit:C,onBack:R,onNavigate:$,onLogout:J,user:ae,onRefresh:O}){var ut;const I=ne(),E=k=>t({...e,...k}),K=m?{background:"#f9f9f9"}:{},G=vr(v,f,"SB Manager",e.organization),[L,M]=w.useState(""),[Y,Z]=w.useState(!1),V=e.name?m?`${I.formTitle.viewIncident}${e.number||e.name}`:I.formTitle.editIncident:I.formTitle.newIncident,ke=fe(r,e.management).map(k=>({name:k.name,label:k.name1||k.name})),De=fe(l,e.department).map(k=>({name:k.name,label:k.department_name||k.name})),Ae=fe(i,e.branch).map(k=>({name:k.name,label:k.branch||k.name})),he=fe(a,e.type).map(k=>({name:k.name,label:k.name1||k.name})),Fe=fe(c,e.incident_class).map(k=>({name:k.name,label:k.name1||k.name})),H=fe(d,e.incident_field).map(k=>({name:k.name,label:k.name1||k.name})),se=e.workflow_state||"New",st=A==="Employee",re=A==="Auditor"||A==="Admin",rt=A==="Manager",ct=e.name?se==="New"?[{label:I.wf.submit,action:"Submit",color:"#2563eb"}]:se==="Initial Evaluation"&&re?[{label:I.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:se==="Accept & Under Progress"&&(rt||re)?[{label:I.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:se==="working on resolution"&&(rt||re)?[{label:I.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function B(k){if(e.name){Z(!0),M("");try{const ee={};k==="Assign to Manager"&&(e.assigned_to&&(ee.assigned_to=e.assigned_to),e.priority&&(ee.priority=e.priority),e.economy_class&&(ee.economy_class=e.economy_class),e.entity_scope&&(ee.entity_scope=e.entity_scope),e.hses_field&&(ee.hses_field=e.hses_field),ee.product_relation=String(e.product_relation??0),ee.repeated=String(e.repeated??0)),k==="Submit Solution"&&(e.solution&&(ee.solution=e.solution),e.summary&&(ee.summary=e.summary),e.cost&&(ee.cost=String(e.cost))),(k==="Resolution complete"||k==="Submit Solution")&&e.auditor_comment&&(ee.auditor_comment=e.auditor_comment),await Yy(e.name,k,JSON.stringify(ee)),M("Done"),O==null||O()}catch(ee){M(ee.message||"Error")}finally{Z(!1)}}}const ye=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:13},children:I.wf.workflow}),n.jsx("span",{style:I0(se),children:se})]}),se==="Initial Evaluation"&&re&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:I.wf.assignToManager}),n.jsxs("select",{style:P,value:e.assigned_to||"",onChange:k=>E({assigned_to:k.target.value}),children:[n.jsx("option",{value:"",children:I.field.selectMgr}),G.map(k=>n.jsx("option",{value:k.name,children:k.full_name||k.name},k.name))]})]}),(se==="Accept & Under Progress"||se==="working on resolution")&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:I.field.solution}),n.jsx("textarea",{style:{...P,height:75,resize:"vertical"},value:e.solution||"",onChange:k=>E({solution:k.target.value}),placeholder:I.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:6},children:I.field.actualCost}),n.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:k=>E({cost:parseFloat(k.target.value)||0}),placeholder:"0.00"})]}),se==="working on resolution"&&re&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:I.field.auditorComment}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:k=>E({auditor_comment:k.target.value}),placeholder:I.field.commentPlaceholder})]}),ct.length>0?n.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:ct.map(k=>n.jsx("button",{onClick:()=>B(k.action),disabled:Y,style:{padding:"7px 14px",borderRadius:6,border:"none",background:k.color,color:"white",fontWeight:600,fontSize:12,cursor:Y?"not-allowed":"pointer",opacity:Y?.7:1},children:Y?I.wf.applying:k.label},k.action))}):n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions}),L&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:L==="Done"?N.green:N.red},children:L})]}),n.jsx(aa,{doctype:D.incidents,docname:e.name,currentUserName:ae.name}),n.jsx(oa,{doctype:D.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),j&&S&&!e.custom_is_deleted&&n.jsx(la,{title:"Delete Request",btnText:I.delete,onDelete:()=>S(e.name)})]}):null;return n.jsxs(Ue,{title:V,activePage:"incidents",user:ae,formStatus:u,buttonText:I.saveIncident,buttonColor:N.accent,viewMode:m,onEdit:h,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:T,rightPanel:ye,onSubmit:C,onBack:R,onNavigate:$,onLogout:J,children:[e.custom_is_deleted===1&&n.jsx(_l,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0}),n.jsxs("div",{style:e.name?Nr:Ma,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[I.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:k=>E({organization:k}),organizations:s,disabled:m||!!ae.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.title}),n.jsx("input",{style:{...P,...K},value:e.title,disabled:m,onChange:k=>E({title:k.target.value})})]})]}),n.jsxs("div",{style:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.management}),n.jsx(pe,{value:e.management,onChange:k=>E({management:k}),items:ke,placeholder:I.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.department}),n.jsx(pe,{value:e.department,onChange:k=>E({department:k}),items:De,placeholder:I.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.section}),n.jsx("input",{style:{...P,...K},value:e.section_field||"",disabled:m,onChange:k=>E({section_field:k.target.value})})]})]}),n.jsxs("div",{style:Ma,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.branch}),n.jsx(pe,{value:e.branch,onChange:k=>E({branch:k}),items:Ae,placeholder:I.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.hsesField}),n.jsx("input",{style:{...P,...K},value:e.hses_field||"",disabled:m,onChange:k=>E({hses_field:k.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.type}),n.jsx(pe,{value:e.type,onChange:k=>E({type:k}),items:he,placeholder:I.field.selectType,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.incidentClass}),n.jsx(pe,{value:e.incident_class,onChange:k=>E({incident_class:k}),items:Fe,placeholder:I.field.selectClass,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.incidentField}),n.jsx(pe,{value:e.incident_field,onChange:k=>E({incident_field:k}),items:H,placeholder:I.field.selectField,disabled:m})]})]}),n.jsxs("div",{style:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.date}),n.jsx(me,{value:e.date,onChange:k=>E({date:k}),disabled:!0,style:{...P,background:"#f9f9f9"}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.time}),n.jsx("input",{type:"time",style:{...P,background:"#f9f9f9"},value:e.time,disabled:!0,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.assignedTo}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#334155"},value:((ut=G.find(k=>k.name===e.assigned_to))==null?void 0:ut.full_name)||e.assigned_to||"Unassigned",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[I.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"New",readOnly:!0,disabled:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.description}),n.jsx("textarea",{style:{...P,...K,height:120,resize:"vertical"},value:e.description,disabled:m,onChange:k=>E({description:k.target.value})})]}),!st&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:I.steps.auditorTriage}),n.jsxs("div",{style:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.priority}),n.jsxs("select",{style:{...P,...m||!re?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:m||!re,onChange:k=>E({priority:k.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"High",children:I.field.high}),n.jsx("option",{value:"Normal",children:I.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.economyClass}),n.jsxs("select",{style:{...P,...m||!re?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:m||!re,onChange:k=>E({economy_class:k.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Expenses",children:I.field.expenses}),n.jsx("option",{value:"Capital",children:I.field.capital}),n.jsx("option",{value:"Earn",children:I.field.earn}),n.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.entityScope}),n.jsxs("select",{style:{...P,...m||!re?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:m||!re,onChange:k=>E({entity_scope:k.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Upstream",children:I.field.upstream}),n.jsx("option",{value:"On-stream",children:I.field.onstream}),n.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:m||!re,onChange:k=>E({product_relation:k.target.checked?1:0})})," ",I.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:m||!re,onChange:k=>E({repeated:k.target.checked?1:0})})," ",I.field.repeatedEvent]})]})]}),!st&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:I.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.solution}),n.jsx("textarea",{style:{...P,height:100,resize:"vertical",...m&&!rt&&!re?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:m&&!rt&&!re,onChange:k=>E({solution:k.target.value}),placeholder:I.field.solutionPlaceholder})]}),n.jsxs("div",{style:Ma,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...m&&!rt&&!re?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:m&&!rt&&!re,onChange:k=>E({cost:parseFloat(k.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.summary}),n.jsx("input",{style:{...P,...m&&!rt&&!re?{background:"#f9f9f9"}:{}},value:e.summary||"",disabled:m&&!rt&&!re,onChange:k=>E({summary:k.target.value}),placeholder:"Brief summary"})]})]})]}),!st&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:I.steps.ownerComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...m&&!re?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:m&&!re,onChange:k=>E({auditor_comment:k.target.value}),placeholder:I.field.commentPlaceholder})]})]})}function P0({ideas:e,organizations:t,departments:s,branches:r,ideaStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=ne(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*le,h*le);return n.jsxs(n.Fragment,{children:[n.jsx(ia,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.numberTitle}),n.jsx("input",{style:Ge,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.organization}),n.jsxs("select",{style:Ge,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.department}),n.jsxs("select",{style:Ge,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.branch}),n.jsxs("select",{style:Ge,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.status}),n.jsxs("select",{style:Ge,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:f.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:f.noIdeas})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{children:o.title||"—"}),o.sb_order&&n.jsxs("span",{style:{fontSize:11,background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["📦 ",o.sb_order]})]})}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Hn(f.deletedBadge):o.status?Hn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(qe,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!An("idea",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx($e,{page:h,total:g.length,onPageChange:S})]})}const Ha={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Jl={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},A0={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 R0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...A0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function L0({ideaForm:e,setIdeaForm:t,organizations:s,managements:r,departments:l,branches:i,ideaTypes:a,ideaStatuses:c,users:d=[],userRoleMap:p={},formStatus:v,viewMode:f,canModify:u,onEdit:m,onDelete:j,onRestore:h,onNavigateToOrder:S,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,userRole:T,onSubmit:A,onBack:C,onNavigate:R,onLogout:$,user:J,onRefresh:ae}){var ct;const O=ne(),I=B=>t({...e,...B}),E=f?{background:"#f9f9f9"}:{},K=vr(d,p,"SB Manager",e.organization),[G,L]=w.useState(""),[M,Y]=w.useState(!1),Z=e.name?f?`${O.formTitle.viewIdea}${e.number||e.title||e.name}`:O.formTitle.editIdea:O.formTitle.newIdea,V=fe(r,e.management).map(B=>({name:B.name,label:B.name1||B.name})),ke=fe(l,e.department).map(B=>({name:B.name,label:B.department_name||B.name})),De=fe(i,e.branch).map(B=>({name:B.name,label:B.branch||B.name})),Ae=fe(a,e.type).map(B=>({name:B.name,label:B.name1||B.name})),he=e.workflow_state||"New",Fe=T==="Employee",H=T==="Auditor"||T==="Admin",se=T==="Manager",st=e.name?he==="New"?[{label:O.wf.submit,action:"Submit",color:"#2563eb"}]:he==="Initial Evaluation"&&H?[{label:O.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:O.wf.reject,action:"Reject",color:"#dc2626"}]:he==="Accept & Under Progress"&&(se||H)?[{label:O.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:he==="working on proposal"&&H?[{label:O.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:O.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function re(B){if(e.name){Y(!0),L("");try{const ye={};B==="Assign to Manager"&&(e.assigned_to&&(ye.assigned_to=e.assigned_to),e.priority&&(ye.priority=e.priority),e.economy_class&&(ye.economy_class=e.economy_class),e.entity_scope&&(ye.entity_scope=e.entity_scope),e.hses_field&&(ye.hses_field=e.hses_field),ye.product_relation=String(e.product_relation??0),ye.repeated=String(e.repeated??0)),B==="Submit Proposal"&&(e.solution&&(ye.solution=e.solution),e.proposed_condition&&(ye.proposed_condition=e.proposed_condition),e.cost&&(ye.cost=String(e.cost))),e.auditor_comment&&(B==="Move to Outsourcing"||B==="Reject")&&(ye.auditor_comment=e.auditor_comment);const ut=await Xy(e.name,B,JSON.stringify(ye));ut!=null&&ut.created_order&&I({sb_order:ut.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),L("Done"),ae==null||ae()}catch(ye){L(ye.message||"Error")}finally{Y(!1)}}}const rt=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:13},children:O.wf.workflow}),n.jsx("span",{style:R0(he),children:he})]}),he==="Initial Evaluation"&&H&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:O.wf.assignToManager}),n.jsxs("select",{style:P,value:e.assigned_to||"",onChange:B=>I({assigned_to:B.target.value}),children:[n.jsx("option",{value:"",children:O.field.selectMgr}),K.map(B=>n.jsx("option",{value:B.name,children:B.full_name||B.name},B.name))]})]}),he==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:O.field.solution}),n.jsx("textarea",{style:{...P,height:75,resize:"vertical"},value:e.solution||"",onChange:B=>I({solution:B.target.value}),placeholder:O.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:6},children:O.field.actualCost}),n.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:B=>I({cost:parseFloat(B.target.value)||0}),placeholder:"0.00"})]}),he==="working on proposal"&&H&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:z,children:O.field.auditorComment}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:B=>I({auditor_comment:B.target.value}),placeholder:O.field.commentPlaceholder})]}),st.length>0?n.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:st.map(B=>n.jsx("button",{onClick:()=>re(B.action),disabled:M,style:{padding:"7px 14px",borderRadius:6,border:"none",background:B.color,color:"white",fontWeight:600,fontSize:12,cursor:M?"not-allowed":"pointer",opacity:M?.7:1},children:M?O.wf.applying:B.label},B.action))}):n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:O.wf.noActions}),G&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:G==="Done"?N.green:N.red},children:G})]}),n.jsx(aa,{doctype:D.ideas,docname:e.name,currentUserName:J.name}),n.jsx(oa,{doctype:D.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),u&&j&&!e.custom_is_deleted&&n.jsx(la,{title:"Delete Request",btnText:O.delete,onDelete:()=>j(e.name)})]}):null;return n.jsxs(Ue,{title:Z,activePage:"ideas",user:J,formStatus:v,buttonText:O.saveIdea,buttonColor:N.teal,viewMode:f,onEdit:m,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,rightPanel:rt,onSubmit:A,onBack:C,onNavigate:R,onLogout:$,children:[e.custom_is_deleted===1&&n.jsx(_l,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:h?()=>h(e.name):void 0}),e.sb_order&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"6px 12px",marginBottom:14,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[n.jsx("span",{style:{fontSize:14,flexShrink:0},children:"📦"}),n.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#15803d",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[O.field.convertedToOrder,":"]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#14532d",whiteSpace:"nowrap"},children:e.sb_order})]}),S&&n.jsxs("button",{type:"button",onClick:()=>S(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:B=>B.currentTarget.style.background="#15803d",onMouseLeave:B=>B.currentTarget.style.background="#16a34a",children:[O.field.viewOrder," →"]})]}),n.jsxs("div",{style:e.name?Jl:Ha,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[O.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:B=>I({organization:B}),organizations:s,disabled:f||!!J.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.title}),n.jsx("input",{style:{...P,...E},value:e.title,disabled:f,onChange:B=>I({title:B.target.value})})]})]}),n.jsxs("div",{style:Jl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.management}),n.jsx(pe,{value:e.management,onChange:B=>I({management:B}),items:V,placeholder:O.field.select,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.department}),n.jsx(pe,{value:e.department,onChange:B=>I({department:B}),items:ke,placeholder:O.field.select,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.section}),n.jsx("input",{style:{...P,...E},value:e.section_field||"",disabled:f,onChange:B=>I({section_field:B.target.value})})]})]}),n.jsxs("div",{style:Ha,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.branch}),n.jsx(pe,{value:e.branch,onChange:B=>I({branch:B}),items:De,placeholder:O.field.select,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.date}),n.jsx(me,{value:e.date||"",onChange:B=>I({date:B}),disabled:!0,style:{...P,background:"#f9f9f9"}})]})]}),n.jsxs("div",{style:Jl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.type}),n.jsx(pe,{value:e.type,onChange:B=>I({type:B}),items:Ae,placeholder:O.field.selectType,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.ideaClass}),n.jsxs("select",{style:{...P,...E},value:e.idea_class||"",disabled:f,onChange:B=>I({idea_class:B.target.value}),children:[n.jsx("option",{value:"",children:O.field.select}),n.jsx("option",{value:"Safety",children:"Safety"}),n.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.hsesField}),n.jsx("input",{style:{...P,...E},value:e.hses_field||"",disabled:f,onChange:B=>I({hses_field:B.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:Ha,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.assignedTo}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#334155"},value:((ct=K.find(B=>B.name===e.assigned_to))==null?void 0:ct.full_name)||e.assigned_to||"Unassigned",readOnly:!0,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[O.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"New",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.currentCondition}),n.jsx("textarea",{style:{...P,...E,height:110,resize:"vertical"},value:e.current_condition,disabled:f,onChange:B=>I({current_condition:B.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.proposedCondition}),n.jsx("textarea",{style:{...P,...E,height:110,resize:"vertical"},value:e.proposed_condition,disabled:f,onChange:B=>I({proposed_condition:B.target.value})})]}),!Fe&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:O.steps.auditorEval}),n.jsxs("div",{style:Jl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.priority}),n.jsxs("select",{style:{...P,...f&&!H?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:f&&!H,onChange:B=>I({priority:B.target.value}),children:[n.jsx("option",{value:"",children:O.field.select}),n.jsx("option",{value:"High",children:O.field.high}),n.jsx("option",{value:"Normal",children:O.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.economyClass}),n.jsxs("select",{style:{...P,...f&&!H?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:f&&!H,onChange:B=>I({economy_class:B.target.value}),children:[n.jsx("option",{value:"",children:O.field.select}),n.jsx("option",{value:"Expenses",children:O.field.expenses}),n.jsx("option",{value:"Capital",children:O.field.capital}),n.jsx("option",{value:"Earn",children:O.field.earn}),n.jsx("option",{value:"Pay/Loss",children:O.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.entityScope}),n.jsxs("select",{style:{...P,...f&&!H?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:f&&!H,onChange:B=>I({entity_scope:B.target.value}),children:[n.jsx("option",{value:"",children:O.field.select}),n.jsx("option",{value:"Upstream",children:O.field.upstream}),n.jsx("option",{value:"On-stream",children:O.field.onstream}),n.jsx("option",{value:"Downstream",children:O.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:f&&!H,onChange:B=>I({product_relation:B.target.checked?1:0})})," ",O.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:f&&!H,onChange:B=>I({repeated:B.target.checked?1:0})})," ",O.field.repeatedEvent]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:O.wf.assignToManager}),n.jsxs("select",{style:{...P,...f||!H?{background:"#f9f9f9"}:{}},value:e.assigned_to||"",disabled:f||!H,onChange:B=>I({assigned_to:B.target.value}),children:[n.jsx("option",{value:"",children:O.field.select}),K.map(B=>n.jsx("option",{value:B.name,children:B.full_name||B.name},B.name))]})]})]}),!Fe&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:O.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:O.field.solution}),n.jsx("textarea",{style:{...P,height:100,resize:"vertical",...f&&!se&&!H?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:f&&!se&&!H,onChange:B=>I({solution:B.target.value}),placeholder:O.field.solutionPlaceholder})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:O.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...f&&!se&&!H?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:f&&!se&&!H,onChange:B=>I({cost:parseFloat(B.target.value)||0}),placeholder:"0.00"})]})]}),!Fe&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:O.steps.ownerComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...f&&!H?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:f&&!H,onChange:B=>I({auditor_comment:B.target.value}),placeholder:O.field.commentPlaceholder})]})]})}function O0({orders:e,organizations:t,departments:s,branches:r,orderStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=ne(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*le,h*le);return n.jsxs(n.Fragment,{children:[n.jsx(ia,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.numberTitle}),n.jsx("input",{style:Ge,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.organization}),n.jsxs("select",{style:Ge,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.department}),n.jsxs("select",{style:Ge,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.branch}),n.jsxs("select",{style:Ge,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.status}),n.jsxs("select",{style:Ge,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:f.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.type}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:f.noOrders})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{children:o.title||"—"}),o.sb_idea&&n.jsxs("span",{style:{fontSize:11,background:"#eff6ff",color:"#1d4ed8",border:"1px solid #bfdbfe",borderRadius:9999,padding:"2px 8px",fontWeight:600},children:["💡 ",o.sb_idea]})]})}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.type?Wd(o.type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Hn(f.deletedBadge):o.status?Hn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(qe,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!An("order",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx($e,{page:h,total:g.length,onPageChange:S})]})}const Vl={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Wr={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},D0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},N0={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 W0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...N0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function B0({orderForm:e,setOrderForm:t,organizations:s,managements:r,departments:l,branches:i,orderTypes:a,orderStatuses:c,cycles:d=[],users:p=[],userRoleMap:v={},formStatus:f,viewMode:u,canModify:m,onEdit:j,onDelete:h,onRestore:S,onNavigateToIdea:g,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:T,currentUser:A,userRole:C,onSubmit:R,onBack:$,onNavigate:J,onLogout:ae,user:O,onRefresh:I}){var rn;const E=ne(),K=W=>t({...e,...W}),G=u?{background:"#f9f9f9"}:{},L=vr(p,v,"SB Employee",e.organization),[M,Y]=w.useState(""),[Z,V]=w.useState(""),[ke,De]=w.useState(!1),[Ae,he]=w.useState("Agree"),Fe=e.name?u?`${E.formTitle.viewOrder}${e.number||e.title||e.name}`:E.formTitle.editOrder:E.formTitle.newOrder,H=fe(r,e.management).map(W=>({name:W.name,label:W.name1||W.name})),se=fe(l,e.department).map(W=>({name:W.name,label:W.department_name||W.name})),st=fe(i,e.branch).map(W=>({name:W.name,label:W.branch||W.name})),re=fe(a,e.type).map(W=>({name:W.name,label:W.name1||W.name})),rt=fe(d,e.cycle).map(W=>({name:W.name,label:W.name1||W.cycle_name||W.name})),ct=!!e.name,B=e.workflow_state||"Draft",ye=Math.min(5,(e.stage||0)+1),[ut,k]=w.useState(ye);w.useEffect(()=>{k(Math.min(5,(e.stage||0)+1))},[e.stage]);const ee=C==="Auditor"||C==="Admin",Q=C==="Auditor"||C==="Admin"||C==="Manager",zl=Q||C==="Owner",sn=!!(A&&(e.actor===A||e.assigned_to===A)),Tl=ct?B==="Closed"?[]:B==="Draft"&&Q?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:B==="Pending Actor"&&(sn||Q)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:B==="Review"&&zl?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:B==="In Study"&&zl?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function ks(W){if(e.name){De(!0),Y("");try{let Je;W==="Update Status"&&(Je=Ae);const _s=await Qy(e.name,W,Z,W==="Update Status"?String(ut):void 0,void 0,Je);if(V(""),he("Agree"),Y("Done"),_s){const Dt=_s;t({...e,...Dt,stage:Dt.stage??e.stage,completion_pct:Dt.completion_pct??e.completion_pct,workflow_state:Dt.workflow_state??e.workflow_state})}I==null||I()}catch(Je){Y(Je.message||"Error")}finally{De(!1)}}}const da=ct?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:13},children:E.wf.workflow}),n.jsx("span",{style:W0(B),children:B})]}),B==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:["Stage (1–5) — ",ut*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...P,width:"100%"},value:ut,onChange:W=>k(Math.min(5,Math.max(1,parseInt(W.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Cycle Status"}),n.jsxs("select",{style:P,value:Ae,onChange:W=>he(W.target.value),children:[n.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),n.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),n.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),n.jsxs("div",{style:{marginBottom:12},children:[n.jsxs("label",{style:z,children:["Comment ",Ae==="Deviate"&&B==="Pending Actor"?n.jsx("span",{style:{color:N.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical",borderColor:Ae==="Deviate"&&!Z?"#fca5a5":void 0},value:Z,onChange:W=>V(W.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:Tl.map(W=>{const Je=W.action==="Update Status"&&Ae==="Deviate"&&!Z.trim();return n.jsx("button",{onClick:()=>ks(W.action),disabled:ke||Je,title:Je?"Comment required when status is Deviate":void 0,style:{padding:"7px 14px",borderRadius:6,border:"none",background:W.color,color:"white",fontWeight:600,fontSize:12,cursor:ke||Je?"not-allowed":"pointer",opacity:ke||Je?.5:1},children:ke?E.wf.applying:W.label},W.action)})}),M&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:M==="Done"?N.green:N.red},children:M}),Tl.length===0&&n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:E.wf.noActions})]}),n.jsx(aa,{doctype:D.orders,docname:e.name,currentUserName:O.name}),n.jsx(oa,{doctype:D.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&h&&!e.custom_is_deleted&&n.jsx(la,{title:"Delete Request",btnText:E.delete,onDelete:()=>h(e.name)})]}):null;return n.jsxs(Ue,{title:Fe,activePage:"orders",user:O,formStatus:f,buttonText:E.saveOrder,buttonColor:N.purple,viewMode:u,onEdit:j,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:_,onViewProfile:T,rightPanel:da,onSubmit:R,onBack:$,onNavigate:J,onLogout:ae,children:[e.custom_is_deleted===1&&n.jsx(_l,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:S?()=>S(e.name):void 0}),e.sb_idea&&n.jsxs("div",{style:{background:"#f0f7ff",border:"1px solid #bfdbfe",borderRadius:8,padding:"6px 12px",marginBottom:14,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontSize:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[n.jsx("span",{style:{fontSize:14,flexShrink:0},children:"💡"}),n.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"#1e40af",textTransform:"uppercase",letterSpacing:"0.4px",whiteSpace:"nowrap"},children:[E.field.originatingIdea,":"]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e3a8a",whiteSpace:"nowrap"},children:e.sb_idea})]}),g&&n.jsxs("button",{type:"button",onClick:()=>g(e.sb_idea),style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontWeight:600,fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"background 0.15s ease"},onMouseEnter:W=>W.currentTarget.style.background="#1d4ed8",onMouseLeave:W=>W.currentTarget.style.background="#2563eb",children:[E.field.viewIdea," →"]})]}),n.jsxs("div",{style:e.name?Wr:Vl,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[E.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:W=>K({organization:W}),organizations:s,disabled:u||!!O.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.title}),n.jsx("input",{style:{...P,...G},value:e.title,disabled:u,onChange:W=>K({title:W.target.value})})]})]}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.management}),n.jsx(pe,{value:e.management,onChange:W=>K({management:W}),items:H,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.department}),n.jsx(pe,{value:e.department,onChange:W=>K({department:W}),items:se,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.section}),n.jsx("input",{style:{...P,...G},value:e.section_field||"",disabled:u,onChange:W=>K({section_field:W.target.value})})]})]}),n.jsxs("div",{style:Vl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.branch}),n.jsx(pe,{value:e.branch,onChange:W=>K({branch:W}),items:st,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.type}),n.jsx(pe,{value:e.type,onChange:W=>K({type:W}),items:re,placeholder:E.field.selectType,disabled:u})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.priority}),n.jsxs("select",{style:{...P,...G},value:e.priority||"",disabled:u,onChange:W=>K({priority:W.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"High",children:E.field.high}),n.jsx("option",{value:"Normal",children:E.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.economyClass}),n.jsxs("select",{style:{...P,...G},value:e.economy_class||"",disabled:u,onChange:W=>K({economy_class:W.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Expenses",children:E.field.expenses}),n.jsx("option",{value:"Capital",children:E.field.capital}),n.jsx("option",{value:"Earn",children:E.field.earn}),n.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.entityScope}),n.jsxs("select",{style:{...P,...G},value:e.entity_scope||"",disabled:u,onChange:W=>K({entity_scope:W.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:E.field.upstream}),n.jsx("option",{value:"On-stream",children:E.field.onstream}),n.jsx("option",{value:"Downstream",children:E.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:u,onChange:W=>K({planned:W.target.checked?1:0})})," Planned"]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:W=>K({product_relation:W.target.checked?1:0})})," ",E.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:E.field.hsesField}),n.jsx("input",{style:{...P,...G},value:e.hses_field||"",disabled:u,onChange:W=>K({hses_field:W.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.budget}),n.jsx("input",{type:"number",style:{...P,...G},value:e.budget||"",disabled:u,onChange:W=>K({budget:parseFloat(W.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...G},value:e.actual_cost||"",disabled:u,onChange:W=>K({actual_cost:parseFloat(W.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Variance"}),(()=>{const W=(e.budget||0)-(e.actual_cost||0);return n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontWeight:700,fontSize:13,background:W>=0?"#f0fdf4":"#fef2f2",color:W>=0?"#166534":"#dc2626",border:`1px solid ${W>=0?"#bbf7d0":"#fecaca"}`},children:[W>=0?"+":"",W.toFixed(2)]})})()]})]}),n.jsxs("div",{style:Vl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.currency}),n.jsxs("select",{style:{...P,...G},value:e.currency||"",disabled:u,onChange:W=>K({currency:W.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"SAR",children:"SAR"}),n.jsx("option",{value:"USD",children:"USD"}),n.jsx("option",{value:"EUR",children:"EUR"}),n.jsx("option",{value:"AED",children:"AED"}),n.jsx("option",{value:"GBP",children:"GBP"})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[E.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"Draft",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.startingDate}),n.jsx(me,{value:e.starting_date,onChange:W=>K({starting_date:W}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.endingDate}),n.jsx(me,{value:e.ending_date,onChange:W=>K({ending_date:W}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.actor}),n.jsxs("select",{style:{...P,...u||!ee?{background:"#f9f9f9"}:{}},value:e.actor||e.assigned_to||"",disabled:u||!ee,onChange:W=>K({actor:W.target.value,assigned_to:W.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),L.map(W=>n.jsx("option",{value:W.name,children:W.full_name||W.name},W.name))]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:12},children:"Cycle & Progress"}),n.jsxs("div",{style:Vl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycle}),n.jsx(pe,{value:e.cycle||"",onChange:W=>K({cycle:W}),items:rt,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...P,background:"#f9f9f9",maxWidth:80},value:e.stage||1,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Completion"}),n.jsx("input",{style:{...P,background:"#f9f9f9",maxWidth:100},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd"},children:D0[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.escalationLevel}),n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",background:"#fecaca",color:"#e74c3c",borderRadius:8,fontWeight:700,fontSize:13},children:["Level ",e.escalation_level]})]})]})]})]}),ct&&((rn=e.order_cycle_log)==null?void 0:rn.length)>0&&n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:10},children:"Cycle History"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(W=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:W},W))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map((W,Je)=>{const _s=W.status==="Agree"?"#166534":W.status==="Deviate"?"#c2410c":"#92400e",Dt=W.status==="Agree"?"#f0fdf4":W.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:W.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:W.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:W.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:Dt,color:_s,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:W.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:W.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:W.comment?"normal":"italic"},children:W.comment||"—"})]},Je)})})]})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.description}),n.jsx("textarea",{style:{...P,...G,height:100,resize:"vertical"},value:e.description,disabled:u,onChange:W=>K({description:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.notes}),n.jsx("textarea",{style:{...P,...G,height:100,resize:"vertical"},value:e.notes,disabled:u,onChange:W=>K({notes:W.target.value})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:E.field.auditorComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...u&&sn&&!Q?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:u&&sn&&!Q,onChange:W=>K({auditor_comment:W.target.value}),placeholder:E.field.commentPlaceholder})]})]})}function $0({processes:e,organizations:t,departments:s,branches:r,processStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=ne(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(_=>({..._,[o]:y})),[h,S]=w.useState(1),g=e.filter(o=>!(u.search&&!`${o.number} ${o.title}`.toLowerCase().includes(u.search.toLowerCase())||u.organization&&o.organization!==u.organization||u.department&&o.department!==u.department||u.branch&&o.branch!==u.branch||u.status&&o.status!==u.status));w.useEffect(()=>{S(1)},[u]);const x=g.slice((h-1)*le,h*le);return n.jsxs(n.Fragment,{children:[n.jsx(ia,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"10px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.numberTitle}),n.jsx("input",{style:Ge,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.organization}),n.jsxs("select",{style:Ge,value:u.organization,onChange:o=>j("organization",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.department}),n.jsxs("select",{style:Ge,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),s.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.branch}),n.jsxs("select",{style:Ge,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:He,children:f.filter.status}),n.jsxs("select",{style:Ge,value:u.status,onChange:o=>j("status",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allStatuses}),l.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"7px 14px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#475569",fontWeight:500},children:f.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",overflow:"hidden",border:"1px solid #f1f5f9"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc",color:"#64748b",textAlign:"left",borderBottom:"1px solid #e2e8f0"},children:[n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.number}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.title}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.organization}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.field.cycleType}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.status}),n.jsx("th",{style:{padding:"12px 16px",fontWeight:600,fontSize:12},children:f.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#94a3b8"},children:f.noProcesses})}):x.map((o,y)=>n.jsxs("tr",{className:"app-table-row",onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f1f5f9",background:o.custom_is_deleted?"#fff1f2":y%2===0?"white":"#fafafa",cursor:"pointer",transition:"background 0.15s ease"},children:[n.jsx("td",{style:{padding:"12px 16px",color:"#64748b",fontSize:12,fontWeight:500},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 16px",fontWeight:600,color:"#1e293b"},children:o.title||o.name||"—"}),n.jsx("td",{style:{padding:"12px 16px",color:"#475569"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.cycle_type?Wd(o.cycle_type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Hn(f.deletedBadge):o.status?Hn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:_=>_.stopPropagation(),children:n.jsx(qe,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!An("process",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx($e,{page:h,total:g.length,onPageChange:S})]})}const U0={Draft:[{action:"Submit for Review",next:"Pending Actor",allowedRoles:["Auditor","Manager"]}],"Pending Actor":[{action:"Update Status",next:"Pending Comment",allowedRoles:["Employee","Manager"]}],"Pending Comment":[{action:"Add Comment",next:"Review",allowedRoles:["Auditor","Manager"]}],Review:[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Move to Study",next:"In Study",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},F0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Pending Comment":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function Iu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...F0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Zl={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function M0({processName:e,userRole:t,onRefresh:s,canUpdateStatus:r=!0}){const[l,i]=w.useState(null),[a,c]=w.useState(!0),[d,p]=w.useState(""),[v,f]=w.useState(!1),[u,m]=w.useState(""),[j,h]=w.useState(""),[S,g]=w.useState("Pass"),[x,o]=w.useState(""),[y,_]=w.useState({}),T=w.useCallback(async()=>{if(!e){c(!1);return}c(!0),p("");try{const O=await Kr(e);i(O);const I={};for(const E of O.progress_indicators||[])I[E.name]=E.actual_value!=null?String(E.actual_value):"";_(I)}catch(O){p(O instanceof Error?O.message:"Failed to load process")}c(!1)},[e]);if(w.useEffect(()=>{T()},[T]),a)return n.jsx("div",{style:{width:"100%",flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:24,color:"#aaa",fontSize:13,textAlign:"center"},children:"Loading…"})});if(d||!l)return n.jsx("div",{style:{width:"100%",flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:n.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:d||"Could not load workflow"})})});const A=l.workflow_state||"Draft",C=U0[A]??[],R=t==="Employee"||t==="Manager",$=t!=="Manager"||r,J=C.filter(O=>(t==="Admin"||O.allowedRoles.includes(t))&&(O.action!=="Update Status"||$)),ae=async O=>{f(!0),m(""),h("");try{const I={};if(O==="Update Status"){I.actor_status=S,I.actor_comment=x;const K=l.progress_indicators||[];K.length>0&&(I.progress_indicators=K.map(G=>({name:G.name,actual_value:y[G.name]??""})))}O==="Add Comment"&&x&&(I.actor_comment=x);const E=await o0(l.name,O,I);i(E),o(""),h(`Done — now: ${E.workflow_state||"updated"}`),s==null||s()}catch(I){m(I instanceof Error?I.message:"Action failed")}f(!1)};return n.jsx("div",{style:{width:"100%",flexShrink:0},children:n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),n.jsx("div",{style:Iu(A),children:A})]}),A==="Pending Actor"&&R&&$&&n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Update Status"}),Array.isArray(l.progress_indicators)&&l.progress_indicators.length>0&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Actual Value"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:l.progress_indicators.map(O=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("span",{style:{fontSize:11,color:"#555",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:O.name1,children:O.name1||O.name}),n.jsx("input",{type:"number",value:y[O.name]??"",onChange:I=>_(E=>({...E,[O.name]:I.target.value})),style:{...Zl,width:70,flexShrink:0},placeholder:"0"})]},O.name))})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),n.jsxs("select",{value:S,onChange:O=>g(O.target.value),style:Zl,children:[n.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),n.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),n.jsx("textarea",{value:x,onChange:O=>o(O.target.value),style:{...Zl,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(A==="Pending Comment"||A==="Review")&&!R&&n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Auditor Comment"}),Array.isArray(l.cycle_logs)&&l.cycle_logs.length>0&&n.jsxs("div",{style:{marginBottom:8,padding:"6px 10px",background:"#f8fafc",borderRadius:6,border:"1px solid #e2e8f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",marginBottom:3},children:"Latest cycle status:"}),(()=>{const O=l.cycle_logs,I=O[O.length-1],E=I.status==="Pass"?"#16a34a":I.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:E},children:[I.status," ",I.comment?`— ${I.comment}`:""]})})()]}),n.jsx("textarea",{value:x,onChange:O=>o(O.target.value),style:{...Zl,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:J.length>0?"1px solid #f0f0f0":"none"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),J.length===0&&n.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",n.jsx("strong",{children:t})," in ",n.jsx("strong",{children:A}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:J.map(O=>n.jsxs("button",{onClick:()=>ae(O.action),disabled:v,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:O.action==="Close Process"?"#64748b":O.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:v?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:v?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("span",{children:v?"Applying…":O.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",O.next]})]},O.action))}),u&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:u}),j&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:j})]}),C.length>0&&n.jsxs("div",{style:{padding:"12px 14px"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),C.map(O=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:O.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:Iu(O.next),children:O.next})]},O.action))]})]})})}const ei={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},ns={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function H0({processForm:e,setProcessForm:t,organizations:s,managements:r,departments:l,branches:i,processTypes:a,processStatuses:c,cycles:d=[],users:p=[],userRoleMap:v={},formStatus:f,viewMode:u,canModify:m,onEdit:j,onDelete:h,onRestore:S,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,userRole:T,delegatedFunctions:A=[],delegatedOrgs:C=null,onRefreshProcess:R,onSubmit:$,onBack:J,onNavigate:ae,onLogout:O,user:I}){const E=ne(),K=k=>t({...e,...k}),G=u?{background:"#f9f9f9"}:{},L=!u&&T==="Manager"&&Array.isArray(C),M=L?s.filter(k=>(C||[]).includes(k.organization_name||k.name)):s,Y=L&&(C||[]).length===1||!!I.custom_organization,Z=fe(r,e.management).map(k=>({name:k.name,label:k.name1||k.name})),V=fe(l,e.department).map(k=>({name:k.name,label:k.department_name||k.name})),ke=fe(i,e.branch).map(k=>({name:k.name,label:k.branch||k.name})),De=fe(a,e.type).map(k=>({name:k.name,label:k.name1||k.name})),Ae=fe(d,e.cycle).map(k=>({name:k.name,label:k.name1||k.name})),he=vr(p,v,"SB Employee",e.organization).map(k=>({name:k.name,label:k.full_name||k.name})),Fe=vr(p,v,"SB Manager",e.organization).map(k=>({name:k.name,label:k.full_name||k.name})),H=(k,ee)=>{const Q=[...e.cycle_logs||[]];Q[k]={...Q[k],...ee},K({cycle_logs:Q})},se=()=>{K({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},st=k=>{const ee=[...e.cycle_logs||[]];ee.splice(k,1),K({cycle_logs:ee})},re=(k,ee)=>{const Q=[...e.progress_indicators||[]];Q[k]={...Q[k],...ee},K({progress_indicators:Q})},rt=()=>{K({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},ct=k=>{const ee=[...e.progress_indicators||[]];ee.splice(k,1),K({progress_indicators:ee})},B=e.name?u?`${E.formTitle.viewProcess}${e.title||e.name}`:E.formTitle.editProcess:E.formTitle.newProcess,ye=T!=="Manager"||e.actor===I.name||A.includes("update_process_status"),ut=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsx(M0,{processName:e.name,userRole:T||I.role||"Employee",onRefresh:R,canUpdateStatus:ye}),n.jsx(aa,{doctype:D.processes,docname:e.name,currentUserName:I.name}),n.jsx(oa,{doctype:D.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&h&&!e.custom_is_deleted&&n.jsx(la,{title:"Delete Request",btnText:E.delete,onDelete:()=>h(e.name)})]}):void 0;return n.jsxs(Ue,{title:B,activePage:"processes",user:I,formStatus:f,buttonText:E.saveProcess,buttonColor:N.blue,viewMode:u,onEdit:j,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:_,rightPanel:ut,onSubmit:$,onBack:J,onNavigate:ae,onLogout:O,children:[e.custom_is_deleted===1&&n.jsx(_l,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:S?()=>S(e.name):void 0}),n.jsxs("div",{style:e.name?ns:ei,children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[E.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:k=>K({organization:k}),organizations:M,disabled:u||Y}),L&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(C||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(C||[]).length>1?"s":""}: ${(C||[]).join(", ")}`})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.title}),n.jsx("input",{style:{...P,...G},value:e.title,disabled:u,onChange:k=>K({title:k.target.value})})]})]}),n.jsx("div",{style:ei,children:n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.type}),n.jsx(pe,{value:e.type,onChange:k=>K({type:k}),items:De,placeholder:E.field.selectType,disabled:u})]})}),n.jsxs("div",{style:ns,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.management}),n.jsx(pe,{value:e.management,onChange:k=>K({management:k}),items:Z,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.department}),n.jsx(pe,{value:e.department,onChange:k=>K({department:k}),items:V,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.section}),n.jsx("input",{style:{...P,...G},value:e.section_field||"",disabled:u,onChange:k=>K({section_field:k.target.value})})]})]}),n.jsxs("div",{style:ei,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.branch}),n.jsx(pe,{value:e.branch,onChange:k=>K({branch:k}),items:ke,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[E.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#888",fontWeight:400},children:"(Auto-updated from Workflow)"})]}),n.jsx("input",{style:{...P,background:"#f9f9f9",fontWeight:600,color:"#1e293b"},value:e.status||e.workflow_state||"Draft",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:ns,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.chainLocation}),n.jsxs("select",{style:{...P,...G},value:e.chain_location||"",disabled:u,onChange:k=>K({chain_location:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:"Upstream"}),n.jsx("option",{value:"On-stream",children:"On-stream"}),n.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.economyClass}),n.jsxs("select",{style:{...P,...G},value:e.economy_class||"",disabled:u,onChange:k=>K({economy_class:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Expenses",children:E.field.expenses}),n.jsx("option",{value:"Capital",children:E.field.capital}),n.jsx("option",{value:"Earn",children:E.field.earn}),n.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.impactLevel}),n.jsxs("select",{style:{...P,...G},value:e.impact_level||"",disabled:u,onChange:k=>K({impact_level:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"High",children:E.field.high}),n.jsx("option",{value:"Normal",children:E.field.normal})]})]})]}),n.jsxs("div",{style:ns,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.entityScope}),n.jsxs("select",{style:{...P,...G},value:e.entity_scope||"",disabled:u,onChange:k=>K({entity_scope:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:E.field.upstream}),n.jsx("option",{value:"On-stream",children:E.field.onstream}),n.jsx("option",{value:"Downstream",children:E.field.downstream})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.hsesField}),n.jsx("input",{style:{...P,...G},value:e.hses_field||"",disabled:u,onChange:k=>K({hses_field:k.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:22},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:k=>K({product_relation:k.target.checked?1:0})})," ",E.field.productRelation]})})]})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:"KPI"}),n.jsxs("div",{style:ns,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.kpiName}),n.jsx("input",{style:{...P,...G},value:e.kpi_name||"",disabled:u,onChange:k=>K({kpi_name:k.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.kpiType}),n.jsxs("select",{style:{...P,...G},value:e.kpi_type||"",disabled:u,onChange:k=>K({kpi_type:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Human",children:"Human"}),n.jsx("option",{value:"Substantial",children:"Substantial"}),n.jsx("option",{value:"System",children:"System"}),n.jsx("option",{value:"Value",children:"Value"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.kpiMeasure}),n.jsx("input",{style:{...P,...G},value:e.kpi_measure||"",disabled:u,onChange:k=>K({kpi_measure:k.target.value}),placeholder:"Unit of measure"})]})]})]}),n.jsxs("div",{style:ns,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.dateStart}),n.jsx(me,{value:e.date_start,onChange:k=>K({date_start:k}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.dateEnd}),n.jsx(me,{value:e.date_end,onChange:k=>K({date_end:k}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycleType}),n.jsxs("select",{style:{...P,...G},value:e.cycle_type||"",disabled:u,onChange:k=>K({cycle_type:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:ei,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 1"}),n.jsx(me,{value:e.long_cycle_date_1||"",onChange:k=>K({long_cycle_date_1:k}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 2"}),n.jsx(me,{value:e.long_cycle_date_2||"",onChange:k=>K({long_cycle_date_2:k}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 3"}),n.jsx(me,{value:e.long_cycle_date_3||"",onChange:k=>K({long_cycle_date_3:k}),disabled:u,style:{...P,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 4"}),n.jsx(me,{value:e.long_cycle_date_4||"",onChange:k=>K({long_cycle_date_4:k}),disabled:u,style:{...P,...G}})]})]})]}),n.jsxs("div",{style:{marginTop:24,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...z,margin:0,fontSize:15},children:"Progress Indicators"}),!u&&n.jsx("button",{type:"button",onClick:rt,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Order"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Name"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Type"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Unit"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Target"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Min"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Max"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Manager"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actual Value"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Comment"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?14:15,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((k,ee)=>n.jsxs("tr",{style:{background:ee%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G,width:60},value:k.order??"",disabled:u,onChange:Q=>re(ee,{order:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G},value:k.name1,disabled:u,onChange:Q=>re(ee,{name1:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G},value:k.type,disabled:u,onChange:Q=>re(ee,{type:Q.target.value}),children:[n.jsx("option",{children:"Nominal"}),n.jsx("option",{children:"Ordinal"}),n.jsx("option",{children:"Interval"}),n.jsx("option",{children:"Ratio"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G,width:70},type:"text",value:k.unit??"",disabled:u,onChange:Q=>re(ee,{unit:Q.target.value}),placeholder:"e.g. °C, kg, %"})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G,minWidth:120},value:k.cycle,disabled:u,onChange:Q=>re(ee,{cycle:Q.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Ae.map(Q=>n.jsx("option",{value:Q.name,children:Q.label},Q.name)),k.cycle&&!Ae.some(Q=>Q.name===k.cycle)&&n.jsx("option",{value:k.cycle,children:k.cycle})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G,width:80},value:k.target,disabled:u,onChange:Q=>re(ee,{target:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G,width:80},value:k.minimum,disabled:u,onChange:Q=>re(ee,{minimum:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G,width:80},value:k.maximum,disabled:u,onChange:Q=>re(ee,{maximum:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G,minWidth:140},value:k.manager,disabled:u,onChange:Q=>re(ee,{manager:Q.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Fe.map(Q=>n.jsx("option",{value:Q.name,children:Q.label},Q.name)),k.manager&&!Fe.some(Q=>Q.name===k.manager)&&n.jsx("option",{value:k.manager,children:k.manager})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G,width:90},type:"number",value:k.actual_value??"",disabled:u,onChange:Q=>re(ee,{actual_value:parseFloat(Q.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G},value:k.cycle_status??"",disabled:u,onChange:Q=>re(ee,{cycle_status:Q.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(me,{value:k.cycle_date||"",onChange:Q=>re(ee,{cycle_date:Q}),disabled:u,style:{...P,...G,width:110}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G},value:k.cycle_comment??"",disabled:u,onChange:Q=>re(ee,{cycle_comment:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G},value:k.status??"",disabled:u,onChange:Q=>re(ee,{status:Q.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),!u&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>ct(ee),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},ee))]})]})})]}),n.jsxs("div",{style:{marginTop:28,borderTop:"1px solid #e9ecef",paddingTop:20},children:[n.jsx("div",{style:{...z,fontSize:15,marginBottom:14},children:"Cycle & Assignment"}),n.jsxs("div",{style:ns,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.cycle}),n.jsx(pe,{value:e.cycle||"",onChange:k=>K({cycle:k}),items:Ae,placeholder:E.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.actor}),n.jsxs("select",{style:{...P,...G},value:e.actor||"",disabled:u,onChange:k=>K({actor:k.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),he.map(k=>n.jsx("option",{value:k.name,children:k.label},k.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:E.field.costPerCycle}),n.jsx("input",{style:{...P,...G},type:"number",value:e.cost_per_cycle||"",disabled:u,onChange:k=>K({cost_per_cycle:parseFloat(k.target.value)||0}),placeholder:"0.00"})]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:E.field.escalationLevel}),n.jsx("input",{style:{...P,...G,maxWidth:120},type:"number",value:e.escalation_level||"",disabled:u,onChange:k=>K({escalation_level:parseInt(k.target.value)||0})})]})]}),n.jsxs("div",{style:{marginTop:28,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...z,margin:0,fontSize:15},children:"Cycle History"}),!u&&n.jsx("button",{type:"button",onClick:se,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actor"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Comment"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?5:6,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No cycle history"})}),(e.cycle_logs||[]).map((k,ee)=>n.jsxs("tr",{style:{background:ee%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G},value:k.cycle||"",disabled:u,onChange:Q=>H(ee,{cycle:Q.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),Ae.map(Q=>n.jsx("option",{value:Q.name,children:Q.label},Q.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(me,{value:k.cycle_date||"",onChange:Q=>H(ee,{cycle_date:Q}),disabled:u,style:{...P,...G,width:130}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G},value:k.status,disabled:u,onChange:Q=>H(ee,{status:Q.target.value}),children:[n.jsx("option",{value:"Pass",children:"Pass"}),n.jsx("option",{value:"Fail",children:"Fail"}),n.jsx("option",{value:"Unknown",children:"Unknown"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...G},value:k.actor||"",disabled:u,onChange:Q=>H(ee,{actor:Q.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),he.map(Q=>n.jsx("option",{value:Q.name,children:Q.label},Q.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...G},value:k.comment||"",disabled:u,onChange:Q=>H(ee,{comment:Q.target.value})})}),!u&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>st(ee),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},ee))]})]})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:16},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:E.field.auditorComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",background:"#f9f9f9"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:E.field.commentPlaceholder})]})]})}const G0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function K0({user:e,profileUser:t,darkMode:s,canModify:r,onBack:l,organizations:i=[],managements:a=[],departments:c=[],branches:d=[]}){const p=t||{},v=!!r&&e.role==="Admin",[f,u]=w.useState({first_name:p.first_name||"",middle_name:p.middle_name||"",last_name:p.last_name||"",mobile_no:p.mobile_no||"",custom_organization:p.custom_organization||"",custom_management:p.custom_management||"",custom_department:p.custom_department||"",custom_branch:p.custom_branch||"",custom_number:p.custom_number||"",custom_category:p.custom_category||""}),[m,j]=w.useState(""),[h,S]=w.useState(!1),[g,x]=w.useState({new:"",confirm:""}),[o,y]=w.useState(""),_=p.email||p.name||"",T=[f.first_name,f.middle_name,f.last_name].filter(Boolean).join(" ")||p.full_name||"",A=p.username||p.name||"",C=f.custom_category||"",R=p.enabled===0?"Inactive":"Active",$=G0[e.role]||"#6b7280",J=s,ae=J?"#0f172a":"#f0f2f5",O=J?"#1e293b":"white",I=J?"#2d3748":"#e5e7eb",E=J?"#e2e8f0":"#1a2332",K=J?"#94a3b8":"#6b7280",G=J?"#374151":"white",L=J?"#2d3748":"#f9fafb",M={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${I}`,fontSize:13,background:G,color:E,fontFamily:"inherit",outline:"none"},Y={...M,background:L,color:K},Z={...M,cursor:"pointer"},V={fontSize:12,fontWeight:600,color:K,marginBottom:5,display:"block"},ke={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},De={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},Ae=async()=>{if(r){j("saving");try{await Fi("User",p.name,{first_name:f.first_name,middle_name:f.middle_name,last_name:f.last_name,mobile_no:f.mobile_no,custom_organization:f.custom_organization,custom_management:f.custom_management,custom_department:f.custom_department,custom_branch:f.custom_branch,custom_number:f.custom_number,custom_category:f.custom_category}),j("saved"),setTimeout(()=>j(""),2e3)}catch{j("error"),setTimeout(()=>j(""),3e3)}}},he=async()=>{if(!g.new){y("Enter a new password");return}if(g.new!==g.confirm){y("Passwords do not match");return}y("saving");try{await oh(p.name,g.new),y("done"),x({new:"",confirm:""}),setTimeout(()=>{y(""),S(!1)},2e3)}catch{y("error")}},Fe=({title:H,icon:se,children:st})=>n.jsxs("div",{style:{background:O,borderRadius:12,padding:22,border:`1px solid ${I}`,boxShadow:`0 1px 4px rgba(0,0,0,${J?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${I}`},children:[se,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:E},children:H})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:st})]});return n.jsxs("div",{style:{background:ae,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:O,borderBottom:`1px solid ${I}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[n.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:E,fontFamily:"inherit"},children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),r&&n.jsxs("button",{onClick:Ae,style:{display:"flex",alignItems:"center",gap:8,background:m==="saved"?"#16a34a":m==="error"?"#dc2626":"#16a34a",color:"white",border:"none",borderRadius:8,padding:"9px 22px",fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:[n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),n.jsx("polyline",{points:"17,21 17,13 7,13 7,21"}),n.jsx("polyline",{points:"7,3 7,8 15,8"})]}),m==="saving"?"Saving…":m==="saved"?"Saved!":m==="error"?"Error":"Save Changes"]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",gap:22,padding:"0 28px"},children:[n.jsxs("div",{style:{borderRadius:14,overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.12)",alignSelf:"start"},children:[n.jsxs("div",{style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",padding:"32px 20px 28px",display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[n.jsx("div",{style:{width:78,height:78,borderRadius:"50%",background:"rgba(255,255,255,0.22)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:4,border:"3px solid rgba(255,255,255,0.3)"},children:n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"rgba(255,255,255,0.9)",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]})}),n.jsx("div",{style:{fontSize:17,fontWeight:700,color:"white",textAlign:"center",lineHeight:1.3},children:T||_}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:_})]}),n.jsx("div",{style:{background:O},children:[{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),label:"Username",value:A},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),n.jsx("circle",{cx:"9",cy:"7",r:"4"}),n.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),n.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:C||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:R==="Active"?"#16a34a":"#dc2626",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),label:"Status",value:R,valueColor:R==="Active"?"#16a34a":"#dc2626"},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:_},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:n.jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.69 13a19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 3.6 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),label:"Phone",value:f.mobile_no||"—"}].map(({icon:H,label:se,value:st,valueColor:re})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${I}`},children:[n.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:H}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:11,color:K,marginBottom:1},children:se}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:re||E,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:st})]})]},se))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(Fe,{title:"Basic Information",icon:n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7"})]}),children:[n.jsxs("div",{style:ke,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Email ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]})}),n.jsx("input",{style:{...Y,paddingLeft:32},value:_,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:Y,value:T,readOnly:!0})]})]}),n.jsxs("div",{style:De,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:r?M:Y,value:f.first_name,readOnly:!r,onChange:H=>u(se=>({...se,first_name:H.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:V,children:"Middle Name"}),n.jsx("input",{style:r?M:Y,value:f.middle_name,readOnly:!r,onChange:H=>u(se=>({...se,middle_name:H.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:V,children:"Last Name"}),n.jsx("input",{style:r?M:Y,value:f.last_name,readOnly:!r,onChange:H=>u(se=>({...se,last_name:H.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:ke,children:[n.jsxs("div",{children:[n.jsx("label",{style:V,children:"Phone Number"}),n.jsx("input",{style:r?M:Y,value:f.mobile_no,readOnly:!r,onChange:H=>u(se=>({...se,mobile_no:H.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:V,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...Y,paddingRight:44},value:f.custom_number||p.name||"",readOnly:!0}),n.jsx("div",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",background:"#ef4444",borderRadius:5,padding:"3px 7px",cursor:"default",display:"flex",alignItems:"center"},children:n.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"white",children:[n.jsx("circle",{cx:"5",cy:"12",r:"2"}),n.jsx("circle",{cx:"12",cy:"12",r:"2"}),n.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Category ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:Z,value:f.custom_category,onChange:H=>u(se=>({...se,custom_category:H.target.value})),children:[n.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(H=>n.jsx("option",{value:H,children:H},H))]}):n.jsx("input",{style:Y,value:C||"—",readOnly:!0})]})]}),n.jsxs(Fe,{title:"Organization Information",icon:n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#8b5cf6",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),n.jsx("path",{d:"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"})]}),children:[n.jsxs("div",{style:ke,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Organization ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:Z,value:f.custom_organization,onChange:H=>u(se=>({...se,custom_organization:H.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),fe(i,f.custom_organization).map(H=>n.jsx("option",{value:H.name,children:H.organization_name||H.name},H.name))]}):n.jsx("input",{style:Y,value:f.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Management ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:Z,value:f.custom_management,onChange:H=>u(se=>({...se,custom_management:H.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),fe(a,f.custom_management).map(H=>n.jsx("option",{value:H.name,children:H.name1||H.name},H.name))]}):n.jsx("input",{style:Y,value:f.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:ke,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Department ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:Z,value:f.custom_department,onChange:H=>u(se=>({...se,custom_department:H.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),fe(c,f.custom_department).map(H=>n.jsx("option",{value:H.name,children:H.department_name||H.name},H.name))]}):n.jsx("input",{style:Y,value:f.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Branch ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:Z,value:f.custom_branch,onChange:H=>u(se=>({...se,custom_branch:H.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),fe(d,f.custom_branch).map(H=>n.jsx("option",{value:H.name,children:H.branch||H.name},H.name))]}):n.jsx("input",{style:Y,value:f.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:O,borderRadius:12,padding:22,border:`1px solid ${I}`,boxShadow:`0 1px 4px rgba(0,0,0,${J?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("span",{style:{fontSize:14,fontWeight:700,color:E},children:"Change Password"})]}),r&&n.jsx("button",{onClick:()=>{S(H=>!H),y("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:h?"Cancel":"Change Password"})]}),h&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:De,children:[n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:M,value:g.new,onChange:H=>x(se=>({...se,new:H.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:V,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:M,value:g.confirm,onChange:H=>x(se=>({...se,confirm:H.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:he,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:o==="saving"?"Saving…":"Update Password"})})]}),o&&o!=="saving"&&n.jsx("div",{style:{fontSize:13,color:o==="done"?"#16a34a":"#dc2626",fontWeight:500},children:o==="done"?"Password updated successfully":o==="error"?"Failed to update password":o})]})]})]})]})]})}function we({label:e,val:t,color:s}){return n.jsxs("div",{style:{background:"white",borderRadius:8,padding:"8px 16px",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${s}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:s},children:t}),n.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const uh={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},Q0={...uh,cursor:"pointer"};function dt({filters:e,defaultOpen:t=!1}){const[s,r]=w.useState(t);return n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>r(l=>!l),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:s?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),s&&n.jsx("div",{style:{padding:"18px 20px"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((l,i)=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:l.label}),l.type==="search"?n.jsx("input",{style:uh,placeholder:l.placeholder,value:l.value,onChange:a=>l.onChange(a.target.value)}):n.jsx("select",{style:Q0,value:l.value,onChange:a=>l.onChange(a.target.value),children:l.options.map(a=>n.jsx("option",{value:a.value,children:a.label},a.value))})]},i))})})]})}function Y0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function X0({organizations:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),[v,f]=w.useState("all"),u={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},m=w.useMemo(()=>e.filter(g=>{const x=[g.organization_name,g.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!x.includes(a.toLowerCase())||d!=="all"&&g.type!==d||v!=="all"&&(g.is_active?"Active":"Inactive")!==v)}),[e,a,d,v]),[j,h]=w.useState(1);w.useEffect(()=>{h(1)},[a,d,v]);const S=m.slice((j-1)*le,j*le);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(we,{label:"Total",val:m.length,color:"#1a2332"}),n.jsx(we,{label:"Active",val:m.filter(g=>g.is_active).length,color:N.green}),n.jsx(we,{label:"Government",val:m.filter(g=>g.type==="Government").length,color:N.blue}),n.jsx(we,{label:"Private",val:m.filter(g=>g.type==="Private").length,color:N.orange})]}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:v,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:u,children:i.col.name}),n.jsx("th",{style:u,children:i.col.type}),n.jsx("th",{style:u,children:i.col.city}),n.jsx("th",{style:u,children:i.field.creationDate}),n.jsx("th",{style:u,children:i.col.status}),n.jsx("th",{style:u,children:i.col.actions})]})}),n.jsx("tbody",{children:m.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((g,x)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(g),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Y0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:vl(g.is_active?i.field.statusActive:i.field.statusInactive,g.is_active?N.green:N.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(g),onEdit:t&&r?()=>r(g):void 0,onDelete:t&&l?()=>l(g.name):void 0})})]},g.name))})]})}),n.jsx($e,{page:j,total:m.length,onPageChange:h})]})}const cn=e=>({background:e?"#f9f9f9":void 0});function q0({orgForm:e,setOrgForm:t,groupCompanies:s=[],formStatus:r,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=ne(),g=e.name?l&&e.organization_name||S.formTitle.editOrg:S.formTitle.newOrg,x=s.map(o=>({name:o.name,label:o.company_name?`${o.company_name} (${o.name})`:o.name}));return n.jsxs(Ue,{title:g,activePage:"organizations",user:h,formStatus:r,buttonText:S.saveOrg,buttonColor:N.accent,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.orgName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...P,...cn(l||!!e.name)},value:e.organization_name,disabled:l||!!e.name,required:!0,onChange:o=>t({...e,organization_name:o.target.value})})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.orgAcronym," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...P,...cn(l||!!e.name)},value:e.acronym||"",disabled:l||!!e.name,required:!0,onChange:o=>t({...e,acronym:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Group Company (Tenant)"}),n.jsx(pe,{value:e.group_company||"",onChange:o=>t({...e,group_company:o}),items:x,placeholder:"Select Group Company",disabled:l||!!h.custom_group_company})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.organizationType}),n.jsxs("select",{style:{...P,...cn(l)},value:e.type,disabled:l,onChange:o=>t({...e,type:o.target.value}),children:[n.jsx("option",{children:"Government"}),n.jsx("option",{children:"Private"}),n.jsx("option",{children:"Non-Profit"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.orgCity}),n.jsx("input",{type:"text",style:{...P,...cn(l)},value:e.city,disabled:l,onChange:o=>t({...e,city:o.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.contactEmail}),n.jsx("input",{type:"email",style:{...P,...cn(l)},value:e.contact_email,disabled:l,onChange:o=>t({...e,contact_email:o.target.value})})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>t({...e,creation_date:o}),disabled:l,style:{...P,...cn(l)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsxs("select",{style:{...P,...cn(l)},value:e.is_active?"Active":"Inactive",disabled:l,onChange:o=>t({...e,is_active:o.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...cn(l)},value:e.incident_triage_window_days??3,disabled:l,onChange:o=>t({...e,incident_triage_window_days:parseInt(o.target.value)||3})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...cn(l)},value:e.incident_resolution_window_days??5,disabled:l,onChange:o=>t({...e,incident_resolution_window_days:parseInt(o.target.value)||5})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})]})}function J0({groupCompanies:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=[h.company_name,h.acronym,h.code,h.owner_user].filter(Boolean).join(" ").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(we,{label:"Total Group Cos",val:f.length,color:"#1a2332"}),n.jsx(we,{label:"Active",val:f.filter(h=>(h.status||"Active")==="Active").length,color:N.green}),n.jsx(we,{label:"Inactive",val:f.filter(h=>h.status==="Inactive").length,color:N.orange})]}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Company name, code, owner…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Inactive",label:"Inactive"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:"#fafafa"},children:[n.jsx("th",{style:v,children:"Company Name"}),n.jsx("th",{style:v,children:"Code / Acronym"}),n.jsx("th",{style:v,children:"Group Co Owner"}),n.jsx("th",{style:v,children:"Status"}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsxs("tbody",{children:[j.map((h,S)=>{const g=h.custom_is_deleted===1;return n.jsxs("tr",{style:{borderBottom:"1px solid #f0f0f0",background:g?"#fef2f2":S%2===0?"white":"#fafafa"},children:[n.jsxs("td",{style:{padding:"12px 14px",fontWeight:600},children:[h.company_name,g&&n.jsx("span",{style:{marginLeft:8},children:vl(i.deletedBadge,"#ef4444")})]}),n.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:[h.code,h.acronym].filter(Boolean).join(" / ")||"—"}),n.jsx("td",{style:{padding:"12px 14px",color:"#555"},children:h.owner_user||"—"}),n.jsx("td",{style:{padding:"12px 14px"},children:vl(h.status||"Active",(h.status||"Active")==="Active"?N.green:N.orange)}),n.jsx("td",{style:{padding:"12px 14px"},children:n.jsx(qe,{onView:s?()=>s(h):void 0,onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name)}),f.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:24,textAlign:"center",color:"#aaa"},children:"No Group Companies found"})})]})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}const Eu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function V0({form:e,setForm:t,users:s=[],formStatus:r,viewMode:l,onEdit:i,onRestore:a,darkMode:c,notifCount:d,onToggleDark:p,onCountChange:v,onViewProfile:f,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,user:S}){const g=_=>t({...e,..._}),x=l?{background:"#f9f9f9"}:{},o=e.name?l?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",y=s.map(_=>({name:_.name,label:_.full_name?`${_.full_name} (${_.name})`:_.name}));return n.jsxs(Ue,{title:o,activePage:"group-companies",user:S,formStatus:r,buttonText:"Save Group Company",buttonColor:N.purple,viewMode:l,onEdit:i,darkMode:c,notifCount:d,onToggleDark:p,onCountChange:v,onViewProfile:f,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,children:[e.custom_is_deleted===1&&n.jsx(_l,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:a?()=>a(e.name):void 0}),n.jsxs("div",{style:Eu,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:["Company Name ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.company_name||"",disabled:l||!!e.name,onChange:_=>g({company_name:_.target.value}),placeholder:"e.g. Company A Group"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Company Code"}),n.jsx("input",{style:{...P,...x},value:e.code||"",disabled:l,onChange:_=>g({code:_.target.value}),placeholder:"e.g. CO-A"})]})]}),n.jsxs("div",{style:{...Eu,marginTop:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Acronym"}),n.jsx("input",{style:{...P,...x},value:e.acronym||"",disabled:l,onChange:_=>g({acronym:_.target.value}),placeholder:"e.g. CAG"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Status"}),n.jsxs("select",{style:{...P,...x},value:e.status||"Active",disabled:l,onChange:_=>g({status:_.target.value}),children:[n.jsx("option",{value:"Active",children:"Active"}),n.jsx("option",{value:"Inactive",children:"Inactive"})]})]})]}),n.jsxs("div",{style:{marginTop:16},children:[n.jsx("label",{style:z,children:"Group Co Owner / Admin User"}),n.jsx(pe,{value:e.owner_user||"",onChange:_=>g({owner_user:_}),items:y,placeholder:"Select owner user",disabled:l})]}),n.jsxs("div",{style:{marginTop:16},children:[n.jsx("label",{style:z,children:"Notes"}),n.jsx("textarea",{style:{...P,...x,height:80,resize:"vertical"},value:e.notes||"",disabled:l,onChange:_=>g({notes:_.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})}function Z0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function e1({managements:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.blue})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Z0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function t1({form:e,setForm:t,organizations:s,formStatus:r,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=ne(),g=y=>t(_=>({..._,...y})),x=l?{background:"#f9f9f9"}:{},o=e.name?l?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return n.jsxs(Ue,{title:o,activePage:"managements",user:h,formStatus:r,buttonText:S.saveMgmt,buttonColor:N.blue,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:y=>g({organization:y}),organizations:s,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.name1,disabled:l||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:y=>g({creation_date:y}),disabled:l,style:{...P,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsxs("select",{style:{...P,...x},value:e.status||"Active",disabled:l,onChange:y=>g({status:y.target.value}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})]})}function n1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function s1({departments:e,managements:t,canModify:s,onView:r,onEdit:l,onDelete:i}){const a=ne(),[c,d]=w.useState(""),[p,v]=w.useState(""),[f,u]=w.useState("all"),m=o=>{var y;return((y=t.find(_=>_.name===o))==null?void 0:y.name1)||o||"—"},j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},h=w.useMemo(()=>e.filter(o=>{const y=(o.department_name||o.name||"").toLowerCase();return!(c&&!y.includes(c.toLowerCase())||p&&o.custom_management!==p||f!=="all"&&(o.custom_status||"Active")!==f)}),[e,c,p,f]),[S,g]=w.useState(1);w.useEffect(()=>{g(1)},[c,p,f]);const x=h.slice((S-1)*le,S*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:h.length,color:N.teal})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:c,onChange:d,placeholder:"Search by name…"},{type:"select",label:a.col.management,value:p,onChange:v,options:[{value:"",label:"All Managements"},...t.map(o=>({value:o.name,label:o.name1||o.name}))]},{type:"select",label:"Status",value:f,onChange:u,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:j,children:a.col.name}),n.jsx("th",{style:j,children:a.col.management}),n.jsx("th",{style:j,children:a.field.creationDate}),n.jsx("th",{style:j,children:a.field.status}),n.jsx("th",{style:j,children:a.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):x.map((o,y)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(o),style:{borderTop:"1px solid #f0f0f0",background:y%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.department_name||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:m(o.custom_management)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:n1(o.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:o.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(qe,{onView:()=>r==null?void 0:r(o),onEdit:s&&l?()=>l(o):void 0,onDelete:s&&i?()=>i(o.name):void 0})})]},o.name))})]})}),n.jsx($e,{page:S,total:h.length,onPageChange:g})]})}const r1={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function l1({form:e,setForm:t,organizations:s,managements:r,formStatus:l,viewMode:i,onEdit:a,darkMode:c,notifCount:d,onToggleDark:p,onCountChange:v,onViewProfile:f,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,user:S}){const g=ne(),x=T=>t(A=>({...A,...T})),o=i?{background:"#f9f9f9"}:{},y=e.name?i?`${g.formTitle.editDept}: ${e.department_name||e.name}`:g.formTitle.editDept:g.formTitle.newDept,_=fe(r,e.custom_management).map(T=>({name:T.name,label:T.name1||T.name}));return n.jsxs(Ue,{title:y,activePage:"departments",user:S,formStatus:l,buttonText:g.saveDept,buttonColor:N.teal,viewMode:i,onEdit:a,darkMode:c,notifCount:d,onToggleDark:p,onCountChange:v,onViewProfile:f,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.custom_organization,onChange:T=>x({custom_organization:T}),organizations:s,disabled:i||!!S.custom_organization})]}),n.jsxs("div",{style:r1,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.department_name,disabled:i||!!e.name,onChange:T=>x({department_name:T.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.management}),n.jsx(pe,{value:e.custom_management,onChange:T=>x({custom_management:T}),items:_,placeholder:g.field.select,disabled:i})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.custom_creation_date||"",onChange:T=>x({custom_creation_date:T}),disabled:i,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.custom_status||"Active",disabled:i,onChange:T=>x({custom_status:T.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})]})}function i1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function a1({branches:e,managements:t,departments:s,canModify:r,onView:l,onEdit:i,onDelete:a}){const c=ne(),[d,p]=w.useState(""),[v,f]=w.useState(""),[u,m]=w.useState(""),[j,h]=w.useState("all"),S=A=>{var C;return((C=t.find(R=>R.name===A))==null?void 0:C.name1)||A||"—"},g=A=>{var C;return((C=s.find(R=>R.name===A))==null?void 0:C.department_name)||A||"—"},x={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=w.useMemo(()=>e.filter(A=>{const C=(A.branch||A.name||"").toLowerCase();return!(d&&!C.includes(d.toLowerCase())||v&&A.management!==v||u&&A.department!==u||j!=="all"&&(A.custom_status||"Active")!==j)}),[e,d,v,u,j]),[y,_]=w.useState(1);w.useEffect(()=>{_(1)},[d,v,u,j]);const T=o.slice((y-1)*le,y*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:o.length,color:N.purple})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:d,onChange:p,placeholder:"Search by name…"},{type:"select",label:c.col.management,value:v,onChange:f,options:[{value:"",label:"All Managements"},...t.map(A=>({value:A.name,label:A.name1||A.name}))]},{type:"select",label:c.col.department,value:u,onChange:m,options:[{value:"",label:"All Departments"},...s.map(A=>({value:A.name,label:A.department_name||A.name}))]},{type:"select",label:"Status",value:j,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:c.field.statusActive},{value:"Inactive",label:c.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:x,children:c.col.branch}),n.jsx("th",{style:x,children:c.col.management}),n.jsx("th",{style:x,children:c.col.department}),n.jsx("th",{style:x,children:c.field.creationDate}),n.jsx("th",{style:x,children:c.field.status}),n.jsx("th",{style:x,children:c.col.actions})]})}),n.jsx("tbody",{children:o.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noData})}):T.map((A,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(A),style:{borderTop:"1px solid #f0f0f0",background:C%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:A.branch||A.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:S(A.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:g(A.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:i1(A.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:A.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:A.custom_status==="Inactive"?c.field.statusInactive:c.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:R=>R.stopPropagation(),children:n.jsx(qe,{onView:()=>l==null?void 0:l(A),onEdit:r&&i?()=>i(A):void 0,onDelete:r&&a?()=>a(A.name):void 0})})]},A.name))})]})}),n.jsx($e,{page:y,total:o.length,onPageChange:_})]})}const o1={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function d1({form:e,setForm:t,organizations:s,managements:r,departments:l,formStatus:i,viewMode:a,onEdit:c,darkMode:d,notifCount:p,onToggleDark:v,onCountChange:f,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,user:g}){const x=ne(),o=C=>t(R=>({...R,...C})),y=a?{background:"#f9f9f9"}:{},_=e.name?a?`${x.formTitle.editBranch}: ${e.branch||e.name}`:x.formTitle.editBranch:x.formTitle.newBranch,T=fe(r,e.management).map(C=>({name:C.name,label:C.name1||C.name})),A=fe(l,e.department).map(C=>({name:C.name,label:C.department_name||C.name}));return n.jsxs(Ue,{title:_,activePage:"branches",user:g,formStatus:i,buttonText:x.saveBranch,buttonColor:N.purple,viewMode:a,onEdit:c,darkMode:d,notifCount:p,onToggleDark:v,onCountChange:f,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:C=>o({organization:C}),organizations:s,disabled:a||!!g.custom_organization})]}),n.jsxs("div",{style:o1,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...y},value:e.branch,disabled:a||!!e.name,onChange:C=>o({branch:C.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.management}),n.jsx(pe,{value:e.management,onChange:C=>o({management:C}),items:T,placeholder:x.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.department}),n.jsx(pe,{value:e.department,onChange:C=>o({department:C}),items:A,placeholder:x.field.select,disabled:a})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.creationDate}),n.jsx(me,{value:e.custom_creation_date||"",onChange:C=>o({custom_creation_date:C}),disabled:a,style:{...P,...y}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.status}),n.jsxs("select",{style:{...P,...y},value:e.custom_status||"Active",disabled:a,onChange:C=>o({custom_status:C.target.value}),children:[n.jsx("option",{value:"Active",children:x.field.statusActive}),n.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})]})}function c1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function u1({incidentTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.red})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:c1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function p1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(Ue,{title:x,activePage:"incident-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.red,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function f1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function h1({ideaTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.teal})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:f1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function g1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(Ue,{title:x,activePage:"idea-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.teal,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function x1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function m1({orderTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.purple})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:x1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function y1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(Ue,{title:x,activePage:"order-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.purple,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function v1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function j1({processTypes:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.blue})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:v1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function b1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(Ue,{title:x,activePage:"process-types",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.blue,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function S1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function w1({incidentStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.red})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.notifyManager}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:S1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function k1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(Ue,{title:x,activePage:"incident-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.red,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:jr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function _1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function C1({ideaStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.teal})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.notifyManager}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:_1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function z1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(Ue,{title:x,activePage:"idea-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.teal,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:jr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function T1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function I1({orderStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.purple})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.notifyManager}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:T1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function E1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(Ue,{title:x,activePage:"order-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.purple,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:jr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}function P1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function A1({processStatuses:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},f=w.useMemo(()=>e.filter(h=>{const S=(h.name1||h.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d!=="all"&&(h.status||"Active")!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total",val:f.length,color:N.blue})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:"Status",value:d,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:i.col.name}),n.jsx("th",{style:v,children:i.field.notifyManager}),n.jsx("th",{style:v,children:i.field.creationDate}),n.jsx("th",{style:v,children:i.field.status}),n.jsx("th",{style:v,children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:P1(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}function R1({form:e,setForm:t,formStatus:s,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=ne(),S=o=>t(y=>({...y,...o})),g=r?{background:"#f9f9f9"}:{},x=e.name?r?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(Ue,{title:x,activePage:"process-statuses",user:j,formStatus:s,buttonText:h.saveName,buttonColor:N.blue,viewMode:r,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...g},value:e.name1,disabled:r||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:jr}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:r,style:{...P,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...P,...g},value:e.status||"Active",disabled:r,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}const L1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function O1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function D1({users:e,canModify:t,onView:s,onEdit:r,onDisable:l}){const i=ne(),[a,c]=w.useState(!1),[d,p]=w.useState(""),[v,f]=w.useState(""),[u,m]=w.useState(""),[j,h]=w.useState("active"),[S,g]=w.useState(1),[x,o]=w.useState(null),[y,_]=w.useState(""),[T,A]=w.useState("idle"),[C,R]=w.useState(null),$=async()=>{if(!(!x||!y.trim())){A("loading");try{await oh(x.name,y.trim()),A("success"),setTimeout(()=>{o(null),_(""),A("idle")},1200)}catch{A("error")}}},J=async L=>{if(window.confirm(i.users.disableConfirm)){R(L);try{await(l==null?void 0:l(L))}finally{R(null)}}},ae=e.filter(L=>{if(j==="active"&&(L.enabled===0||L.enabled==="0")||j==="inactive"&&L.enabled!==0&&L.enabled!=="0")return!1;const M=L.custom_category||"";if(u&&M!==u)return!1;const Y=L.custom_organization||"";if(v&&!Y.toLowerCase().includes(v.toLowerCase()))return!1;if(d){const Z=d.toLowerCase();if(![L.full_name,L.email,L.name,L.username,L.mobile_no].join(" ").toLowerCase().includes(Z))return!1}return!0}),O=[...new Set(e.map(L=>L.custom_organization).filter(Boolean))],I=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];w.useEffect(()=>{g(1)},[d,v,u,j]);const E=ae.slice((S-1)*le,S*le),K={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},G={...K,cursor:"pointer"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:["Total: ",ae.length," users"]}),n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>c(L=>!L),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:a?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),a&&n.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:14},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),n.jsx("input",{style:K,placeholder:"Name, email, username…",value:d,onChange:L=>p(L.target.value)})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),n.jsxs("select",{style:G,value:v,onChange:L=>f(L.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),O.map(L=>n.jsx("option",{value:L,children:L},L))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),n.jsxs("select",{style:G,value:u,onChange:L=>m(L.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),I.map(L=>n.jsx("option",{value:L,children:L},L))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),n.jsxs("select",{style:G,value:j,onChange:L=>h(L.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:L,w:M})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:M,letterSpacing:.3,textTransform:"uppercase"},children:L},L))})}),n.jsx("tbody",{children:ae.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:13,style:{padding:"48px 20px",textAlign:"center",color:"#aaa",fontSize:14},children:"No users found"})}):E.map((L,M)=>{const Y=L.custom_category||"",Z=L1[Y]||"#6b7280";return n.jsxs("tr",{onClick:()=>s==null?void 0:s(L),style:{borderBottom:"1px solid #f3f4f6",background:M%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:V=>V.currentTarget.style.background="#f0f7ff",onMouseLeave:V=>V.currentTarget.style.background=M%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:Y?n.jsx("span",{style:{background:Z+"18",color:Z,border:`1px solid ${Z}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:Y}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:L.full_name||L.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.email||L.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:O1(L.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:L.enabled?"#16a34a":"#dc2626",fontWeight:600},children:L.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:V=>V.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:V=>{V.stopPropagation(),s==null||s(L)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t&&r&&n.jsx("button",{onClick:V=>{V.stopPropagation(),r(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:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t&&n.jsx("button",{onClick:V=>{V.stopPropagation(),o({name:L.name,email:L.email||L.name}),_(""),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:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),t&&n.jsx("button",{onClick:V=>{V.stopPropagation(),J(L.name)},disabled:C===L.name,title:"Disable",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",opacity:C===L.name?.5:1},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},L.name)})})]})}),n.jsx($e,{page:S,total:ae.length,onPageChange:g}),x&&n.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[n.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:i.users.setPassword}),n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",n.jsx("strong",{children:x.email})]}),n.jsx("input",{type:"password",value:y,onChange:L=>_(L.target.value),placeholder:i.users.newPassword,style:{width:"100%",padding:"10px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",marginBottom:16,fontFamily:"Segoe UI",outline:"none"},onKeyDown:L=>L.key==="Enter"&&$(),autoFocus:!0}),T==="success"&&n.jsx("div",{style:{color:"#166534",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Password updated successfully"}),T==="error"&&n.jsx("div",{style:{color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px",marginBottom:12,fontSize:13},children:"Failed to update password"}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:$,disabled:T==="loading"||!y.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:y.trim()?1:.5},children:T==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),_(""),A("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}const ti={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function N1({form:e,setForm:t,groupCompanies:s=[],organizations:r,managements:l,departments:i,branches:a,formStatus:c,viewMode:d,onEdit:p,darkMode:v,notifCount:f,onToggleDark:u,onCountChange:m,onViewProfile:j,isSelfProfile:h,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,user:y}){const _=ne(),T=I=>t(E=>({...E,...I})),A=d?{background:"#f9f9f9"}:{},C=!e.name,R=h?"My Profile":C?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,$=s.map(I=>({name:I.name,label:I.company_name?`${I.company_name} (${I.name})`:I.name})),J=fe(l,e.custom_management).map(I=>({name:I.name,label:I.name1||I.name})),ae=fe(i,e.custom_department).map(I=>({name:I.name,label:I.department_name||I.name})),O=fe(a,e.custom_branch).map(I=>({name:I.name,label:I.branch||I.name}));return n.jsxs(Ue,{title:R,activePage:"users",user:y,formStatus:c,buttonText:_.saveUser,buttonColor:N.blue,viewMode:d,onEdit:p,darkMode:v,notifCount:f,onToggleDark:u,onCountChange:m,onViewProfile:j,hideSettings:h,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Group Company (Tenant)"}),n.jsx(pe,{value:e.custom_group_company||"",onChange:I=>T({custom_group_company:I}),items:$,placeholder:"-- Select Group Company --",disabled:d||!!y.custom_group_company})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.organization}),n.jsx(Ot,{value:e.custom_organization,onChange:I=>T({custom_organization:I}),organizations:r,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.management}),n.jsx(pe,{value:e.custom_management,onChange:I=>T({custom_management:I}),items:J,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:ti,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.department}),n.jsx(pe,{value:e.custom_department,onChange:I=>T({custom_department:I}),items:ae,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.branch}),n.jsx(pe,{value:e.custom_branch,onChange:I=>T({custom_branch:I}),items:O,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:ti,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.number}),n.jsx("input",{style:{...P,...A},value:e.custom_number,disabled:d,onChange:I=>T({custom_number:I.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[_.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...A},value:e.first_name,disabled:d,onChange:I=>T({first_name:I.target.value}),placeholder:"Full name",required:!0})]})]}),n.jsxs("div",{style:ti,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.username}),n.jsx("input",{style:{...P,...A},value:e.username,disabled:d,onChange:I=>T({username:I.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.phoneNumber}),n.jsx("input",{style:{...P,...A},value:e.mobile_no,disabled:d,onChange:I=>T({mobile_no:I.target.value}),placeholder:"Phone number"})]})]}),n.jsxs("div",{style:ti,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[_.field.emailAddress," ",C&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...d||!C?{background:"#f9f9f9"}:{}},value:e.email,disabled:d||!C,onChange:I=>T({email:I.target.value}),placeholder:"user@example.com",type:"email",required:C})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.category}),n.jsxs("select",{style:{...P,...A},value:e.custom_category,disabled:d,onChange:I=>T({custom_category:I.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{children:"Admin"}),n.jsx("option",{children:"Chairman"}),n.jsx("option",{children:"Auditor"}),n.jsx("option",{children:"X-Auditor"}),n.jsx("option",{children:"Manager"}),n.jsx("option",{children:"Employee"})]})]})]})]})}const Pu={Active:N.green,Closed:N.gray};function W1({cycles:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState(""),[v,f]=w.useState("all"),u=w.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),m=w.useMemo(()=>e.filter(o=>{const y=(o.name1||o.name||"").toLowerCase();return!(a&&!y.includes(a.toLowerCase())||d&&o.organization!==d||v!=="all"&&o.status!==v)}),[e,a,d,v]),[j,h]=w.useState(1);w.useEffect(()=>{h(1)},[a,d,v]);const S=m.slice((j-1)*le,j*le),g=m.filter(o=>o.status==="Active").length,x=m.filter(o=>o.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(we,{label:"Total",val:m.length,color:N.teal}),n.jsx(we,{label:"Active",val:g,color:N.green}),n.jsx(we,{label:"Closed",val:x,color:N.gray})]}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:d,onChange:p,options:[{value:"",label:"All Organizations"},...u.map(o=>({value:o,label:o}))]},{type:"select",label:"Status",value:v,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.name}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.frequency}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.startDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.endDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:m.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((o,y)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:y%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:Pu[o.status]+"22",color:Pu[o.status]||"#666"},children:o.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(o),onEdit:t&&r?()=>r(o):void 0,onDelete:t&&l?()=>l(o.name):void 0})})]},o.name))})]})}),n.jsx($e,{page:j,total:m.length,onPageChange:h})]})}const Ga={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},B1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],$1=["Active","Closed"];function U1({form:e,setForm:t,organizations:s,formStatus:r,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=ne(),g=y=>t(_=>({..._,...y})),x=l?{background:"#f9f9f9"}:{},o=e.name?l?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return n.jsxs(Ue,{title:o,activePage:"cycles",user:h,formStatus:r,buttonText:S.saveCycle,buttonColor:N.teal,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:[n.jsxs("div",{style:Ga,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.name1||"",disabled:l||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:y=>g({organization:y}),organizations:s,disabled:l||!!h.custom_organization})]})]}),n.jsxs("div",{style:Ga,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.col.frequency}),n.jsx(pe,{value:e.frequency,onChange:y=>g({frequency:y}),items:B1.map(y=>({name:y,label:y})),placeholder:"-- Select Frequency --",disabled:l})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsx(pe,{value:e.status,onChange:y=>g({status:y}),items:$1.map(y=>({name:y,label:y})),placeholder:"-- Select Status --",disabled:l})]})]}),n.jsxs("div",{style:Ga,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.dateStart}),n.jsx(me,{value:e.start_date||"",onChange:y=>g({start_date:y}),disabled:l,style:{...P,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.dateEnd}),n.jsx(me,{value:e.end_date||"",onChange:y=>g({end_date:y}),disabled:l,style:{...P,...x}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...x,maxWidth:160},value:e.update_window_days??2,disabled:l,onChange:y=>g({update_window_days:parseInt(y.target.value)||2})}),n.jsx("span",{style:{fontSize:12,color:"#888",marginLeft:8},children:"Grace period after cycle ends before Unknown is auto-assigned"})]})]})}function F1({kpiInputs:e,canModify:t,onView:s,onEdit:r,onDelete:l}){const i=ne(),[a,c]=w.useState(""),[d,p]=w.useState(""),v=w.useMemo(()=>[...new Set(e.map(h=>h.organization).filter(Boolean))],[e]),f=w.useMemo(()=>e.filter(h=>{const S=[h.organization,h.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||d&&h.organization!==d)}),[e,a,d]),[u,m]=w.useState(1);w.useEffect(()=>{m(1)},[a,d]);const j=f.slice((u-1)*le,u*le);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(we,{label:"Total Records",val:f.length,color:N.blue})}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:a,onChange:c,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:d,onChange:p,options:[{value:"",label:"All Organizations"},...v.map(h=>({value:h,label:h}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:f.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,S)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(h),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.period||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.revenue_growth!=null?`${h.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.net_profit!=null?h.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.customer_satisfaction!=null?h.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:g=>g.stopPropagation(),children:n.jsx(qe,{onView:()=>s==null?void 0:s(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx($e,{page:u,total:f.length,onPageChange:m})]})}const Au={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ru={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function M1({form:e,setForm:t,organizations:s,formStatus:r,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,user:h}){const S=ne(),g=_=>t(T=>({...T,..._})),x=l?{background:"#f9f9f9"}:{},o=_=>T=>g({[_]:parseFloat(T.target.value)||0}),y=e.name?l?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return n.jsxs(Ue,{title:y,activePage:"kpi-input",user:h,formStatus:r,buttonText:S.saveKpi,buttonColor:N.blue,viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:[n.jsxs("div",{style:Au,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Ot,{value:e.organization,onChange:_=>g({organization:_}),organizations:s,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...x},value:e.period||"",disabled:l,onChange:_=>g({period:_.target.value}),placeholder:"e.g. Q1 2026"})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Financial KPIs"}),n.jsxs("div",{style:Ru,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.revenue_growth||"",disabled:l,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.net_profit||"",disabled:l,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.cash_flow||"",disabled:l,onChange:o("cash_flow")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Operational KPIs"}),n.jsxs("div",{style:Ru,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.strategic_goal_pct||"",disabled:l,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.customer_satisfaction||"",disabled:l,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.employee_turnover_pct||"",disabled:l,onChange:o("employee_turnover_pct")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Safety & Compliance"}),n.jsxs("div",{style:Au,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...P,...x},value:e.open_safety_incidents||"",disabled:l,onChange:_=>g({open_safety_incidents:parseInt(_.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...x},value:e.compliance_score||"",disabled:l,onChange:o("compliance_score")})]})]})]})]})}const H1={create_processes:"Create Processes",update_process_status:"Update Process Status"},Lu={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function G1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function K1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function Q1({delegations:e,organizations:t,userRole:s,currentUser:r,onView:l,onRevoke:i}){const a=ne(),[c,d]=w.useState(""),[p,v]=w.useState(""),[f,u]=w.useState("all"),m={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},j=w.useMemo(()=>e.filter(y=>{const _=`${y.auditor} ${y.manager}`.toLowerCase();return!(c&&!_.includes(c.toLowerCase())||p&&y.organization!==p||f!=="all"&&y.status!==f)}),[e,c,p,f]),[h,S]=w.useState(1);w.useEffect(()=>{S(1)},[c,p,f]);const g=j.slice((h-1)*le,h*le),x=j.filter(y=>y.status==="Pending").length,o=j.filter(y=>y.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(we,{label:"Total",val:j.length,color:N.purple}),n.jsx(we,{label:"Pending",val:x,color:N.orange}),n.jsx(we,{label:"Accepted",val:o,color:N.green})]}),n.jsx(dt,{filters:[{type:"search",label:"Search",value:c,onChange:d,placeholder:"Auditor or Manager…"},{type:"select",label:a.col.organization,value:p,onChange:v,options:[{value:"",label:"All Organizations"},...t.map(y=>({value:y.organization_name||y.name,label:y.organization_name||y.name}))]},{type:"select",label:"Status",value:f,onChange:u,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:m,children:a.col.number}),n.jsx("th",{style:m,children:a.col.auditor}),n.jsx("th",{style:m,children:a.col.manager}),n.jsx("th",{style:m,children:a.col.organization}),n.jsx("th",{style:m,children:a.col.functions}),n.jsx("th",{style:m,children:a.col.status}),n.jsx("th",{style:m,children:a.col.requestedOn}),n.jsx("th",{style:m,children:a.col.actions})]})}),n.jsx("tbody",{children:j.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):g.map((y,_)=>{const T=!!i&&(y.status==="Pending"||y.status==="Accepted")&&(s==="Admin"||s==="Auditor"&&y.auditor===r);return n.jsxs("tr",{onClick:()=>l==null?void 0:l(y),style:{borderTop:"1px solid #f0f0f0",background:_%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:y.number||y.name}),n.jsx("td",{style:{padding:"10px 14px"},children:y.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:y.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:y.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:K1(y).map(A=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:H1[A]||A},A))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(Lu[y.status]||N.gray)+"22",color:Lu[y.status]||N.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:y.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:G1(y.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:A=>A.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>l==null?void 0:l(y),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),T&&n.jsx("button",{onClick:()=>i==null?void 0:i(y.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"})]})})]},y.name)})})]})}),n.jsx($e,{page:h,total:j.length,onPageChange:S})]})}const Ou={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Du={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function Y1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function X1({form:e,setForm:t,organizations:s,users:r,userRoleMap:l,formStatus:i,viewMode:a,onEdit:c,darkMode:d,notifCount:p,onToggleDark:v,onCountChange:f,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,user:g}){var A;const x=ne(),o=C=>t(R=>({...R,...C})),y=a?{background:"#f9f9f9"}:{},_=vr(r,l,"SB Manager").map(C=>({name:C.name,label:C.full_name||C.name})),T=e.name?`${x.formTitle.viewDelegation}${e.number||e.name}`:x.formTitle.newDelegation;return n.jsxs(Ue,{title:T,activePage:"delegations",user:g,formStatus:i,buttonText:x.saveDelegation,buttonColor:N.purple,viewMode:a,onEdit:c,darkMode:d,notifCount:p,onToggleDark:v,onCountChange:f,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(Du[e.status]||N.gray)+"22",color:Du[e.status]||N.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:Ou,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.col.auditor}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.auditor||g.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(pe,{value:e.manager,onChange:C=>o({manager:C}),items:_,placeholder:"-- Select Manager --",disabled:a})]})]}),n.jsx("div",{style:Ou,children:n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.col.organization}),n.jsx(Ot,{value:e.organization,onChange:C=>o({organization:C}),organizations:s,placeholder:"-- All Organizations --",disabled:a})]})}),n.jsxs("div",{style:{marginTop:8},children:[n.jsxs("label",{style:z,children:[x.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginTop:6},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:jr,checked:!!e.create_processes,disabled:a,onChange:C=>o({create_processes:C.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Create Processes"})]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:jr,checked:!!e.update_process_status,disabled:a,onChange:C=>o({update_process_status:C.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Update Process Status"})]})]})]}),!a&&n.jsxs("div",{style:{marginTop:20},children:[n.jsx("label",{style:z,children:"Remarks"}),n.jsx("textarea",{style:{...P,...y,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:C=>o({remarks:C.target.value}),placeholder:"Optional note for the Manager…"})]}),a&&(((A=e.delegation_log)==null?void 0:A.length)??0)>0&&n.jsxs("div",{style:{marginTop:28},children:[n.jsx("label",{style:z,children:"Audit Trail"}),n.jsx("div",{style:{background:"white",borderRadius:8,border:"1px solid #eee",overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Action"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Actor"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((C,R)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0"},children:[n.jsx("td",{style:{padding:"8px 14px",fontWeight:600},children:C.action}),n.jsx("td",{style:{padding:"8px 14px"},children:C.actor}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:Y1(C.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:C.remarks||"—"})]},C.name||R))})]})})]})]})}const Nu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Br={process:N.blue,order:N.purple,incident:N.red,idea:N.green,delegation:N.orange},Wu={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function $r(e,t){const s=e.replace("#",""),r=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),i=parseInt(s.substring(4,6),16);return`rgba(${r}, ${l}, ${i}, ${t})`}function q1({onNavigate:e,onRefresh:t}){const s=ne(),[r,l]=w.useState([]),[i,a]=w.useState(!0),[c,d]=w.useState(""),[p,v]=w.useState(""),f=()=>Vy().then(g=>{l(g),a(!1)});w.useEffect(()=>{f()},[]);const u=r.filter(g=>g.requires_action),m=r.filter(g=>!g.requires_action),j={};for(const g of r)j[g.type]=(j[g.type]||0)+1;const h=async(g,x)=>{d(g),v("");try{await e0(g,x),await f(),t==null||t()}catch{v(g)}d("")};function S(g,x,o){return x.length===0?null:n.jsxs("div",{style:{marginBottom:28},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("span",{style:{fontSize:12,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:o?N.accent:"#8a8fa3"},children:g}),n.jsx("span",{style:{fontSize:11,fontWeight:700,minWidth:22,textAlign:"center",padding:"2px 7px",borderRadius:999,color:o?"white":"#6b7280",background:o?N.accent:"#e9eaf2"},children:x.length}),n.jsx("div",{style:{flex:1,height:1,background:"linear-gradient(90deg, #e6e7f0, transparent)"}})]}),n.jsx("div",{className:"inbox-card-grid",children:x.map((y,_)=>{const T=y.type!=="delegation",A=Br[y.type]||N.gray;return n.jsxs("div",{className:"inbox-card",onClick:T?()=>e(Nu[y.type],y.name):void 0,style:{borderTop:`3px solid ${A}`,cursor:T?"pointer":"default"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[n.jsx("div",{style:{width:38,height:38,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:17,background:$r(A,.14)},children:Wu[y.type]||"📌"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13,color:A,letterSpacing:.3},children:y.number}),y.requires_action&&n.jsx("span",{style:{fontSize:10,fontWeight:700,color:N.red,background:$r(N.red,.12),padding:"1px 7px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4},children:"Action"})]}),n.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:600,marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.title}),n.jsxs("div",{className:"inbox-card-meta",style:{marginTop:5,fontSize:12},children:[y.action,y.organization&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),y.organization]}),y.date&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),y.date]})]}),p===y.name&&n.jsx("div",{style:{marginTop:6,fontSize:12,color:N.red,fontWeight:600},children:"Failed to respond — please try again."})]})]}),y.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,marginTop:14},children:[n.jsx("button",{onClick:()=>h(y.name,"Accepted"),disabled:c===y.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:N.green,color:"white",fontWeight:700,fontSize:13,cursor:c===y.name?"wait":"pointer",opacity:c===y.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>h(y.name,"Rejected"),disabled:c===y.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:N.red,color:"white",fontWeight:700,fontSize:13,cursor:c===y.name?"wait":"pointer",opacity:c===y.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:C=>{C.stopPropagation(),e(Nu[y.type],y.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:y.requires_action?A:$r(A,.12),color:y.requires_action?"white":A,fontWeight:700,fontSize:13,cursor:"pointer"},children:y.requires_action?"Act Now →":s.view})]},_)})})]})}return n.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!i&&r.length>0&&n.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:24},children:Object.entries(j).map(([g,x])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"6px 12px 6px 9px",borderRadius:999,background:$r(Br[g]||N.gray,.1),border:`1px solid ${$r(Br[g]||N.gray,.25)}`},children:[n.jsx("span",{style:{fontSize:13},children:Wu[g]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Br[g]||N.gray,textTransform:"capitalize"},children:g}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Br[g]||N.gray,opacity:.7},children:x})]},g))}),i&&n.jsx("p",{style:{color:"#888"},children:s.loading}),!i&&r.length===0&&n.jsxs("div",{className:"inbox-empty",children:[n.jsx("div",{style:{fontSize:46,marginBottom:10},children:"✨"}),n.jsx("p",{style:{fontSize:16,fontWeight:600},children:s.inbox.noMessages}),n.jsx("p",{style:{fontSize:13,marginTop:4,opacity:.7},children:"You're all caught up — nothing needs your attention right now."})]}),!i&&S("Needs Action",u,!0),!i&&S("Informational",m,!1)]})}const J1=[{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"]}],$d={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 V1(e,t){const s=e.map(l=>$d[l]||l).join(","),r=t.map(l=>e.map(i=>`"${l[i]??""}"`).join(",")).join(`
`);return s+`
`+r}function Z1(e,t){const s=new Blob([e],{type:"text/csv"}),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=t,l.click(),URL.revokeObjectURL(r)}const Bu=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function ev(e,t,s){const r=e.map(p=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Bu($d[p]||p)}</th>`).join(""),l=t.map(p=>`<tr>${e.map(v=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Bu(p[v])}</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>${r}</tr></thead><tbody>${l}</tbody></table></body></html>`,a=new Blob(["\uFEFF"+i],{type:"application/vnd.ms-excel"}),c=URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=s,d.click(),URL.revokeObjectURL(c)}const ph="report-print-area",Ka="report-print-portal";function tv(){const e=document.getElementById(ph);if(!e)return;const t=document.createElement("div");t.id=Ka,t.innerHTML=e.innerHTML,document.body.appendChild(t);const s=document.createElement("style");s.id="report-print-style",s.textContent=`
#${Ka} { display: none; }
@media print {
#root { display: none !important; }
#${Ka} { display: block !important; }
}
`,document.head.appendChild(s);const r=()=>{t.remove(),s.remove(),window.removeEventListener("afterprint",r)};window.addEventListener("afterprint",r),window.print()}const $u={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Qa={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function nv({organizations:e,userRole:t}){const s=ne(),r=J1.filter(R=>R.roles.includes(t)),[l,i]=w.useState(""),[a,c]=w.useState(""),[d,p]=w.useState(""),[v,f]=w.useState(""),[u,m]=w.useState(String(new Date().getFullYear())),[j,h]=w.useState([]),[S,g]=w.useState([]),[x,o]=w.useState(!1),[y,_]=w.useState(""),T=r.find(R=>R.id===l);async function A(){if(l){o(!0),_(""),g([]),h([]);try{const R={};a&&(R.organization=a),d&&(R.from_date=d),v&&(R.to_date=v),(T==null?void 0:T.extraFilter)==="year"&&u&&(R.year=u);const $=await Jy(l,R);h($.columns||[]),g($.rows||[])}catch(R){_(R.message||"Error running report")}finally{o(!1)}}}const C=(T==null?void 0:T.label)||l;return n.jsxs("div",{children:[n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:r.map(R=>n.jsxs("div",{onClick:()=>i(R.id),style:{background:l===R.id?"#ebf5fb":"white",border:l===R.id?`2px solid ${N.accent}`:"2px solid transparent",borderRadius:10,padding:"14px 16px",cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:R.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:R.description})]},R.id))}),n.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),n.jsxs("select",{style:$u,value:l,onChange:R=>i(R.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),r.map(R=>n.jsx("option",{value:R.id,children:R.label},R.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:$u,value:a,onChange:R=>c(R.target.value),children:[n.jsx("option",{value:"",children:s.filter.allOrgs}),e.map(R=>n.jsx("option",{value:R.name,children:R.organization_name||R.name},R.name))]})]}),(T==null?void 0:T.extraFilter)==="year"?n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),n.jsx("input",{type:"number",style:{...Qa,width:90},value:u,onChange:R=>m(R.target.value),min:2020,max:2099})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),n.jsx(me,{value:d,onChange:p,style:Qa})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(me,{value:v,onChange:f,style:Qa})]})]}),n.jsx("button",{onClick:A,disabled:!l||x,style:{padding:"9px 20px",borderRadius:8,border:"none",background:N.accent,color:"white",fontWeight:700,fontSize:13,cursor:l?"pointer":"not-allowed",opacity:l?1:.5},children:x?s.loading:s.reports.generate}),S.length>0&&n.jsx("button",{onClick:()=>Z1(V1(j,S),`${l}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),S.length>0&&n.jsx("button",{onClick:()=>ev(j,S,`${l}.xls`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #107c41",background:"white",color:"#107c41",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export Excel"}),S.length>0&&n.jsx("button",{onClick:tv,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),y&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:y}),S.length>0&&n.jsxs("div",{id:ph,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[n.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontWeight:700,color:"#333"},children:C}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[S.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:j.map(R=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:$d[R]||R.replace(/_/g," ").toUpperCase()},R))})}),n.jsx("tbody",{children:S.map((R,$)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:$%2===0?"white":"#fafafa"},children:j.map(J=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:R[J]!=null?String(R[J]):"—"},J))},$))})]})]}),!x&&S.length===0&&l&&!y&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),r.length===0&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const Cl=()=>new Date().toISOString().split("T")[0],Ud=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],sv=()=>new Date().toTimeString().slice(0,5),un=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:Cl(),time:sv(),management:"",department:"",section_field:"",branch:"",assigned_to:"",status:"",description:"",summary:"",workflow_state:"New",hses_field:"",priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),Jt=()=>({name:"",number:"",title:"",organization:"",type:"",management:"",department:"",section_field:"",branch:"",current_condition:"",proposed_condition:"",status:"",assigned_to:"",workflow_state:"New",idea_class:"",hses_field:"",date:Cl(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),Vt=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Cl(),ending_date:Ud(),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:""}),ni=()=>({name:"",title:"",date_start:Cl(),date_end:Ud(),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:""}),Ws=()=>({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}),ss=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),rs=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),ls=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Bs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),$s=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Us=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Fs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ms=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Hs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Gs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ks=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),si=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),is=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:Cl(),end_date:Ud(),update_window_days:2}),as=()=>({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}),Ur=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),rv=new Set(["incidents","incidents-form","ideas","ideas-form"]),lv=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),iv=new Set(th.flatMap(({id:e})=>[e,`${e}-form`])),av=new Set(["Admin","Owner","Auditor","Manager"]),ov=new Set(["Admin","Owner","Auditor","Manager"]),dv=new Set(["Admin","Auditor","Manager"]);function cv({user:e,onLogout:t,darkMode:s,onToggleDark:r}){const l=ne(),i=e.role,a=av.has(i),c=ov.has(i),d=dv.has(i),p=b=>b==="users"||b==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(lv.has(b)||(b==="processes"||b==="processes-form")&&Hd.includes("create_processes")):rv.has(b),v=b=>i==="Employee"&&!!b&&b!=="New",f=a?"dashboard":"inbox",u=b=>b==="dashboard"?a:b==="reports"?c:b==="delegations"||b==="delegations-form"?d:b==="users"||b==="users-form"?i==="Admin":iv.has(b)?i==="Admin"||i==="Auditor":!0,[m,j]=w.useState(()=>{const b=u0(Su());return b&&u(b)?b:f});w.useEffect(()=>{const b=p0(m);window.location.hash!==b&&window.history.pushState(null,"",b)},[m]),w.useEffect(()=>{const b=()=>{const F=Su();j(F&&u(F)?F:f)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[]);const h=e.custom_organization||"",[S,g]=w.useState(""),[x,o]=w.useState("");w.useEffect(()=>{if(!x)return;const b=setTimeout(()=>o(""),0);return()=>clearTimeout(b)},[x]);const y=(b,F)=>{o(F),j(b)},[_,T]=w.useState(0),[A,C]=w.useState([]),[R,$]=w.useState([]),[J,ae]=w.useState([]),[O,I]=w.useState([]),[E,K]=w.useState([]),[G,L]=w.useState([]),[M,Y]=w.useState([]),[Z,V]=w.useState([]),[ke,De]=w.useState([]),[Ae,he]=w.useState([]),[Fe,H]=w.useState([]),[se,st]=w.useState([]),[re,rt]=w.useState([]),[ct,B]=w.useState([]),[ye,ut]=w.useState([]),[k,ee]=w.useState([]),[Q,zl]=w.useState([]),[sn,Tl]=w.useState([]),[ks,da]=w.useState([]),[rn,W]=w.useState({}),[Je,_s]=w.useState([]),[Dt,fh]=w.useState([]),[Fd,hh]=w.useState([]),[Md,gh]=w.useState([]),[Hd,xh]=w.useState([]),[Gd,mh]=w.useState({}),[ca,yh]=w.useState([]),Il=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[Kd,Cs]=w.useState(Il()),[je,ce]=w.useState(!0),[Ne,ie]=w.useState("idle"),[We,te]=w.useState(!1),[Qd,Yd]=w.useState(!1),[El,Xd]=w.useState(null),[vh,jh]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),bh=()=>jh(b=>{const F=!b;return localStorage.setItem("sb_sidebar",F?"1":"0"),F}),[Sh,ua]=w.useState(!1);w.useEffect(()=>{ua(!1)},[m]);const[ln,an]=w.useState(un()),[on,Qt]=w.useState(Jt()),[Yn,Yt]=w.useState(Vt()),[Xn,Xt]=w.useState(ni()),[qd,zs]=w.useState(Ws()),[Jd,qn]=w.useState(ss()),[Vd,Jn]=w.useState(rs()),[Zd,Vn]=w.useState(ls()),[ec,Ts]=w.useState(Bs()),[tc,Is]=w.useState($s()),[nc,Es]=w.useState(Us()),[sc,Ps]=w.useState(Fs()),[rc,As]=w.useState(Ms()),[lc,Rs]=w.useState(Hs()),[ic,Ls]=w.useState(Gs()),[ac,Os]=w.useState(Ks()),[_r,Pl]=w.useState(si()),[oc,Zn]=w.useState(is()),[dc,es]=w.useState(as()),[Ds,Cr]=w.useState(Ur()),bt=async()=>{ce(!0);try{const[b,F,Qe,Nt,wn,Te,ga,jg,bg,Sg,wg,kg,_g,Cg,zg,Tg,Ig,Eg,Pg,Ag,Rg,Lg,Og,Dg,Ng,Wg,Bg]=await Promise.all([Ce(D.incidents),Ce(D.organizations),Ce(D.ideas),Ce(D.orders),Ce(D.processes),Ry(),Ce(D.managements),Ce(D.departments),Ce(D.branches),Ce(D.incidentTypes),Ce(D.incidentClass),Ce(D.incidentField),Ce(D.ideaTypes),Ce(D.orderTypes),Ce(D.processTypes),Ce(D.incidentStatuses),Ce(D.ideaStatuses),Ce(D.orderStatuses),Ce(D.processStatuses),Ny(),Wy(),Ce(D.cycles),Ce(D.kpiInput),n0(),r0(),l0(),i0()]);C(b||[]),$(F||[]),ae(Qe||[]),I(Nt||[]),K(wn||[]),_s(Te||[]),L(ga||[]),Y(jg||[]),V(bg||[]),De(Sg||[]),he(wg||[]),H(kg||[]),st(_g||[]),rt(Cg||[]),B(zg||[]),ut(Tg||[]),ee(Ig||[]),zl(Eg||[]),Tl(Pg||[]),da(Ag||[]),W(Rg||{}),fh(Lg||[]),hh(Og||[]),gh(Dg||[]),xh(Ng||[]),mh(Wg||{}),yh(Bg||[])}catch(b){console.error("Error loading data:",b)}ce(!1)},cc=async()=>{try{const b=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(b.ok){const F=await b.json();T(Number(F.message)||0)}}catch{}};w.useEffect(()=>{bt(),cc();const b=setInterval(cc,6e4);return()=>clearInterval(b)},[e.name]);const[dn,Sn]=w.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),_e=(b,F,Qe)=>{Sn({isOpen:!0,doctype:b,name:F,title:Qe||F,isDeleting:!1})},wh=async b=>{Sn(F=>({...F,isDeleting:!0}));try{await Fo(dn.doctype,dn.name,b,!1),Sn(F=>({...F,isOpen:!1,isDeleting:!1})),await bt()}catch(F){console.error("Delete error:",F),alert((F==null?void 0:F.message)||"Delete failed. Please try again."),Sn(Qe=>({...Qe,isDeleting:!1}))}},kh=async b=>{Sn(F=>({...F,isDeleting:!0}));try{await Fo(dn.doctype,dn.name,b,!0),Sn(F=>({...F,isOpen:!1,isDeleting:!1})),await bt()}catch(F){console.error("Permanent delete error:",F),alert((F==null?void 0:F.message)||"Permanent delete failed. Please try again."),Sn(Qe=>({...Qe,isDeleting:!1}))}},zr=async(b,F)=>{if(window.confirm(l.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){ce(!0);try{await Ay(b,F),alert(l.restoredOk||"Record restored successfully!"),await bt()}catch(Qe){console.error("Restore error:",Qe),alert((Qe==null?void 0:Qe.message)||"Restore failed. Please try again.")}ce(!1)}},_h=async b=>{try{await Fy(b),await bt()}catch(F){console.error("Disable user error:",F)}},Ch=async b=>{te(!0),ce(!0);try{const F=await St(D.incidents,b.name);an({...un(),...F})}catch{an({...un(),...b})}j("incidents-form"),ce(!1)},zh=async b=>{te(!0),ce(!0);try{const F=await St(D.ideas,b.name);Qt({...Jt(),...F})}catch{Qt({...Jt(),...b})}j("ideas-form"),ce(!1)},Th=async b=>{te(!0),ce(!0);try{const F=await St(D.orders,b.name);Yt({...Vt(),...F})}catch{Yt({...Vt(),...b})}j("orders-form"),ce(!1)},Ih=async b=>{te(!0),ce(!0);try{const F=await Kr(b.name);Xt({...F,progress_indicators:F.progress_indicators||[],cycle_logs:F.cycle_logs||[]}),j("processes-form")}catch{Xt({...b,progress_indicators:b.progress_indicators||[]}),j("processes-form")}ce(!1)},Eh=b=>xe(D.organizations,b,zs,Ws(),"organizations-form",!0),Ph=b=>{te(!0),Cs(b),j("group-companies-form")},Ah=b=>{te(!1),Cs(b),j("group-companies-form")},Rh=async b=>{te(!0),ce(!0);try{const F=await St(D.managements,b.name);qn({...ss(),...F})}catch{qn({...ss(),...b})}j("managements-form"),ce(!1)},Lh=async b=>{te(!0),ce(!0);try{const F=await St(D.departments,b.name);Jn({...rs(),...F})}catch{Jn({...rs(),...b})}j("departments-form"),ce(!1)},Oh=async b=>{te(!0),ce(!0);try{const F=await St(D.branches,b.name);Vn({...ls(),...F})}catch{Vn({...ls(),...b})}j("branches-form"),ce(!1)},Dh=async b=>{te(!0),ce(!0);try{const F=await St(D.cycles,b.name);Zn({...is(),...F})}catch{Zn({...is(),...b})}j("cycles-form"),ce(!1)},Nh=async b=>{te(!0),ce(!0);try{const F=await St(D.kpiInput,b.name);es({...as(),...F})}catch{es({...as(),...b})}j("kpi-input-form"),ce(!1)},Ke=async(b,F,Qe,Nt,wn)=>{ie("loading");try{if(F.name)await Fi(b,F.name,F),ie("success"),bt(),setTimeout(()=>{ie("idle"),j(Nt)},1500);else if(wn){const Te=await Fa(b,F);wn((Te==null?void 0:Te.data)??Te),ie("success"),bt(),setTimeout(()=>ie("idle"),1500)}else await Fa(b,F),Qe(),ie("success"),bt(),setTimeout(()=>{ie("idle"),j(Nt)},1500)}catch(Te){console.error("Submit error:",Te),ie(Te instanceof Error?Te.message:"Error saving. Please try again.")}},Re=async()=>{await Oy(),t()},xe=async(b,F,Qe,Nt,wn,Te)=>{te(Te),ce(!0);try{const ga=await St(b,F.name);Qe({...Nt,...ga})}catch{Qe({...Nt,...F})}j(wn),ce(!1)},Wh=b=>xe(D.incidents,b,an,un(),"incidents-form",!1),Bh=b=>xe(D.ideas,b,Qt,Jt(),"ideas-form",!1),$h=b=>xe(D.orders,b,Yt,Vt(),"orders-form",!1),Uh=b=>{te(!1),ce(!0),Kr(b.name).then(F=>{Xt({...F,progress_indicators:F.progress_indicators||[],cycle_logs:F.cycle_logs||[]})}).catch(()=>{Xt({...b,progress_indicators:b.progress_indicators||[]})}).finally(()=>{j("processes-form"),ce(!1)})},Fh=b=>xe(D.organizations,b,zs,Ws(),"organizations-form",!1),Mh=b=>xe(D.managements,b,qn,ss(),"managements-form",!1),Hh=b=>xe(D.departments,b,Jn,rs(),"departments-form",!1),Gh=b=>xe(D.branches,b,Vn,ls(),"branches-form",!1),Kh=b=>xe(D.cycles,b,Zn,is(),"cycles-form",!1),Qh=b=>xe(D.kpiInput,b,es,as(),"kpi-input-form",!1),Yh=async b=>{te(!0),ce(!0);try{const F=await s0(b.name);Cr({...Ur(),...F})}catch{Cr({...Ur(),...b})}j("delegations-form"),ce(!1)},Xh=async()=>{ie("loading");try{const b=[];Ds.create_processes&&b.push("create_processes"),Ds.update_process_status&&b.push("update_process_status"),await Zy(Ds.manager,b,Ds.organization,Ds.remarks),Cr(Ur()),ie("success"),bt(),setTimeout(()=>{ie("idle"),j("delegations")},1500)}catch(b){console.error("Delegation submit error:",b),ie(b instanceof Error?b.message:"Error saving. Please try again.")}},qh=async b=>{if(window.confirm(l.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){ce(!0);try{await t0(b),await bt()}catch(F){console.error("Revoke delegation error:",F),alert(F instanceof Error?F.message:"Revoke failed. Please try again.")}ce(!1)}},Jh=b=>xe(D.incidentTypes,b,Ts,Bs(),"incident-types-form",!0),Vh=b=>xe(D.incidentTypes,b,Ts,Bs(),"incident-types-form",!1),Zh=b=>xe(D.ideaTypes,b,Is,$s(),"idea-types-form",!0),eg=b=>xe(D.ideaTypes,b,Is,$s(),"idea-types-form",!1),tg=b=>xe(D.orderTypes,b,Es,Us(),"order-types-form",!0),ng=b=>xe(D.orderTypes,b,Es,Us(),"order-types-form",!1),sg=b=>xe(D.processTypes,b,Ps,Fs(),"process-types-form",!0),rg=b=>xe(D.processTypes,b,Ps,Fs(),"process-types-form",!1),lg=b=>xe(D.incidentStatuses,b,As,Ms(),"incident-statuses-form",!0),ig=b=>xe(D.incidentStatuses,b,As,Ms(),"incident-statuses-form",!1),ag=b=>xe(D.ideaStatuses,b,Rs,Hs(),"idea-statuses-form",!0),og=b=>xe(D.ideaStatuses,b,Rs,Hs(),"idea-statuses-form",!1),dg=b=>xe(D.orderStatuses,b,Ls,Gs(),"order-statuses-form",!0),cg=b=>xe(D.orderStatuses,b,Ls,Gs(),"order-statuses-form",!1),ug=b=>xe(D.processStatuses,b,Os,Ks(),"process-statuses-form",!0),pg=b=>xe(D.processStatuses,b,Os,Ks(),"process-statuses-form",!1),fg=async b=>{Xd(b),j("profile")},hg=b=>{te(!1),Yd(!1),Pl({...si(),...b}),j("users-form")},gg=async()=>{ie("loading");try{if(!_r.name){const F=await Fa("User",{..._r,send_welcome_email:0,user_type:"System User"});Pl({...si(),..._r,...(F==null?void 0:F.data)??F}),te(!0),ie("success"),bt(),setTimeout(()=>ie("idle"),1500)}else{const{name:F,email:Qe,creation:Nt,full_name:wn,...Te}=_r;await Fi("User",F,Te),ie("success"),bt(),setTimeout(()=>{ie("idle"),j("users")},1500)}}catch(b){console.error("User submit error:",b),ie(b instanceof Error?b.message:"Error saving. Please try again.")}},Le=()=>{const b=ks.find(F=>F.name===e.name||F.username===e.name);Xd(b||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),j("profile")},pa=(b,F)=>{if(F){const Nt={"processes-form":D.processes,"orders-form":D.orders,"incidents-form":D.incidents,"ideas-form":D.ideas}[b];if(Nt){te(!0),ce(!0),(b==="processes-form"?Kr(F).then(Te=>({...Te,progress_indicators:Te.progress_indicators||[],cycle_logs:Te.cycle_logs||[]})):St(Nt,F)).then(Te=>{b==="processes-form"?Xt(Te):b==="orders-form"?Yt({...Vt(),...Te}):b==="incidents-form"?an({...un(),...Te}):b==="ideas-form"&&Qt({...Jt(),...Te}),j(b),ce(!1)}).catch(()=>{j(b),ce(!1)});return}}j(b)};if(m==="incidents-form")return n.jsx(E0,{incForm:ln,setIncForm:an,organizations:R,managements:G,departments:M,branches:Z,incidentTypes:ke,incidentClasses:Ae,incidentFields:Fe,incidentStatuses:ye,users:Je,userRoleMap:rn,formStatus:Ne,viewMode:We||!p("incidents-form")||v(ln.workflow_state),canModify:p("incidents-form"),onEdit:p("incidents-form")&&!v(ln.workflow_state)&&!An("incident",ln.workflow_state)?()=>te(!1):void 0,onDelete:p("incidents-form")?b=>_e(D.incidents,b,ln.title||ln.number):void 0,onRestore:i==="Admin"?b=>zr(D.incidents,b):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,userRole:i,onSubmit:()=>Ke(D.incidents,ln,()=>an(un()),"incidents",b=>an({...un(),...b})),onBack:()=>{j("incidents"),ie("idle")},onNavigate:j,onLogout:Re,user:e,onRefresh:async()=>{if(ln.name){const b=await St(D.incidents,ln.name).catch(()=>null);b&&an({...un(),...b})}Ce(D.incidents).then(b=>C(b||[])).catch(()=>{})}});if(m==="ideas-form")return n.jsx(L0,{ideaForm:on,setIdeaForm:Qt,organizations:R,managements:G,departments:M,branches:Z,ideaTypes:se,ideaStatuses:k,users:Je,userRoleMap:rn,formStatus:Ne,viewMode:We||!p("ideas-form")||v(on.workflow_state),canModify:p("ideas-form"),onEdit:p("ideas-form")&&!v(on.workflow_state)&&!An("idea",on.workflow_state)?()=>te(!1):void 0,onDelete:p("ideas-form")?b=>_e(D.ideas,b,on.title||on.number):void 0,onRestore:i==="Admin"?b=>zr(D.ideas,b):void 0,onNavigateToOrder:b=>xe(D.orders,{name:b},Yt,Vt(),"orders-form",!0),darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,userRole:i,onSubmit:()=>Ke(D.ideas,on,()=>Qt(Jt()),"ideas",b=>Qt({...Jt(),...b})),onBack:()=>{j("ideas"),ie("idle")},onNavigate:j,onLogout:Re,user:e,onRefresh:async()=>{if(on.name){const b=await St(D.ideas,on.name).catch(()=>null);b&&Qt({...Jt(),...b})}Ce(D.ideas).then(b=>ae(b||[])).catch(()=>{})}});if(m==="orders-form")return n.jsx(B0,{orderForm:Yn,setOrderForm:Yt,organizations:R,managements:G,departments:M,branches:Z,orderTypes:re,orderStatuses:Q,cycles:Dt,users:Je,userRoleMap:rn,formStatus:Ne,viewMode:We||!p("orders-form"),canModify:p("orders-form"),onEdit:p("orders-form")&&!An("order",Yn.workflow_state)?()=>te(!1):void 0,onDelete:p("orders-form")?b=>_e(D.orders,b,Yn.title||Yn.number):void 0,onRestore:i==="Admin"?b=>zr(D.orders,b):void 0,onNavigateToIdea:b=>xe(D.ideas,{name:b},Qt,Jt(),"ideas-form",!0),darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,currentUser:e.name,userRole:i,onSubmit:()=>Ke(D.orders,Yn,()=>Yt(Vt()),"orders",b=>Yt({...Vt(),...b})),onBack:()=>{j("orders"),ie("idle")},onNavigate:j,onLogout:Re,user:e,onRefresh:async()=>{if(Yn.name){const b=await St(D.orders,Yn.name).catch(()=>null);b&&Yt({...Vt(),...b})}Ce(D.orders).then(b=>I(b||[])).catch(()=>{})}});if(m==="processes-form")return n.jsx(H0,{processForm:Xn,setProcessForm:Xt,organizations:R,managements:G,departments:M,branches:Z,processTypes:ct,processStatuses:sn,cycles:Dt,users:Je,userRoleMap:rn,formStatus:Ne,viewMode:We||!p("processes-form"),canModify:p("processes-form"),onEdit:p("processes-form")&&!An("process",Xn.workflow_state)?()=>te(!1):void 0,onDelete:p("processes-form")?b=>_e(D.processes,b,Xn.title||Xn.number):void 0,onRestore:i==="Admin"?b=>zr(D.processes,b):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,userRole:e.role,delegatedFunctions:Hd,delegatedOrgs:Gd.create_processes,onRefreshProcess:async()=>{if(Xn.name)try{const b=await Kr(Xn.name);Xt({...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})}catch{}Ce(D.processes).then(b=>K(b||[])).catch(()=>{})},onSubmit:()=>Ke(D.processes,Xn,()=>Xt(ni()),"processes",b=>Xt({...ni(),...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})),onBack:()=>{j("processes"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="organizations-form")return n.jsx(q0,{orgForm:qd,setOrgForm:zs,groupCompanies:ca,formStatus:Ne,viewMode:We||!p("organizations-form"),onEdit:p("organizations-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.organizations,qd,()=>zs(Ws()),"organizations",b=>{zs({...Ws(),...b}),te(!0)}),onBack:()=>{j("organizations"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="managements-form")return n.jsx(t1,{form:Jd,setForm:qn,organizations:R,formStatus:Ne,viewMode:We||!p("managements-form"),onEdit:p("managements-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.managements,Jd,()=>qn(ss()),"managements",b=>{qn({...ss(),...b}),te(!0)}),onBack:()=>{j("managements"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="departments-form")return n.jsx(l1,{form:Vd,setForm:Jn,organizations:R,managements:G,formStatus:Ne,viewMode:We||!p("departments-form"),onEdit:p("departments-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.departments,Vd,()=>Jn(rs()),"departments",b=>{Jn({...rs(),...b}),te(!0)}),onBack:()=>{j("departments"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="branches-form")return n.jsx(d1,{form:Zd,setForm:Vn,organizations:R,managements:G,departments:M,formStatus:Ne,viewMode:We||!p("branches-form"),onEdit:p("branches-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.branches,Zd,()=>Vn(ls()),"branches",b=>{Vn({...ls(),...b}),te(!0)}),onBack:()=>{j("branches"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="cycles-form")return n.jsx(U1,{form:oc,setForm:Zn,organizations:R,formStatus:Ne,viewMode:We||!p("cycles-form"),onEdit:p("cycles-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.cycles,oc,()=>Zn(is()),"cycles",b=>{Zn({...is(),...b}),te(!0)}),onBack:()=>{j("cycles"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="kpi-input-form")return n.jsx(M1,{form:dc,setForm:es,organizations:R,formStatus:Ne,viewMode:We||!p("kpi-input-form"),onEdit:p("kpi-input-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.kpiInput,dc,()=>es(as()),"kpi-input",b=>{es({...as(),...b}),te(!0)}),onBack:()=>{j("kpi-input"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="incident-types-form")return n.jsx(p1,{form:ec,setForm:Ts,formStatus:Ne,viewMode:We||!p("incident-types-form"),onEdit:p("incident-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.incidentTypes,ec,()=>Ts(Bs()),"incident-types",b=>{Ts({...Bs(),...b}),te(!0)}),onBack:()=>{j("incident-types"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="idea-types-form")return n.jsx(g1,{form:tc,setForm:Is,formStatus:Ne,viewMode:We||!p("idea-types-form"),onEdit:p("idea-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.ideaTypes,tc,()=>Is($s()),"idea-types",b=>{Is({...$s(),...b}),te(!0)}),onBack:()=>{j("idea-types"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="order-types-form")return n.jsx(y1,{form:nc,setForm:Es,formStatus:Ne,viewMode:We||!p("order-types-form"),onEdit:p("order-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.orderTypes,nc,()=>Es(Us()),"order-types",b=>{Es({...Us(),...b}),te(!0)}),onBack:()=>{j("order-types"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="process-types-form")return n.jsx(b1,{form:sc,setForm:Ps,formStatus:Ne,viewMode:We||!p("process-types-form"),onEdit:p("process-types-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.processTypes,sc,()=>Ps(Fs()),"process-types",b=>{Ps({...Fs(),...b}),te(!0)}),onBack:()=>{j("process-types"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="incident-statuses-form")return n.jsx(k1,{form:rc,setForm:As,formStatus:Ne,viewMode:We||!p("incident-statuses-form"),onEdit:p("incident-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.incidentStatuses,rc,()=>As(Ms()),"incident-statuses",b=>{As({...Ms(),...b}),te(!0)}),onBack:()=>{j("incident-statuses"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="idea-statuses-form")return n.jsx(z1,{form:lc,setForm:Rs,formStatus:Ne,viewMode:We||!p("idea-statuses-form"),onEdit:p("idea-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.ideaStatuses,lc,()=>Rs(Hs()),"idea-statuses",b=>{Rs({...Hs(),...b}),te(!0)}),onBack:()=>{j("idea-statuses"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="order-statuses-form")return n.jsx(E1,{form:ic,setForm:Ls,formStatus:Ne,viewMode:We||!p("order-statuses-form"),onEdit:p("order-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.orderStatuses,ic,()=>Ls(Gs()),"order-statuses",b=>{Ls({...Gs(),...b}),te(!0)}),onBack:()=>{j("order-statuses"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="process-statuses-form")return n.jsx(R1,{form:ac,setForm:Os,formStatus:Ne,viewMode:We||!p("process-statuses-form"),onEdit:p("process-statuses-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.processStatuses,ac,()=>Os(Ks()),"process-statuses",b=>{Os({...Ks(),...b}),te(!0)}),onBack:()=>{j("process-statuses"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="users-form")return n.jsx(N1,{form:_r,setForm:Pl,groupCompanies:ca,organizations:R,managements:G,departments:M,branches:Z,formStatus:Ne,viewMode:We||!p("users-form"),onEdit:p("users-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,isSelfProfile:Qd,onSubmit:gg,onBack:()=>{j(Qd?a?"dashboard":"inbox":"users"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="delegations-form")return n.jsx(X1,{form:Ds,setForm:Cr,organizations:R,users:Je,userRoleMap:rn,formStatus:Ne,viewMode:We||!p("delegations-form"),onEdit:p("delegations-form")?()=>te(!1):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:Xh,onBack:()=>{j("delegations"),ie("idle")},onNavigate:j,onLogout:Re,user:e});if(m==="group-companies-form")return n.jsx(V0,{form:Kd,setForm:Cs,users:Je,formStatus:Ne,viewMode:We||!p("group-companies-form"),onEdit:p("group-companies-form")?()=>te(!1):void 0,onRestore:i==="Admin"?b=>zr(D.groupCompanies,b):void 0,darkMode:s,notifCount:_,onToggleDark:r,onCountChange:T,onViewProfile:Le,onSubmit:()=>Ke(D.groupCompanies,Kd,()=>Cs(Il()),"group-companies",b=>{Cs({...Il(),...b}),te(!0)}),onBack:()=>{j("group-companies"),ie("idle")},onNavigate:j,onLogout:Re,user:e});const xg={...l.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},mg={"group-companies":{color:N.purple,formPage:"group-companies-form",reset:()=>Cs(Il())},incidents:{color:N.accent,formPage:"incidents-form",reset:()=>an({...un(),organization:h||S})},ideas:{color:N.teal,formPage:"ideas-form",reset:()=>Qt({...Jt(),organization:h||S})},orders:{color:N.purple,formPage:"orders-form",reset:()=>Yt({...Vt(),organization:h||S})},processes:{color:N.blue,formPage:"processes-form",reset:()=>{const b=Gd.create_processes,F=h||(i==="Manager"&&b&&b.length===1?b[0]:S);Xt({...ni(),organization:F})}},organizations:{color:N.accent,formPage:"organizations-form",reset:()=>zs(Ws())},managements:{color:N.blue,formPage:"managements-form",reset:()=>qn({...ss(),organization:h||S})},departments:{color:N.teal,formPage:"departments-form",reset:()=>Jn({...rs(),custom_organization:h||S})},branches:{color:N.purple,formPage:"branches-form",reset:()=>Vn({...ls(),organization:h||S})},cycles:{color:N.teal,formPage:"cycles-form",reset:()=>Zn({...is(),organization:h||S})},"kpi-input":{color:N.blue,formPage:"kpi-input-form",reset:()=>es({...as(),organization:h||S})},"incident-types":{color:N.red,formPage:"incident-types-form",reset:()=>Ts(Bs())},"idea-types":{color:N.orange,formPage:"idea-types-form",reset:()=>Is($s())},"order-types":{color:N.green,formPage:"order-types-form",reset:()=>Es(Us())},"process-types":{color:N.accent,formPage:"process-types-form",reset:()=>Ps(Fs())},"incident-statuses":{color:N.red,formPage:"incident-statuses-form",reset:()=>As(Ms())},"idea-statuses":{color:N.teal,formPage:"idea-statuses-form",reset:()=>Rs(Hs())},"order-statuses":{color:N.purple,formPage:"order-statuses-form",reset:()=>Ls(Gs())},"process-statuses":{color:N.blue,formPage:"process-statuses-form",reset:()=>Os(Ks())},users:{color:N.blue,formPage:"users-form",reset:()=>{Pl(si()),Yd(!1)}},delegations:{color:N.purple,formPage:"delegations-form",reset:()=>Cr(Ur())}},yg={"group-companies":"New Group Company",incidents:l.formTitle.newIncident,ideas:l.formTitle.newIdea,orders:l.formTitle.newOrder,processes:l.formTitle.newProcess,organizations:l.formTitle.newOrg,managements:l.formTitle.newMgmt,departments:l.formTitle.newDept,branches:l.formTitle.newBranch,users:l.formTitle.newUser,cycles:l.formTitle.newCycle,"kpi-input":l.formTitle.newKpi,delegations:l.formTitle.newDelegation,"incident-types":"New Incident Type","idea-types":"New Idea Type","order-types":"New Order Type","process-types":"New Process Type","incident-statuses":"New Incident Status","idea-statuses":"New Idea Status","order-statuses":"New Order Status","process-statuses":"New Process Status"},vg={incidents:A,ideas:J,orders:O,processes:E,organizations:R,managements:G,departments:M,branches:Z,cycles:Dt,"kpi-input":Fd,"incident-types":ke,"idea-types":se,"order-types":re,"process-types":ct,"incident-statuses":ye,"idea-statuses":k,"order-statuses":Q,"process-statuses":sn,users:ks,delegations:Md},ts=gy[m],fa=vg[m],q=p(m),ha=q?mg[m]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:s?"#0f172a":N.bg},children:[n.jsx(ih,{collapsed:vh,onToggleCollapsed:bh,activePage:m,onNavigate:b=>j(b),hasDashboard:a,hasReports:c,hasDelegations:d,role:i,rtl:l.rtl,navLabels:l.nav,settingsLabel:l.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsx("div",{style:{background:s?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${s?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:s?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:n.jsx(ch,{notifCount:_,darkMode:s,onCountChange:T,onToggleDark:r,onNavigate:pa,onViewProfile:Le,onLogout:Re,userName:e.full_name||e.name,userRole:i})}),m!=="profile"&&n.jsxs("div",{style:{background:s?"#1e293b":"white",padding:"9px 20px",borderBottom:`1px solid ${s?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:s?"#e2e8f0":"#1e1b4b"},children:xg[m]||m}),n.jsxs("div",{style:{display:"flex",gap:8},children:[ts&&fa&&n.jsx("button",{onClick:()=>ua(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),ha&&n.jsxs("button",{onClick:()=>{ha.reset(),te(!1),ie("idle"),j(ha.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",yg[m]||l.new]})]})]}),ts&&fa&&Sh&&n.jsx(Ty,{title:ts.label,rows:fa,columns:ts.columns,defaultColumnKeys:ts.defaultColumns,orgField:ts.orgField,organizations:ts.orgField?R:void 0,filenameBase:m,onClose:()=>ua(!1)}),n.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:m==="profile"?0:"20px 24px",gap:m==="profile"?0:16},children:[je&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:l.loading}),!je&&m==="dashboard"&&a&&n.jsx(v0,{incidents:A,ideas:J,orders:O,processes:E,organizations:R,incidentStatuses:ye,ideaStatuses:k,orderStatuses:Q,processStatuses:sn,selectedOrg:S,onOrgChange:g,onNavigate:pa,onNavigateStatus:y,userRole:i}),!je&&m==="inbox"&&n.jsx(q1,{onNavigate:pa,onRefresh:bt}),!je&&m==="reports"&&c&&n.jsx(nv,{organizations:R,userRole:i}),!je&&m==="incidents"&&n.jsx(j0,{incidents:A,organizations:R,departments:M,branches:Z,incidentStatuses:ye,initialOrg:S,initialStatus:x,onView:Ch,onEdit:q?Wh:void 0,onDelete:q?b=>_e(D.incidents,b):void 0,canModify:q}),!je&&m==="ideas"&&n.jsx(P0,{ideas:J,organizations:R,departments:M,branches:Z,ideaStatuses:k,initialOrg:S,initialStatus:x,onView:zh,onEdit:q?Bh:void 0,onDelete:q?b=>_e(D.ideas,b):void 0,canModify:q}),!je&&m==="orders"&&n.jsx(O0,{orders:O,organizations:R,departments:M,branches:Z,orderStatuses:Q,initialOrg:S,initialStatus:x,onView:Th,onEdit:q?$h:void 0,onDelete:q?b=>_e(D.orders,b):void 0,canModify:q}),!je&&m==="processes"&&n.jsx($0,{processes:E,organizations:R,departments:M,branches:Z,processStatuses:sn,initialOrg:S,initialStatus:x,onView:Ih,onEdit:q?Uh:void 0,onDelete:q?b=>_e(D.processes,b):void 0,canModify:q}),!je&&m==="organizations"&&n.jsx(X0,{organizations:R,onView:Eh,onEdit:q?Fh:void 0,onDelete:q?b=>_e(D.organizations,b):void 0,canModify:q}),!je&&m==="group-companies"&&n.jsx(J0,{groupCompanies:ca,onView:Ph,onEdit:q?Ah:void 0,onDelete:q?b=>_e(D.groupCompanies,b):void 0,canModify:q}),!je&&m==="managements"&&n.jsx(e1,{managements:G,onView:Rh,onEdit:q?Mh:void 0,onDelete:q?b=>_e(D.managements,b):void 0,canModify:q}),!je&&m==="departments"&&n.jsx(s1,{departments:M,managements:G,onView:Lh,onEdit:q?Hh:void 0,onDelete:q?b=>_e(D.departments,b):void 0,canModify:q}),!je&&m==="branches"&&n.jsx(a1,{branches:Z,managements:G,departments:M,onView:Oh,onEdit:q?Gh:void 0,onDelete:q?b=>_e(D.branches,b):void 0,canModify:q}),!je&&m==="cycles"&&n.jsx(W1,{cycles:Dt,canModify:q,onView:Dh,onEdit:q?Kh:void 0,onDelete:q?b=>_e(D.cycles,b):void 0}),!je&&m==="kpi-input"&&n.jsx(F1,{kpiInputs:Fd,canModify:q,onView:Nh,onEdit:q?Qh:void 0,onDelete:q?b=>_e(D.kpiInput,b):void 0}),!je&&m==="incident-types"&&n.jsx(u1,{incidentTypes:ke,onView:Jh,onEdit:q?Vh:void 0,onDelete:q?b=>_e(D.incidentTypes,b):void 0,canModify:q}),!je&&m==="idea-types"&&n.jsx(h1,{ideaTypes:se,onView:Zh,onEdit:q?eg:void 0,onDelete:q?b=>_e(D.ideaTypes,b):void 0,canModify:q}),!je&&m==="order-types"&&n.jsx(m1,{orderTypes:re,onView:tg,onEdit:q?ng:void 0,onDelete:q?b=>_e(D.orderTypes,b):void 0,canModify:q}),!je&&m==="process-types"&&n.jsx(j1,{processTypes:ct,onView:sg,onEdit:q?rg:void 0,onDelete:q?b=>_e(D.processTypes,b):void 0,canModify:q}),!je&&m==="incident-statuses"&&n.jsx(w1,{incidentStatuses:ye,onView:lg,onEdit:q?ig:void 0,onDelete:q?b=>_e(D.incidentStatuses,b):void 0,canModify:q}),!je&&m==="idea-statuses"&&n.jsx(C1,{ideaStatuses:k,onView:ag,onEdit:q?og:void 0,onDelete:q?b=>_e(D.ideaStatuses,b):void 0,canModify:q}),!je&&m==="order-statuses"&&n.jsx(I1,{orderStatuses:Q,onView:dg,onEdit:q?cg:void 0,onDelete:q?b=>_e(D.orderStatuses,b):void 0,canModify:q}),!je&&m==="process-statuses"&&n.jsx(A1,{processStatuses:sn,onView:ug,onEdit:q?pg:void 0,onDelete:q?b=>_e(D.processStatuses,b):void 0,canModify:q}),!je&&m==="users"&&n.jsx(D1,{users:ks,roleMap:rn,onView:fg,onEdit:q?hg:void 0,onDelete:q?b=>_e("User",b):void 0,onDisable:q?_h:void 0,canModify:q}),!je&&m==="delegations"&&d&&n.jsx(Q1,{delegations:Md,organizations:R,userRole:i,currentUser:e.name,onView:Yh,onRevoke:q?qh:void 0}),m==="profile"&&(()=>{const b=!!El&&(El.name===e.name||El.email===e.name);return n.jsx(K0,{user:e,profileUser:El,sbUsers:ks,organizations:R,managements:G,departments:M,branches:Z,darkMode:s,canModify:q||b,onBack:()=>j(b?a?"dashboard":"inbox":"users"),onNavigate:j})})()]})]}),n.jsx(Py,{isOpen:dn.isOpen,doctype:dn.doctype,docname:dn.name,docTitle:dn.title,isAdmin:i==="Admin"||e.name==="Administrator",isDeleting:dn.isDeleting,onClose:()=>Sn(b=>({...b,isOpen:!1})),onConfirmSoftDelete:wh,onConfirmPermanentDelete:kh})]})}function uv(e){return e.some(t=>["SB Admin","System Manager"].includes(t))?"Admin":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":e.includes("SB Manager")?"Manager":"Employee"}function pv(){const[e,t]=w.useState(()=>{try{const c=localStorage.getItem("sidrah_user");return c?JSON.parse(c):null}catch{return null}}),[s,r]=w.useState(()=>localStorage.getItem("sb_dark")==="1"),l=()=>{const c=!s;r(c),localStorage.setItem("sb_dark",c?"1":"0"),document.documentElement.classList.toggle("dark",c)};w.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[]),w.useEffect(()=>{e&&ah().then(async c=>{const d=c||e.name,p=await dh(d);if(!p.length)return;const v=uv(p),f=await Ky();if(v!==e.role||d!==e.name||f!==(e.custom_organization||"")){const m={...e,name:d,role:v,custom_organization:f};t(m),localStorage.setItem("sidrah_user",JSON.stringify(m))}})},[e==null?void 0:e.name]);const i=c=>{t(c),localStorage.setItem("sidrah_user",JSON.stringify(c))},a=()=>{t(null),localStorage.removeItem("sidrah_user")};return e?n.jsx(cv,{user:e,onLogout:a,darkMode:s,onToggleDark:l}):n.jsx(f0,{onLogin:i})}eh(document.getElementById("root")).render(n.jsx(w.StrictMode,{children:n.jsx(pv,{})}));